[Date Prev][Date
Next][Thread Prev][Thread Next][Date
Index][Thread Index]
RE: OT: Perl problem
that's far more complete than my alternative ;-)
open(FROM,$ARGV[0]) or die "$!\n";
while(read FROM, $buf, 80) { print $buf,"\n"; }
kieran
-----Original Message-----
From: Philip Coombes [mailto:philip.coombes@xxxxxxx]
Subject: Re: [ukha_d] OT: Perl problem
==============
#!/usr/bin/perl -w
use strict;
$ = 1;
# Read all the data in one go, it's only 15Mb!
local $/;
my $data = <>;
# Remove any newlines (if there are any)
$data =~ s/\n//g;
# Break it into 80 char chunks
my @lines = split( /(.{80})/, $data );
# And join all the non-empty ones together with newlines
print join( "\n", grep { $_ } @lines );
# Add a trailing new line if you want one.
print "\n";
===============
Home |
Main Index |
Thread Index
|