2. What can I use Perl for?
Most people use PERL for either automating administrative tasks (write a .pl file and launch it with PERL.EXE) or in combination with a webserver to create dynamice web pages. Most UNIX based webservers have PERL support already integrated (like APACHE) whereas you have to install PERL on WIN32 platforms like Windows NT (IIS 4).
3. Variables are declared with a $
4.
print "Your age please $firstname $lastname: ";
$myage =;
$myage =
5. How to define an array in Perl?
@myarray = ("red","green","black");
OR
@myarray = qw(red green black);
OR
$myarray[0] = "red";
$myarray[1] = "green";
$myarray[2] = "black";
OR
@myarray = qw(red green black);
OR
$myarray[0] = "red";
$myarray[1] = "green";
$myarray[2] = "black";
6. Hashes in Perl:A Hash consists not only of onebut two values each - a KEY and a VALUE.
"Hobby" => "Photography",
"Age" => 24
);
OR
$myhash{'Name'} = "Vijay Kumar Sharma";
$myhash{'Hobby'} = "Photography";
$myhash{'shoe size'} = 24;
*** Note Curly braces for hash keys...
foreach $key (keys %myhash) { print $key.": ".$myhash{$key}."\n"; } ==>> Ignore if not able to understand at this moment... I have to separately see how for loop works in PERL
To initialize a hash write:
%myhash = ( "Name" => "Vijay Kumar Sharma","Hobby" => "Photography",
"Age" => 24
);
OR
$myhash{'Name'} = "Vijay Kumar Sharma";
$myhash{'Hobby'} = "Photography";
$myhash{'shoe size'} = 24;
*** Note Curly braces for hash keys...
foreach $key (keys %myhash) { print $key.": ".$myhash{$key}."\n"; } ==>> Ignore if not able to understand at this moment... I have to separately see how for loop works in PERL
No comments:
Post a Comment