Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^9: writing two files (different in length) to one output

by hippo (Bishop)
on May 31, 2017 at 07:29 UTC ( [id://1191675]=note: print w/replies, xml ) Need Help??


in reply to Re^8: writing two files (different in length) to one output
in thread writing two files (different in length) to one output

while ( (print "Prompt: "), $line=<STDIN>, $line !~ /^\s*Q(uit)\s*$/i )

Having spent 5 minutes looking at this one line I'm still stumped as to the purpose of the capture group in the regex. Can you explain the purpose? ie. why would /^\s*Quit\s*$/i not perform exactly the same in your given code (since you have not subsequently referred to the captured data)? Thanks.

Replies are listed 'Best First'.
Re^10: writing two files (different in length) to one output
by Marshall (Canon) on Jun 01, 2017 at 18:30 UTC
    You spotted a missing ? to make (uit) optional. Should be:
    while ( (print "Prompt: "), $line=<STDIN>, $line !~ /^\s*Q(uit)?\s*$/i + )
    That way both the single letter q,Q or the full word Quit works. I just made a typing goof and didn't fully test, otherwise I would have seen that a simple "q" didn't work.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-29 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found