Hello monks!
I have the following bit of code that I'm having a bit of trouble with. I'm in Iraq right now, so I apologize if a lot of this is something I can search/read about - internet time and books on Perl are in short supply around here.
Basically I have this script that opens a file called ccrutil.pl, and goes through it looking for a tag of "#CCR", then spits that, and the following line, to an html file.
It _kind of_ works, but I'm having two problems - one is that I get an error that says "Use of uninitialized hash element at extract1.pl line 48, <DATA> line (60, 80, 136)" when executing.
Secondly, it's ignoring my entire top section where I build the html header, and I don't know why. Any insight at all would really be appreciated, and thank you as always! :D
#!/usr/bin/perl -w
use strict;
use IO::File;
use Data::Dumper;
use Getopt::Long;
open(DATA,"ccrutil.pl") or die $!;
my $file ="ccrutil.html";
open FILE, ">$file" or die "unable to open $file $!";
print FILE "\<html\>\n"; # Build HTML header
print FILE "\<title\>CCRUTIL.HTML\<\\title\>\n";
print FILE "\<body bgcolor\=\"black\"\>\n";
close FILE;
my %functxt;
while (<DATA>) {
my $line = $_;
chomp($line);
if ($line =~ /^\#CCR/) {
my ($functionName) = $line =~ /^\#CCR-(.*)/;
my $desc = <DATA>; # pull the next line
$functxt{$functionName} = $desc;
}
}
foreach my $func (keys(%functxt)) {
my $text = $functxt{$func};
my $file ="ccrutil.html";
open FILE, ">$file" or die "unable to open $file $!";
print FILE "\<b\>Function $func does $text\<\/b\>\n";
close FILE;
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.