in reply to print line to file on win32

Your first example isn't working, as you've forgotten some quotes around the string to print. The second example isn't much better as you're not setting RANDOM to anything in particular to begin. It seems a bit weird to generate a lot of one-line output files. This doesn't instill confidence that you're asking the right questions, but if I can guess at your intent:
$x = int(rand(65535)); my $in; open($in, '<', "somefile") or die $!; for $line (<$in>) { my $out; open($out, '>', "prefix$x.txt") or die $!; print $out $line; $x++; }

Update:: Changed to work exactly like the shell version (as far as I can tell without being arsed to test it). Didn't try to optimize it or golf it further, so you can see the relative syntaxes involved.

And this has nothing to do with Win32, by the way.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: print line to file on win32
by sans-clue (Beadle) on Oct 29, 2007 at 19:32 UTC
    Thanks, this is what I needed
    my $out; open($out, '>', "prefix$x.txt") or die $!; print $out $line; $x++;

    work great now. Why ? Perl is great at not placing a filehandle on a log file on win32 that I am tailing, but I have a vbscript that has to process each line. It is a looping vbscript, and I don't want to fork it for each line, rather have it loop picking up lines/files. Thanks

      Perl is great at not placing a filehandle on a log file on win32

      Could you please explain what this means? We can probably help you fix your real problem instead of your hack.