Timothy B wrote:
"Hello out there - I have learned a lot of Perl today, but I am still
trying
to figure one more thing out.
How can I go through a file and extract all the text between certain
delimiters - for example I have:
Bilbo, "Why I like rings" Freemont Press, 1998.
Frodo, "Why I don't" Bridgedale Freemans, 1832
Etc
I want to get:
Why I like rings
Why I don't
It seems like there should be a real quick way to do this. . . thoughts?
tim"
You could look at the page and see what the phrases have in common, then
make a regex delimiter to extract them. see below:
#!/usr/bin/perl -w
use strict;
my $bilbo = "Bilbo,\"Why I like rings\" Freemont Press, 1998,";
my $frodo = "Frodo, \"Why I don't\" Bridgedale Freemans, 183";
my @array=($bilbo,$frodo);
#I want to get:
#Why I like rings
#Why I don't
foreach(@array){
(/(".*")/) ? print $1 . "\n" : print "not your string\n";
}
In the above example i had to escape the quotes to use them. If you have
a whole plain text file of you can just use the open(FILE, "myHobit") ||
die "$!"; then use a similar search. Have fun.
-dw5