Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Column Heading and Split Function

by thirdm (Sexton)
on Mar 28, 2013 at 16:24 UTC ( #1025994=note: print w/ replies, xml ) Need Help??


in reply to Title of Column and Split Function

use File::Slurp; my %rates = (); $_ = read_file(\*DATA); /$/mg; # skip first line $rates{$1} = $2 while /^(\w+)\h+(\d+)/mg; $, = "\t"; print %rates; __DATA__ Patient Heart Rates Molly 70 Glenn 69


Comment on Re: Column Heading and Split Function
Download Code
Replies are listed 'Best First'.
Re^2: Column Heading and Split Function
by thirdm (Sexton) on Mar 28, 2013 at 16:53 UTC
    hmmm.
    use File::Slurp; $_ = read_file(\*DATA); /$/mg; # skip first line my %rates = /^(\w+)\h+(\d+)/mg; $, = "\t"; print %rates; __DATA__ Patient Heart Rates Molly 70 Glenn 69

      One more reduction and we have to put this node into Obfuscation... ;-)

      But while thinking it's interesting it deserves a ++

      McA

        <DATA>; # remove header line $/=undef; # instead of File::Slurp my %rates = split /\s+/, <DATA>; print map { "$_ $rates{$_}\n" } keys %rates; __DATA__ Patient Heart Rates Molly 70 Glenn 69

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (16)
As of 2015-07-07 20:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls