I would like to extract the user ID's only from the log file. I have copied the sample code below. All the user ID's are inbetween the text "ID principal: " & ", ". Later i would like to use the data to be copied into an excel sheet to create a chart. Can anybody help me to write a perl script for the same. I have never done some complex task on perl prog till now. --------------------------------------------------------- Sample log file code:

Compilation error:C:\Users\vut2kor>perl -wc C:\Users\vut2kor\Desktop\Extract.pl Applying pattern match (m//) to @array will act on scalar(@array) at C:\Users\vut2kor\Desktop\Extract.pl line 9. Name "main::line" used only once: possible typo at C:\Users\vut2kor\Desktop\Extract.pl line 7. Name "main::matches" used only once: possible typo at C:\Users\vut2kor\Desktop\Extract.pl line 9. C:\Users\vut2kor\Desktop\Extract.pl syntax OK

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