#!/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