--- [EMAIL PROTECTED] wrote:
> You might do like this...
> 
> Depending of what you really want to do with your data...
>
> $file_name = "log.txt";
> 
> open (log_file, $file_name)|| die "Cannot open $file_name for reading\n";
>   while (<log_file>) {
>     chomp;
>     #Row from log.txt
>     #2002_01_17_2345 8 9 0 0 36 0 0 2 24 0 22 0 0 0 0
>     ($date, $id_1, $id_2, $id_3, $id_4, $id_5, $id_6, $id_7, $id_8, $id_9,
> $id_10, $id_11, $id_12, $id_13, $id_13, $id_14, $id_15) = split(/ /,$_);
>     print $date, "\n";
>   }
> 
> close log_file;

Whenever you see multiple variables with the same name but with numbers 
differentiating them, you
should reconsider your design.  In this case, we're begging for an array:

    open LOG_FILE, "< $file_name" or die "Cannot open $file_name for reading: $!";

    while (<LOG_FILE>) 
    {
        chomp;
        my ( $date, @id ) = split;
        # do what you will with the variables...
    }

Cheers,
Curtis "Ovid" Poe

=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to