in reply to Split a file
Hello and Welcome to the Guided Quick Tour to the Perl Documentation. Today, we will focus on two important aspects of Perl variables that will be of convenient assistance when needing to split files.
To your left, you find perlvar, also accessible as perldoc perlvar when using the command prompt. Please take a close look at the "input record separator", and especially how setting it to a reference to a number will make Perl read in records of a fixed length.
To your right, you will find binmode, also accessible as perldoc -f binmode from your command prompt. Using binmode on any filehandle has become almost mandatory on any operating system when you want to prevent any character set manipulation that Perl might perform and when you want to emancipate yourself from whatever character set your operating system believes to be current.
If you use these two features in conjunction, for example, in a loop, you can easily emulate the Unix split command, which does the same thing.
This concludes our Guided Quick Tour to the Perl Documentation, if you have further question, please read the leaflet How (Not) To Ask A Question before continuing. If you haven't received the leaflet at the start of the tour, there is an online version available as well.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split a file
by xdg (Monsignor) on Aug 05, 2005 at 12:22 UTC |