perl coding style question

marcos rebelo oleber at gmail.com
Tue Aug 16 12:28:05 BST 2011


the is the case of the given/when, the code blocks and $_, for example:

use strict;
use warnings;
use v5.10;

use List::Util;

given (0) {
	when (0) {
		say List::Util::first { $::_ > 3 } (1..10)
	}
}


prints 4





use strict;
use warnings;
use v5.10;

use List::Util;

given (0) {
	when (0) {
		say List::Util::first { $_ > 3 } (1..10)
	}
}

first return undef




Crazy result ;)

Best Regards
Marcos

On Tue, Aug 16, 2011 at 12:47, Alex Brelsfoard
<alex.brelsfoard at gmail.com> wrote:
> Hi All,
>
> I just came across some code that used some old-style coding practice, and I
> wanted to know if there was still any GOOD reason for using it.
>
> The code I saw was referencing variables using the $:: pragma:
>
> if ($::var) {
>   ...
> }
>
> To my understanding this is a bit messy, and not to mention potentially
> dangerous as it kinda goes against the "use strict;" methodology, does it
> not?
>
> I haven't seen this style code in a long time so I wanted to get other
> feedback on its potential benefits before I suggest updating it.
> Thanks in advance to all that can help.
>
> --Alex
>



-- 
Marcos Rebelo
http://www.oleber.com/
Webmaster of http://perl5notebook.oleber.com



More information about the london.pm mailing list