in reply to Re: Matching quoted variables. Cant make it work..
in thread Matching quoted variables. Cant make it work..

You should never assign a variable like so:

Well, not necessarily "never". In general for 99.99999% of the cases you don't want the extra quotes; however there's times when you may want to explicitly "stringify" something (say an object with an overloaded q// method). They're few and far between, but not never ever.</pedant>

Replies are listed 'Best First'.
Re^3: Matching quoted variables. Cant make it work..
by roboticus (Chancellor) on Mar 17, 2006 at 00:58 UTC
    Fletch--

    I'm often a pedant myself, so thanks for the correction. I don't quite follow what you mean, though. Could you provide or point me to a trivial example, perhaps?

    --roboticus

      Suppose you've got a roman numeral class. If you treat an instance as a number it works as a number ($fourty_two = $rn_six * $rn_seven;); however when you print it out it represents itself as the roman numeral form (print "The answer is $fourty_two\n"). To get the string version you might explicitly use $as_roman = "$roman_instance" to force stringification (granted in most cases you'd probably be either interpolating it with something else or concatenating it with another string). Or another plausible occurrence might be some operation that just returns the string value, i.e. return "$roman_instance".

      Again, it's a very contrived case, but there are occasions where you will use $a = "$b".