K.Moeng wrote:
hello.
Hello,
Here is my problem. i am unable to return the 2 strings as true.
you're not returning anything anywhere...
it false back to the else statement.
have you tried printing $msg to see what it contains to manually verify
it matches what you think it matches?
# always always always
use strict;
use warnings;
use lib '/usr/lib/perl5';
Why? POSIX should be in @INC already
use POSIX qw(strftime);
You never use this, why have it?
######################## GET ARGS ##########################
$source = $ARGV[0];
$msg = $ARGV[1];
$msg =~ s/\"/' /ig;#$msg =~ s/"/' /ig; #$msg =~ s/\"/' /ig;
$found = 0;
print "DEBUG: \$msg = $msg\n";
if ($msg =~ /roam act/i)
{
$name = 'ACTivated';
$found = 1;
}
elsif ($msg =~ /roam dact/i)
{
$name = 'DeACTivated';
$found = 1;
}
if ($found == 1)
print "Your Prepaid Roaming service will be $name within the next 2 hours.Thank you.
\n";
}
else
{
print "Sorry. Your request has not been sent for Roaming. Please send 'ROAM ACT' TO
ACTIVATE or 'ROAM DACT' TO DEACTIVATE.\n";
}
exit;
You don't need exit()...
Try this:
#!/usr/bin/perl
use strict;
use warnings;
if($ARGV[0] =~ /roam act/i) {
print two_hour_notice('ACTivated');
}
elsif($ARGV[0] =~ /roam dact/i) {
print two_hour_notice('DeACTivated');
}
else {
print "Unknown input: $ARGV[0]\n";
}
sub two_hour_notice {
my $service_type = shift;
return "Your Prepaid Roaming service will be $service_type within
the next 2 hours.Thank you.\n";
}
./test.pl "iroam activ"
./test.pl "iroam dacti"
./test.pl "foo bar baz"
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>