From: "Ing. Branislav Gerzo" <[EMAIL PROTECTED]>
> Harsh Busa [HB], on Sunday, January 16, 2005 at 01:42 (+0530) thinks
> about:
> 
> HB>  my $doc =
> $atomic->get('http://www.timaoutloud.org/xml/atom.xml');
> 
> in this line you have error, you have to write:
> my ($doc) = $atomic->get('http://www.timaoutloud.org/xml/atom.xml');

Don't think so. This may make a difference, but I don't think it 
would in this case.

I tried Harhs's code with a recently installed XML::Atom::Syndication 
0.08 and it seems to work fine. Exactly the same results without and 
with the braces.

Jenda

P.S.: Explanation for those new engough to Perl:
The braces change the context in which the $atomic->get() method is 
called. In the first case it's called in scalar context, in the 
second in list context. The method may test for the context using the 
wantarray() builtin and return different results in each case:

        my $x = localtime();
        print "$x\n";
vs.
        my ($x) = localtime();
        print "$x\n";

The result may be different even without the method testing it 
directly. If the return statement looks like this:

        return @array;

then in scalar context you'll get the number of elements in the array 
and in list context you'll get the contents. In which case the 
behaviour could be 1 in scalar context and the object in list 
context:

        sub foo {
                my @arr = ('obj');
                return @arr;
        }

        my $x = foo();
        print "$x\n";
        my ($x) = foo();
        print "$x\n";

Doesn't seem to be the case with XML::Atom::Syndication.

Jenda

===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to