[Israel.pm] using "system"

Mikhael Goikhman migo at homemail.com
Sun Oct 31 05:18:47 PST 2004

On 31 Oct 2004 14:23:30 +0200, Offer Kaye wrote:
> On Sun, 31 Oct 2004 11:28:30 +0000, Mikhael Goikhman <migo at homemail.com> wrote:
> > 
> > Here is an example of both:
> > 
> >   system("ls", "-al");
> > 
> >   system {"ls"} "dir", "-al";
> I think I get it - the "system PROGRAM LIST" format of the command is
> just a way of "fooling" the program into thinking it is running as
> "dir" while it is really running "ls"?
> What is that good for?

I think I explained the reasons in my message. Here is one more time. :)

Reason number one: to get fancier output in "ps" and "top".

Reason number two: if a program itself supports several simulation modes
depending on the way it is called (i.e. by looking at argv[0]), to be
able to activate a specific mode by running the program directly.
(Other possible ways to activate these modes would be by running any
symlinks or hardlinks to that program, but these may or may not exist,
it is more flexible to fiddle with argv[0] of that program directly.)

You never usually need to fiddle with setting argv[0] of other programs.

Perl itself does not include its real argv[0] in @ARGV, for simplicity.
So, the only way to implement simulation modes in perl is to use real
symlinks or hardlinks, and to look at $0.

For example, the GUI for GNU Arch, archway-0.1.0 that will be released
today or tomorrow has one perl executable archway and 8 symlinks to it:

  archang -> archway
  archaos -> archway
  archelf -> archway
  archero -> archway
  archeye -> archway
  archgen -> archway
  archmag -> archway
  archrog -> archway

So, you choose your character and play as ArchAngel, ArchChaos, ArchHero,
ArchElf, ArchGenie, ArchMage or ArchRogue.  Woops, it is not really RPG,
but you get the idea.  [In reality, it's just a way to have 9 stand-alone
guis and not just one monolithic GUI. I.e. if you only want to work with
the project tree, you run "archelf", if you are only interesting in
merges then "archmag", and so on.]

And if we speak about it, I know several people here use Arch, you may
try archway-0.1.0 tomorrow. If nothing else, it has nice logos. :)


perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'

More information about the Perl mailing list