Hacking a script (makemenu.pl)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank Louden

    Hacking a script (makemenu.pl)

    Hi. Infrequent hacker here.

    (Originally posted to alt.comp.lang.p erl. Not much happening over there!)

    I've spent the last two days trying to hack H. Churchyard's makemenu.pl so
    it will work on my WinME PC. I've got lots of hair but I won't have for
    long.

    If there is anyone out there that knows this script, I think I might learn
    quite a bit by hacking my way thru this one but I could sure use some help.

    I'm not looking for a working script or someone to do it for me. I'd just
    like to understand what's going on here and why I am having such a tough
    time getting very far with this. I'm using Activestate's perl, v5.8.6 built
    for MSWin32-x86-multi-thread.

    There are two "eval" lines here...

    eval "exec /usr/local/bin/perl -S $0 $*" if $running_under_ some_shell;

    and...

    eval '$'.$1.'$2;' while $ARGV[0] =~ /^(title=|toc=|d irprefix=)(.*)/ &&
    shift;

    The first is unnecessary (I think) and the second is extracting info from
    the command line.

    I don't know how advanced this script might be but it seems to be using
    lot's of tricks that aren't taught in "Learning Perl on Win32 Systems". ;^)

    Anyway, if there is someone that can spare the time to share some of their
    knowledge with me, I'd be grateful.

    I would attempt to contact the author of this script if I knew how. I've
    used it "as is" on Linux and it works quite well for what I am wanting to
    do.

    Here's the error I get...

    F:\Programming\ Perl\HTML Menu Project>perl -d test2.pl title="My Menu" toc=1
    *.htm > My_Menu.htm
    Win32::OLE operating in debugging mode: _Unique => 1
    Can't open *.htm: No such file or directory at test2.pl line 12.

    And I have several small HTML files with the ".htm" extension in this
    directory.

    I've stripped this script down to what I think is the barest essentials for
    testing. I don't expect this fragment to do anything I'm just trying to get
    over a hump. I hit the "while (<>)" line and I get nothing. Here's what I
    have at this time...

    $title = ''; $toc = 0; $dirprefix = '';
    eval '$'.$1.'$2;' while $ARGV[0] =~ /^(title=|toc=|d irprefix=)(.*)/ &&
    shift;
    $[ = 1; # set array base to 1
    $\ = "\n"; # set output record separator
    foreach $X (@ARGV) {
    if ($X =~ /^[^=]+=/) {
    print STDERR "Apparent misspelled or badly-placed command-line
    option $\
    &";
    print STDERR "Attempting to continue anyway...";}}
    $accum = ''; $haccum = '';
    $xRS = $/;
    #
    while (<>) {
    if ($_ =~ /$xRS$/o) {chop;} # strip record separator
    if (($.-$FNRbase) == 1) {
    if ($. == 1) {
    if (!$title) {
    $title = 'Menu for HTML files';}
    print "<html><head><t itle>$title</title></head>";
    print "<body><h1>$tit le</h1><hr><ul>";}
    else {
    if ($toc) {
    &liout();}}
    $hlevel = 0;}

    };

    Thanks in advance.

    Raffles


  • Jürgen Exner

    #2
    Re: Hacking a script (makemenu.pl)

    Frank Louden wrote:[color=blue]
    > (Originally posted to alt.comp.lang.p erl. Not much happening over
    > there!)[/color]

    Probably even less happing here because this NG is defunct.
    Many years ago it has been replaced by a complete comp.lang.perl. *
    hierarchy.

    See the FAQ "perldoc -q newsgroup":
    What are the Perl newsgroups on Usenet? Where do I post questions?
    for details.

    jue


    Comment

    • Frank Louden

      #3
      Re: Hacking a script (makemenu.pl)

      Thanks Jurgen. I'll repost to one of the others.

      "Jürgen Exner" <jurgenex@hotma il.com> wrote in message
      news:DCLSe.9188 $9q4.7405@trndd c08...[color=blue]
      > Frank Louden wrote:[color=green]
      > > (Originally posted to alt.comp.lang.p erl. Not much happening over
      > > there!)[/color]
      >
      > Probably even less happing here because this NG is defunct.
      > Many years ago it has been replaced by a complete comp.lang.perl. *
      > hierarchy.
      >
      > See the FAQ "perldoc -q newsgroup":
      > What are the Perl newsgroups on Usenet? Where do I post questions?
      > for details.
      >
      > jue
      >
      >[/color]


      Comment

      Working...