maddfisherman has asked for the wisdom of the Perl Monks concerning the following question:
Here is the file1.txt:#!/usr/bin/perl -w use strict; my @array; open(FILE, "<file1.txt") || die $!; local $/ = "****"; while (<FILE>) { chomp $_; push (@array, $_); $/= "####"; } close (FILE); my $i="0"; foreach (@array) { $i++; print "$i$_$i";}
and here is the result that perl gives:stuff****more stuff####this shouldnt show up
so in conclusion if you change the $/ inside a loop you cannot use local and the <> does give the rest of the file even if the file doesnt end with the $/C:\Perl>perl test.pl 1stuff12more stuff23this shouldnt show up3
Edit title by tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FYI
by Cine (Friar) on Aug 23, 2001 at 21:52 UTC | |
by maddfisherman (Sexton) on Aug 23, 2001 at 22:03 UTC | |
by Cine (Friar) on Aug 23, 2001 at 22:07 UTC | |
| |
|
Re: FYI
by maddfisherman (Sexton) on Aug 23, 2001 at 21:46 UTC |