I tried the suggested for loop with topicalizer in one of my scripts. I am developing a reporting tool in Perl (fetch data from DB and generate excel or html reports, then send them via mail).
I am still new to Perl, so I am writing baby Perl - I think that's the term for that :), and I must apologize for the sometimes cumbersome solutions.
Here is how my envrionment looks like:
There is a Collect.pm package,which initializes the "global" scalar $USECASE:
There is report.pl which import My::Data::Collect and assings the value to $USECASE using GetOpt::Long like follows:
GetOptions('type=s' => \$USECASE,
'mode=s' => \$MODE);
and then I start the scirpt: report.pl --type uc1.
Later in the same script I call get_pss_ael() subroutine from My::Data::Collect within a for loop, with $USECASE as topicalizer:
Then out of sudden the $USECASE scalar is undef inside the subroutine call. When I check it with say outside the for loop in the main namespace (report.pl) it is there with the value assigned by GetOpt::Long, in My::Data::Collect, outside any code block and subroutine it is there, although when I pass it to a subroutine it is already undef.
Substituting that for construct with if-else solves that problem.
What's going on there?
Could You please provide further explanation?
I hope I described my issue with enough examples, and good code snippets. If not please let me know and I edit.
Thank You!
Kind Regards,
Csaba
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Mark,
I tried the suggested for loop with topicalizer in one of my scripts. I am developing a reporting tool in Perl (fetch data from DB and generate excel or html reports, then send them via mail).
I am still new to Perl, so I am writing baby Perl - I think that's the term for that :), and I must apologize for the sometimes cumbersome solutions.
Here is how my envrionment looks like:
There is a Collect.pm package,which initializes the "global" scalar $USECASE:
There is report.pl which import
My::Data::Collect
and assings the value to$USECASE
usingGetOpt::Long
like follows:GetOptions('type=s' => \$USECASE,
'mode=s' => \$MODE);
and then I start the scirpt:
report.pl --type uc1
.Later in the same script I call
get_pss_ael()
subroutine fromMy::Data::Collect
within a for loop, with$USECASE
as topicalizer:Then out of sudden the
$USECASE
scalar isundef
inside the subroutine call. When I check it with say outside the for loop in the main namespace (report.pl) it is there with the value assigned byGetOpt::Long
, inMy::Data::Collect
, outside any code block and subroutine it is there, although when I pass it to a subroutine it is alreadyundef
.Substituting that for construct with if-else solves that problem.
What's going on there?
Could You please provide further explanation?
I hope I described my issue with enough examples, and good code snippets. If not please let me know and I edit.
Thank You!
Kind Regards,
Csaba