Note that after removing all the line breaks, you might have trouble seeing the whole thing in any sort of shell window. If the input is valid html data, the output should be perfectly viewable in a web browser.#!/usr/bin/perl use strict; use warnings; die "Usage: $0 input.file\n" unless ( @ARGV == 1 and -f $ARGV[0] ); my $input_file = shift; my $input_byte_count = -s $input_file; { local $/; # set input_record_separator to undef -- switch to "slu +rp" mode open( I, $input_file ) or die "$input_file: $!"; my $whole_file = <I>; close I; } if ( length( $whole_file ) < $input_byte_count ) { die "$0: Perl can't read all of $input_file"; } elsif ( length( $whole_file ) > $input_byte_count ) { die "$0: Either -s $input_file is lying, or bytes were added durin +g read\n"; } else { warn "$0: got exactly $input_byte_count bytes from $input_file\n"; } # now, what was it you need to do with $whole_file? ... # to normalize all whitespace to " " (making it just one long line): s/\s+/ /g; print;
In reply to Re: string gets front truncated
by graff
in thread string gets front truncated
by hsfrey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |