Re: Delimiter for string..
From: Singh, Ajit p [EMAIL PROTECTED] 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 PROTECTED] === http://Jenda.Krynicky.cz = 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Delimiter for string..
Ajitpal, [EMAIL PROTECTED] 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response