These first four lines are how every Perl script I write starts.

#!/usr/bin/perl -T
use strict;
use warnings;
use diagnostics -verbose;

my ($oldfile) = $ARGV[0] =~ /^([-a-zA-Z0-9._\/]+)$/;
die "bad old filename" unless $oldfile;

my ($newfile) = $ARGV[1] =~ /^([-a-zA-Z0-9._\/]+)$/;
die "bad new filename" unless $newfile;

open my $OF, "<", $oldfile or die "$oldfile: $!";
open my $NF, ">", $newfile or die "$newfile: $!";

my $letter = $& =~ /(?<=\<h1><)[a-z]{1,1}/;

while (my $line = <$OF>) {
my $navold = '<a href="../man0p_a">Man(0p) a';
my $navnew1 = '<a href="../man0p_';
my $navnew2 = '">Man(0p) ';
my $navnew3 = $navnew1 . $letter . $navnew2 . $letter;
    $line =~ s/$navold/$navnew3/g; # replace string
    print $NF $line;
}

close($OF);
close($NF);


I have read perlsyn, perldata, perlsub, perlop, perlfunc, perlvar, 
perlre, perlreref and perlref several times.

I am sure I have read exactly what I need to but I just don't seem 
to be able to see it or understand it.

I have messed around with this line several different ways

my $letter = $& =~ /(?<=\<h1><)[a-z]{1,1}/;

Perl does not complain but it does not do anything
I could use help understanding how to do this so it will work

I am trying to capture the first letter of a word between 
<h1><[a-z]somemoretext></h1>

Then use that first letter to change the letter here

<a href="../man0p_x

and here

">Man(0p) x

x = the location of the letter that changes

so the nav links to the location of the docs are correct.

-- 
Silverfox
Please don't CC me. I am subscribed to the list.
Do you want someone to do it for you?
They will be glad to, if you pay them.
To get free help one must show evidence
that one has made an honest effort to
find/figure out the answer first.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to