> First off, you should check if open succeeded. Second, what makes you > think you can use OFP$k where Perl expects a filehandle.
> This looks like a very poor attempt at using symbolic file handles (if > such a thing even exsits, I don't know).
Yes, it does. A filehandle is just an unquoted string, so
open "OFP$k", ">$outfile";
'works', FSVO.
(I'm leaving this bit in just in case anyone gets the wrong idea from this post... :) )
> When you find yourself wanting to index something using an integer, you > should use an array.
Ben
-- I touch the fire and it freezes me, [b...@morrow.me.uk] I look into it and it's black. Why can't I feel? My skin should crack and peel--- I want the fire back... Buffy, 'Once More With Feeling'
> Yes, it does. A filehandle is just an unquoted string, so
> open "OFP$k", ">$outfile";
> 'works', FSVO.
> (I'm leaving this bit in just in case anyone gets the wrong idea from > this post... :) )
Does "works" mean it does not generate error but still cannot achieve the effect of printing into different files? Because I'm able to open empty file1, file2, ..., file10 but nothing is printed into them.
Unless $size is always evenly divisible by 10000 then $i will not be the number you expect it to be (use $i = int($size/10000); instead) and it will never print into one of the file handles you have open. (for example, $size = 11,000 then $i = 11000/10000 will equal 1.1, not the "1" you expect.)
Unless $size is always evenly divisible by 10000 then $i will not be the number you expect it to be (use $i = int($size/10000); instead) and it will never print into one of the file handles you have open. (for example, $size = 11,000 then $i = 11000/10000 will equal 1.1, not the "1" you expect.)
Bill H
Yes, u a right. and I've already added int ($size/10000)
Ela wrote: >>Yes, it does. A filehandle is just an unquoted string, so
>> open "OFP$k", ">$outfile";
>>'works', FSVO.
>>(I'm leaving this bit in just in case anyone gets the wrong idea from >>this post... :) )
> Does "works" mean it does not generate error but still cannot achieve the > effect of printing into different files? Because I'm able to open empty > file1, file2, ..., file10 but nothing is printed into them.
use strict; use warnings;
my @fh; my $k = 0;
open $fh[$k],'>','/tmp/test.txt' or die $!; print {$fh[$k]} "Hello\n" or die $!; close $fh[$k] or die $!;
Frank -- Dipl.-Inform. Frank Seitz; http://www.fseitz.de/ Anwendungen für Ihr Internet und Intranet Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel