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: Need a Custom or Prewritten Perl Program?: I need a program that...: Re: [vdthoughts] Extract specific data (user ID) from log file: Edit Log



BillKSmith
Veteran

Nov 5, 2013, 11:31 AM


Views: 13539
Re: [vdthoughts] Extract specific data (user ID) from log file

Try to understand your warning messages.


Quote
Applying pattern match (m//) to @array will act on scalar(@array) at C:\Users\vut2kor\Desktop\Extract.pl line 9.


The match operator is meant to operate on a string. You have specified an array (@matches). Perl will convert the array to a scalar (number of elements in the array) This is definitly not what you intend!


Quote
Name "main::line" used only once: possible typo at C:\Users\vut2kor\Desktop\Extract.pl line 7.


The variable $line (in package main) is used only once (on line 7)


Quote
Name "main::matches" used only once: possible typo at C:\Users\vut2kor\Desktop\Extract.pl line 9.


Same story for $matches on line 9.


Quote
C:\Users\vut2kor\Desktop\Extract.pl syntax OK


Your code is valid Perl, but given the warnings above, it probably will not do what you intend.


You should always use the following two statements at the beginning of your perl scripts:


Code
use strict; 
use warnings;


It may seem like an inconvenience that they require you to declare (with my) all your variables. The effort will be repaid with less debug time.

Your open statements do not do what you think. Always use the three argument form (Refer: perldoc -f open).

Always use lexical filehandles.


Code
open $LOGFILE, '<', "C:\\Users\\vut2kor\\Desktop\\lic_usage.log" 
or die "Could not open log file.";


Your regex will fail when an ID comes at the end of a line (no comma).



Note: [perl][/perl] tags do not work on this site. Use code instead.
Good Luck,
Bill

(This post was edited by BillKSmith on Nov 5, 2013, 9:22 PM)


Edit Log:
Post edited by BillKSmith (Veteran) on Nov 5, 2013, 9:22 PM: Fix tags


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

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