in reply to Re: Re: Re: Finding part of a file
in thread Finding part of a file
when warnings are turned on.... I'm not entirely sure why 'last'ing out of an eval block is bad, but I do know that eval is overkill for what you've written. do is probably more appropriate. The following code issues no warnings:Exiting eval via last at line 8, <DATA> line 5.
Update: You might want to replace the last above with a next if you want multiple windows to print... For instance, it changes what gets printed using this data:#!/usr/bin/perl -wT use strict; my $begin='banana'; my $end='grape'; while(<DATA>) { /^$begin$/ && do { /^$end$/ ? last : print while (<DATA>) } } __DATA__ apple banana pear peach grape orange
Notice that 'cow' and 'pig' are between a second set of on/off toggles... last will skip them next will print them. Which is the desired behavior? Your guess is as good as mine.__DATA__ banana pear peach grape orange banana cow pig grape
-Blake
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re4: Finding part of a file
by belden (Friar) on Dec 05, 2001 at 22:54 UTC |