in reply to Altering Behavior of a Script

On *NIX, the environment variable $- will contain 'i' iff the shell was invoked interactively i.e.
if ($ENV{'-'} =~ 'i') { # interactive invocation } else { # non-interactive e.g. cron, invocation }
A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: Altering Behavior of a Script
by bichonfrise74 (Vicar) on Sep 03, 2009 at 20:44 UTC
    I'm on a Linux system, but the script you provided does not seem to be working for me. In fact, if I do this,
    perl -e 'print join "\n", keys %ENV';
    I do not even see '-', the closest thing that would resemble this is '_'. But if I print the value of '_', it will give me this: /usr/bin/perl
      Bloodnok is thinking of special bash variable $-. It is not an environment variable, and it would be useless to a child anyway.