How to call a bash command from within a perl script?

In a bash script, one can call a perl command in the following manner, where "myperlcommand" is a perl command.

perl -e 'myperlcommand(arguments)'

perl -e 'print("UUUU"x4)'

Now, how can one call a bash command from within a perl script? (Suppose that mybashcommand is a bash command that I would like to call.)

Many thanks in advance.

$
$ # Bash command
$ cat testfile
this is a test file
$
$
$ # Perl program
$ cat -n call_bash.pl
     1  #!/usr/bin/perl -w
     2  # Call Bash command
     3  system ("cat testfile");
$
$ # Run the Perl program
$ perl call_bash.pl
this is a test file
$
$

tyler_durden

1 Like