Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^6: First attempt at bringing in file for input/output

by soonix (Abbot)
on Oct 26, 2018 at 08:15 UTC ( #1224721=note: print w/replies, xml ) Need Help??

in reply to Re^5: First attempt at bringing in file for input/output
in thread First attempt at bringing in file for input/output

but but but … isn't "end of <DATA>" the end-of-loop condition?

reacting to a /Q(uit)?/i input is more or less just a convenience function, thus secondary :-)

Replies are listed 'Best First'.
Re^7: First attempt at bringing in file for input/output
by Marshall (Abbot) on Nov 02, 2018 at 23:37 UTC
    You are quite correct.
    My examples were quickly contrived with the focus on variable scoping of something in a while loop which has a logical conditional expression.

    For a normal while (my $line = <$fh>){} loop, I would usually have something like "next if blank line" in the body of the loop. The idea expressed in the loop conditional being that all lines will be looked at.

    For a command loop, one that is interactive with the user, I would express the idea that "this loop usually ends when the user types "quit" of some variant of that" within the while() statement. I would prefer that as opposed to "last if ...." within the body of the loop. I didn't frame examples in the context of a command loop from <STDIN> because testing such things takes a few extra steps in my dev environment. My code tends to have either a super fancy GUI or no UI at all, with the later case being far and away the most common. I tend to write "middleware" data processing or system code.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2019-05-24 23:06 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (151 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!