in reply to a Couple of questions!
a) There's a recent thread here (I think in meditations, "Perl idioms explained", but I'll look it up for you) that explains what happens with // and //g. In short: you need to use //g in list context, and extract the count from there.
$count = () = $data =~ m/and/g;
Update: Got it: Perl Idioms Explained - @ary = $str =~ m/(stuff)/g
b) Even if it's another "and"? Use lookahead.
You can use list context again, in which case you'll get a list of list of matches, but flattened.my($next_word) = /and(?=\W*(\w+))/;
Test script:my @pairs = /(and)(?=\W*(\w+))/g;
Result:$_ = 'foo and bar and baz went to the sea.'; my @pairs = /(and)(?=\W*(\w+))/g; print join "#", @pairs;
and#bar#and#baz
c) That's just his point of view. Tastes vary. I happen to disagree. But that's just me. :)
d) Dunno. Maybe you should try out one of those template modules. That way you can separate code (script) from design (template). There's a nice list in the intro chapter of the Mason book: chapter 1
There's also a comparative list in this article on <perl.com>: Choosing a Templating System
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: a Couple of questions!
by Nik (Initiate) on Sep 20, 2003 at 14:49 UTC | |
by jeffa (Bishop) on Sep 20, 2003 at 15:18 UTC |