Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: 2048 character limit

by scain (Curate)
on Jun 05, 2002 at 22:46 UTC ( [id://172037]=note: print w/replies, xml ) Need Help??


in reply to 2048 character limit

druid,

Along the lines of Ryszard's solution, but it puts the print inside the while, like Beatnik suggested, and breaks long lines:

while (<FH>) { my $templine = $_; while (length $templine > 60) { my $substring = substr ($templine, 0, 60); print "$substring\n"; $templine = substr ($templine, 61); } print "$templine\n"; }

Note that this is untested code, and I am notorius for screwing up indexes in things like substr, so be sure to check for off by one errors.

Scott
Please see my resume; I am looking for a Bioinformatics Scientist position.

Replies are listed 'Best First'.
Re^2: 2048 character limit
by Aristotle (Chancellor) on Jun 06, 2002 at 00:52 UTC
    Or much simpler:
    while (<>) { print "$1\n" while s/^(.{60})//; print "$_\n" if $_; }
    ____________
    Makeshifts last the longest.
      doesnt work ..

        Yes it does; maybe your problem is that I'm using the diamond operator. Either make that <FH> or drop the file opening code at the top. In the latter case, call it with the filename on the commandline (script /etc/passwd) or pipe the data into it (script < /etc/passwd).

        Rationale: I tend to use the diamond operator rather than handle the file opening myself because it makes scripts more flexible as to where they accept input from, while at the same time they take less time to write - no monkeying with open, much less (if any) manual error checking, etc. Perl does the job for me, why should I?

        Makeshifts last the longest.

Re: Re: 2048 character limit
by druid (Initiate) on Jun 06, 2002 at 07:50 UTC
    doesnt work.. i just get the same line over and over .. ill try and discover the prob..

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://172037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found