Link to home
Start Free TrialLog in
Avatar of jl66
jl66Flag for United States of America

asked on

why the perl one-liner not run with variable input files

Have the following code block
set WKDIR=D:\TEMP\
set _out1=%WKDIR%\test2.txt
set _in1=%WKDIR%\test1.txt
perl -lne "$lines{ $_ }++; END{ print for sort keys %lines }"  %_in1% > %_out1%
I got the error:
----
Missing right curly or square bracket at -e line 1, at end of line
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
----------------
but when I did the following
----------------
d:
cd D:\TEMP
perl -lne "$lines{ $_ }++; END{ print for sort keys %lines }"  test1.txt > test2.txt
----------------
I can get the right result without errors.
-------------
D:\TEMP>type test1.txt
WWW
AB_C
ABB
ACB
ABB
XYZ
123
-------
SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't get that error.
Are you sure you are enclosing the command in quotes?
Avatar of jl66

ASKER

willettmeister, I tried your suggestions. I got the error messages. Also I rtied to run the same perl on different servers, I got the same. What is wrong with that.
Why don't the other one-liners have this kind of issues? ozo, I copied/pasted the code here. The quotes are here.
 
Avatar of jl66

ASKER

dragon-it, thanks for pointing out this, but it does not make any difference.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial