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