$ in text string

Discussion in 'Perl Misc' started by Terri, Dec 2, 2004.

  1. Terri

    Terri Guest

    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?
     
    Terri, Dec 2, 2004
    #1
    1. Advertising

  2. Terri

    Tore Aursand Guest

    On Thu, 02 Dec 2004 10:06:33 -0700, Terri wrote:
    > 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...?


    --
    Tore Aursand <>
    "First get your facts; then you can distort them at your leisure."
    (Mark Twain)
     
    Tore Aursand, Dec 2, 2004
    #2
    1. Advertising

  3. Terri wrote:
    > 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
     
    Jürgen Exner, Dec 2, 2004
    #3
  4. Terri

    Terri Guest


    > 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
     
    Terri, Dec 2, 2004
    #4
  5. Terri wrote:
    > 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
     
    Jürgen Exner, Dec 2, 2004
    #5
  6. Terri

    Alan Mead Guest

    On Thu, 02 Dec 2004 10:06:33 -0700, Terri wrote:

    > 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
     
    Alan Mead, Dec 2, 2004
    #6
  7. "Terri" <> wrote in message
    news:cono5p$crj$...
    >
    > 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
     
    Brian Helterline, Dec 2, 2004
    #7
  8. Terri <> wrote:


    > 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!


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Dec 2, 2004
    #8
  9. Terri

    Anno Siegel Guest

    Tad McClellan <> wrote in comp.lang.perl.misc:
    > Terri <> wrote:


    [...]

    > > 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
     
    Anno Siegel, Dec 3, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brown Smith
    Replies:
    1
    Views:
    503
    Frankie
    Jun 25, 2005
  2. Migrators

    Reading text file String by String

    Migrators, Dec 9, 2003, in forum: Java
    Replies:
    7
    Views:
    16,878
    adahlman
    Sep 26, 2007
  3. Umesh
    Replies:
    17
    Views:
    876
  4. leo
    Replies:
    1
    Views:
    287
    Bob Lehmann
    Dec 5, 2005
  5. Mark
    Replies:
    17
    Views:
    231
    Mirco Wahab
    Mar 25, 2007
Loading...

Share This Page