On Tue, Apr 17, 2012 at 02:30:59PM +0200, Manfred Lotz wrote:
> > Could someone please expand on this as I seem to always have to do
> > this. If I 'use strict' and 'use warnings' I get errors if I don't.
> > 
> 
> One example is this:
> 
> #! /usr/bin/perl
> 
> use strict;
> use warnings;
> 
> mysub;
> 
> sub mysub {
>   print "Hi there\n";
> }
> 
> If you run this you get an error:
> Bareword "mysub" not allowed while "strict subs" in use at ./testsub.pl
> line 6. Execution of ./testsub.pl aborted due to compilation errors.
 
Alternatively, and to my sensibilities cleaner:

#!/usr/bin/perl
use strict;
use warnings;

sub mysub;  #  declares it, mysub no longer a bareword

mysub();    #  does it, () not required for Perl parser, but are nice for 
maintainers
            
sub mysub { # defines it
  print "Hi!  Nice to see you!\n";
}

-- 
            Michael Rasmussen, Portland Oregon  
      Other Adventures: http://www.jamhome.us/ or http://westy.saunter.us/
Fortune Cookie Fortune du courrier:
Whatever destiny your relationship has, a tandem will get you there faster.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to