Re: SCALAR ref

2010-04-13 Thread Shlomi Fish
On Tuesday 13 Apr 2010 12:29:37 Akhthar Parvez K wrote: > Got that, thanks Shlomi! However, can this be done by referencing $1 > directly with strict refs on? I definitely feel it can be done and would > be nice to know how! It cannot be done directly using ${$idx} as you've shown but as a wise ma

Re: SCALAR ref

2010-04-13 Thread Akhthar Parvez K
Got that, thanks Shlomi! However, can this be done by referencing $1 directly with strict refs on? I definitely feel it can be done and would be nice to know how! Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to

Re: SCALAR ref

2010-04-13 Thread Shlomi Fish
; strict refs, I'm getting the following error: > > Can't use string ("3") as a SCALAR ref while "strict refs" in use at > test.pl > > I tried to overcome this issue using scalar(), but didn't help. Could > someone please let me know what is

SCALAR ref

2010-04-13 Thread Akhthar Parvez K
want to store the matched string to a variable like: my $c = ${$rx{$string1}}; #$c should store the value of $2 I can get the desired result if I don't use strict refs. However, with strict refs, I'm getting the following error: Can't use string ("3") as a SCALAR ref

Re: can't use Scalar ref...

2004-09-16 Thread Jenda Krynicky
From: "Ing. Branislav Gerzo" <[EMAIL PROTECTED]> > it isn't of course only foo. I am parsing ini file, which looks like: > > [ini] > foo=test > bar=foo [%foo%] bar > > and of course, I want to get (after using some config module) > $bar='foo test bar' Is it really necessary to use [%foo%]? I'm

Re: can't use Scalar ref...

2004-09-15 Thread JupiterHost.Net
JN> Then you need to do 'no strict;' before you do that: JN> no strict; JN> $x =~ s/^\[%([^%]+)%\]$/${$1}/g; JN> use strict; I think turning off strict is bad idea, also, that doesn't work either. It is a bad idea but it is what needs done to use soft references like you are doing. JN> Why not ju

Re: can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
Jenda Krynicky [JK], on Thursday, September 16, 2004 at 00:34 (+0200) typed the following: JK> You most probably want to store the data you want to fill into the JK> template in a hash (some call it associative array, please don't): JK> my %data = ( JK>foo =>> 'test', JK>bar =>> '

Re: can't use Scalar ref...

2004-09-15 Thread Gunnar Hjalmarsson
JupiterHost.Net wrote: Ing. Branislav Gerzo wrote: I want change [%foo%] to $foo, so I expect in result 'test' as before defined. Then you need to do 'no strict;' before you do that: no strict; $x =~ s/^\[%([^%]+)%\]$/${$1}/g; use strict; Well, a better suggestion IMO would be that $foo is replaced

Re: can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
JupiterHost.Net [JN], on Wednesday, September 15, 2004 at 17:21 (-0500) made these points: JN> Then you need to do 'no strict;' before you do that: JN> no strict; JN> $x =~ s/^\[%([^%]+)%\]$/${$1}/g; JN> use strict; I think turning off strict is bad idea, also, that doesn't work either. JN> Why

Re: can't use Scalar ref...

2004-09-15 Thread Jenda Krynicky
+)%\]$/${$1}/g; > print $x . " "; > } > > -- > ...it gives me compilation error: > Can't use string ("foo") as a SCALAR ref while "strict refs" in use > at... > > it doesn't work as I expected, I expect output: > >

Re: can't use Scalar ref...

2004-09-15 Thread Jeff 'japhy' Pinyan
On Sep 15, Ing. Branislav Gerzo said: >use strict; >use warnings; > >my $foo = 'test'; >my @bar = ( 'foo', '[%foo%]', 'bar' ); >my @list = (); > >foreach my $x (@bar) { >$x =~ s/^\[%([^%]+)%\]$/${$1}/g; >print $x . " "; >} You should use a hash instead of a set of variables. my

Re: can't use Scalar ref...

2004-09-15 Thread JupiterHost.Net
Ing. Branislav Gerzo wrote: JupiterHost.Net [JN], on Wednesday, September 15, 2004 at 16:52 (-0500) made these points: my $foo = 'test'; my @bar = ( 'foo', '[%foo%]', 'bar' ); JN> The question would be why you're doing ${$1} since nothing in @bar is a JN> reference. I want change [%foo%] to $foo,

Re: can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
JupiterHost.Net [JN], on Wednesday, September 15, 2004 at 16:52 (-0500) made these points: >> my $foo = 'test'; >> my @bar = ( 'foo', '[%foo%]', 'bar' ); JN> The question would be why you're doing ${$1} since nothing in @bar is a JN> reference. I want change [%foo%] to $foo, so I expect in result

Re: can't use Scalar ref...

2004-09-15 Thread JupiterHost.Net
Ing. Branislav Gerzo wrote: Hi pals, Hello, use strict; use warnings; my $foo = 'test'; my @bar = ( 'foo', '[%foo%]', 'bar' ); my @list = (); foreach my $x (@bar) { $x =~ s/^\[%([^%]+)%\]$/${$1}/g; its esentially doing ${foo} since the string foo is in @bar. that is a soft reference and no

can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
Hi pals, use strict; use warnings; my $foo = 'test'; my @bar = ( 'foo', '[%foo%]', 'bar' ); my @list = (); foreach my $x (@bar) { $x =~ s/^\[%([^%]+)%\]$/${$1}/g; print $x . " "; } -- ...it gives me compilation error: Can'