Shlomi Fish wrote:
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:
On Wed, 5 Sep 2012 14:33:13 +0100
jet speed<speedj...@googlemail.com> wrote:
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.
There is no good reason why you should do that.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/