Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Help with problem

by Anonymous Monk
on May 23, 2012 at 05:44 UTC ( #971953=note: print w/replies, xml ) Need Help??


in reply to Help with problem

I cannot understand how this would happen with the above code!

Its probably because you skip the empty lines

Count the empty lines, add the number to the new linecounts, compare to original linecounts

#!/usr/bin/perl -- #~ perltidy -csc -otr -opr -ce -nibc -i=4 use strict; use warnings; use autodie; use IO::Handle; Main( @ARGV ); exit( 0 ); sub Main { local *ARGV; local $^I; my $pre = shift @_; local @ARGV = @_; for (@ARGV) { s/^(\s+)/.\/$1/; # leading whitespace preserved s/^/< /; # force open for input $_ .= qq/\0/; # trailing whitespace preserved & pipes fo +rbidden } my $linenum = 0; my $filenum = 0; my $skipped = 0; open FILEOUT, '>', $pre . "-" . $filenum; while (<ARGV>) { if (/^\s*$/) { $skipped++; next; } elsif ( $linenum <= 300000 ) { print FILEOUT $_; $linenum++; } elsif ( $linenum > 300000 ) { $linenum = 0; # reset line counter every 300,000 lines $filenum++; # increment file counter every 300,000 l +ines # and open new file handle close FILEOUT; open FILEOUT, '>', $pre . "-" . $filenum; print FILEOUT $_; } ## end elsif ( $linenum > 300000) } ## end while (<>) close FILEOUT; my $countedLines = ( ( ( $filenum - 1 ) * 300_000 ) + $linenum ); warn "# TOTAL files $filenum \n", ARGV->input_line_ +number; warn '# ($filenum -1 ) * 300_000 + $linenum = ', "$countedLines\n" +; warn "# TOTAL lines ", ARGV->input_line_number, "\n"; warn "# TOTAL SKIPPED $skipped\n"; warn "# COUNTED + SKIPPED = ", $countedLines + $skipped, "\n"; } ## end sub Main

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971953]
help
Chatterbox?
[LanX]: what is the intention of your question?
[LanX]: why do you need to see the nodelet without votes left???
[marinersk]: LanX, the problem is that the lack of interface visual stability is disconcerting to me. The Nodelet appearing and disappearing is distracting, and despite over a decade, still troubles me. It jangles me.
[LanX]: I see
[marinersk]: I appear to be unusually dependent on spacial stability. I have had trouble from someone moving an object a mere four inches to the left.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-05-29 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?