ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: Custom iterators
by Uri Guttman other posts by this author
Sep 25 2001 4:59PM messages near this date
Re: Custom iterators | Re: Custom iterators
> >>>> "MGS" == Michael G Schwern <schwern@[...].com> writes:


  MGS>  Backwards?


  MGS>      File.read_backwards($filename) {

  MGS>          print

  MGS>      }


not trivial but not too hard. check out File::ReadBackwards for a way to
do it efficiently in perl5. it requires some careful seeking, buffering
and scanning for the line endings. it probably should be a module and
not core. it could be combined with a bunch of other useful file or file
iterators classes.

  MGS>  How about each line seperated by the string "Peterbilt"?


  MGS>      my $fh = File.open($filename);

  MGS>      $fh.each('Peterbilt') {

  MGS>          print

  MGS>      }


wouldn't that be better as a input record separator attribute on $fh? it
shouldn't be passed to the iterator as it is usually set only once.

	$fh.irs( 'Peterbilt' ) ;
	$fh.each { print } ;

uri

-- 
Uri Guttman  ---------  uri@[...].com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


Thread:
Michael G Schwern
Piers Cawley
Michael G Schwern
Bart Lateur
Michael G Schwern
Bart Lateur
Michael G Schwern
Uri Guttman
Michael G Schwern
Brent Dax
Bryan C. Warnock
Michael G Schwern

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved