Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Extending the line input (angle) operator
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?

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Dunbar
10-28-04 01:56 PM


Re: Extending the line input (angle) operator
"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';



Report this thread to moderator Post Follow-up to this message
Old Post
Peter Wyzl
10-28-04 01:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:06 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.