Thursday, October 14, 2010

require, subroutine call, cut, pattern matching

*************** library.pl ************************
our $cmd='net user anand password /add';

************* mainprogram.pl **********************
# Windows command line execution
use warnings;
use Sum; # user defined package

$\="\n";
require "library.pl"; # this statement will compile and make ready for use
#print "Test Windows Command\n";
#our $cmd = ;
#chomp($cmd);
# $cmd = "net user perluser passw0rd!";
# print "$cmd";
# ` $cmd `;
sub commandParam {
# print "command is $cmd";

$out=system($cmd);
eval{'$x=10/0'}; # exception is stored in $? by default
print "exception is : $? \n";
#print $out;
#$out=$out>>8;
if($out==0)
{
print "success";
}
else
{
print "fail";
}
return 1;
}

&commandParam;
# return 1;

# Pattern matching
# $x=172.172.172.172

# $x=~ /(\d{1,3})\.\1\.\1\.\1/;

# $x=172.22.59.10

# $x =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;

# $x = 1.5.1.5
# $x =~ /(\d{1})\.(\d{1})\.\1\.\2/;

# To comment multiple lines
=cut
=cut

No comments:

Post a Comment

 

©2010 Software Testing powered by Free Blogger Templates | Author : Anand Satish