Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Hash from a file

by naikonta (Curate)
on Oct 04, 2007 at 15:56 UTC ( #642689=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Hash from a file
in thread Hash from a file

Be careful. Saying ['data2 data2 data2 data2 data2'] means that the value is an array reference with a single element, 'data2 data2 data2 data2 data2', which is a string. It's not the same as ['data2', 'data2', 'data2', 'data2', 'data2'] which is an array reference consist of some elements that are all strings. If what you want is the latter, then toolic has given the answer.

However, if what you want is the former then you can join back @description separated by, for example, spaces. This also replaces tabs with single spaces. From toolic's code:

my ($id, @description) = split; $hash{$id} = [join ' ', @description];

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


Comment on Re^3: Hash from a file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (16)
As of 2014-07-31 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls