$ in text string

T

Terri

I'm brand new to perl any help would be appreciated. I have a perl script
that parses 2 files and imports data into a database. One file maps field
names between the data source and destination. The other file is the source
of the data. The script was working fine until I needed to add a field
called $custom1.

In my mapping fiel a line might look like this:

Table1.Field1 = price.price

The above works. This wont work.

Table1.Field1 = price.$custom1

Instead of getting the value of $custom1 in my destination field I get the
string "price"

I understand that the $ is used to declare a variable in perl. How can I get
perl to interpret $custom1 as a string and not a variable?
 
T

Tore Aursand

I'm brand new to perl any help would be appreciated. I have a perl
script that parses 2 files and imports data into a database. One file
maps field names between the data source and destination. The other file
is the source of the data. The script was working fine until I needed
to add a field called $custom1.

[...]

Where is the code? I don't see any...?
 
J

Jürgen Exner

Terri said:
I'm brand new to perl any help would be appreciated. I have a perl
script that parses 2 files and imports data into a database. One file
maps field names between the data source and destination. The other
file is the source of the data. The script was working fine until I
needed to add a field called $custom1.

In my mapping fiel a line might look like this:

Table1.Field1 = price.price

The above works. This wont work.

Table1.Field1 = price.$custom1

Instead of getting the value of $custom1 in my destination field I
get the string "price"

I understand that the $ is used to declare a variable in perl. How
can I get perl to interpret $custom1 as a string and not a variable?

Normally I would have said just don't ask Perl to interpolate the string by
_not_ using double quotes but use e.g. single quotes instead.

However, your comment about "price.$custom1" producing just "price" without
the trailing dot makes me believe, that there is something else going on.
Unfortunately you are not showing us the relevant part of your code,
therefore we can only try the crystal ball and read tea leaves but are you
using 'eval()' by any chance? This is about the only way I can think of that
would make the dot disappear.

Also, I suspect that you are not using strictures and warnings because
otherwise perl should have warned you about an unitialized value for
$custom1 and you could pinpoint the location where the problem is in your
code.

Without seeing a minimal sample program (strict and warnings save!) that
exhibits the problem it is impossible to guess what you did wrong.

jue
 
T

Terri

Normally I would have said just don't ask Perl to interpolate the string by
_not_ using double quotes but use e.g. single quotes instead.

However, your comment about "price.$custom1" producing just "price" without
the trailing dot makes me believe, that there is something else going on.
Unfortunately you are not showing us the relevant part of your code,
therefore we can only try the crystal ball and read tea leaves but are you
using 'eval()' by any chance? This is about the only way I can think of that
would make the dot disappear.

Also, I suspect that you are not using strictures and warnings because
otherwise perl should have warned you about an unitialized value for
$custom1 and you could pinpoint the location where the problem is in your
code.

Without seeing a minimal sample program (strict and warnings save!) that
exhibits the problem it is impossible to guess what you did wrong.

jue

Thanks to both of you for replying. I didn't post the code because I didn't
write it, I don't understand it, it's long, and it's copyrighted by a
third-party vendor. Not understanding the code I can't even post the
relevant part or a representation of the relevant part.

I realize I 'm not giving you much to go on. I going to experiment with
using single and double quotes. Eval() often appears in the code. I'll
continue to look at this and post back if I can formulate a more precise
question with sample code.
Thanks
 
J

Jürgen Exner

Terri said:
Thanks to both of you for replying. I didn't post the code because I
didn't write it, I don't understand it, it's long, and it's
copyrighted by a third-party vendor.

Well, in that case I would have a conversation with the vendor.
It's their problem and their job to fix it.

jue
 
A

Alan Mead

I'm brand new to perl any help would be appreciated. I have a perl script
that parses 2 files and imports data into a database. One file maps field
names between the data source and destination. The other file is the source
of the data. The script was working fine until I needed to add a field
called $custom1.

Insert 'use strict;' at the top of your script. Fix the resulting errors.
Or, if you cannot, post a small example of your code and we'll try to help.

-Alan
 
B

Brian Helterline

Terri said:
I realize I 'm not giving you much to go on. I going to experiment with
using single and double quotes. Eval() often appears in the code. I'll
continue to look at this and post back if I can formulate a more precise
question with sample code.
Thanks
If you want another shot in the dark, try
price.\$custom1
 
T

Tad McClellan

Thanks to both of you for replying. I didn't post the code because I didn't
write it, I don't understand it, it's long, and it's copyrighted by a
third-party vendor.


Then ask the vendor to fix it.

Eval() often appears in the code.


That can be very dangerous, I hope the vendor is a True Expert, else
there is a very high probability that the code opens security holes...

My guess is that the vendor is a script kiddie, and that the
many eval()s are not strictly necessary.

Who is the vendor?

What is the name of their software?

Surely they won't object to you giving that info out, it is
free advertising for them!
 
A

Anno Siegel

Tad McClellan said:
[...]
Eval() often appears in the code.


That can be very dangerous, I hope the vendor is a True Expert, else
there is a very high probability that the code opens security holes...

My guess is that the vendor is a script kiddie, and that the
many eval()s are not strictly necessary.

Who is the vendor?

What is the name of their software?

Surely they won't object to you giving that info out, it is
free advertising for them!

Not really. After even the bit we've heard about the code it isn't.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top