On Wed, 27 Jun 2007 11:56:51 +0300
"Levenglick Dov-RM07994" <[EMAIL PROTECTED]> wrote:

> Can someone please explain why call_bad doesn't print the file? What
> is the difference between it and call_good?
> 

Try this, then read the docs referenced in comments.
here's a snippet of same:

"If what's within the angle brackets is neither a filehandle nor a
simple scalar variable containing a filehandle name, typeglob, or
typeglob reference, it is interpreted as a file- name pattern to be
globbed, and either a list of filenames or the next filename in the
list is returned, depending on context.  This distinction is determined
on syntactic grounds alone.  That means "<$x>" is always a readline()
from an indirect handle, but "<$hash{key}>" is always a glob().  That's
because $x is a simple scalar variable, but "$hash{key}" is not--it's a
hash element."


#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
use Fcntl qw(:seek);

open (IN, "$0") or die "$!\n";
call_good(*IN);
seek(IN,0,SEEK_SET); #rewind the file
call_bad(*IN);

sub call_bad 
{
        my $moof;
        print "also works!\n";
        $moof=shift;
        print while <$moof>;
        #for why, see perlop, grep angle brackets is neither a
}
sub call_good 
{
        print "Works\n";
        *A = $_[0];
        print while <A>;
}


-- 
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
Art is a lie which makes us realize the truth.
                -- Picasso
----

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl

Reply via email to