in reply to parsing arguments
Now if you wanted to parse some values into more complicated data structures then just scalars, well, it gets slightly more complicated. For example, the lexwhere key. You might be able to get away with something like:my %hash; for(@ARGV) { my($key,$val) = split/=/,$_,2; $hash{$key}=$val; } use Data::Dumper; print Dumper(\%hash); __END__ Output: $VAR1 = { 'vchtyp' => 'I', 'jrnltyp' => 'D', 'title' => '\'this is a title\'', 'lexwhere' => '\'in(\'DIS\', \'DIM\', \'DIR\')\'' }; (Data::Dumper is inserting those extraneous backslashes, ignore them)
But thats really fragile and requires having strict controls over what gets passed to your script. (in fact, it's so fragile it doesn't even work on the data as presented, you'll need to munge off the beginning and ending single quotes)my @vals = $hash{lexwhere}=~/'([^'])'/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: parsing arguments
by mifflin (Curate) on Oct 07, 2003 at 23:53 UTC | |
by etcshadow (Priest) on Oct 08, 2003 at 00:54 UTC | |
|
Re: Re: parsing arguments
by mifflin (Curate) on Oct 08, 2003 at 15:46 UTC | |
by etcshadow (Priest) on Oct 09, 2003 at 03:22 UTC |