alright, here is where i spill the beans. Take note this was finished before graf's last message. It is also a great reason to listen to grandfathers advice about regex and html.

however it is a working hack job which is perfect for what i needed to do to help a friend out. And he is currently very impressed with the community.

anyways heres the scenario.

modify the subpages of this link so that similarly paged links are shifted over by headings.

Here is the final code.

#!/usr/bin/perl -w use strict; sub go{ my $temp; my %DB; my $hist; my $tab= "&nbsp;&nbsp;&nbsp;&nbsp"; my $head; my $c=0; my ($r) = shift @_; open (F,$r) || die "Couldnt open $! $r"; $r =~ s/\./1\./; #@Data = <F>; my $store = "<Head>"; while (<F>){ if (/.*<B>/ && ! /Last modified/){ #If line is a title $temp = $_; $_=~ s/(<[^<>]+>)+//g; chomp; if (/\(/){ $store = $_; $store =~ s/[\(\)]//g; $DB{$store} = $temp; }else{ $store = $_; $store =~ s/[\(\)]//g; $DB{$store} = $temp; } }else{ #Not a title ($store ne "<Head>")? $DB{$store}:$head .= $_; } } print "writing $r"; open (N, ">$r")||die "Can't open to write"; print N "$head";$hist = "---"; foreach (sort keys %DB){ if ((/^$hist[s:]* /)){ $DB{$_} =~ s/<\/*B>/$tab/; $DB{$_} =~ s/<DD>/<DD>$tab/; print N "$DB{$_}"; }else{ $hist = $_; print N $DB{$_}; } } } my @t; my @DIR; my $d; opendir (D,".") || die "Could not open directory! Check to make sure t +his file is in the right place. $!"; @DIR = readdir (D); print "Please select a file to modify\n"; $d=0; foreach (@DIR){ if (/keyword.\.html/){push @t, $_;print ++$d.". $_\n";} ; } print "Selection: "; $a = <>; go $t[$a-1] || die "Invalid Number! Try something within below $#t GOS +H!!!";

I used grandfathers advice, i havent tried many others. i realized a regex error late in the game because some hash values had '(' that were messing up the code... Feel free to throw modifications to this, my buddy just may use it! Thanks a lot


In reply to Re: Reading from large files by zer
in thread Reading from large files by zer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.