Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Any suggestions/hints as to where I'm going wrong?#!/usr/bin/perl #htmltest2.plx # Program will read in an html file, remove the img tag and print out # no need for file variable yet: open (INFILE, "<".$htmlFile) or die(" +Can't read source file!\n"); use warnings; use diagnostics; use strict; my @htmlLines; open INFILE, "E:\\Documents and Settings\\Richard Lamb\\My Documents\\ +HTMLworkspace\\HTML practice\\My First Page!\\firsttest\.html" or die + ("Sod! Can't open this file.\n"); @htmlLines = <INFILE>; scrapTag(); # calls method to remove image tags sub scrapTag # removes image tags from HTML document { while($htmlLines[$i] =~ m/<IMG\s+([^>]+)>/ig) # finds each instance +of image tag in the input file { s/<IMG\s+([^>]+)>/ig//ig # replaces each instance of image tag wit +h nothing! } return @htmlLines; } for my $i (0..@htmlLines-1) { print $htmlLines[$i]; } print "\n\n"; sleep 2; print "Success?!\n"
Cheers,
Richard
update (broquaint): added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML image tag stripping
by Aristotle (Chancellor) on Aug 05, 2003 at 16:07 UTC | |
|
Re: HTML image tag stripping
by Lachesis (Friar) on Aug 05, 2003 at 16:11 UTC | |
|
Re: HTML image tag stripping
by bm (Hermit) on Aug 05, 2003 at 15:50 UTC | |
by Anonymous Monk on Aug 05, 2003 at 15:53 UTC | |
|
Re: HTML image tag stripping
by bm (Hermit) on Aug 05, 2003 at 16:19 UTC | |
|
Re: HTML image tag stripping
by CombatSquirrel (Hermit) on Aug 05, 2003 at 16:22 UTC |