Navid M. wrote:
> Hi Rob,
>
> I'm not very familiar with the qq() operator. I
> always thought this is included when the programmer
> wants to include the quote character in a string
> without having to escape it with a backslash.
> Ex: $string = qq(this is a " without escaping it);
Exactly. It l
Navid M. wrote:
> That did it. Thanks Rob!
>
> --- Rob Dixon <[EMAIL PROTECTED]> wrote: >
> >
> > Eval will work if you give it a valid expression to
> > evaluate.
> > As you say,
> >
> > 1>>$fileName
> >
> > isn't valid Perl, but
> >
> > qq(1>>$fileName)
> >
> > is, and is what you want.
That did it. Thanks Rob!
--- Rob Dixon <[EMAIL PROTECTED]> wrote: >
Navid M. wrote:
> > Hello,
> >
> > I was wondering how you can evaluate parts of a
> > string:
> >
> > Ex: $fileName = "File";
> > $var = '1>>$fileName';
> >
> > Now I would like a *simple* way of evaluating $var
> > such th
Navid M. wrote:
> Hello,
>
> I was wondering how you can evaluate parts of a
> string:
>
> Ex: $fileName = "File";
> $var = '1>>$fileName';
>
> Now I would like a *simple* way of evaluating $var
> such that only '$fileName' gets substituted for its
> value. 'eval' doesn't work since it tries t
Can't you regex out anything that comes before the $ in $var,
and then proceed from there? Maybe I'm missing something here ...
$var='1>>$fileName'; # This is coming from your first perl script, right?
$filename="File1";
$var=~s/.*(\$\S+).*/$1/;
# Now $var eq '$fileName';
$string=eval($var);
Pete
On Tue, 18 Mar 2003, Navid M. wrote:
> But this won't work if $var='1>>$fileName'. I was
> hoping there would be a simple way getting around this
> without using any regexps.
I think Pete's solution is as simple as it gets!
-- Brett
http://www.chapelperi
Thanks Pete, I actually thought about this, but
because of the format of my perl script, it'll get too
messy if I do this with a regex. The thing is, If I
didn't have any other string other than the filename,
then this would have been really easy to do. Ex:
$fileName = "File1";
$var = '$fileName
Your first perl script sends '1>>$filename' (single quotes, this is NOT a
variable) ... and you want to replace '$filename' with the contents of the
variable $filename?
If I have that correct, a regex will help:
my $string='1>>$filename'; # This is coming from your first perl script.
my $filename
On Tue, 18 Mar 2003, Navid M. wrote:
> No, I can't use double quotes. This is what's being
> done:
> . One of my perl scripts is sending this string
> 1>>$filename' to another perl script, and it's
> in the second perl script where $filename is
> defined.
> So I need to take the string '1>>
No, I can't use double quotes. This is what's being
done:
. One of my perl scripts is sending this string
1>>$filename' to another perl script, and it's
in the second perl script where $filename is
defined.
So I need to take the string '1>>$filename' and
replace $filename with its actual
> -Original Message-
> From: Navid M. [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 18, 2003 7:49 AM
> To: [EMAIL PROTECTED]
> Subject: Evaluating parts of a string
>
>
> Hello,
>
> I was wondering how you can evaluate parts of a
> string:
>
> Ex: $fileName = "File";
> $var = '1>
On Tue, 18 Mar 2003, Navid M. wrote:
> I was wondering how you can evaluate parts of a
> string:
>
> Ex: $fileName = "File";
> $var = '1>>$fileName';
>
> Now I would like a *simple* way of evaluating $var
> such that only '$fileName' gets substituted for its
> value. 'eval' doesn't work since
12 matches
Mail list logo