![]() |
|
Just another Perl shrine | |
PerlMonks |
Re^2: Text Analysis: given(){when(){}} block throws a 'useless use of private variable...etc' errorby biohisham (Priest) |
on Oct 18, 2010 at 17:15 UTC ( [id://865993]=note: print w/replies, xml ) | Need Help?? |
You provided some very interesting clues to inspire me
I'm quessing $_ is the private variable which is not used.If given takes a single variable or value and yet quite interesting still, it actually works with two values, even with three values as I tried it in the following demo, that means it is a very strong function that we probably need to develop more for us to avail of its full capacity in Perl 5. Thinking about if we can have an embedded given(){when(){}} to make it accept two arguments is out of the question since that may lead to a labyrinth of brain-damaging curlies but maybe just keeping track of the arguments passed to given in @_ may provide a path to beat if that can be possible... Notice that the last 2 when blocks are both true however, the first one in order which evaluates to true is the one that gets its print statement executed and the second one is totally ignored, perambulation of the when blocks can testify to that... The reason I used a switch statement is because I wanted to clean up my code from the if else pollution in a quick way and the switch is a very neat way to do so, also, the values assigned to '' are going to be needed in another extension to the original code ergo the $var ||= '' statement. Checking perlsyn for clues.. Excellence is an Endeavor of Persistence. A Year-Old Monk :D .
In Section
Seekers of Perl Wisdom
|
|