Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Change variable multiple times within a single string?

by toolic (Bishop)
on Apr 27, 2013 at 13:51 UTC ( #1030964=note: print w/replies, xml ) Need Help??


in reply to Change variable multiple times within a single string?

split
use warnings; use strict; my $string="A111B111A111B111"; my $yes_or_no="no"; for (split //, $string) { if ($_ eq 'A') { $yes_or_no = 'yes'; print "$_ yes_or_no=$yes_or_no\n"; } if ($_ eq 'B') { $yes_or_no = 'no'; print "$_ yes_or_no=$yes_or_no\n"; } } __END__ A yes_or_no=yes B yes_or_no=no A yes_or_no=yes B yes_or_no=no

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1030964]
help
Chatterbox?
[LanX]: hmm interesting link
[Discipulus]: Eduardo De Filippo explains how to do coffe - ITA

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-01-16 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (149 votes). Check out past polls.