more useful options | |
PerlMonks |
Re: Splitting a large file into smaller files according to indexesby shmem (Chancellor) |
on Apr 06, 2018 at 08:43 UTC ( [id://1212408]=note: print w/replies, xml ) | Need Help?? |
Can't use string ("00000140") as a symbol ref while "strict refs" in use at ./partition_file.pl line 26, <$FH> line 6. The code you posted doesn't produce this error message, it most likely stems from an earlier version of your program, in which you e.g. used $OUT overall instead of $NEW. In this case, in line 26, you would be trying to use a string as a filehandle. Are you sure that your "mrule" tokens are grouped? If after mrule=150 some line containing mrule=140 is found further down in the source file, you overwrite the file 00000140.log with that line. To avoid that, open a file for every mrule token and store the open filehandles in a hash:
Note the extra braces in the print statement around $fh{$mrule}. These are necessary to disambiguate $fh{$mrule} as being a filehandle rather than part of the LIST for print.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
In Section
Seekers of Perl Wisdom
|
|