[tpm] how to resubstitute a captured value

Dave Doyle dave.s.doyle at gmail.com
Fri Apr 19 08:07:16 PDT 2013


Not the most efficient, but you can just always remove and add them back:

#!/usr/bin/perl

use strict;

while (my $line = <DATA>) {
$line =~ s/^-?(.+?):?$/-$1:/;
print $line;
}

__DATA__
stuff
-stuff
stuff:
-stuff:


--
dave.s.doyle at gmail.com


On 19 April 2013 10:58, Fulko Hew <fulko.hew at gmail.com> wrote:

> The subject line may not say it properly, but I need
> a _single_ (because of other constraints) s/// statement
> that effectively performs the following:
>
> If the string doesn't start with a hyphen and end with colon,
> then I want them added.
>
> ie:
>
> stuff   => -stuff:
> -stuff  => -stuff:
> stuff:  => -stuff:
> -stuff: => -stuff:
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20130419/ee035b5c/attachment.html>


More information about the toronto-pm mailing list