Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Ámbito de variables en Perl: lo básico

by Hue-Bond (Priest)
on Jul 03, 2006 at 16:13 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://559011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found