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.

my($next_word) = /and(?=\W*(\w+))/;
You can use list context again, in which case you'll get a list of list of matches, but flattened.
my @pairs = /(and)(?=\W*(\w+))/g;
Test script:
$_ = 'foo and bar and baz went to the sea.'; my @pairs = /(and)(?=\W*(\w+))/g; print join "#", @pairs;
Result:
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


In reply to Re: a Couple of questions! by bart
in thread a Couple of questions! by Nik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.