Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Perl = Greek to me

by Not_a_Number (Parson)
on Dec 22, 2011 at 20:56 UTC ( #944851=note: print w/replies, xml ) Need Help??

in reply to Re: Perl = Greek to me
in thread Perl = Greek to me

my $slurp; { local $/ = undef; open my $textfile, '<', 'filename.txt' or die $!; $slurp = <$textfile>; close $textfile; }

The above code is unnecessary. It is syntactically correct if you want to read an entire file into a single scalar variable ($slurp), but then your code needs to use this variable, which it doesn't.

Far better to do this:

open my $textfile, '<', 'filename.txt' or die $!; while ( my $line = <$textfile> ) { ## Do something with $line }

Update: Do you see how much better formated my post looks than yours? That's because I followed the guidelines, wrapping code (and data) in <c>...</c> tags and paragraphs of text in <p>...</p> tags.

There's nothing stopping you from going back and correcting your posts now...

Update: Corrected minor tpyos.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://944851]
[Corion]: Hmm - is anybody aware of a "protocol-only" HTTP module? I'd like to teach Prima non-blocking HTTP ideally without using threads, but that means reimplementing/ rewriting something like HTTP::Tiny (except asynchronous) or AnyEvent::HTTP
[Corion]: Ideally, the HTTP state machine but with a way to feed it HTTP data whenever I get it instead of it actively doing stuff.
[Corion]: Now that I talk about this, maybe Net::Inspect::L7:: HTTP would be the right kind of thing for the responses at least.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2016-12-07 15:10 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (128 votes). Check out past polls.