Yun yun wrote:
>
> How can I read a line from a file, and judge whether
> this line include some substr?
> Now I only can open(HANDLE,"<XXXXX");
> then how should I do?
#!/usr/bin/perl -w
use strict;
my $substr = 'something';
open HANDLE, '<XXXXX' or die "Cannot open 'XXXXX' $!";
while ( <HANDLE> ) {
# method 1
if ( /$substr/ ) {
# $substr is in the current line ($_) somewhere
# perldoc perlre
# perldoc perlop
}
# method 2
if ( ( my $pos = index( $_, $substr ) ) >= 0 ) {
# $substr is in the current line ($_) at $pos
# perldoc -f index
# perldoc -f rindex
}
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]