Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Parsing output from a command

by Limbic~Region (Chancellor)
on Mar 24, 2009 at 17:40 UTC ( [id://752928]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Parsing output from a command
in thread Parsing output from a command

BrowserUk,
Can you explain how it will screw up?

I have subsequently tested it and it works as I expect it to. I did find that on my AIX, the output of the command isn't exactly the same as described by the OP - specifically there are two spaces before hdisk## but after accounting for that, it works as intended. Update: The modifications I made that may make the difference (as I said, it worked as expected) were as follows:

local $/ = "\n hdisk"; my ($disk) = $_ =~ /\s+(hdisk\w+)/;

Cheers - L~R

Replies are listed 'Best First'.
Re^4: Parsing output from a command
by BrowserUk (Patriarch) on Mar 24, 2009 at 18:33 UTC

    Hm. I got this output when I ran your code on the OP's data (c&p'd from the console window):

    c:\test>junk4 hdisk0 0009E05B hdisk1 P1/Z1-Ab 16 Bit LVD SCSI Disk Drive (18200 MB) Manufacturer................IBM Machine Type and Model......ST318305LC FRU Number..................09P4437 Serial Number...............0004A0D2 Part Number.................09P4436

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      BrowserUk,
      The problem isn't what you suggest:
      That'll screw up on the last record because there is no "\nhdisk" delimiter following it.

      The problem is that the regex was anchored at ^. As I said, I had to make a minor modificiation to match the real AIX command (removing that). If you modify my code to drop the ^ it will work against the OP's DATA or the two modifications above if you want to run it on the real command.

      Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-23 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found