how to read fixed length records in perl

I know I can use:

while (<>){
....
}

to read each line of the input file,

but, how to read fixed length records that have no "new line" in the
file at all?
David Wolf [ Di, 01 November 2005 17:27 ] [ ID #1039372 ]

Re: how to read fixed length records in perl

david wolf wrote:
> I know I can use:
>
> while (<>){
> ...
> }
>
> to read each line of the input file,
>
> but, how to read fixed length records that have no "new line" in the
^^^^
> file at all?

You have just asked a SAQ (Self-Answering Question)

perldoc -f read

Paul Lalli
Paul Lalli [ Di, 01 November 2005 17:37 ] [ ID #1039374 ]

Re: how to read fixed length records in perl

Sorry for the silly question, I am just a programmer starting on perl.
David Wolf [ Di, 01 November 2005 22:41 ] [ ID #1039376 ]

Re: how to read fixed length records in perl

david wolf wrote:
> I know I can use:
>
> while (<>){
> ...
> }
>
> to read each line of the input file,
>
> but, how to read fixed length records that have no "new line" in the
> file at all?

$/ = \256; # Set IRS to fixed length records

while ( <> ) {
...
}



John
--
use Perl;
program
fulfillment
someone [ Mi, 02 November 2005 01:21 ] [ ID #1041153 ]

Re: how to read fixed length records in perl

david wolf wrote:
> Sorry for the silly question, I am just a programmer starting on perl.

The question you should have been asking yourself is "Where can I
find a list of Perl's operators and built-in functions?" There are
several at your disposal. You really ought to familiarize yourself
with those before continuing.

perldoc perlfunc
perldoc perlop
perldoc perlrun
perldoc perlvar


-Joe
Joe Smith [ Mi, 02 November 2005 11:36 ] [ ID #1041155 ]
Perl » alt.perl » how to read fixed length records in perl

Vorheriges Thema: how to sleep few seconds in perl
Nächstes Thema: $_ and @_