Link to home
Start Free TrialLog in
Avatar of ming-wen
ming-wen

asked on

Passing a tab as a command line argument using system function

I have trouble of running another PERL script inside of PERL script and passing a tab as a command line argument.  For example, the following is what I would like to do

$command = "PERL second_script.pl \"     \"";
system $command;

However, after tab is passed into the second script, the second script actually sees it as a space.  

What should I do to make it correct?
Avatar of daluu
daluu
Flag of United States of America image

try using the escape character for a tab instead, which is "\t".

Programming languages do not understand tabs by pressing tab unlike a word processor. A tab is either nothing or just a space in source code. You need to use the escape characters for such situations. However, on running the program, the keyboard tab input will be converted and recognized as a tab (but not when typing the source code)

so your code would be this:

$command = "PERL second_script.pl \"\t\"";
Avatar of ming-wen
ming-wen

ASKER

Have tried but it gives the same result (still sees it as a space).
Have tried but it gives the same result (still sees it as a space).
Avatar of ozo
@command = ("PERL","second_script.pl","     "_;
 system @command;
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America 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
Not quite right.  It should be

@command = ("PERL", "second_script.pl", "\"     \"");