in reply to creating new files bases on string size
use Modern::Perl; my @filehandle; my $maxlength = 10; for ( 1 .. $maxlength ) { open $filehandle[$_], '>', "text$_.txt" or die "Could not open tex +t$_.txt"; } while (<DATA>) { chomp; select $filehandle[ length($_) ]; say $_; } __DATA__ ABC DEFG HIJ KL 1234XYZ G HI S 12ER 34TY
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|