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:
# 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;
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?
thanks
brother dep
--
Laziness, Impatience, Hubris, and Generosity.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.