Jim Conner wrote: > > At 19:01 11.18.2001 -0800, John W. Krahn wrote: > >Andrea Holstein wrote: > > > > > > Prasanthi Tenneti wrote: > > > > > > > > Iam a beginner in perl.I have one question, > > > > Iam trying to write one prog,in which i have to search for one word in a > > > > file, > > > > If I found that word,print next 4 lines. > > > > PLs help me,how to write code. > > > > > > open FILE, "<filename"; > > > while (<FILE>) { > > > print(<FILE>,<FILE>,<FILE>,<FILE>), last if /your_word/; > > > > print(scalar <FILE>,scalar <FILE>,scalar <FILE>,scalar <FILE>), > >last if /your_word/; > > How could this be done using the 'x' operator? ie > > print (scalar<FILE>)x4; # doesn't work > > Is there a way to make that work so that you don't have to use "scalar > <FILE>" so many times?
if ( /your_word/ ) { print scalar <FILE> for 1..4; last } > > > } > > > close FILE; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]