Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

RFC: Tutorial: use strict; now what!?

by Xiong (Hermit)
on Feb 08, 2012 at 09:32 UTC ( #952446=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    
  2. or download this
    (SOME_ERROR_TEXT) at (FILE) line (LINE).
    Execution of (FILE) aborted due to compilation errors.
    
  3. or download this
    # Code:
        $x  = 5;                            # no strict 'vars'
    ...
    Global symbol "$x" requires explicit package name at strict-demo.pl li
    +ne 10.
    Global symbol "$x" requires explicit package name at strict-demo.pl li
    +ne 11.
    Execution of strict-demo.pl aborted due to compilation errors.
    
  4. or download this
        my $x;                              # declare first
        $x  = 5;                            # strict okay
        print "$x\n";
    
  5. or download this
        $newPig    = 'Keisha';
    
        # much, much later...
        print $Newpig;                      # prints nothing; why?
    
  6. or download this
    # Code:
        my $subroutine  = factorial;        # no strict 'subs'
    ...
    # Output:
    Bareword "factorial" not allowed while "strict subs" in use at strict-
    +demo.pl line 13.
    Execution of strict-demo.pl aborted due to compilation errors.
    
  7. or download this
        my $subroutine  = \&factorial;      # strict okay
        print $subroutine->(7), "\n";
    
  8. or download this
    # Code:
        our $dog;
    ...
    
    # Output:
    Can't use string ("dog") as a SCALAR ref while "strict refs" in use at
    + strict-demo.pl line 18.
    
  9. or download this
        our $dog;
        my $pet     = \$dog;                # hard reference
        ${ $pet }   = 'Rover';              # strict okay
        print "$dog\n";
    
  10. or download this
    no strict 'vars';
    no strict 'subs';
    no strict 'refs';
    
  11. or download this
    #       strict-demo.pl
    #       =  Copyright 2011 Xiong Changnian <xiong@cpan.org>   =
    ...
    };
    
    __END__
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://952446]
Approved by moritz
Front-paged by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2014-12-25 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls