Welcome to the Monastery | |
PerlMonks |
variables with colonsby SavannahLion (Pilgrim) |
on Jul 29, 2010 at 05:50 UTC ( [id://851848]=perlquestion: print w/replies, xml ) | Need Help?? |
SavannahLion has asked for the wisdom of the Perl Monks concerning the following question: Why does Perl think I'm trying to use a variable $typ:: when I can't ever declare $typ:: anyways? I whacked my head for a good hour trying to work this one out. Readily assume that $data holds valid data and the pattern match is functioning as expected (I know the \n is in an odd place, just bear with me). Use strict and warnings are also in place. Here is a sample:
I get the following error:
So two quick changes to see what's going on:
What the heck? $1 is receiving the expected value. The assignment is working as expected. Yeah, yeah, I know that print should technically be:
This is a QaD utility to re-parse some pre-existing data for another batch of code. It's not really meant for long term use. After wasting too much of my life, I finally worked out that perl thinks I'm trying to use $typ:: rather than $typ. Yet perl is never going to allow me to create a variable called $typ::. and yes, I did miss the subtle :: in the error message. I get a lot of crap error message in other languages that often actually have nothing to do with the actual error itself. eg C++. I forget Perl is a little bit more concise in the error message department.
Back to
Seekers of Perl Wisdom
|
|