#!/usr/bin/perl -w =head1 CONFUSION, SELF-DOUBT, AND BEER =begin text ## Well this test script was propted by a query on File::Slurp and la +ter file slurp which led me to 'Slurp a file' (http://perlmonks.com/i +ndex.pl?node_id=50525) by AnonymousMonk: Description: Slurp a file into a scalar. Jean-Daniel Gamache webmaster +@perls.org open (IN, "<myfile.txt"); {local $/; $file_content = <IN>;} print $file_content; ## Then davorg (man with the munchies) replies with: Oops. You've just left $/ set to undef for the rest of the program. Th +is can lead to all sorts of nastiness. Better to do something like this: my $file_text; { local $/; $file_text = <FILE>; } print $file_text; Which returns $/ to its original value once you leave the bare block. -- <http://www.dave.org.uk> "Perl makes the fun jobs fun and the boring jobs bearable" - me ## This really had me confused. The original post had a block, it doesn't matter (and 'the Rock' chime +s in 'It doesn't matter!') where you declare $file_content, as it has + no bearing on local or $/ since {;;;;;} is a valid block!.... I was kind of in doubt of my faculties for a split second, and then I +scrolled down the page, and found an AnonymousMonk node saying "Sorry +, you were right!" Then it came to me (in a vision =;:): davorg had been coding drunk aga +in. ... there's always a valuable lesson to be learned ... keep (c|n)ode +-ing =end =cut # some quick test code print '$/',"is = '$/';\n"; { local $/; # in effect, makes $/ uninitialized print '$/',"is = '$/';\n"; print <DATA>; } print '$/',"is = '$/';\n"; __DATA__ I AM DATA
update: Hmmm, I saw no mention of that, oh well: "you live you die, it's all for perl and peanuts ;-)".

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


In reply to CONFUSION, SELF-DOUBT, AND BEER by crazyinsomniac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.