shell - /usr/bin/perl -e "statement" doesn't accept variables -


I would like to execute perl script as the following:

  perl -e 'print 'My $ var = "Hello"; Print $ var "World \ n"; '  

This ends in the following error message:

  Bearded found that the operator is on -e line 1, $ var = "hello" Near the pass (unavailable) operator "hello", the operator is expected, with the print $ var "" (Do you need to predeceate Hello?) Backslash found that the operator will be found on "e-line 1", "near the world" string found that at the end of the operator's expected line-line (Missing semicolon on previous row?) Syntax error, "near $ var" = "hello", "can not find string terminator" 'before eof - e line 1. first   

The following statement works perfectly:

  perl -e ' Rint 'Hello'; Print "World \ n"; '  

It seems that perl -e variable does not accept whether this is true and if so, why?

You have an additional ":

 < Code> perl -e 'print' my $ var = "hello"; print $ var. "World \ n"; '# here __ ^   

delete it. < P> But it's not really clear what you want.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -