$name" or die "Can't create $name: $!";...">

The :: gensym symbol is still useful after perl 5.6?

I saw a code like this:

my $fh = gensym; open $fh, ">$name" or die "Can't create $name: $!"; 

which can be written as:

 open my $fh, ">$name" or die "Can't create $name: $!"; 

Is gensym just obsolete or still useful in some cases?

+6
source share
1 answer

Inheritance. Globes, not vocabulary, sometimes required by old modules, but what is it.

 use IPC::Open3 qw( open3 ); open(local *CHILD_STDIN, '<', '/dev/null') or die $!; my $pid = open3( '<&CHILD_STDIN', my $CHILD_STDOUT = gensym(), my $CHILD_STDERR = gensym(), $cmd, @args, ); 

On the other hand, you can also use them to create aliases (although Data :: Alias can do this with lexical files).

 my $foo; our $bar; local *bar = \$foo; $foo = 123; say $bar; # 123 $bar = 456; say $foo; # 456 
+8
source

All Articles