in reply to Re: Creating 'new' subroutine.
in thread Creating 'new' subroutine.

if the second element is empty
then shift @_ moves to the $_ nothing
which means scalar @_ returns zero
in which case : {} adds into hash nothing,
but creates reference to it
so $options {@_} would do the trick, I guess

please correct if it's wrong

updated


thanks for the correction snippet was incorrect

Replies are listed 'Best First'.
Re^3: Creating 'new' subroutine.
by Anonymous Monk on Oct 11, 2013 at 11:00 UTC
    @_ is an array, an array in scalar context returns the number of elements (a number), and anumber is never a reference
      yes but
      @a = ();
      $b = {@a};
      will create a reference to a hash
Re^3: Creating 'new' subroutine.
by nitin.sh1982 (Initiate) on Oct 17, 2013 at 04:27 UTC
    Thanks for the reply. I still am far from testing it as we are running on mac, and are struggling with the setup. So, do you mean scalar @_ determines how many elements to be added into hash while creating the reference?