On 5/23/06, Uri Guttman <[EMAIL PROTECTED]> wrote:
> >>>>> "BT" == Ben Tilly <[EMAIL PROTECTED]> writes:
>
>   BT> If you didn't remember the do local trick, you could always use Symbol
>   BT> and then call gensym to get your typeglob.
>
> i have used Symbol::gensym for years and it is fine for this. it comes
> with perl5 from way back before 5.6 (not sure how old it is). in fact i
> still use it in some modules as i want them to be backward compatible
> with older perls.
>
>   BT> As for passing old-style filehandles, both of the following syntaxes
>   BT> are likely to work:
>
>   BT>   call_function(*FILEHANDLE);
>   BT>   call_function(\*FILEHANDLE);
>
> i prefer the ref version but inside the called sub it won't make a
> difference and the code will mostly be the same.
>
> but there is one difference which is whether you can do OO calls on the
> handle. you may need to load IO::Handle (or one of its many subclasses)
> to get that support.

That isn't a difference, at least not with current versions of Perl.
You can do OO calls on the handle after using either syntax to pass it
in.  Which methods are available depends on what modules have been
loaded.

  perl -le 'sub foo {$fh = shift; $fh->print("hello")} foo(*STDOUT)'
  perl -MFileHandle -le 'sub foo {$fh = shift; $fh->print("hello")}
foo(*STDOUT)'

I don't know whether that flexibility goes back to Perl 5.005 though.

Cheers,
Ben
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to