Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help for pasing 1

Status
Not open for further replies.

trinita

IS-IT--Management
Oct 23, 2006
14
Hi everybody,

this is my first topic in this website, but damn it's amazing!!! Surely, it won't be the only one!
So, keep out formality and I ask you a big hand:
How can I pasing, using PERL, this text file?

PowerPath pseudo device names in use:

Pseudo Device Name Major# Minor#
emcpoweray 120 800
emcpowerd 120 48
emcpoweral 120 592
emcpowerak 120 576

Consider that I'd like to skip the first two lines and associate every colum to a vector of an hash.

Let me know if you have an idea (sorry if my perl knowledge is so low, but I'm studing it since yesterday!!).

Trinita
 
Not tested:
Code:
use strict;
use warnings;
use Data::Dumper;

my %devices;

while (<>) {
   $devices{$1} = [$2, $3] if (/(\w+)\s+(\d+)\s+(\d+)/);
}

print Dumper(%devices);

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Thank you Steve!

Your script have just open a world in front to me! I was getting crazy with split and other options!!

Bye

Ale
 
No problem...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
didn't know perl could open worlds:

Code:
my $surprise = WORLD->new or die "$!";

but it works! [yoda]

That deserves a star (or 20) [smile]

- Kevin, perl coder unexceptional!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top