On Dec 11, 2003, at 9:30 AM, Eric Walker wrote: [..]
yes( "hello" "goodbye"

     ( (one 2) (two 3) (three 4)
     )
     (( mon 1) (tues 2) (wed 3)
     )
     ((jan 1) (feb 2) (march 3)
     )
)
[..]
The question of course is whether that 'ordering'
is important, or can you just use a hash?

IF you do not really need to know about the
paren count then don't count it. IF you
know that your generalized date is going to
be of the form

(<word> <num>)

then your word_num regEx would look like

        my $word_num = qr/\( # our opening paren
                (\w+)\s+(\d+)
                \)/ix; # our closing paren

I use the 'x' option to lay it out pretty like that.

then the rest is a walker

        while ( <INFO1> ) {
                chomp;
                next if (/^\s*$/); # no need empty lines
                s/^\s+//; # kill leaing lines
                my $line = $_; # now we have a line to play with
                while ( $line =~ /$word_num(.*)/)
                {
                        $hash{$1} = $2; # our $word_num pattern fetched these
                        $line = $3; # for everything else there is (.*)
                }
        }
        
        while (my ($k, $v) = each %hash)
        {
                print "$k -> $v\n";
        }



ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to