lochan.brijesh
BAN USER#!/usr/bin/perl -w
use strict;
my $lines;
open(IN, "c++code.txt") or die("$!\n");
while(defined($lines = <IN>))
{
$lines =~ s/\/\///g;
$lines =~ s/\/\*//g;
$lines =~ s/\*\///g;
print $lines;
}
close IN;
Please take the content of the two files in 2 arrays. After that the below logic would be fine.
#!/usr/bin/perl -w
use strict;
my @prim_array = qw(Cat Dog Snake Tiger);
my @sec_array = qw(Squirrel Cat Dog Snake);
my %hash;
my %hash1;
foreach (@prim_array)
{
$hash{$_} = undef;
}
foreach (@sec_array)
{
$hash1{$_} = undef;
}
my $flag = 0;
foreach my $key (sort keys %hash)
{
if(!(exists($hash1{$key})))
{
$flag = 1;
last;
}
}
if($flag == 1)
{
print "Secondary file does not contain all elements of primary file\n";
}
else
{
print "Secondary file contains all elements of primary file\n";
}
- lochan.brijesh March 02, 2015#!/usr/bin/perl -w
use strict;
my $string = $ARGV[0];
if($string =~ m/[a-zA-Z]{3,}/ && $string =~/[aeiouAEIOU]/)
{
print "Valid Word\n";
}
else
{
print "Non-Valid Word\n";
}
- lochan.brijesh March 02, 2015#!/usr/bin/perl -w
use strict;
my $file_path = "F:\\Thesis Work\\SLAMS_IP.csv";
open(FILE, $file_path) or die("Unable to open a file, $!");
open(HANDLE, ">file.txt") or die("Unable to open a file, $!");
my %ip_hash;
my $count;
while(defined(my $lines = <FILE>))
{
if($lines =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)
{
if(!(defined($ip_hash{$1})))
{
$count = 1;
}
else
{
$count++;
}
$ip_hash{$1} = $count;
}
}
foreach my $key(sort {$ip_hash{$b} <=> $ip_hash{$a}}keys %ip_hash)
{
print HANDLE "$key:$ip_hash{$key}\n";
}
close(HANDLE);
close(FILE);
#!/usr/bin/perl -w
use strict;
my $string = "My Name is Brijesh";
my @array = split(/\s+/,$string);
foreach(@array)
{
my @temp = split(//, $_);
for(my $i = $#temp; $i>=0; $i--)
{
print $temp[$i];
}
print " ";
}
- lochan.brijesh March 02, 2015#!/usr/bin/perl -w
use strict;
#Task 1: Input IP Address. Check if it lies between 172.125.1.0 and 172.125.25.0?
my $ip_add = $ARGV[0];
if($ip_add =~ m/^172\.125\.(\d{1,3})\.(\d{1,3})$/ && ($1>0 && $1<25) && ($2>=0 && $2<256) || $ip_add =~ m/172.125.25.0/)
{
print "Valid IP Address\n";
}
else
{
print "Non-Valid IP Address\n";
}
- lochan.brijesh March 02, 2015#!/usr/bin/perl -w
use strict;
#Task 1: Input IP Address. Check if it lies between 172.125.1.0 and 172.125.25.0?
my $ip_add = $ARGV[0];
if($ip_add =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ && ($1>171 && $1<173)
&& ($2>124 && $2<126) && ($3>0 && $3<25) && ($4>=0 && $4<256) || $ip_add =~ m/172.125.25.0/)
{
print "Valid IP Address\n";
}
else
{
print "Non-Valid IP Address\n";
}
- lochan.brijesh March 02, 2015
- lochan.brijesh July 12, 2015