Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: File Manipulation

by johngg (Abbot)
on Aug 23, 2013 at 13:26 UTC ( #1050673=note: print w/ replies, xml ) Need Help??


in reply to File Manipulation

Just to bring another bottle to the party and to take up ww's suggestion on input record separator.

$ perl -Mstrict -Mwarnings -MData::Dumper -e ' open my $inFH, q{<}, \ <<EOD or die $!; [server1] /tmp/location1/file.log /tmp/location2/file.log [server2] /usr/loc1/file.log /usr/loc2/file.log [server3] /citrix/dir3/file.log EOD my %assoc; { local $/ = q{[}; scalar <$inFH>; # Get rid of first '[' while ( <$inFH> ) { chomp; my( $server, $fileStr ) = split m{]\n}; $assoc{ $server } = [ split m{\n}, $fileStr ]; } } print Data::Dumper->Dumpxs( [ \ %assoc ], [ qw{ *assoc } ] );' %assoc = ( 'server3' => [ '/citrix/dir3/file.log' ], 'server2' => [ '/usr/loc1/file.log', '/usr/loc2/file.log' ], 'server1' => [ '/tmp/location1/file.log', '/tmp/location2/file.log' ] ); $

I hope this is helpful.

Cheers,

JohnGG


Comment on Re: File Manipulation
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-12-18 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls