[PLUG] perl question, Math::Matrix stuff

Eric Wilhelm scratchcomputing at gmail.com
Sat May 6 04:24:16 UTC 2006


# from Russell Senior
# on Friday 05 May 2006 10:53 am:

>  @output = ($subject,$s->transpose);
>  print OUTPUT join(",", at output);

Sorry to leave you hanging all day.  Looks like you figured it out.  
Dereference to get a list.

  @output = ($subject,@{$s->transpose->[0]});

Your earlier output contained ($scalar, $object) where $object would 
typically print as something like the following:

  $ perl -e 'print bless({}, "foo");'
  foo=HASH(0x814cc20)

Or actually, this is an array ref under the hood.

  $ perl -e 'print bless([], Math::Matrix);'
  Math::Matrix=ARRAY(0x814cc20)

But, operator overloading on "" is on, thus the ugly dump builtin 
stringification gets turned into $object->as_string().

>I never had this problem in Awk.

Does awk do operator overloading?

Don't worry.  I still don't quite get it either :-)

  $ perl -e 'print scalar(%{{a => b}})'
  1/8

--Eric
-- 
"Everything goes wrong all at once."
--Quantized Revision of Murphy's Law
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------



More information about the PLUG mailing list