Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: s// doesn't work when second loop!

by choroba (Bishop)
on Jan 10, 2018 at 16:56 UTC ( #1207078=note: print w/replies, xml ) Need Help??


in reply to s// doesn't work when second loop!

That's because after the replacement, the pattern no longer matches the string.
#! /usr/bin/perl use warnings; use strict; my $input = 'a'; my $doesnt_work = $input; for (1 .. 10) { my $works = $input; $works =~ s/a/$_/; $doesnt_work =~ s/a/$_/; print "Works: $works\n", "Doesn't work: $doesnt_work\n"; }
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1207078]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2018-01-21 11:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (227 votes). Check out past polls.

    Notices?