Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Ámbito de variables en Perl: lo básico

by Hue-Bond (Priest)
on Jul 03, 2006 at 16:13 UTC ( #559011=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    
    package Szywiecki;
    ...
    # terminate("arturo"); # produce un error si se descomenta
    __OUTPUT__
    el jefe ha despedido a arturo
    
  2. or download this
    #!/usr/bin/perl -w
    
    use strict;
    
    $Robert = "el jefe";  # error!
    print "\$Robert = $Robert\n";
    
  3. or download this
    #!/usr/bin/perl -w
    
    use strict;
    
    $main::Robert = "el jefe";
    print "\$main::Robert = $main::Robert\n";
    
  4. or download this
    #!/usr/bin/perl -w
    
    package Szywiecki;
    ...
    print "Aquí en el trabajo, 'Robert' es $Robert, pero en la piscina, 'R
    +obert' es $PoolHall::Robert\n";
    __OUTPUT__
    Aquí en el trabajo, 'Robert' es el jefe, pero en la piscina, 'Robert' 
    +es el experto en dardos
    
  5. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
    $foo: Hey!
    $main::foo: Yo!  
    $foo: Hey!
    
  6. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
    package Movie;
    
    print "Bob => $bob, Carol => $carol\n";
    
  7. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
    mysub    result 'global value'
    localsub result 'local value'
    no sub   result 'global value'
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://559011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-11-23 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (130 votes), past polls