Next | System Programming in Perl | 14 |
sub parse { my @words = grep $_ =~ /\S/, split /( \s+ | < | >> | > )/x, $_[0]; my %d; $d{program} = shift @words; while (@words) { local $_ = shift @words; if ($_ eq '<') { $d{stdin} = shift @words; } elsif ($_ eq '>' || $_ eq '>>') { $d{stdout} = shift @words; $d{append} = $_; } else { push @{$d{args}}, $_; } } %d; }
Next | Copyright © 2003 M. J. Dominus |