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"
In reply to $/ usage
by mimiandi
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|