Code Comments
Programming Forum and web based access to our favorite programming groups.I would like to extend the line input operator to treat something
other than CR/LF/CRLF as the end of line character.
I'm scanning very very large structured files which contain very few
end of line characters yet the structure is such that another set
string of characters has the same semantics "),(" in this case.
Naturally I could use fgetc or buffered reads or link to a C routine
but this seems like exactly the kind of thing Perl usually allows
insteading of needing to reivent.
Is there a way to extend this operator in current Perl?
If not, is there a module which offers what I want?
If not, would anybody care to recommend the quickest, most effective
way to reach my goal of a line-reading function in Perl which thinks
of a "line" as ending with "),(" rather than \n?
Post Follow-up to this message"Andrew Dunbar" <hippytrail@gmail.com> wrote in message
news:ba1b6b9f.0410280049.2cbce46b@posting.google.com...
>I would like to extend the line input operator to treat something
> other than CR/LF/CRLF as the end of line character.
>
> I'm scanning very very large structured files which contain very few
> end of line characters yet the structure is such that another set
> string of characters has the same semantics "),(" in this case.
>
> Naturally I could use fgetc or buffered reads or link to a C routine
> but this seems like exactly the kind of thing Perl usually allows
> insteading of needing to reivent.
>
> Is there a way to extend this operator in current Perl?
> If not, is there a module which offers what I want?
> If not, would anybody care to recommend the quickest, most effective
> way to reach my goal of a line-reading function in Perl which thinks
> of a "line" as ending with "),(" rather than \n?
The standard variable $/ is what you are looking for.
set $/ to be what you want (before the read)...
$/ = '),(';
Even better, localise it within a block.
$/ is "\n" here...
{
local $/ = '),(';
#read with <> here...
}
$/ back to default "\n" here...
Check it out in perlvar (INPUT_RECORD_SEPARATOR)
--
Wyzelli
print map{++$_;y{0-9A-Za-mn-z;}
{0-9A-Za-no-y z;}ds;$_}split '',
reverse 'qdjbzGykqdOyqdgsnmzysrtI';
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.