Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Moose and File::Temp

by tobyink (Abbot)
on Nov 19, 2012 at 14:05 UTC ( #1004544=note: print w/replies, xml ) Need Help??


in reply to Re: Moose and File::Temp
in thread Moose and File::Temp

You may have some difficulty with isa => 'FileHandle' because while FileHandle is a core Perl module, Moose uses the type constraint string "FileHandle" to refer to unblessed Perl file handles - i.e. not objects created by the FileHandle package.

open my $fh , "<", "temp.txt"; $self->fh($fh); while (<$fh>) { print $_; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^3: Moose and File::Temp
by gsiglet (Acolyte) on Nov 19, 2012 at 14:26 UTC
    So it is impossible to use  while(<$self->{IamAfileHandleAttribute}>) { ... } > to read a file, outside my constructor. I guess I will have to do:
    my $temp_fh = $self->{IamAfileHandleAttribute}; while (<$temp_fh>) { ... }
      So it is impossible to use while(<$self->{IamAfileHandleAttribute}>) { ... } > to read a file
      no, it's not really impossible. you can just use readline instead of the diamond operator.
      while (readline $self->{IamAfileHandleAttribute}) {

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004544]
help
Chatterbox?
[erix]: yeah, you mediteraaneans are one big family :)
[Discipulus]: greece had to copyrigth etymologies to fill the debt..
[erix]: good no-nonsense american approach to these soft european practices: "Upon entering the Almshouses in Connecticut, patients were whipped up to 10 times"
Discipulus should have..
[erix]: the almshouse generally seems to have become an anglosaxon relic :P
[Discipulus]: just to be sure was not for a free lunch.. sbaaam!
[Discipulus]: here now we call them Cities
[erix]: 'cities'? in italian? are they funded by charity?
[LanX]: The New Testament was first "published" in Greek, that's why

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-11-23 20:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (338 votes). Check out past polls.

    Notices?