Need help

Hi,

I wrote following sub routine. But got error like this
"Use of uninitialized value in pattern match (m//) at checkYadInsertFamily.pm line 71, <GEN4> line 6."

Could not find where I am doing wrong.

I will appreciate for your help.

thanks,

Bilashi


sub checkFreqCapping() {
my ($fhlog, $prop, $cmpnInfo, $orderInfo, $result) = [at] _;
my $name = $$cmpnInfo{"cmpgn_name"};
if( $name =~ /freqcap/ )
{
$fhlog->print("FreqINFO: Freqcapping is there\n");
$$result = "p";

}
}



_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Bilashi Sahu [ Do, 14 August 2008 08:38 ] [ ID #1964142 ]

Re: Need help

Bilashi Sahu wrote:
> Hi,
>
> I wrote following sub routine. But got error like this
> "Use of uninitialized value in pattern match (m//) at checkYadInsertFamily.pm line 71, <GEN4> line 6."

1) Always supply a complete standalone test case that reproduces your
problem.
2) Always have a use strict and use warnings in your test case.
3) Sometimes just doing 1) and 2) will lead you to solve your own
problem.

> sub checkFreqCapping() {
> my ($fhlog, $prop, $cmpnInfo, $orderInfo, $result) = [at] _;
> my $name = $$cmpnInfo{"cmpgn_name"};
> if( $name =~ /freqcap/ )
> {
> $fhlog->print("FreqINFO: Freqcapping is there\n");
> $$result = "p";
>
> }
> }

You should have gotten an error on your prototype:
main::checkFreqCapping() called too early to check prototype at xx.pl line xxxx.
I removed the () from the sub definition which basically said that
the sub had no args and had no errors.

Output from my test:
FreqINFO: Freqcapping is there
result=p

I created the test case you should have posted:

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

use strict;
use warnings;
use IO::Handle;

my $io = new IO::Handle;
my $fhlog = $io->fdopen(fileno (STDOUT), "w") or die;

my $prop = 0;
my %cmpnInfo = (
cmpgn_name => 'freqcap',
foobar => 'barfu',
);
my $orderInfo = 0;
my $result = 0;

checkFreqCapping ($fhlog, $prop, \%cmpnInfo, $orderInfo, \$result);
print "result=$result\n";
exit;

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub checkFreqCapping {
my ($fhlog, $prop, $cmpnInfo, $orderInfo, $result) = [at] _;

my $name = $$cmpnInfo{'cmpgn_name'} or do {
$$result = 'Error';
return;
};

if ($name =~ /freqcap/) {
$fhlog->print("FreqINFO: Freqcapping is there\n");
$$result = 'p';
}
$$result = 'Error';

}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

__END__
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Bill Luebkert [ Do, 14 August 2008 09:36 ] [ ID #1964143 ]
Perl » gmane.comp.lang.perl.active-perl » Need help

Vorheriges Thema: UTC time conversion to local time
Nächstes Thema: Duplicate Perl Processes