IL PROTECTED]
> Subject: Re: finding variable name in string
>
>
> Dan
>
> > I think that's exactly whatI'm doing wrong.
> >
> > I think what's Jenda has been trying to get across to my
> little brain
> > all
> along.
> >
> > Thw
Dan
> I think that's exactly whatI'm doing wrong.
>
> I think what's Jenda has been trying to get across to my little brain all
along.
>
> Thw way I'm doing it is this
>
> $string = "$row[2] $row[4] $row[5] $row[3]";
> If ($string
> But $string is already interpolated!
>
> What Jenda has bee
xon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 14, 2003 9:48 AM
To: [EMAIL PROTECTED]
Subject: Re: finding variable name in string
Hi Dan
"Dan Muey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
That's the idea but the prob
"Dan Muey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I would think, and have been trying :
> $line =~ /\$myVariable/
> If I do $line like this :
That's exctly right.
> $line = 'HI $myVariable';
> If($line =~ /\$myVariable/) { print "HI"; }
> It works
ary 14, 2003 9:44 AM
To: [EMAIL PROTECTED]
Subject: RE: finding variable name in string
From: "Dan Muey" <[EMAIL PROTECTED]>
> Thanks for the reply.
>
> To simplify the question and not get off track I need to see if a
> string contains a variable 'name' n
Hi Dan
"Dan Muey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
That's the idea but the problem is is that @ row seems to transalet itself
into 'print userrname; and print
> mysecretpassword;' so that when it checks to see if it contains that
string '$password'
Hi Ben
"Ben Siders" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I believe that what he's after is a RE that will match the name of a
> variable proceded by a dollar sign.
>
> I.E., given this:
>
> $foo = "bar";
>
> if ( $var =~ // ) { print "true" }
>
> He w
yVariable";
Which is actually "HI whatevermyvariablecontains"
That's the dilemma.
-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 14, 2003 9:40 AM
To: [EMAIL PROTECTED]
Subject: Re: finding variable name in string
Hi Ben
You
From: "Dan Muey" <[EMAIL PROTECTED]>
> Thanks for the reply.
>
> To simplify the question and not get off track I need to see if a
> string contains a variable 'name' not 'value'.
I guess we all got lost in what's the actuall variable name, what's
to be interpolated when ad so forth. Let's try s
Hi Ben
"Ben Siders" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I believe that what he's after is a RE that will match the name of a
> variable proceded by a dollar sign.
>
> I.E., given this:
>
> $foo = "bar";
>
> if ( $var =~ // ) { print "true" }
>
> He w
Exactly! The problem is is that $var conatins '$foo' but it sees it as having 'bar'.
Thanks for helping me clarify.
-Original Message-
From: Ben Siders [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 14, 2003 9:36 AM
To: Rob Dixon
Cc: [EMAIL PROTECTED]
Subject:
Hi Ben
You're not soing what you think you're doing. See below.
"Ben Siders" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> To expand, I wrote a brief sample program to figure this out, since I
> actually had no idea how to do it. Here it is:
>
> #!/usr/bin/p
time. I do appreciate it. I'm also trying stuff on this end so
I'll post here if I figure it out.
Thanks
Dan
-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 14, 2003 9:31 AM
To: [EMAIL PROTECTED]
Subject: Re: finding variable name in string
I believe that what he's after is a RE that will match the name of a
variable proceded by a dollar sign.
I.E., given this:
$foo = "bar";
if ( $var =~ // ) { print "true" }
He wants the expression to evaluate true if $var contains the string
$foo; that is, the character '$' followed by 'f' 'o'
Hi Dan
Not clear what your problem is. This works, is it representative?
my @row = ('print $user;', 'print $password;' );
foreach (@row)
{
print $_;
print ( /\$password/ ? "\t# Invalid" : "\t# OK");
print "\n";
}
Cheers,
Rob
"Dan Muey" <[EMAIL PROTECTE
for the 'value' of $variable?
I need it to find the actual string '$variable' not what $variable
contains.
Any other ideas?
-Original Message-
From: Paul Johnson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 14,
2003 9:12 AM
To: Dan Muey
Cc: Jenda Krynicky;
--
From: Paul Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 14, 2003 9:12 AM
To: Dan Muey
Cc: Jenda Krynicky; [EMAIL PROTECTED]
Subject: RE: finding variable name in string
Dan Muey said:
To simplify the question and not get off track I need to see if a
string contains a var
n Muey
Cc: Jenda Krynicky; [EMAIL PROTECTED]
Subject: RE: finding variable name in string
Dan Muey said:
> To simplify the question and not get off track I need to see if a
> string contains a variable 'name' not 'value'.
>
> If($string =~ m/\$variable/) { print
Dan Muey said:
> To simplify the question and not get off track I need to see if a string
> contains a variable 'name' not 'value'.
>
> If($string =~ m/\$variable/) { print "Yes \$variable exists"; }
Don't escape the $ in the RE.
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To
) { print "NO way pal \n"; }
# ie if $code contains the string '$password' then don't do it!
else { ...
Why not just hard code that in you ask? Because this needs to be very very flexible
and do almost anything.
Some of the more common tasks I've created subroutines
From: "Dan Muey" <[EMAIL PROTECTED]>
> Sorry to bother but...
> I have a script that I have to do an eval on code that someone else
> has put in a database. ...
Are you sure you want to do that? Are you sure you want them to be
able to run any code they with inside your script? Deleting files
th
21 matches
Mail list logo