in reply to Re: Implicit assignment to $_
in thread Implicit assignment to $_

"This is a prime example of why I preach so heavily about use strict;. If you had invoked that pragma you'd have seen the warning:

"Use of uninitialized value $_ in print at sopw-simple.pl line 6."

Nuh-uh... strict does no such thing.

strict does three things:

strict never issues any warnings. And strict doesn't care about variables being undef (unless you try to dereference them).

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^3: Implicit assignment to $_
by blue_cowdawg (Monsignor) on Feb 26, 2013 at 18:40 UTC
        Nuh-uh... strict does no such thing.

    Really? That's a copy/paste from my terminal. Wish there was a way to post screenshots to PM.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

      You probably ran Perl with -w then, because it's warnings that produces that error.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

        Confirmed (with 5.14.2):

        $ cat test.pl use strict; "Test A"or"Test B"; print; $ perl test.pl $ perl -w test.pl Use of uninitialized value $_ in print at test.pl line 3.