The goal is to read the code in the file being opened and output only the text strings that match the regular expression of /<b>anything</b>/ to a new file.
Here is the current code:
____________________________________________________________
#!/usr/bin/perl
open(SOURCE, "file") || die("can't open file: $!");
So where do you need help?
Seems like you got most of it. Just do a little more studying.
Code:
#!/usr/bin/perl
use strict;
## open filename1 for reading
open(SOURCE, "file") || die("can't open file: $!");
## open filename2 for writing
open(DESTIN, "file") || die("can't open file: $!");
while (<SOURCE>) {
chomp; ## remove EOL char
if (regex test valid) {
print DESTIN "$_\n";
}
}
close DESTIN;
close SOURCE;
Bookmarks