Ask a Question related to PERL Beginners, Design and Development.
-
Ajit P Singh #1
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
-
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... -
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... -
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... -
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 =... -
Regex help (? as delimiter)
Lawrence Tierney wrote: --------------^ No it doesn't. Exchange \d for \w and it matches. -- Gunnar Hjalmarsson -
Chuck Fox #2
Re: Delimiter for string..
Ajitpal,
[email]ajit.pal.singh@thus.net[/email] wrote:
Try doing this instead: (untested)>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");
>
>
@respon = $placesock->print("./test.pl \"$param1\" \"$param2\" \"$param3\"\n");
HTH,>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,
>
>
Chuck
Chuck Fox Guest
-
Mark Anderson #3
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)The simple answer is that you are forgetting to escape "> @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.
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
""./test.pl> i m getting the following error message...
>
> String found where operator expected at mybly.pl line 263, near> . " " . $param1.""
> (Missing operator before " . $param1."?)
> panic: realloc at mybly.pl line 263.Mark Anderson Guest
-
Jenda Krynicky #4
Re: Delimiter for string..
From: "Singh, Ajit p" <ajit.pal.singh@thus.net>
I'm sure you'll like the qq operator:> 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");
@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



Reply With Quote

