There's more than one way to do things | |
PerlMonks |
Confusion with contextby thinker (Parson) |
on Mar 11, 2005 at 10:39 UTC ( [id://438593]=perlquestion: print w/replies, xml ) | Need Help?? |
thinker has asked for the wisdom of the Perl Monks concerning the following question: Hello everyone I was writing a function to extract enum values from a mysql table, when I encountered something which confused me. My first attempt was
This works fine, but I felt there should be no need for the temporary $f variable My first attempts at removing it brought failure, as the $ref -> [1] =~ /enum\('(.*)'\)/ was returning in the wrong context (I think), and returning "1". After some experimentation I discovered that what I wanted could be achieved by return split "','", ( $ref->[1] =~ /enum\('(.*)'\)/ )[0]; I have decided that my original version, with temp variable, is clearest, and will be what i use, but I wonder if anyone could kindly explain what is happening here, and why I need the [0] at the end Thank You thinker
Back to
Seekers of Perl Wisdom
|
|