Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi All, I am looking for a certain string from a huge log file for approx 1000 ID's. The log file is in a text format. Each log file is separate for each ID and the no of lines each has varies. With the code I have written it goes into each log file, looks for that particular string. When it does not find anything it does not print anything. But once it hits the string I am looking for it keeps on printing the same string for all the other ID's. Any help will be greatly appreciated. My code is as below:

$messages = "N/A"; open(MYINPUTFIL3, "file path"); while(<MYINPUTFIL3>){ chomp; $SYS=$_; $SYS =~ s/\r|\n//g; if($SYS =~ /search string/i) { $message_1=$SYS ; $message_1 =~ s/\r|\n//g; $message_1=~ s/^\s+//; $message_1=~ s/\s+$//; $message_11 = $message_1; $message_12 = $message_1; $message_12 = s/[^a-zA-Z]*//g; $message_11 =~ s/[^0-9.]*//g; last; } } close MYINPUTFIL3; print "$message_1\n"; open(FILEWRITE, ">>trial_one.txt"); print FILEWRITE "$message_1\n"; close (FILEWRITE);

In reply to Looking for a string from a huge log file by perl_req

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found