Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2015-07-28 18:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls