mimiandi has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks -- quick question for ya guys i thought i could slurp the whole file from command line using the following code, havent had any luck. wonder if can't do this from the commandline -- if i replaced the /n with // it shows up in one line but was wondering why it wouldnt work with undef $/ Thanks and Happy New Year!
perl -e 'undef $/; $text=<>; print $text; $/="\n";' list
list contains the following information
server1 ipaddress
server2 ipaddress
server3 ipaddress
etc ..
graff: thanks -
Went with the following to do what i wanted :
perl -e 'undef $/; $text=<>; $text =~ tr/\n//; 1 while $text =~ s/\b( +\w+\d+\s*\d+\.\d+\.\d+\.\d+)\s*\1\b/$1/ig; print $text; $/="\n"; list
basically deletes the duplicates entries one after the other with "slurping"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: $/ usage
by graff (Chancellor) on Jan 02, 2013 at 21:41 UTC | |
by mimiandi (Novice) on Jan 02, 2013 at 21:54 UTC | |
by graff (Chancellor) on Jan 02, 2013 at 22:44 UTC | |
Re: $/ usage
by ww (Archbishop) on Jan 02, 2013 at 21:38 UTC | |
Re: $/ usage
by 7stud (Deacon) on Jan 03, 2013 at 02:08 UTC | |
Re: $/ usage
by Anonymous Monk on Jan 02, 2013 at 21:27 UTC | |
by mimiandi (Novice) on Jan 02, 2013 at 21:47 UTC |
Back to
Seekers of Perl Wisdom