If you have an input file named sql.txt with the following contents:
this is sql1 line1 this here is sql2 and now we have sql3 for a change
and if you use the following code:
#!/usr/bin/env perl use warnings; use strict; my $FileName = $ARGV[0]; my $String = $ARGV[1]; open(INFILE, $FileName) or die "Cant open the file\n"; # read in each line of the input file while (<INFILE>) { if (/$String/) { # If the $String is found... s/^.*$String//; # Delete $String and everything # before it. print; # then just print to STDOUT } }
then the following output will be produced if you execute this program with the arguments "sql.txt sql1":
line1
Is this what you are trying to accomplish? If not, then please provide some sample contents of your input file, and what your output should look like. Also, it is useful if you post the exact code which you have attempted; the code you provided does not compile.
In reply to Re: isolating strings
by toolic
in thread isolating strings
by dhudnall
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |