Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^5: Loop Array - If $var is something write values until $var is something else

by Marshall (Canon)
on Sep 29, 2018 at 20:53 UTC ( [id://1223292]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Loop Array - If $var is something write values until $var is something else
in thread Loop Array - If $var is something write values until $var is something else

If this doesn't quite do what you want, see if you can modify it so that it does:
#!/usr/bin/perl use strict; use warnings; while (defined (my $x= <DATA>)) { chomp $x; if ($x =~ /^JOB::/) { print $x, "\n"; } elsif ($x =~ m/^Something\s*$/) { print "~~Something~~ ", $x, "\n"; } else { print "~~Something Else~~ ", $x, "\n"; } } =prints JOB::HEREISASTRING ~~Something~~ Something ~~Something Else~~ StringA ~~Something Else~~ StringB ~~Something Else~~ StringC ~~Something Else~~ StringD ~~Something Else~~ Something Else ~~Something Else~~ StringE ~~Something Else~~ StringF ~~Something Else~~ StringG ~~Something Else~~ StringH JOB::HEREISANOTHERSTRING ~~Something~~ Something ~~Something Else~~ StringI ~~Something Else~~ StringJ ~~Something Else~~ StringK ~~Something Else~~ StringL ~~Something Else~~ Something Else ~~Something Else~~ StringM ~~Something Else~~ StringN ~~Something Else~~ StringO ~~Something Else~~ StringP =cut __DATA__ JOB::HEREISASTRING Something StringA StringB StringC StringD Something Else StringE StringF StringG StringH JOB::HEREISANOTHERSTRING Something StringI StringJ StringK StringL Something Else StringM StringN StringO StringP
  • Comment on Re^5: Loop Array - If $var is something write values until $var is something else
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1223292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found