<font face="courier new,monospace">Thats what I started with, but...<br>I forgot to mention that the match expression and replacement<br>expresssion need to be inside variables<br>ie.<br><br>#!/usr/bin/perl<br>use strict;<br>

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

<br></font><br><div class="gmail_quote">On Fri, Apr 19, 2013 at 11:07 AM, Dave Doyle <span dir="ltr"><<a href="mailto:dave.s.doyle@gmail.com" target="_blank">dave.s.doyle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Not the most efficient, but you can just always remove and add them back:<div><br></div><div><div>#!/usr/bin/perl</div><div><br></div><div>use strict;</div><div><br></div><div>while (my $line = <DATA>) {</div>


<div><span style="white-space:pre-wrap">  </span>$line =~ s/^-?(.+?):?$/-$1:/;</div><div><span style="white-space:pre-wrap">    </span>print $line;</div><div>}</div><div><br></div><div>__DATA__</div><div>stuff</div><div>
-stuff</div><div>stuff:</div><div>-stuff:</div></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div>--</div><a href="mailto:dave.s.doyle@gmail.com" target="_blank">dave.s.doyle@gmail.com</a></div>



<br><br><div class="gmail_quote"><div><div class="h5">On 19 April 2013 10:58, Fulko Hew <span dir="ltr"><<a href="mailto:fulko.hew@gmail.com" target="_blank">fulko.hew@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div class="h5">
<font face="courier new,monospace">The subject line may not say it properly, but I need<br>a _single_ (because of other constraints) s/// statement<br>that effectively performs the following:<br><br>If the string doesn't start with a hyphen and end with colon,<br>




then I want them added.<br><br>ie:<br><br>stuff   => -stuff:<br>-stuff  => -stuff:<br>stuff:  => -stuff:<br>-stuff: => -stuff:<br></font>
<br></div></div>_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br>