Back again: I have some more questions. I also wanted to ask about cukimunsters help on my script. Here is the suggestion:

open(FW_LOG, $firewall_log) or die "$firewall_log open() failed: $!"; open(MYNEWFILE, ">>$my_new_log:") or die "$my_new_log open() failed: $!"; while ($line = <FW_LOG>) { if ($line =~ /kernel Temporarily blocking host/ || $line =~ /block +ed/) { # your line transformations would go here... print MYNEWFILE $line; } close(FW_LOG) or die "$firewall_log close() failed: $!"; close(MYNEWFILE) or die "$my_new_log close() failed: $!";
Now, I was playing around with this code. (Granted, I am very new and raw to Perl so please bear with me.) I was trying to figure out how to implement this code and learn from it, but for some reason, I cannot seem to get it working. It is probably because I have a TON of information on Perl to learn, but I am working on it. Anyways, I tried to add some code from my original script and this is what I got: (Note, I cant get this script to work though :/ )
#!/usr/bin/perl #Variables $firewall_log = "/home/jwilliams/firewall.txt"; $my_new_log = "/home/jwilliams/extracted_log"; open(FW_LOG, $firewall_log) or die "$firewall_log open() failed: $!"; open(MYNEWFILE, ">>$my_new_log:") or die "$my_new_log open() failed: $!"; while ($line = <FW_LOG>) { if ($line =~ /kernel Temporarily blocking host/ || $line =~ /block +ed/) { # your line transformations would go here... print MYNEWFILE $line; } close(FW_LOG) or die "$firewall_log close() failed: $!"; close(MYNEWFILE) or die "$my_new_log close() failed: $!";
If anyone has some thoughts, feel free to. I have learned a tremendous amount about Perl in just the last day from being here.

Secondly, what steps would anyone recommend take for me to fully learn and understand Perl so I can utilize it more efficiently? I appreciate all comments and suggestions.

Tarballed


In reply to Re: My first Perl script by tarballed
in thread My first Perl script by tarballed

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.