Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

the basic datatypes, three

by root (Monk)
on Oct 29, 1999 at 01:53 UTC ( [id://861]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $a=5;
    $b="five";
    $c=5.0
    
  2. or download this
    $a="5.0"; # set up our variables
    $b="5";   # # to the end of a line is a comment in perl
    ...
    print "These variables are equal as strings\n" if($a eq $b);
    print "These variables are equal numerically\n" if($a==$b);
    
  3. or download this
    @a=(1,2,3);
    @simpsonsfamily=("homer","marge","lisa","maggie","bart");
    
  4. or download this
    push @array, $value; #puts $value onto the end of @array.
    
  5. or download this
    @array=reverse @array;
    
  6. or download this
    @array=("key1","value1","key2","value2");   #an array filled with key 
    +value pairs
    %hash1=("key1"=>"value1","key2"=>"value2"); #one way to initialize a h
    +ash (key=>value,key2=>value2,..)
    %hash2=@array;                              #making %hash2 out of a co
    +llection of key value pairs in an array
    $hash3{"key1"}="value1";                    #creates key of "key1" and
    + value of "value1"
    $hash3{"key2"}="value2";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found