in reply to Re: system/exec and %ENV
in thread system/exec and %ENV

Thanks a ton for that quick reply... Indeed, as you mentioned, exec was the culprit (I am a n00b ;-) ). The code fragment, nonetheless is here (have commented out the exec) - Thanks again for your help and reply on the dot.:
#!/usr/bin/perl system "date"; #system 'ls -l $HOME |awk \'{ print $8 }\''; #exec "date"; #print "$ENV{'PATH'}\n"; #$ENV{'PATH'} = "/home/athampan:$ENV{'PATH'}"; #print "$ENV{'PATH'}\n"; foreach $var (sort keys %ENV) { print "$var => $ENV{$var}\n" }

Replies are listed 'Best First'.
Re^3: system/exec and %ENV
by Hue-Bond (Priest) on Jul 16, 2008 at 06:37 UTC

    Had you used warnings, you'd have got an error message:

    use strict; use warnings; exec 'date'; print "still alive\n";
    Statement unlikely to be reached at - line 5. (Maybe you meant system() when you said exec()?) Wed Jul 16 08:36:05 CEST 2008

    --
    David Serrano

Re^3: system/exec and %ENV
by ikegami (Patriarch) on Jul 16, 2008 at 05:57 UTC
    Works (as expected) for me, linux and Windows:
    Tue Jul 15 22:56:32 PDT 2008 CDPATH => .:/home/ikegami:/home/ikegami/www EDITOR => pico -w -z ...
    The current date is: 2008/07/16 Enter the new date: (yy-mm-dd) ALLUSERSPROFILE => C:\Documents and Settings\All Users APPDATA => C:\Documents and Settings\ikegami\Application Data CLIENTNAME => Console ...
      HI Ikegami and pc88mxer - thanks much for both of your efforts, this issue is sorted out quickly through your replies. Regards to all.
Re^3: system/exec and %ENV
by Fletch (Bishop) on Jul 16, 2008 at 12:56 UTC

    Unrelated to your original question, but calling out to a shell to get a listing of files is very Rube-Goldberg-ian. See opendir and readdir (and possibly stat if you're interested in the file properties ls -l shows).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Thanks Hue-Bond and Fletch for your insights. As I mentioned, I am a n00b and "learning perl ... randal et al" and was trying out the commands in the book. As is characteristic n00bishness, I hadn't read the material immediately following the exec treatment (I assumed it to function much like the php directive). Thanks all for the kind help (and not yelling at me to go read the book :-) )