On Dec 17, 2003, at 7:28 PM, PerlDiscuss - Perl Newsgroups and mailing lists wrote:

Hi, I have a file extremely large in size and length. I want to read the
file line by line and worry about matching up each line and running that
line through a subroutine instead of opening the entire file (which would
take a while).
So how do I open a file up and process each line individually?

Well the following is traditional.


#!/usr/bin/perl

use strict;
use warnings;

while (<>) {      # use with >perl script_name file1 file2 ...
        # do something here
        # line is in default variable, $_
}

__END__

Hope that helps.

James


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




  • Line by line PerlDiscuss - Perl Newsgroups and mailing lists
    • James Edward Gray II

Reply via email to