in reply to My first Perl script
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 :/ )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.#!/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: $!";
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: My first Perl script
by Nkuvu (Priest) on Apr 10, 2003 at 19:58 UTC | |
by tarballed (Initiate) on Apr 10, 2003 at 20:13 UTC | |
by Nkuvu (Priest) on Apr 10, 2003 at 21:19 UTC |