Hi,
I have a simple 30 line perl script which basically just compares a bunch of numbers in a list. I'm a little rusty with perl as I haven't used it in a few years now, but no matter what I try, I can't get past the syntax error which is complaining about the line where I compare two numbers out of my array. I've given up and just can't see what is wrong. Is there a monk out there who could guide me please? I hate to post up on such a simple thing, but I'm totally stuck.
Running the script complains of a syntax error:
$ ./perlAnalyzeDailyStats.pl
syntax error at ./perlAnalyzeDailyStats.pl line 29, near "@array("
Execution of ./perlAnalyzeDailyStats.pl aborted due to compilation err
+ors.
1 #!/usr/bin/perl
2
3 @files = `ls -1trh s3_dailystats.*`;
4 foreach (@files)
5 {
6 $filename = $_;
7 #print $filename;
8 open(FH,"<$filename");
9 while(<FH>)
10 {
11 $line = $_;
12 if($line =~ /([0-9]{17,18})/)
13 {
14 print "$1\n";
15 push(@array,$1);
16 last;
17 }
18 }
19 }
20 $arrayCount = @array;
21 print "array count is $arrayCount";
22 foreach(@array)
23 {
24 if ($counter eq $arrayCount)
25 {
26 last;
27 }
28 $counter++;
29 print "difference is " . @array($counter) - @array($counte
+r - 1);
30 }
31
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.