Delimiter for string..

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Delimiter for string..

    Friends,


    I am running a perl script as below which is working perfectly and want to
    replace the hardcoded values with variables.
    (the script accepts space as the delimiter)

    @respon = $placesock->print("./test.pl \"7741266\" \"DEM EXPO\"
    \"255.255.255.255\" \n");

    and i am doing this

    @respon = $placesock->print("./test.pl." ".$param1." ".$param2." ".$param3
    \n");

    Whats the mistake i am commiting.

    i m getting the following error message...

    String found where operator expected at mybly.pl line 263, near ""./test.pl
    .. " " . $param1.""
    (Missing operator before " . $param1."?)
    panic: realloc at mybly.pl line 263.



    ----------------------------------------------------------------------------
    ----------------

    regards,

    Ajitpal Singh,

    Ajit P Singh Guest

  2. Similar Questions and Discussions

    1. changing query string delimiter?
      Does anyone know how(or if) you can change the query string delimiter in Coldfusion. I want to change it from '?' to '/' for obvious reasons. Is...
    2. Can I convert a string to a list by some kind of delimiter?
      > I would like to know if it is possible in Director MX that I can convert a Yes, by iterating through all the items in the string. Possibilities...
    3. Delimiter WITHOUT lots of IF's
      Hi all, I need to create an automatic process for visitors who are adding items into a shopping cart, be able to see how many MBs and how many...
    4. Delimiter Split
      Hello, The string.Split method is very useful for splitting strings that use a single character as a delimiter. i.e.: string str =...
    5. Regex help (? as delimiter)
      Lawrence Tierney wrote: --------------^ No it doesn't. Exchange \d for \w and it matches. -- Gunnar Hjalmarsson
  3. #2

    Default Re: Delimiter for string..

    Ajitpal,

    [email]ajit.pal.singh@thus.net[/email] wrote:
    >Friends,
    >
    >
    >I am running a perl script as below which is working perfectly and want to
    >replace the hardcoded values with variables.
    >(the script accepts space as the delimiter)
    >
    >@respon = $placesock->print("./test.pl \"7741266\" \"DEM EXPO\"
    >\"255.255.255.255\" \n");
    >
    >and i am doing this
    >
    >@respon = $placesock->print("./test.pl." ".$param1." ".$param2." ".$param3
    >\n");
    >
    >
    Try doing this instead: (untested)

    @respon = $placesock->print("./test.pl \"$param1\" \"$param2\" \"$param3\"\n");
    >Whats the mistake i am commiting.
    >
    >i m getting the following error message...
    >
    >String found where operator expected at mybly.pl line 263, near ""./test.pl
    >. " " . $param1.""
    > (Missing operator before " . $param1."?)
    >panic: realloc at mybly.pl line 263.
    >
    >
    >
    >----------------------------------------------------------------------------
    >----------------
    >
    >regards,
    >
    >Ajitpal Singh,
    >
    >
    HTH,

    Chuck

    Chuck Fox Guest

  4. #3

    Default RE: Delimiter for string..

    > I am running a perl script as below which is working perfectly and want to
    > replace the hardcoded values with variables.
    > (the script accepts space as the delimiter)
    > @respon = $placesock->print("./test.pl \"7741266\" \"DEM EXPO\"
    > \"255.255.255.255\" \n");
    >
    > and i am doing this
    >
    > @respon = $placesock->print("./test.pl." ".$param1." ".$param2." ".$param3
    > \n");
    >
    > Whats the mistake i am commiting.
    The simple answer is that you are forgetting to escape "
    Really, I think you're getting confused about when you are in the "s and
    when you aren't.


    The more complicated answer is how to get what you want. I'll give it a
    try:

    @respon = $placesock->print("./test.pl \"".$param1."\" \"".$param2."\"
    \"".$param3."\" \n");

    but that is way more complicated than it needs to be, since " will replace
    $var with it's value, so you should be able to do:

    @respon = $placesock->print("./test.pl \"$param1\" \"$param2\" \"$param3\"
    \n");

    for me, that's a little hard to read, but others may prefer it. Another
    option, if you don't put anything in "s that needs to be replaced would be:

    @respon = $placesock->print('./test.pl "'.$param1.'" "'.$param2.'"
    "'.$param3.'" '."\n");

    All three of these produce the same output as the hardcoded version that you
    gave us when given proper values for $params
    > i m getting the following error message...
    >
    > String found where operator expected at mybly.pl line 263, near
    ""./test.pl
    > . " " . $param1.""
    > (Missing operator before " . $param1."?)
    > panic: realloc at mybly.pl line 263.
    Mark Anderson Guest

  5. #4

    Default Re: Delimiter for string..

    From: "Singh, Ajit p" <ajit.pal.singh@thus.net>
    > I am running a perl script as below which is working perfectly and
    > want to replace the hardcoded values with variables. (the script
    > accepts space as the delimiter)
    >
    > @respon = $placesock->print("./test.pl \"7741266\" \"DEM EXPO\"
    > \"255.255.255.255\" \n");
    >
    > and i am doing this
    >
    > @respon = $placesock->print("./test.pl." ".$param1." ".$param2."
    > ".$param3 \n");
    I'm sure you'll like the qq operator:

    @respon = $placesock->print(
    qq{./test.pl "$param1" "$param2" "$param3"\n}
    );

    or

    @respon = $placesock->print(
    qq<./test.pl "$param1" "$param2" "$param3"\n>
    );

    or

    @respon = $placesock->print(
    qq#./test.pl "$param1" "$param2" "$param3"\n#
    );

    or
    ....

    The qq (as well as it's brother q and relatives qx, qr, qw and even m
    and s) allows you to use any delimiter you like. Which means that if
    you select well you do not have to escape any quotes.

    See the "Quote and Quote-like Operators" section of the perlop
    manpage:
    perldoc perlop

    Jenda
    ===== [email]Jenda@Krynicky.cz[/email] === [url]http://Jenda.Krynicky.cz[/url] =====
    When it comes to wine, women and song, wizards are allowed
    to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery

    Jenda Krynicky Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139