From: Justin Mason (jm at domain jmason.org)
Date: Mon 14 Feb 2000 - 12:16:27 GMT
Lee Hosty said:
> what I'm doing is sucking in a webpage using LWP off a site thats run on a
> mac ...
> I dump this to a file ... then I open this file and want to seperate the
> lines in it ... the at domain array seems to read it in as one element ... so
> chomp() wont work and the only way I can think of to seperate it is by
> splitting it up using the newline element ... \n doesnt work, nor \r\n ...
> I've tried a few combinations of \f \n and \r but still no joy ...
I can't remember the newline sep variable (see man perlvar), but a quick
way to do it would be:
$blob = join ('', <HANDLE>);
at domain lines = split (/[\r\n]+/, $blob);
that'll handle any platform's line-endings and split it into lines.
However multiple blank lines will be ignored with this method, c'est la
To specifically handle Mac line endings, use this:
at domain lines = split (/\r/, $blob);
Macs use \r, windoze uses \r\n, and UNIX is \n.
BTW regarding RedHat's printfilter stuff -- (a) it shouldn't be in the
/var/spool/lpd directory anyway for security reasons and (b) it should
DEFINITELY not be a shell script of all things. That's definitely the
kind of thing that they should have done an rpm on, i.e. come up with a
new, well-designed, well-implemented utility. In fact, I'd seen two
half-built implementations of the same thing in C by that point, so they
should just have adopted one of those!!
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:05:25 GMT