C
Clint Olsen
I tried to return a reference to a capture buffer ($1), and it looks like
the contents are destroyed out from under me. Is there something special
about a capture buffer that makes this impossible?
#!/usr/bin/perl -w
use strict;
use warnings;
sub foo {
my $foo = "barbell";
if ($foo =~ /(bar)/) {
print "$1\n";
\$1;
}
}
print "output of foo is ", ${&foo}, "\n";
results in:
bar
Use of uninitialized value in print at /tmp/reftest line 14.
output of foo is
Thanks,
-Clint
the contents are destroyed out from under me. Is there something special
about a capture buffer that makes this impossible?
#!/usr/bin/perl -w
use strict;
use warnings;
sub foo {
my $foo = "barbell";
if ($foo =~ /(bar)/) {
print "$1\n";
\$1;
}
}
print "output of foo is ", ${&foo}, "\n";
results in:
bar
Use of uninitialized value in print at /tmp/reftest line 14.
output of foo is
Thanks,
-Clint