CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Re: [yanivr78] Regex source -> destination line matches...: Edit Log



FishMonger
Veteran / Moderator

Mar 8, 2013, 4:44 PM


Views: 2623
Re: [yanivr78] Regex source -> destination line matches...


Quote
if you can see, there are 3 IP's within these lines,

Those sample lines have 2 IP addresses each. I'm not sure where you're getting 3 IP's. So, which IP's do you want to capture?

A couple side comments.

Please use the code tags around your code to retain the code formatting which makes it easier for us to read your script.

You should add the warnings and strict pragmas, which should be in every Perl script you write.


Code
#!/usr/bin/perl 

use warnings;
use strcit;


The strict pragma will require you to declare your vars, which is normally done by adding the 'my' keyword.

Code
my %arguments=@ARGV;


Your script would be improved by using the Getopts::Long module for handling the parsing of the command line args.
http://search.cpan.org/~jv/Getopt-Long-2.38/lib/Getopt/Long.pm

Add to that the use of Pod::Usage module to handle the output of the usage statement and additional help documentation.
http://search.cpan.org/~marekr/Pod-Usage-1.61/lib/Pod/Usage.pm

Don't use bareword filehandles. Instead, use a lexical var for the handle. Also, use the 3 arg form of open and include the reason it failed in the die statement (i.e., include the $! var in the statement).

Don't use '&' when calling a sub unless you know and understand its side effects and want/need those side effects.


(This post was edited by FishMonger on Mar 8, 2013, 4:46 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Mar 8, 2013, 4:45 PM
Post edited by FishMonger (Veteran) on Mar 8, 2013, 4:46 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives