Google Groups Home
Help | Sign in
Message from discussion write 10 files
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Bill H  
View profile
 More options May 16, 10:05 am
Newsgroups: comp.lang.perl.misc
From: Bill H <b...@ts1000.us>
Date: Fri, 16 May 2008 07:05:39 -0700 (PDT)
Local: Fri, May 16 2008 10:05 am
Subject: Re: write 10 files
On May 16, 5:45 am, "Ela" <e...@yantai.org> wrote:

> The following codes are not accepted by Perl and even string concatenation
> doesn't work. Any suggestions?

> #!/usr/bin/perl

> $infile = $ARGV[0];
> foreach $k (0..10) {
>     $outfile = $infile . $k;
>     open (OFP$k, ">$outfile");

> }

> $i = $size/10000;
> print OFP$i "something"; #0-10k, 10-20k, .... 90-100k...

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google