Hello,
I am noob to Perl Programming. Here's what I need to do. I need to match a string value from a file and upon matching the value, I need the remainder of the file to be printed to an output.
For example: Here's the File I'll be reading:
Hilton also told Superior Court Judge Michael T. Sauer she was trying to take more responsibility for her life. This, after Hilton essentially laid the blame for her troubles on longtime publicist Elliot Mintz, whom she said told her the license was only suspended for 30 days, through last December, while it had actually been suspended into March.
Value to match = Elliot
Reqd Output:
Mintz, whom she said told her the license was only suspended for 30 days, through last December, while it had actually been suspended into March.
Here's the code i have so far:
open (FILE, "$infile") or die "Cannot Open Log File!\n";
open (DAT,">$outfile") || die("Cannot Open File");
while (@variable = <FILE>) {
for (@variable =~ m/Elliot/) {
@Stringvar = "@variable";
@Stringvars = split(m/Elliot/,@Stringvar);
# write to the data file
print DAT "$IOSvars[0]\n";
}
}
close DAT;
close FILE;
I am noob to Perl Programming. Here's what I need to do. I need to match a string value from a file and upon matching the value, I need the remainder of the file to be printed to an output.
For example: Here's the File I'll be reading:
Hilton also told Superior Court Judge Michael T. Sauer she was trying to take more responsibility for her life. This, after Hilton essentially laid the blame for her troubles on longtime publicist Elliot Mintz, whom she said told her the license was only suspended for 30 days, through last December, while it had actually been suspended into March.
Value to match = Elliot
Reqd Output:
Mintz, whom she said told her the license was only suspended for 30 days, through last December, while it had actually been suspended into March.
Here's the code i have so far:
open (FILE, "$infile") or die "Cannot Open Log File!\n";
open (DAT,">$outfile") || die("Cannot Open File");
while (@variable = <FILE>) {
for (@variable =~ m/Elliot/) {
@Stringvar = "@variable";
@Stringvars = split(m/Elliot/,@Stringvar);
# write to the data file
print DAT "$IOSvars[0]\n";
}
}
close DAT;
close FILE;