cheech has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use IO::File; use constant FILE => 'search.txt'; use constant FIND => 'string to find'; IO::File->input_record_separator(FIND); my $fh = IO::File->new(FILE, O_RDONLY) or die 'Could not open file ', FILE, ": $!"; $fh->getline; #fast forward to the first match #print each occurence in the file print IO::File->input_record_separator while $fh->getline; $fh->close;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Scanning a file for a match, printing different part of the line when found.
by wind (Priest) on Mar 26, 2011 at 19:20 UTC | |
by cheech (Beadle) on Mar 26, 2011 at 19:42 UTC | |
Re: Scanning a file for a match, printing different part of the line when found.
by jwkrahn (Abbot) on Mar 26, 2011 at 19:27 UTC | |
Re: Scanning a file for a match, printing different part of the line when found.
by ww (Archbishop) on Mar 26, 2011 at 20:10 UTC | |
Re: Scanning a file for a match, printing different part of the line when found.
by philipbailey (Curate) on Mar 26, 2011 at 19:42 UTC | |
by ww (Archbishop) on Mar 26, 2011 at 20:21 UTC | |
Re: Scanning a file for a match, printing different part of the line when found.
by ELISHEVA (Prior) on Mar 26, 2011 at 18:55 UTC |