in reply to Re: Meaning of 'use constant USAGEMSG = > ...'
in thread Meaning of 'use constant USAGEMSG = > ...'

Your code won't work because use is executed before the assignment to $c. Even if $c was initialized in a BEGIN block, it would still be too late.

Replies are listed 'Best First'.
Re^3: Meaning of 'use constant USAGEMSG = > ...'
by Anonymous Monk on Feb 09, 2005 at 11:37 UTC
    #!/usr/bin/perl use strict; use warnings; my $c; BEGIN { $c = <<USAGE; What do you mean, too late? USAGE } use constant USAGEMSG => $c; print +USAGEMSG; __END__ What do you mean, too late?

      hum, I had tested

      BEGIN { $c = <<USAGE; What do you mean, too late? USAGE use constant USAGEMSG => $c; }

      and

      BEGIN { $c = <<USAGE; What do you mean, too late? USAGE } use constant USAGEMSG => $c;

      and both gave me the same error. Maybe the file wasn't properly saved for the second test?

      Thanks for verifying; it puzzled me.