Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: Having trouble loading a hash with map

by AnomalousMonk (Canon)
on May 03, 2012 at 18:58 UTC ( #968801=note: print w/replies, xml ) Need Help??

in reply to Re: Having trouble loading a hash with map
in thread Having trouble loading a hash with map

If the File::Slurp module is not available, I find the
    do { local $/;  <> }
expression preferable due to narrower, thus better controlled, scoping. (In original reply, lexical  my %hash; was defined within, accessed from outside of a block.)

>perl -wMstrict -le "use Data::Dumper; ;; my %hash = map { chomp; $_ => '1' } split /(\s+|\W+)/, do { local $/; <> }; ;; print Dumper \%hash; " new_ib1.txt | head -10 $VAR1 = { '' => '1', 'BIG' => '1', 'you' => '1', 'model' => '1', 'NOT' => '1', ',' => '1', 'understand' => '1', 'MY' => '1', '2' => '1',

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968801]
[haukex]: You can put it in SOPW, but use <readmore> tags
[haukex]: Also you might want to label it "code review"
[haukex]: Unless you have specific questions, in which case SSCCE's are much better
[cbeckley]: Excellent, thank you.
[cbeckley]: CUFP is more appropriate for stuff that's finished^h^h^h^h more advanced state of completeness?

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2017-03-24 15:10 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (304 votes). Check out past polls.