Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: A Few Questions About IO::File

by hdb (Monsignor)
on Mar 18, 2013 at 15:19 UTC ( [id://1024082]=note: print w/replies, xml ) Need Help??


in reply to Re^2: A Few Questions About IO::File
in thread A Few Questions About IO::File

When you chain the commands you will not get a handle to close the file. I have to admit that I am not so sure myself when the file will get closed...

Replies are listed 'Best First'.
Re^4: A Few Questions About IO::File
by tobyink (Canon) on Mar 18, 2013 at 15:30 UTC

    It will close when Perl hits the semi-colon, because that is when Perl realises the object has gone out of scope.

    Quick demo:

    use v5.14; package Foo { sub new { my $class = shift; say "new"; bless [] => $class; } sub some_method { my $self = shift; say "some_method"; return $self; } sub other_method { my $self = shift; say "other_method"; return 123; } sub DESTROY { my $self = shift; say "DESTROY"; } } say "START"; say Foo->new->some_method->other_method and say 456; say "END";

    DESTROY happens after "456" is printed, but before "END".

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1024082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found