in reply to mapping through filehandles

See perlman:perldata. Here an example:
my $log = "Hello World!"; my $stdout_handler = \*STDOUT; my $r_handler = \*R; # R has been open()-ed as usual map { print $_ $log } ($stdout_handler, $r_handler);

Replies are listed 'Best First'.
Re: Re: mapping through filehandles
by runrig (Abbot) on Oct 28, 2001 at 21:49 UTC
    No need for map in void context:
    print $_ $log for \*STDOUT, \*R;
    P.S. I think I saw this from tye in the CB awhile back :-)
Re: Re: mapping through filehandles
by Anonymous Monk on Oct 28, 2001 at 20:51 UTC
    That can be simplified to
    map { print $_ $log } (STDOUT, R);
    without the need for the $stdout_handler or $r_handler.
      Yes, as Anonymous Monk said, one could be lazy, without using any reference to file handles, but this practice has the backlash that is does not work using strict. A solution (but I personally don't like it) is to use a throw-away block in order to conjuring with barewords without strict:
      { no strict; map { print $_ $log } (STDOUT, R); } $foo = "bar"; # Error! here we're re-using string

      Update: runrig's one is the best way to be lazy :)