How to match crossing line?

J

Jürgen Exner

firenet said:
#!/usr/bin/perl -w
undef $/;
$temp=<>;
#print $temp;
$temp =~ /author (.*?)<\/a>/gs;
print $1;

You should _always_ test is the pattern match sussessfull before using the
captured result.
Had you done that
if ($temp =~ /author (.*?)<\/a>/gs) {
print $1;
} else {
print 'Can\'t match /author (.*?)<\/a>/';
}
then perl would have told you.
I want to get Brian W.Kerniham below.But i get a message"Use of
uninitialized value in print at sss.pl line 6, <> chunk 1." what's
wrong? Thank you.

<br><span class="pl2">author: <a
href=http://www.douban.com/subject_search?search_text=Brian W.Kernigham&amp;cat=1001>
Brian W.Kernigham</a>

jue
 
F

firenet

thank you! i get the name but also the <a herf=url>
i'll work to get rid of it!
thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,041
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top