Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Help with script recognizing variable in string

by bliako (Monsignor)
on Jun 20, 2018 at 09:43 UTC ( [id://1216994]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Help with script recognizing variable in string
in thread Help with script recognizing variable in string

Hmmm, watch out double quotes could lead to problems if you had other variable-looking items, e.g. those prepended by a sigill ($,%,@,&,etc.) in your string and perl would want to interpolate them too! If they happen to exist, perl would be eager to replace them, if they do not exist perl will replace them with empty unless you used use strict; use warnings;

Why don't you build your $bfquery as a sequence of string concatenations using single quotes or variable contents, for example:

$bfquery= # this is a string in single quotes so nothing is interpolated 'query?relevance=%28names%20of%20it%2C%20ip%20addresses%20of%20it +%2C%20root%20server%20of%20it%2C%20operating%20systems%20of%20it%2C%2 +0 last%20report%20time%20of%20it%2C%20agent%20versions%20of%20it%2C%20va +lues%20of%20results%20from%20%28BES%20Property%20%22_SupportGroup%22% +29%20of%20it%29%20of%20bes%20 computers%20whose%20%28%20name%20of%20it%20as%20lowercase%20starts%20w +ith%20%22' # add to this the value of this perl variable . $bfcomputer # and also this fixed string . '%22%29' # end of concatenation ;

Replies are listed 'Best First'.
Re^4: Help with script recognizing variable in string
by TonyNY (Beadle) on Jun 20, 2018 at 20:20 UTC

    Hi bliako, when trying to concatenate I get the following errors

    $bfquery= # this is a string in single quotes so nothing is interpolated 'query?relevance=%28names%20of%20it%2C%20ip%20addresses%20of%20it +%2C%20root%20server%20of%20it%2C%20operating%20systems%20of%20it%2C%2 +0 +last%20report%20time%20of%20it%2C%20agent%20versions%20of%20it%2C%20v +a +lues%20of%20results%20from%20%28BES%20Property%20%22_SupportGroup%22% +29%20of%20it%29%20of%20bes%20computers%20whose%20%28%20name%20of%20it +%20as%20lowercase%20starts%20 +with%20%22' # add to this the value of this perl variable . $bfcomputer # and also this fixed string . '%22%29'; # end of concatenation <?xml version="1.0" encoding="UTF-8"?> <BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNa +mespaceSchemaLocation="BESAPI.xsd"> <Query Resource="(names of it, ip addresses of it"> <Result></Result> <Error>This expression could not be parsed.</Error> </Query> </BESAPI> sh: +%2C%20root%20server%20of%20it%2C%20operating%20systems%20of%20it% +2C%20: not found sh: +last%20report%20time%20of%20it%2C%20agent%20versions%20of%20it%2C +%20va: not found sh: +lues%20of%20results%20from%20%28BES%20Property%20%22_SupportGroup +%22%: not found sh: +29%20of%20it%29%20of%20bes%20computers%20whose%20%28%20name%20of% +20it: not found sh: +%20as%20lowercase%20starts%20: not found sh: +with%20%22server01%22%29: not found

      make sure you have the correct syntax there: name of it as VS name<blink>S</blink> of it

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found