deprecated has asked for the wisdom of the Perl Monks concerning the following question:
Yes, I am using perl where I could just be using the shell. In this case, I am using perl because it is a little less processor intense (fewer processes forked), and a lot clearer from a readability point of view.
The application is a wrapper around a tape stacker. I want to read in six tapes from a stacker, in sequence, using the command `mtx`. I'm reading its output, here:
slot_1 Full slot_2 Full slot_3 Empty slot_4 Full slot_5 Full slot_6 Full Drive: tape 3 loaded
I can then figure out which tape is in the drive and which ones need to be done. Anyhow, the code that I have created to parse that information is here:
This is pretty cool, but I dont get a feeling of satisfaction from it. What would be a more concise yet still clear way to do this?# status in this case is the output of mtx, above... my @fields = split m[\n|\s+], $status, 13; my $loaded = pop @fields; my %drives = @fields;
thanks
brother dep
--
Laziness, Impatience, Hubris, and Generosity.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Is this concise enough? (code)
by particle (Vicar) on Jun 24, 2001 at 04:31 UTC | |
(tye)Re: Is this concise enough? (code)
by tye (Sage) on Jun 24, 2001 at 10:20 UTC | |
Re: Is this concise enough? (code)
by chipmunk (Parson) on Jun 24, 2001 at 18:08 UTC |
Back to
Seekers of Perl Wisdom