0

Is it possible to include one line commands of ubuntu to perl script, which has able to execute inside the script and it should give output as desired. is it possible to do so?

I wish to convert xlsx file to csv format using xls2csv command, but I want to execute this command inside my perl script .

Can anyone help me to fix this out ?

I'm Geeker
  • 4,601
  • 5
  • 22
  • 41
  • You mean like `system("ls");`? – tripleee Mar 25 '15 at 06:04
  • i wish to convert xlsx file to csv format using xls2csv command, but i want to execute this command inside my perl script . can you help me to fix this out !???? – Aditya Acharya Mar 25 '15 at 06:27
  • Any basic tutorial will show how to `open(H, "xls2csv $file |")` but you may be better off with a [native Perl library](http://perltricks.com/article/108/2014/8/5/Parse-Excel-with-ease-using-Perl). Anyway, please update your question to explain what you actually want, what you already tried, and how it failed. – tripleee Mar 25 '15 at 06:45

1 Answers1

1

To execute a shell command in perl script use system like this :

system("xls2csv");

To store the output of the command, use backticks :

my $output = `xls2csv`;

See the difference between system and backticks here

Difference between system, backtics and exec

Differences between system, backticks and pipes in Perl

Community
  • 1
  • 1
serenesat
  • 4,611
  • 10
  • 37
  • 53