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
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
; 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
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
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
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
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 =>> '
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
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
+)%\]$/${$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:
>
>
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
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,
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
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
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'
15 matches
Mail list logo