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


In reply to Re: Gathering current ksh shell aliases in perl by samarzone
in thread Gathering current ksh shell aliases in perl by kreon3

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.