Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Best way to sort these strings ? recursive way ? use Parse::RecDescent?

by chester (Hermit)
on Oct 01, 2005 at 16:39 UTC ( [id://496653]=note: print w/replies, xml ) Need Help??


in reply to Best way to sort these strings ? recursive way ? use Parse::RecDescent?

I just learned Parse::RecDescent yesterday and I wanted to try it. Consider this an example of how not to solve the problem.

use warnings; use strict; use Parse::RecDescent; use Data::Dumper; my $string = <<END; JOB ID=EX1J DESC='JOB1' JOB ID=EX2J DESC='JOB2' JOB ID=EX3J DESC='JOB3' JOB ID=EX4J DESC='JOB3' EX4J PRED EX2J EX3J PRED EX1J EX4J PRED EX1J END our %data; my $parser = Parse::RecDescent->new (q{ startrule : jobphrase(s) exphrase(s) jobphrase : "JOB ID=" ex "DESC=" jobquote { $::data{$item[2]}{'desc'} = $item[4]; $::data{$item[2]}{'pred'} ||=[] } exphrase : ex "PRED" ex { push @{$::data{$item[1]}{'pred'}}, @item[3] } jobquote : "'" job "'" {$return = $item[2]} ex : /EX\dJ/ job : /JOB\d/ }); $parser->startrule($string); print Dumper \%data;
  • Comment on Re: Best way to sort these strings ? recursive way ? use Parse::RecDescent?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found