CGI Perl Question:
Download Questions PDF

Write an expression or Perl script to identify the entered IP address is valid or not?

Answers:

#! /usr/bin/per
use strict;
#- Use Input
#---------------
my $ip_add = "";

#- Script start
#---------------
print"Enter the IP address\n";
$ip_add = <STDIN>;
chomp($ip_add); # Remove the last "\n" character
$ip_add=$ip_add."\."; # Append . at the end of IP address
#-------Expression to check IP address is valid or not-----#
if($ip_add =~ m/^[0-2]?[0-5]?[0-5]?\.){4}$){
print" Valid IP Address\n";
}else{
print" Invalid IP Address\n"
}

#!/usr/bin/perl
use strict;
print \\"Enter IP Addres\\";
my $ip_add = ;

if ($ip_add =~ m/\\\\d{1,3}[0-255]\\\\.\\\\d{1,3}[0-255]\\\\.\\\\d{1,3}[0-255]\\\\.\\\\d{1,3}[0-255]/){
print \\"valid IP Addres\\\\n\\";
}else {
print \\"Invalid IP Addres\\";
}

Download CGI Perl Interview Questions And Answers PDF

Previous QuestionNext Question
Packing and Unpacking.

Hi, I want to get output as 0x23400000345....
in the below example How to get?
i tried out, but unable to get the answer

$r=0x234;
$t=0x345;
$y=pack(L L,$t,$r);
$x1=unpack(L!,pack(P,$y));
printf("nThe value is $x1");

I didnt get constant output?
Write a script to display mirror image of a entered value and also check whether Palindrome?