************* Output ******my @in = qw(a b c d e f g h); print "Start: ",@in,"\n","***RUNNING MAP***\n\n"; my @out = map { s/.$/x/} @in; print "in : ",@in,"\n"; print "out: ",@out,"\n"
*********************Start: abcdefgh ***RUNNING MAP*** in : xxxxxxxx out: 11111111
************* Output ******my @in = qw(a b c d e f g h); print "Start: ",@in,"\n","***RUNNING MAP***\n\n"; my @out = map { s/.$/x/r} @in; print "in : ",@in,"\n"; print "out: ",@out,"\n"
****************Start: abcdefgh ***RUNNING MAP*** in : abcdefgh out: xxxxxxxx
But what if you REALLY wanted the return value of the regex - and not modify the original output? (why? I don't know)
Localize the input...
************* Output ******my @in = qw(a b c d e f g h); print "Start: ",@in,"\n","***RUNNING MAP***\n\n"; my @out = map { s/.$/x/} my @temp = @in; print "in : ",@in,"\n"; print "out: ",@out,"\n"
Start: abcdefgh ***RUNNING MAP*** in : abcdefgh out: 11111111
In reply to Re^2: Using regex in Map function
by spandox
in thread Using regex in Map function
by narashima
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |