in reply to Re: Improve My Code...
in thread Improve My Code...

Thanks for your suggestions, I appreciate it. This all made sense except one thing.. why when I change my pattern-match variables from arrays to scalars (@rain to $rain = $page +~ /.../ for example) do I need to have parentheses around them to get the output I want. Does it have something to do with scalar vs list data? Thanks again!

Replies are listed 'Best First'.
Re^3: Improve My Code...
by GrandFather (Saint) on Aug 10, 2009 at 00:02 UTC
    Does it have something to do with scalar vs list data?

    Indeed it does. In scalar context (my $var =) a match regex returns true or false. In list context (my ($var) =) a match regex returns the list of captures. You are interested in just the contents of the first capture so:

    my ($var) = $page =~ /...(...).../;

    is the appropriate syntax.

    Update: provide complete code line to illustrate appropriate list context usage.


    True laziness is hard work