Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: About a piece of code

by Anonymous Monk
on Aug 05, 2009 at 12:00 UTC ( #786073=note: print w/ replies, xml ) Need Help??


in reply to Re^4: About a piece of code
in thread About a piece of code

Imagine you're The Soup Nazi, a patron steps forward in line (readline) with a giant \n on their forehead, and you yell NEXT! and kick them out. Then the next person steps forward with a giant "Foo\n" on their forehead. Maybe you give them soup, maybe you make them pay for bread, maybe they object and you yell "No soup for you!" and kick them out :)

nosoup.pl

#!/usr/bin/perl -- while(<DATA>){ /^\s+$/ and next; if(/George/){ print "No soup for you!\n"; } print "What soup you want? $_"; } __DATA__ Kramer Elaine George
and Devel::Trace output
$ perl -d:Trace nosoup.pl >> nosoup.pl:2: while(<DATA>){ >> nosoup.pl:3: /^\s+$/ and next; >> nosoup.pl:3: /^\s+$/ and next; >> nosoup.pl:4: if(/George/){ >> nosoup.pl:7: print "What soup you want? $_"; What soup you want? Kramer >> nosoup.pl:3: /^\s+$/ and next; >> nosoup.pl:3: /^\s+$/ and next; >> nosoup.pl:4: if(/George/){ >> nosoup.pl:7: print "What soup you want? $_"; What soup you want? Elaine >> nosoup.pl:3: /^\s+$/ and next; >> nosoup.pl:3: /^\s+$/ and next; >> nosoup.pl:4: if(/George/){ >> nosoup.pl:5: print "No soup for you!\n"; No soup for you! >> nosoup.pl:7: print "What soup you want? $_"; What soup you want? George


Comment on Re^5: About a piece of code
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-10-25 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls