Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Ronald J Kimball
On Thu, Oct 16, 2008 at 03:45:02PM -0400, Uri Guttman wrote: > working around strict when you don't need to is a bad idea as well. as i > said before symrefs are for when you have to mung the symbol table. no other > uses should be allowed. there is no need for this. the OP needs to learn > to use

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Uri Guttman
> "JM" == Jeremy Muhlich <[EMAIL PROTECTED]> writes: JM> If you restrict your 'no strict' to a very small block, it's really no JM> problem at all. Best practice is to apply it to the smallest possible JM> block possible. This would be even better than what I initially wrote: JM>

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Uri Guttman
> "JM" == Jeremy Muhlich <[EMAIL PROTECTED]> writes: JM> One kind of nasty option is to use string eval: JM> $varname = "\$${_}_type"; JM> eval "$varname = "; JM> There are technical caveats and perhaps moral issues with this approach, JM> but it works. that is like telling a k

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Jonathan Finger
> From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED]; boston-pm@mail.pm.org > Date: Thu, 16 Oct 2008 12:25:02 -0600 > Subject: Re: [Boston.pm] Interpolated scalar as an lvalue? > > I didn't know that usage model for strict refs. Thanks! > > Though, as you & other

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Jeremy Muhlich
If you restrict your 'no strict' to a very small block, it's really no problem at all. Best practice is to apply it to the smallest possible block possible. This would be even better than what I initially wrote: foreach ... { # "setup" code here { no strict 'refs'; $$varnam

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Palit, Nilanjan
o: boston-pm Subject: Re: [Boston.pm] Interpolated scalar as an lvalue? On Thu, 2008-10-16 at 10:39 -0400, Ronald J Kimball wrote: > On Thu, Oct 16, 2008 at 08:32:41AM -0600, Palit, Nilanjan wrote: > > > Perl complains about the second line in the foreach loop during run time: > >

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Jeremy Muhlich
On Thu, 2008-10-16 at 10:39 -0400, Ronald J Kimball wrote: > On Thu, Oct 16, 2008 at 08:32:41AM -0600, Palit, Nilanjan wrote: > > > Perl complains about the second line in the foreach loop during run time: > > Can't use string ("abc_type") as a SCALAR ref while "strict refs" in use at > > test1.p

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Jeremy Muhlich
One kind of nasty option is to use string eval: $varname = "\$${_}_type"; eval "$varname = "; There are technical caveats and perhaps moral issues with this approach, but it works. -- Jeremy On Thu, 2008-10-16 at 08:32 -0600, Palit, Nilanjan wrote: > How (or can) I use an interpolated s

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Uri Guttman
> "PN" == Palit, Nilanjan <[EMAIL PROTECTED]> writes: PN> I was hoping there was a way around that still satisfied 'strict refs'. that is the whole point of strict refs, to disallow using a string for a variable name. there are many reasons this is a good thing and your trying to work aroun

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Palit, Nilanjan
[Boston.pm] Interpolated scalar as an lvalue? On Thu, Oct 16, 2008 at 08:32:41AM -0600, Palit, Nilanjan wrote: > Perl complains about the second line in the foreach loop during run time: > Can't use string ("abc_type") as a SCALAR ref while "strict refs" in use at > tes

Re: [Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Ronald J Kimball
On Thu, Oct 16, 2008 at 08:32:41AM -0600, Palit, Nilanjan wrote: > Perl complains about the second line in the foreach loop during run time: > Can't use string ("abc_type") as a SCALAR ref while "strict refs" in use at > test1.pl line 19. > The error message explains exactly what the problem is

[Boston.pm] Interpolated scalar as an lvalue?

2008-10-16 Thread Palit, Nilanjan
How (or can) I use an interpolated scalar as an lvalue? Example: I want to assign a value to a bunch of scalar variables $_type: my ($abc_type, $def_type, $xyz_type); ... ... foreach (qw(abc def xyz)) #List of prefixes { $varname= $_."_type"; #Actual scalar variable name is $prefix_type