The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: RE: WANTED: Veronica


[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

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.