Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: converting a text into a hash datastructure

by jethro (Monsignor)
on Aug 03, 2011 at 09:47 UTC ( #918212=note: print w/replies, xml ) Need Help??


in reply to converting a text into a hash datastructure

my @textsplit= split /\./, $text; my $p= pop @textsplit; foreach (reverse @textsplit) { my $new->{$_}= $p; $p= $new; }

But this naturally won't work if you want to convert many text lines with common parts (i.e. "a.b.c.d" and "a.b.n.m") and want to get one single data structure out of it

UPDATE: davido found a bug in my code. Corrected with addition of $new.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-10-02 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (11 votes). Check out past polls.

    Notices?