in reply to unable to post to forum

It worked fine for me, no errors, although I didn't check what it is supposed to do.

I'm curious about the syntax:

$agent->get(my $url="http:.....");
I didn't know that's valid, anyone cares to explain? Thanks.

Replies are listed 'Best First'.
Re^2: unable to post to forum
by grinder (Bishop) on Nov 29, 2005 at 12:59 UTC

    The embedded my? Yes it's perfectly valid, although I quite agree that it looks odd, but the simple fact of the matter is that lexicals can be created pretty much anywhere in a statement.

    It's (I think) what lets you do:

    if( my $foo = bar(@quux) ) { $foo exists here } # no foo here

    I'm certain it's what lets you say:

    (my $copy = $original) =~ s/foo/bar/;

    That is, the variable $copy doesn't fall out of scope outside the parentheses. Sometimes it makes for nicer code, sometimes bizarre. Be wary of trying this new toy out everywhere :)

    • another intruder with the mooring in the heart of the Perl

A reply falls below the community's threshold of quality. You may see it by logging in.