in reply to Not writing to file

Not that you'd want to in this case, but you could use select() to set the output filehandle.
#!/usr/local/bin/perl -w use strict; open(FILE, ">/tmp/blah") || die "Can Not Open File\n"; my $oldfh = select(FILE); # $oldfh stores the original filehandle # and FILE becomes the current filehandle # for output for (my $n = 1; $n < 10; $n ++) { # use backticks as noted elsewhere print `ping -c 1 192.168.1.$n`; } select($oldfh); # select the original filehandle, # just for neatness close (FILE);
It's not really worth using here... but it's nice to know it's there.

- FrankG

Updated - changed system to print in for loop per Re: Re: Not writing to file
thanks to dws

Replies are listed 'Best First'.
Re: Re: Not writing to file
by dws (Chancellor) on Apr 04, 2001 at 23:05 UTC
      system `ping -c 1 192.168.1.$n`; Isn't going to do what you expect.
      Doh! Thanks... that's what I get for copying from two scripts and not re-re-re-re-reading.
      system `ping -c 1 192.168.1.$n`;

      Should be:
      print `ping -c 1 192.168.1.$n`;

      - FrankG