http://qs321.pair.com?node_id=663973


in reply to Re^3: regexp list return 5.6 vs 5.8
in thread regexp list return 5.6 vs 5.8

Wow, so the [[] was not a typo? I thought it was. I still don't understand how it could have got there! What does it print when you use different delimiters? (like print "{", scalar(test('abc')), "}";)

use strict; use warnings; print "Just Another Perl Hacker\n";

Replies are listed 'Best First'.
Re^5: regexp list return 5.6 vs 5.8
by hipowls (Curate) on Jan 24, 2008 at 10:21 UTC

    Strange indeed.

    michael$ perl t.pl {{} {} {123} {123}

      Putting the call inside a @{[ ... ]} construct does something different.

      print "[@{ [ scalar test('abc') ] }]\n"; print "[", scalar test('abc'), "]\n\n"; print "[@{ [ test('abc') ] }]\n"; print "[", test('abc'), "]\n\n"; print "[@{ [ scalar test('123') ] }]\n"; print "[", scalar test('123'), "]\n\n"; print "[@{ [ test('123') ] }]\n"; print "[", test('123'), "]\n"; sub test { my @rv = $_[0] =~ /^([0-9]+)$/; return @rv[ 0 .. $#rv ]; }

      produces

      [ ] [[] [] [] [123] [123] [123] [123]

      Running 5.8.4 on Solaris 9.

      Cheers,

      JohnGG