in reply to Gathering current ksh shell aliases in perl

Update:While submitting this answer I assume that you are expecting the command ("alias"), written within backticks, to run like it does inside a shell

Read perldoc for system

perldoc -f system

It says -

...If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system’s command shell for parsing (this is "/bin/sh -c" on Unix platforms, but varies on other platforms). If there are no shell metacharacters in the argument, it is split into words and passed directly to "execvp",...

Check the return value of system or open. They indicate errors.

# perl -e 'print system("alias")' -1 # perl -e 'open (PIPE, "alias |") or die $@;' Died at -e line 1.

When you do system("alias") perl searches for an executable file named alias which, as expected, is not found

type alias alias is a shell builtin
I don't know but I think backtick operators (``) and open should also work execute commands like system

The things I want to say are

  1. when you do perl -e '$output = `alias`' the shell is nowhere in the picture.
  2. you can not grab output of builtin shell commands
  3. you can grab output of only those commands which can be run in following manner # sh -c "cmd args"

------

Kind monks! Please correct me if I am wrong