in reply to Re^4: Split file, first 30 lines only
in thread Split file, first 30 lines only

Lets see if i can keep everyone happy here

... my $line_count=0; open (my $fh , '<', $fullfile) or die 'something'; while (my $line=<$fh>) { last if $line_count > 29; ############## needed to add this dayum chomp $line; ############## needed to add this if($line=~m/^\s*CENTRAL\s*INDEX\s*KEY:\s*(\d*)/m){$cik=$1;} if($line=~m/^\s*FORM\s*TYPE:\s*(.*$)/m){$form_type=$1;} if($line=~m/^\s*CONFORMED\s*PERIOD\s*OF\s*REPORT:\s*(\d*)/m){$ +report_date=$1;} if($line=~m/^\s*FILED\s*AS\s*OF\s*DATE:\s*(\d*)/m){$file_date= +$1;} if($line=~m/^\s*COMPANY\s*CONFORMED\s*NAME:\s*(.*$)/m){$name=$ +1;} $line_count++; print "$cik, $form_type, $report_date, $file_date, $name\n"; print "$line_count,' ', $line,' '\n"; } close $fh or die 'something'; ...
Off the top of my head, and Untested, YMMV

Replies are listed 'Best First'.
Re^6: Split file, first 30 lines only
by wrkrbeee (Scribe) on Feb 27, 2017 at 23:25 UTC
    Thank you huck, I'll not bother you any more. Appreciate your help and patience. Rick

      it wasnt you i was harping about, its the nit-pickers

      This now bothers me qr/\'\n'/, the quotes in there, your lines may begin and end with a single quote you dont want. if so add

      $line=~s/^\'//; $line=~s/\'$//;
      after the "chomp" line;

      i think im just getting old, this stuff just stands out after i hit create.... but not before

        Thanks again huck, appreciate your effort here!! Rick