open > file && s/ / /;



Hi all,

Can someone pls take a look at the script below and explain what I'm doing
wrong.. The script runs w/out errors but the substitution is not working..
Hopefully the note below will be enough info..

I was able to print the file names that I wanted but once I tried to open
the file and s / / /; the wheels fell off.. :~)

I think I can open a file this way....? Pls explain what I am doing
wrong....
Thank you!
---------------------------------
#!/usr/local/bin/perl

use strict;
use warnings;

# dir w/ text files containing text and links
my $dir = "J:/flash_host/ecomm/descriptions/product/small";

# a text file that has the file names which contain broken links
my $bad_file = "c:/brian/spartan/bad_links.txt";

open BAD, "< $bad_file" or die "Can't read $bad_file: $!\n";

# name each record in $bad_file => $file
while (my $file = <BAD>) {
chomp $file;

if (-e "$dir/$file") {

# open the text file w/ a bad link and sub "http://..."; w/ a local
file
open BADFILE, "> $dir/file" or die "Can't open $dir/$file for replace:
$!\n" &&
s & http://.* & descriptions/product/MSDS/$file &;
close BF
}

}
-----------------------------------

Brian Volk
HP Products
317.298.9950 x1245
<mailto:bvolk@xxxxxxxxxxxxxx> bvolk@xxxxxxxxxxxxxx



Relevant Pages

  • Re: saving surrounding text in substitution
    ... am able to make the substitution but cannot seem to ... Please reduce your programs to the shortest possible script which still ... there's just no way of telling without sample I/O. ... Do you have any regular-expession special characters in $code? ...
    (perl.beginners)
  • Re: Dynamically created select not firing events in IE, works in other browses
    ... If the quality of the script in that file is of the same quality as the information in your whatami page then it is best left alone as the whatami document has broken links and is factually incorrect. ... read above again for where the interpretation of what you wrote came from and it may make more sense then. ... either give me a true feature detection script that can cover both of those scenarios or admit that your page is factually incorrect and that I was right. ...
    (comp.lang.javascript)
  • Re: Dynamically created select not firing events in IE, works in other browses
    ... If the quality of the script in that file is of the same quality as the information in your whatami page then it is best left alone as the whatami document has broken links and is factually incorrect. ... Give me a "feature detection" script to tell whether window.external.addFavorites is supported or not. ...
    (comp.lang.javascript)
  • Re: [PHP] variable substitution
    ... I have two variables declared in the global scope of a script. ... One is a string with a reference for substitution to the other ...
    (php.general)
  • Re: [PHP] variable substitution
    ... I have two variables declared in the global scope of a script. ... One is a string with a reference for substitution to the other ...
    (php.general)