RE: shell script problem so simple I'm embarassed to ask

Kezdőlap
Csatolmányok:
Üzenet email-ben
+ (text/plain)
Üzenet törlése
Válasz az üzenetre
Szerző: Jeremy C. Reed
Dátum:  
Címzett: plug-discuss
Tárgy: RE: shell script problem so simple I'm embarassed to ask
On Fri, 11 Feb 2005, Craig White wrote:

> sorted is nice - directed to a text file was what I was hoping to get...
>
> I know this ain't doing that...
>
> {
>    foreach my $elem (sort {$a cmp $b} keys %ENV) {
>      print "$elem $ENV{$elem}\n" > "/tmp/perldump.txt";
>    }

>
> I am dealing with subroutines that don't direct to standard out


open (DUMPFILE, ">/path/to/perldump.txt");
...
print DUMPFILE "whatever";
...
close (DUMPFILE);

(I purposely removed /tmp/ from your filename example. That leads to
unsafe tempfile creation and race conditions in simple examples.)

Jeremy C. Reed

                 open source, Unix, *BSD, Linux training
                http://www.pugetsoundtechnology.com/


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss