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?
$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?
ASKER
Have tried but it gives the same result (still sees it as a space).
ASKER
Have tried but it gives the same result (still sees it as a space).
@command = ("PERL","second_script.pl" ," "_;
system @command;
system @command;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Not quite right. It should be
@command = ("PERL", "second_script.pl", "\" \"");
@command = ("PERL", "second_script.pl", "\" \"");
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\"";