venkatlab has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am trying to match user input ($a=<STDIN>)with the data $_(read from a file). And print or store the data after the matched string.
For example:
if the User input is $a= temp
data read from a file is $_=temp validate end
then print result as Validate
if the 1st string matches then eliminate last string(end) & print the middle string.
sample Codenot working)
#!/usr/bin/perl -w $string = "The food is in the salad bar"; $a=<STDIN>; $string =~ m/($a)/; print "Before: $`\n"; print "Matched: $&\n"; print "After: $'\n";
Kindly help me
Thanks in Advance
Venky
20091208 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl help needed:match user input with data read from a file
by keszler (Priest) on Dec 06, 2009 at 21:16 UTC | |
|
Re: Perl help needed:match user input with data read from a file
by GrandFather (Saint) on Dec 06, 2009 at 21:39 UTC |