Replying to myself, I have a correction which Shawn inspired.

On Wed, 5 Sep 2012 16:49:42 +0300
Shlomi Fish <shlo...@shlomifish.org> wrote:

> Hi Sj,
> 
> On Wed, 5 Sep 2012 14:33:13 +0100
> jet speed <speedj...@googlemail.com> wrote:
> 
> > Hi All,
> > 
> > i have an regx question. i have the array contents, now i want to
> > remove the first 2 characters (fc) of each element in the array and
> > store it in a second array ex: @array2
> > 
> > @array ="fc20/1, fc30/22, fc40/3, fc20/1";
> > 
> > output
> > 
> > @array2 ="20/1, 30/22, 40/3, 20/1";
> > 
> 
> You are using invalid syntax for arrays again. This is getting
> annoying.
> 
> In any case, either of those should do the trick:
> 
>       my @new = (map { substr($_, 2) } @old);
> 
> Or:
> 
>       my @new = (map { s/\A..//r } @old); # If your perl is recent
> enough.

You should add the /m and /s flags to the regular expression here.

> 
> If your Perl is too old you can do:
> 
>       my @new = (map { my $x = $_; $x =~ s/\A..//; $x; } @old);

And here.

Regards,

        Shlomi Fish


-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
What Makes Software Apps High Quality -  http://shlom.in/sw-quality

Sesquipedallianism: making excessive use of long words.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to