Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Passing hash names in a file

by dingus (Friar)
on Dec 10, 2002 at 09:38 UTC ( [id://218757]=note: print w/replies, xml ) Need Help??


in reply to Passing hash names in a file

Assuming the data in your glossary.pl file is as you specify (each hash on a separate line or lines) then you can parse it quite quickly:
$fn = 'glossary.pl'; $/ = ');'.$/; # cunning trick to read in the whole hash open (FILE, "<$fn"); while (<FILE>) { next unless (/%(\w+)(?:\s|=)/s); # match %word = or %word= push @hashnames, $1; } close(FILE);

Dingus


Enter any 47-digit prime number to continue.

Replies are listed 'Best First'.
Re: Re: Passing hash names in a file
by heezy (Monk) on Dec 10, 2002 at 15:59 UTC

    Thanks for everyones suggestions!

    Here's how I solved it in the end.

    while(<MyFile>){ if (/(\%.*?) /){ $item = $1; $item =~ s/\%//; push @dynamicterms, $item } }

    Really wasn't that hard was it!

    Thanks

    M

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found