Nov 5, 2013, 11:31 AM
Try to understand your warning messages.
Re: [vdthoughts] Extract specific data (user ID) from log file
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!
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)
Name "main::matches" used only once: possible typo at C:\Users\vut2kor\Desktop\Extract.pl line 9.
Same story for $matches on line 9.
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:
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.
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.
(This post was edited by BillKSmith on Nov 5, 2013, 9:22 PM)