Hi,
 I'm parsing a log file that contains this format:

1112677214 31388202 181264589
1112677214 8843 59460 8843 59460
1112676919 10728 59045 10728 59045
1112676900 10617 59006 10728 59045
1112676600 8693 58389 9531 59661




These logs are in unix timestamp format:
I'm trying to convert the first column into scalar
localtime.


Here's my code:

our @temp;
open FILE, "./logfile.txt" or die $!;
while (<FILE>){
   foreach my $time(split/\s+/, $_){
 push @temp, $time;
   }
print shift @temp, "\n";
}


... And the output:

1112677214
31388202
181264589
1112677214
8843
59460
8843
59460
1112676919
10728
59045
10728
59045
1112676900
10617
59006
10728
59045
1112676600
8693
58389
9531
59661

This is wiered, it didn't print the very first element
of @temp.

But if I were to change shift into pop:

our @temp;
open FILE, "./logfile.txt" or die $!;
while (<FILE>){
   foreach my $time(split/\s+/, $_){
 push @temp, $time;
   }
print pop @temp, "\n";
}


The output will be:

181264589
59460
59045
59045
59661

It seems to be working fine with pop. 

Any idea?

Thank you very much.














        
                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to