Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Since in that case, there was always a newline character after \local $/ = "<br>"
I assumed I could substitute whitespaces, but that's not happening. Here's a cut down version of the code that generates this.This would be the first line. It's fine and dandy. Something tends to go wrong about here though. And of course the next line would be here. The next line here. And so on and so on.
So, maybe an explanation of what exactly $/ does would get me started. If I'm understanding it write, it can redefine the newline character, no? Or maybe my substitution of whitespaces is just way off. I thought my code above would substitute 2 or and infinite number of whitespaces with a big ole donut, but that didn't work. Thanks.#!/usr/bin/perl # # use strict; use warnings; my $directory = "/path/to/html/files/"; my ($line, $base, $file, $description); undef $/; opendir ( DIR, $directory ) or die "Can't open $directory $!"; while ( my $base = readdir( DIR ) ) { if ( $base =~ /.htm/ ) { $file = $directory . $base; open ( FILE, $file ) or die "Can't open $file $!"; my $whole_file = <FILE>; if ( $whole_file =~ /.+?Title:.*?<\/b>*(.*?)<br>*\s*<br>\s*( +.+?)</si ) { $description = $2; $description =~ s/\s{2,}/ /s; # I tried many varaitions + of this to no avail $description =~ s/ / /s; $description =~ s/<.+?>/ /s; print "$description\n\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help substituting whitespaces?
by Abstraction (Friar) on Aug 07, 2003 at 13:56 UTC | |
|
Re: help substituting whitespaces?
by fourmi (Scribe) on Aug 07, 2003 at 14:07 UTC | |
by Abstraction (Friar) on Aug 07, 2003 at 14:29 UTC | |
by Anonymous Monk on Aug 07, 2003 at 15:01 UTC | |
|
Re: help substituting whitespaces?
by l2kashe (Deacon) on Aug 07, 2003 at 14:59 UTC | |
|
Re: help substituting whitespaces?
by snax (Hermit) on Aug 07, 2003 at 19:11 UTC |