What about messing with $/ ?
------------from perlvar---------
input_record_separator HANDLE EXPR
$INPUT_RECORD_SEPARATOR
$RS
$/
The input record separator, newline by default. This influences Perl's
+ idea of what a ``line'' is. Works like awk's RS variable, including
+treating empty lines as a terminator if set to the null string. (An e
+mpty line cannot contain any spaces or tabs.) You may set it to a mul
+ti-character string to match a multi-character terminator, or to unde
+f to read through the end of file. Setting it to "\n\n" means somethi
+ng slightly different than setting to "", if the file contains consec
+utive empty lines. Setting to "" will treat two or more consecutive e
+mpty lines as a single empty line. Setting to "\n\n" will blindly ass
+ume that the next input character belongs to the next paragraph, even
+ if it's a newline. (Mnemonic: / delimits line boundaries when quotin
+g poetry.)
undef $/; # enable "slurp" mode
$_ = <FH>; # whole file now here
s/\n[ \t]+/ /g;
Remember: the value of $/ is a string, not a regex. awk has to be bett
+er for something. :-)
Setting $/ to a reference to an integer, scalar containing an integer,
+ or scalar that's convertible to an integer will attempt to read reco
+rds instead of lines, with the maximum record size being the referenc
+ed integer. So this:
$/ = \32768; # or \"32768", or \$var_containing_32768
open(FILE, $myfile);
$_ = <FILE>;
will read a record of no more than 32768 bytes from FILE. If you're no
+t reading from a record-oriented file (or your OS doesn't have record
+-oriented files), then you'll likely get a full chunk of data with ev
+ery read. If a record is larger than the record size you've set, you'
+ll get the record back in pieces.
On VMS, record reads are done with the equivalent of sysread, so it's
+best not to mix record and non-record reads on the same file. (This i
+s unlikely to be a problem, because any file you'd want to read in re
+cord mode is probably unusable in line mode.) Non-VMS systems do norm
+al I/O, so it's safe to mix record and non-record reads of a file.
"cRaZy is co01, but sometimes cRaZy is cRaZy".
- crazyinsomniac
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.