Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error with array reference while using 'use strict' 1

Status
Not open for further replies.

sloppyhack

Technical User
Apr 17, 2001
111
US
Getting an error....

can't use "string" as an array reference when "strict ref" is in use

Makes sense...as I'm using a new variable, but it still seems silly. Using array references has proven to be very powerful for me. Anyone know how to get around this? I love "use strict" but want to use my array references too!!! Is this just a problem with my version of Perl? I haven't updated in a year or so.

Cheers,

Sloppyhack
 
Never mind. I'm reading that using variables within variables is generally not a good thing. Funny...I've read several places that it is a good thing and have actually used it a lot with success. I could do the same things with a hash though. I'll go that route. Sorry for the premature post.

Any comments on this subject would be greatly appreciated though.


Cheers,

Sloppyhack
 
You've probably seen this already (since I posted it in another current thread on the same topic) but this is the link I usually post to argue against `variable variable names':
Why it's stupid to use a variable as a variable name.

I'd be interested in seeing the arguments in favour of it though. Apart from the ``it's really handy'' argument (which, IMO, is outweighed by the nighmare maintenance issues, namespace pollution and the relative ease of replacing them with hashes), I can't think of any others.
 
I think it is a matter of experience. When I first began to my perl journey I never used objects and really saw no reason to use them. As I became more experienced I realized there were several ways to cut down on on the confusion in accessing and passing references all led back to objects now I can create easy to maintain and readable perl code with reuseability as a bonus.

just mt 2 cents.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top