#!/usr/bin/perl $string = 'test'; $inputs = 'test.txt'; open(TABLE, $inputs) or die "can't open $inputs.\n"; while ( $line = ) { if ( $_ =~ $string ) { print $_; } } close(IN); #### #!/usr/bin/perl use strict; use warnings; my $string = 'test'; my $inputs = 'test.txt'; # see perlfunc open( my $in, '<', $inputs) or die "can't open $inputs.\n"; while ( <$in> ) { # see perlsyn, perlop if ( $_ =~ m/^$string(.*)/ ) { # see perlre print $1; # see perlvar, perlre } } close( $in ); # see perlfunc #### #!/usr/bin/perl use strict; use warnings; while ( <> ) { # takes filenames on the command line or STDIN if none print ( ( split )[1] ); }