Monday, July 25, 2011

mixed program in perl


#!/usr/bin/perl
use warnings;
use strict;
use charnames ':full';
my $n;
print "my number\n";
0.00000;
chomp($n=<STDIN>);
print "the value $n is",$n ? "true":"false","\n";
$n+=0;
print "the value of $n now:",$n ? "true":"false","\n";
my $name="shrikant";
my $value=substr($name,3,2);
print $value,"\n";
my $sent="this is what i had...!";
print $sent,"\n";
substr($sent,5,2)="is not";
print $sent,"\n";
sub cutoff
{
my (@positions)=@_;
my $template=' ';
my $lastpos=1;
foreach my $place (@positions) {
$template.="A".($place-$lastpos);
$lastpos=$place;
}
$template.="A*";
return $template;
}
my $fmt=cutoff(8,14,20,26,30);
print $fmt,"\n";
print "\N{GREEK CAPITAL LETTER DELTA} is called delta.\n";
my %seen=();
my $string="an apple a day";
foreach my $char (split //,$string) {
$seen{$char}++;
}
print "the unique charector are:",sort(keys %seen),"\n";

Array undefine


#!/user/bin/perl
use warnings;
use strict;
my %hash=("shrikant",23,"shruti",23,"mahesh",22,"santosh",24,"gururaj",43);
print "\n ENTER YOUR NAME:";
my $name=<STDIN>;
chomp($name);
print $hash{$name},"\n";
my @list=(1,2,3,4,5);
print "\n the size of the array", ($#list+1),"\n";
my $i=0;
while($i!=($#list+1))
{
print $list[$i],"\t";
$i++;
}
print "\n";
@list=undef;# this line indicate the undefineing the array

Array in Array programming


#!/usr/bin/perl
use strict;
use warnings;
print "---------------------------\n";
print "ENTER YOUR COMMENT:\n";
print "---------------------------\n";
open(FD,">","list7.txt");
for(my $i=0;$i<10;$i++)
{
my $lines=<STDIN>;
print FD $lines;
if($lines eq "-q")
{
exit 1;
}
}
print "===========================\n";
print "---------------------------\n";
print "Your comment:\n";
print "---------------------------\n";
my $vrs=`cat list7.txt`;
print $vrs;
print "\n";
print "============================\n";
close(FD);

Perl Programing


#!/usr/bin/perl
use strict;
use warnings;
print "this program for the development of the toool\n";
open (FILE,"text1.txt");
my @list=<FILE>;
print "enter your name:\n";
my $name=<STDIN>;
my $set=0;
open (DAT,">> list3.txt");
foreach(@list)
{
if($_ =~/^s(a-z)*/)
{
print DAT $_;
}
}
if($set==1)
{

print ":::::::::::::::::::::::::::::::::::::::::::::::\n";
print "::::::::::::::::::::::::::::::::::::::::::::::::\n";
print "congrats!! you are selected for the final list\n";
print "::::::::::::::::::::::::::::::::::::::::::::::::\n";
print "::::::::::::::::::::::::::::::::::::::::::::::::\n";
}
else
{
print ":::::::::::::::::::::::::::::::::::::::::::::::\n";
print "::::::::::::::::::::::::::::::::::::::::::::::::\n";
print "sorry...!! you not selected for the final list\n";
print "::::::::::::::::::::::::::::::::::::::::::::::::\n";
print "::::::::::::::::::::::::::::::::::::::::::::::::\n";
}
my $count = `wc -l < "list3.txt"`;
print "size of the file searched: $count\n";


close(DAT);
my $title='mail to user';
my $to='shrikant200@gmail.com';
my $from= 'shrikant.badiger@alcatel-lucent.com';
my $subject='welcome to alcatel lucent';