in reply to Re^4: while(){}continue{}; Useful?
in thread while(){}continue{}; Useful?
Note that while lexical variables are defined at the block level (as AnomalousMonk pointed out), the localization in the while conditional holds through the continue block.#!/usr/bin/perl use strict; use warnings; local $/; # slurp my $content = <DATA>; my $error; # Preprocess while (local ($_) = $content =~ /^#include\s(.*?)$/m) { if (/<math/) { # Math library $content =~ s/#include\s$_/import java.lang.Math;/; next; } if (/"stdafx.h"/) { # Autogen MS IDE header for project/system inc +ludes $content =~ s/#include\s$_//; next; } if (/"/) { # A yet unconsidered header file (my $filename) = /"(.*)"/; open my $inc_handle, '<', $filename or warn "File open fail $f +ilename: $!\n" and next; local $/; # slurp my $include = <$inc_handle>; $content =~ s/#include\s$_/$include/; next; } } continue { if ($content =~ s/#include\s$_//) { warn "Unhandled include $_\n"; $error++; } } die "$error errors encountered" if $error; __DATA__ #include "stdafx.h" #include <math.h> #include "AlyLee.h" #include "Common.h"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: while(){}continue{}; Useful?
by BrowserUk (Patriarch) on Apr 05, 2010 at 19:23 UTC | |
by kennethk (Abbot) on Apr 05, 2010 at 22:54 UTC | |
by BrowserUk (Patriarch) on Apr 06, 2010 at 06:14 UTC | |
by kennethk (Abbot) on Apr 06, 2010 at 14:55 UTC |