[8035] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1660 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 17 11:07:26 1998

Date: Sat, 17 Jan 98 08:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 17 Jan 1998     Volume: 8 Number: 1660

Today's topics:
     Re: Access Log (William Byrd)
     Re: converting file names down a directory tree <joseph@5sigma.com>
     Re: converting file names down a directory tree (Tad McClellan)
     Re: EMTY FILE? (William Byrd)
     fork variables <daniel<NOSPAM>@kupfer<NOSPAM>.demon.nl>
     Re: Form Mail & HTML Page (brian d foy)
     Re: Getting the first two chars of a string - URGENT! (William Byrd)
     Re: HELP !! <ajohnson@gpu.srv.ualberta.ca>
     Re: HELP !! <rjk@coos.dartmouth.edu>
     Re: Help - Perl processes in memory (William Byrd)
     Re: How do I allow input to be retrieved from multiple  (Tad McClellan)
     Re: How do I allow input to be retrieved from multiple  <mkleiman@att.com>
     Re: How to substitute for ^\ sequences?? (Gabor)
     Logscribe - where ? (anti-spam - remove 'notreally') (Ian Johnston)
     Re: Puzzling behavior of c.l.p.* readers <rjk@coos.dartmouth.edu>
     reexporting symbols in modules (Tom Dyas)
     Re: Style Q for modules:  best syntax for "hash" argume <sac@genome.stanford.edu>
     Re: Syntax errors with nested braces??? <Sukumar.Patel@mail.tju.edu>
     Re: Tail -f <nick@ni-s.u-net.com>
     Re: Wanted: generic macro/include pre-processor <bowlin@sirius.com>
     Re: Wanted: generic macro/include pre-processor <NOSPAM_mike808@mvp.net>
     What is wrong with this script? <warchie@att.net.hk>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 17 Jan 1998 18:28:33 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: Access Log
Message-Id: <69qiml$jq6$4@winter.news.erols.com>

On Fri, 16 Jan 1998 01:35:36 +0100, Geurt Schimmel <geurt@sybase.com>
wrote:

>
>
>Hans Van Lint wrote:
>
>> Hi,
>>
>> i have a script that shows me detailed information ( in html format) of the
>> access_log file.
>>
>> Now, when I try this,
>>
>> $logfile = "../logs/access_log";
>> open(best, $logfile) || "Error"
>>
>> I get the following error:
>> ../logs/access_log: Permission denied
>>
>
>In fact, you'r trying open(best,"> $logfile") - and that won't work if you're
>not root. When running this program as root, it will remove the logfile
>completely...
>
>Try open(best,"< $logfile");
>
>Geurt
>
>
That should not be right, by default does an open not open for read?

Perhaps the server locks the access_log file while it is running?

while the server is running, try editing the access_log file using
your favourite editor. If it tells you the file is locked, then this
is probably the case
-----------------------------------------------------
Please always check the syntax before applying any fix 
anyone gives you on a newsgroup, no one is perfect. 
Not everyone reads the newgroups every day, but most 
check their e-mail. A private e-mail with the answer
as well as the NG posting is often appreciated. 
Just my 2 cents worth.



------------------------------

Date: Sat, 17 Jan 1998 03:06:55 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: converting file names down a directory tree
Message-Id: <34C082AC.812AFDF8@5sigma.com>

This program executes quickly, although it's not necessarily
quick to write from scratch:

sub recurse {
  local *DH;
  my $dir = shift;
  opendir DH, $dir or die "$0: couldn't opendir $dir: $!";
  my @files = sort grep { $_ ne '.' and $_ ne '..' } readdir DH;
  closedir DH;
  for (@files) {
    recurse("$dir/$_") if -d "$dir/$_";
    next if (my $newname = "$dir/\L$_") eq "$dir/$_";
    warn "$newname exists\n" and next if -e $newname;
    print "renaming: $dir/$_ => $newname\n";
    # rename $_ => $newname;
  }
}
($dir = shift and -d $dir) or die "$0: requires dir as arg";
recurse $dir;

A combination of a Perl script and a find command might be shorter.
Traversing directory trees in Perl is one of those things where
you have to work a little to get the details right.

	-joseph
	 http://www.effectiveperl.com

notsew@wwa.com wrote:
> 
> might someone suggest a quick way to change all file names (say,
> lowercase them) down a directory tree?


------------------------------

Date: Fri, 16 Jan 1998 22:25:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: converting file names down a directory tree
Message-Id: <trbp96.2h5.ln@localhost>

notsew@wwa.com wrote:
: might someone suggest a quick way to change all file names (say,
                          ^^^^^^^^^
: lowercase them) down a directory tree?
                         ^^^^^^^^^^^^^^

Sure.

You do a Dejanews (www.dejanews.com) search in c.l.p.m for 
"directory tree", and find only 205 hits.

Over half of them are answers rather than questions.



Much quicker than your old fashioned post to Usenet and wait a
few hours/days/weeks...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 17 Jan 1998 18:19:37 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: EMTY FILE?
Message-Id: <69qi5u$jq6$3@winter.news.erols.com>

On Fri, 16 Jan 1998 15:02:15 -0800, Tom Phoenix
<rootbeer@teleport.com> wrote:

>On Thu, 15 Jan 1998, Jahnel Klaus wrote:
>
>> How can i test a file weather its empty or not (but not with the testing
>> of the file size)
>
>Could you want the -z filetest? It's documented in the perlfunc manpage.
>Hope this helps! 
>

There are many of us using perl on Macs or Win systems, thus no
perlfunc manpage. I do have the camel book and can look it up (the
book never leaves my computer desk), but is there a winhelp file or
one of those nifty apple help files or hypercard stacks or something
that us non unix users can keep on our desktops for quick reference?

a URL would be appreciated

Bill
-----------------------------------------------------
Please always check the syntax before applying any fix 
anyone gives you on a newsgroup, no one is perfect. 
Not everyone reads the newgroups every day, but most 
check their e-mail. A private e-mail with the answer
as well as the NG posting is often appreciated. 
Just my 2 cents worth.



------------------------------

Date: Sat, 17 Jan 1998 10:55:54 GMT
From: "daniel" <daniel<NOSPAM>@kupfer<NOSPAM>.demon.nl>
Subject: fork variables
Message-Id: <01bd233e$dcb90760$33489fc2@danielk.support.nl.demon.net>
Keywords: variable fork

see code

                FORK:{
                        if($pid = fork) {
                                #parent
                                @notsolongtime=&not_such_a_long_subroutine
                        }else(defined $pid) {
                                #child
                                @longtime=&data_from_a_longtime_subroutine;
                                exit;
                        };
                };
                wait;
                print "@notsolongtime";     #THIS DOESN'T WORK, WHY???!!
                print "@longtime";
        };

It seems that in the parent process which is proceeded after finnishing the
fork doesn't receive the data got in the child process, because
@notsolongtime isn't printed.

What is wrong???!!!
Please let me hear some reaction, thanks,
-- 
Daniel Kupfer.


------------------------------

Date: Sat, 17 Jan 1998 02:19:55 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Form Mail & HTML Page
Message-Id: <comdog-1701980219550001@news.panix.com>
Keywords: just another new york perl hacker

In article <34C02932.5AC7@badger.ac.brocku.ca>, Craig Allen <ca96af@badger.ac.brocku.ca> posted:

> I have looked at 3 different CGI Script Books and for form-mail all have
> been different, some use 'print <<"print_tag"' and others don't. This
> there something special about that "print_tag"????

that's a here document - a method of generalized quoting that allows
you to easily handle multiline strings.  you notice that the 
alternative is lots and lots of print statements.

> One more question.
> The fastest and easiest way to gather data from the form???

CGI.pm is your friend.  it's also part of the standard perl
distribution, so it should be ready to use.

good luck :)

-- 
brian d foy                                 <http://computerdog.com>


------------------------------

Date: Sat, 17 Jan 1998 18:17:25 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: Getting the first two chars of a string - URGENT!
Message-Id: <69qi1q$jq6$2@winter.news.erols.com>

On Fri, 16 Jan 1998 23:28:01 -0500, Chipmunk <rjk@coos.dartmouth.edu>
wrote:

>Ben Holness wrote:
>> 
>> If anyone knows how to return the first two chars of a string, please
>> could you let me know as soon as possible.
>
>I'd suggest using substr:
>
>$first2 = $string;
>substr($first2, -length($first2)-2)) = '';
>
just outta curiosity, why set the $first2 equal to the full string
first and not just:

$first2 = substr($string,0,2);

is there some advantage?

If I am missing something obvious, please remember, I have only
written a few perl scripts, mostly for cgi's, so I am still talking
the perl baby talk.

Bill
-----------------------------------------------------
Please always check the syntax before applying any fix 
anyone gives you on a newsgroup, no one is perfect. 
Not everyone reads the newgroups every day, but most 
check their e-mail. A private e-mail with the answer
as well as the NG posting is often appreciated. 
Just my 2 cents worth.



------------------------------

Date: Sat, 17 Jan 1998 02:14:15 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: HELP !!
Message-Id: <34C06857.72AA92D1@gpu.srv.ualberta.ca>

Chipmunk wrote:
!
! Wayne Patton wrote:
! >
! >     @Fields=split "\|" ;
! > [...]
! > The problem: It wont split on the "|"   How do I split on "|" ???
! 
! That worked for me.  I'm not sure why it didn't work for you.
! I'm especially confused about why everyone else who responded said
! it would not work.  I wonder if they actually tried it...
! 
! (I tested it with perl5.002 and perl5.004)
! 
! On the other hand, as they pointed out, you should be doing
! split /\|/;
! 
! Chipmunk

'split "\|"' will split on null, it will be interpolated first and
used as a regex as 'split /|/' so you'll still get 'a' in the
first field ... but you'll get '|' in the second etc.

$_='a|b|c|d|e|f|g';
@fields=split "\|";
print "first field: $fields[0]\n";
print "the array: @fields\n";
@fields = split /\|/;
print "first field: $fields[0]\n";
print "the array: @fields\n";

prints: (with perl5.004_04)
first field: a
the array: a | b | c | d | e | f | g
first field: a
the array: a b c d e f g

regards
andrew


------------------------------

Date: Sat, 17 Jan 1998 04:10:17 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: HELP !!
Message-Id: <34C07579.810A958D@coos.dartmouth.edu>

[posted and emailed]

Andrew Johnson wrote:
> 
> Chipmunk wrote:
> !
> ! Wayne Patton wrote:
> ! >
> ! >     @Fields=split "\|" ;
> ! > [...]
> ! > The problem: It wont split on the "|"   How do I split on "|" ???
> !
> ! That worked for me.  I'm not sure why it didn't work for you.
> ! I'm especially confused about why everyone else who responded said
> ! it would not work.  I wonder if they actually tried it...
> !
> ! (I tested it with perl5.002 and perl5.004)
> !
> ! On the other hand, as they pointed out, you should be doing
> ! split /\|/;
> 
> 'split "\|"' will split on null, it will be interpolated first and
> used as a regex as 'split /|/' so you'll still get 'a' in the
> first field ... but you'll get '|' in the second etc.

Oh, of course!  Obviously, I did not test it very well at all.
Sorry I goofed that up, thanks for explaining it!

Chipmunk


------------------------------

Date: Sat, 17 Jan 1998 18:14:01 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: Help - Perl processes in memory
Message-Id: <69qhre$jq6$1@winter.news.erols.com>

On Fri, 16 Jan 1998 17:50:12 -0500, Scott Holmes <scotth@nyd2.com>
wrote:

>I have a perl script running on an intranet server that's giving me some
>trouble.  The machine is Windows NT 4.0 and is running Netscape
>Enterprise server 2.0 and Perl 5.  The the admin hasn't updated things
>since they had NS ver 1.0 so Perl scripts must still be run through a
>bat file.  This all works fine...but I'm finding that Perl.exe is
>building up rapidly in memory until you manually have to go into task
>manager and stop all the extra Perl processes to keep the machine from
>crashing.
>
>What is causing this problem and how do I fix it?  Thanks!
>
>
>
any help on this one would be greatly appreciated. I have a similar
problem under win 95 using omnihttp at times. If I run the same perl
script consecutively many times to test/debug, I often begin getting a
message that the machine does not have the resources to run the
program, and when I look at active processes, I will have four or five
incarnations of perl running, at which time I have to manually stop
them and then everything is okay.

Does one have to explicitly exit a perl script on a win32 system
(win95/NT). If so, while being an inconvenience, it is certainly
fixable.

Bill
-----------------------------------------------------
Please always check the syntax before applying any fix 
anyone gives you on a newsgroup, no one is perfect. 
Not everyone reads the newgroups every day, but most 
check their e-mail. A private e-mail with the answer
as well as the NG posting is often appreciated. 
Just my 2 cents worth.



------------------------------

Date: Fri, 16 Jan 1998 22:12:29 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How do I allow input to be retrieved from multiple lines?
Message-Id: <d3bp96.ee5.ln@localhost>


[ no shell or Unix here. Followups trimmed ]


Chocolate (poohba@io.com) wrote:
: How do I make it so that if my input needs more than one line I can hit
: return without sending it?  

: How do I make it so that a line with only a
: period lets it know that I am done inputting?


You just write it that way. You can write code, yes?


$accum='';       # accumulate the multiline string
while (<>) {
   last if $_ eq ".\n";
   $accum .= $_;
}
print "you entered the stuff starting on the line below this one\n";
print $accum;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 17 Jan 1998 13:30:16 GMT
From: "Mike Kleiman" <mkleiman@att.com>
Subject: Re: How do I allow input to be retrieved from multiple lines?
Message-Id: <01bd234c$ad511220$2b273487@mkleiman>

Sticking my neck out..... I'm not aware of a way to achieve this using
shell, though I wouldn't doubt that a command exists that allows you to
pull a character at a time from stdin. This is pretty much what you're
asking to do - pull a character at a time and analyze it's contents. The
read command pulls until a newline is sent or some other terminating signal
i.e. delete key... 

Unless someone else pipes up with the appropriate shell tool, you might
have to write a small c program that uses getc. Your shell program could
call the getc program to retrieve a character at a time.

Mike Kleiman


Chocolate <poohba@io.com> wrote in article
<Pine.BSI.3.96.980116194114.11100A-100000@bermuda.io.com>...
> How do I make it so that if my input needs more than one line I can hit
> return without sending it?  How do I make it so that a line with only a
> period lets it know that I am done inputting?
> 
> 


------------------------------

Date: 17 Jan 1998 14:03:07 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: How to substitute for ^\ sequences??
Message-Id: <slrn6c1e1c.7g4.gabor@vinyl.quickweb.com>

In comp.lang.perl.misc, Jeeves <darlenem@PAS.DE.SPAM.flash.net> wrote :
# 
# I need to be able to substitute all the ^\ sequences in a string. It's
# (obviously) not a printable character. However, how do I put this in a string
# in the source? I can't "\c\\" (perl complains of 'trailing backslash'), and
# single-quoted strings interpolate \\ and \', so

Try the octal escape
s/\034/foo/g;

# 
# $ch = '\' ; $nc = "\c" . $ch; 
# 
# doesn't work either. How do I do this? I need to substitute all the ^\
# sequences in the string with ASCII 175.

You mean the number 175 or the character represented by the number
175 decimal?

If the latter
s/\034/\257/g;


gabor.
--
    I dunno, I dream in Perl sometimes...
        -- Larry Wall in  <8538@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: Sat, 17 Jan 1998 13:04:00 GMT
From: notreallyianj@notreallytrials.co.uk (anti-spam - remove 'notreally') (Ian Johnston)
Subject: Logscribe - where ?
Message-Id: <34c0ab56.1852596@news.virgin.net>

Hi all,

I'm looking for a copy of LOGSCRIBE, the Perl Web Page stats analyser.
The site it is usually available from
(http://www.texas.net/~cedras/logscribe/) is not responding (well, the
download link anyway) and via email they don't respond. Could anybody
let me know if they have a copy. Use the email address below.
ian.johnston4@virgin.net

Thanks in advance.





------------------------------

Date: Sat, 17 Jan 1998 04:22:39 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <34C0785F.EA5FD5E2@coos.dartmouth.edu>

David A. Frantz wrote:
> 
> Andy Lester wrote in message <69ordb$mi3$1@usenet48.supernews.com>...
> >>Sniped
> >
> >* People who negate any chance of correspondence in their spamanoia.  This
> >is all over Usenet, of course, but I'm amazed whenever I see it:
> >"Remove the '.fuckyouspammers' from my email address in order to send me
> >mail."  No, I won't.  You're on your own.
> >
> Andy for the most part I would agree with you and I'am a new PERL user.
> But
> the above remark kinda leaves me wondering if you have every recieved on
> occasion
> to much junk mail.     Its sad but there may be good reason for some to
> respond as
> above.

Can we pleeeeeez not have another discussion on this!

comp.lang.perl.misc is NOT the appropriate newsgroup for debating this topic.

Chipmunk


------------------------------

Date: 17 Jan 1998 03:37:21 -0500
From: tdyas@eden.rutgers.edu (Tom Dyas)
Subject: reexporting symbols in modules
Message-Id: <69pqk1$1hq@er3.rutgers.edu>

Suppose that I have an XS module called Foo that exports some
constants using an AUTOLOAD routine that calls a constant() function
that was generated by h2xs.

I would like make these constants that Foo exports appear as if
another module Bar was exporting them. Bar makes some of the routines
in Foo more friendly but I would like Bar to AUTOLOAD the constants as
it needs them from Foo.

Is there any easy way to do this?

Tom


------------------------------

Date: Sat, 17 Jan 1998 02:58:26 -0800
From: "Steve A. Chervitz" <sac@genome.stanford.edu>
To: vsns-bcd-perl@hermes.hrz.uni-bielefeld.de
Subject: Re: Style Q for modules:  best syntax for "hash" arguments?
Message-Id: <34C08EB3.34B7B252@genome.stanford.edu>

Jim Stern wrote:

> Eryq wrote:
> >
> > Since this question relates to style considerations for
> > authoring reusable modules, I've posted in c.l.p.modules
> > as well...
> >
> > Oftimes, we see subs which take arguments in a hash form,
> > like this [1]:
> >
> >         foo(ThisThing => $this,
> >             ThatThing => $that);
> >
> > Sometimes, we see this instead [2]:
> >
> >         foo(-this_thing => $this,
> >             -that_thing => $that);
> >
> > And even [3]:
> >
> >         foo(THIS_THING => $this);
> >
> > Not to mention some which do extra work to case-fold
> > arguments and chop leading '-'s off, so that you
> > can supply args in more than one style.
> >
> > So: are we at all moving towards a Perl style standard for
> > this... and if so, what is it?  Although I've been doing [1]
> > for years, I've gradually warmed on [2].  And [3] looks
> > too... um... "loud".
>
> I can't say what the consensus is but to me the dashes just
> add clutter.  Since Perl5.000 we've had '=>' as a kind of comma
> that quotes its left operand.  With '=>' you need no leading dash
> so why have one?

When a function can accept either named or unnamed parameters, it would
be nice to have a standard mechanism for discriminating these cases. For
example, it's convenient to allow the following:

     new->Foo("MyFoo");                # Gets default settings.
     new->Foo(-name   => "MyFoo",      # Custom settings.
              -flavor => "vanilla");

If named parameters always start with a "-" then it is easy to
distinguish these situations, regardless what case is used for the tags.

As far as case goes, I'm currently favoring -ALL_CAPS since (1) it
avoids conflicts with function names (typically all lower case, but
watch out for DESTROY) and thus saves you from having to explicitly
quote all the tags, (2) parameter settings stand out better in the code
(take this paragraph, for example), and (3) it seems consistent with the
Perl-ism that things in ALL_CAPS are things that are defined for you.

Until perl gets better at not confusing "-name =>" and "-&name =>"
within argument lists (maybe this is unreasonable to expect?), I'm
sticking with -NAME style tags. One thing I have noticed, though, is
that my own style preferences evolve with time, especially as I learn
from other people's styles. I do however strive for internal consistency
at any given point in time.

Steve Chervitz
sac@genome.stanford.edu

P.S. What might be nice is a standard GetOptions::Long sort of
functionality at the function call level. I worry about incurring
additional method call overhead, but the added flexibility may be worth
it in some situations.

>
>
> Of course, if a keyword matches a sub name or a predefined name,
> you still have to enclose it in quotes to avoid a -w warning.
> But in my experience, that's rare.
>
> And I agree.  [3] is like a drill sergeant screaming, inches
> from your face.  :-)
>
> Just one opinion ...
>
> > [...]
> >
> > However, it might be nice to have perlstyle guidelines for
> > when there is "no good excuse to do otherwise".
>
> But isn't there always "More Than One Way to Do It?"  :-)
>
> --
> Jim Stern -- Views here are my own, not Northrop Grumman's.   (El
> Segundo, CA)





------------------------------

Date: Sat, 17 Jan 1998 09:22:02 -0500
From: Sukumar Patel <Sukumar.Patel@mail.tju.edu>
Subject: Re: Syntax errors with nested braces???
Message-Id: <34C0BE89.1ED5B5A9@mail.tju.edu>



Chipmunk wrote:

> [posted and mailed]
>
> >
> >      Command:     perl -e '$a = ${P{${S{$k}{'s'}}}{'s'}};'
> >      Error:       syntax error at -e line 1, near "}}"
>
> You're using single quotes to protect your code from the shell,
> and then you're using single quotes again within your code.
> Is it any wonder the shell gets confused and munges the code
> before passing it to perl?
>
> Try this instead:
> perl -e '$a = ${P{${S{$k}{"s"}}}{"s"}};'
>
> Chipmunk

Apologies for the typing error. I meant to say "s".   new results below:

       perl -e '$a = ${P{${S{$k}{"s"}}}{"s"}};'
       syntax error at -e line 1, near "}}"
       Execution of -e aborted due to compilation errors.

Help appriciated.


SP



------------------------------

Date: Sat, 17 Jan 1998 12:25:53 +0000
From: Nick Ing-Simmons <nick@ni-s.u-net.com>
Subject: Re: Tail -f
Message-Id: <34C0A351.578C@ni-s.u-net.com>

Michael Fuhr wrote:
> 
> "BDMA" <BDMA@prodigy.net> writes:
> 
> > I have a Perl/Tk program that logs all of its actions by writing them to a
> > file.  I then kick off an xterm with a tail -f.  This xterm displays
> > whatever is written to the log file.  I want to use a textbox to display,
> > in real time, the contents of the log file, instead of using the xterm.
> > Can anyone give me a clue as to how to do this.  I have read Tk/Tcl books,
> > I have looked through the Advanced Perl Programming book, and I looked
> > through the Perl Development Kit manuals.
> 
> This is mentioned in the Perl FAQ:


And then there is 

 .../Tk???.???/tktail 

Note that Steve's filevent readable stuff should work, but as 
disk files are _always_ readable tail -f is better done with 
timer like in the file above.


------------------------------

Date: Fri, 16 Jan 1998 22:59:37 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: b kiefer <bkiefer@hollandhart.com>
Subject: Re: Wanted: generic macro/include pre-processor
Message-Id: <34C056D9.316E1698@sirius.com>

Imatix has some really cool software, but as far as I know
the preprocessor is written in Perl but is for Html.

Jim Bowlin

b kiefer wrote:

> There is a Perl PreProcessor provided by iMatix at:
> http://www.imatix.com
> It may do what you are hoping for.
> 
> bekiefer


------------------------------

Date: Fri, 16 Jan 1998 23:23:21 -0600
From: "Michael King" <NOSPAM_mike808@mvp.net>
Subject: Re: Wanted: generic macro/include pre-processor
Message-Id: <69pf4n$44q$1@twain.mvp.net>

Dunno. POD and pod2html, pod2tex, pod2ps seem to work fine for me...

--
--
# Michael King
# NOSPAM_mike808@mvp.net
# To reply, remove the NOSPAM_ in the address in the line above
# Or, check out my WWW site at:
# http-colon-slash-slash-walden-dot-mo-dot-net-slash-tilde-mike808
#
# These are my views and do not necessarly reflect those of anyone else.
#
# Copyright 1998 Michael King. St. Louis, MO USA
# Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
==================================================================
By US Code Title 47, Sec.227(a)(2)(B), a computer/modem/printer
meets the definition of a telephone fax machine. By Sec.227(b)
(1)(C), it is unlawful to send any unsolicited advertisement to
such equipment, punishable by action to recover actual monetary
loss, or $500, whichever is greater, for EACH violation.
==================================================================

Peter Davis wrote in message ...
>Does anyone have a general purpose pre-processor that handles macro
>(and nested macro) expansion and include files, written in Perl?
>
>I've been experimenting with various solutions to document problems
>for years.  I'd like to be able to take a "readable" ascii file (ie,
>an address book), and be able to process it into HTML, PostScript
>(possibly via TeX or LaTeX), and, ideally, formatted ASCII.  I'm
>thinking the best way to do this would be to define a set of macros
>for each format (HTML, LaTeX, etc.), and write the list using the
>macros.  Then I could include various macro sets depending on whether
>I wanted HTML, LaTeX/PostScript, etc.
>
>So, does anyone know of a macro processor that could be used for this?
>It would basically have to expand macros and nested macros, include
>files, and, perhaps handle conditionals.
>
>Thanks,
>
>-pd
>
>
>--
> Peter Davis
> http://world.std.com/~pd
>
>      "Boycott intrusive advertisers!"




------------------------------

Date: Sat, 17 Jan 1998 00:03:42 +0800
From: Walter Archie <warchie@att.net.hk>
Subject: What is wrong with this script?
Message-Id: <34BF84DE.6A56C771@att.net.hk>

Can someone tell me what is wrong with this script? Or is there anyway
where I can use perl.exe to go througth the coding line by line to see
where the coding has gone wrong. PLEASE HELP!!!

<!---Code Starts Here---!>
#Search Engine Beta Version
#$linktitle, $linkdescrip, $linkwords, $linkdir, $linkurl
#define some variables

$fields= 5; #Number of records
$filename= "search.dat"; #Database File
$filetemp= "temp.dat";   #Temporary Database File
$results= 1000; #Max results
&parse_form;
$searchstring=$FORM{'searchstring'};
&add_record if ($searchstring eq "**ADD RECORD**");
&search;

########
#Search#
########
sub search{
 &open_file("FILE1","",$filename);
 print "Content-type: text/html\n\n";
 print " <HTML><HEAD><TITLE>Search Results</TITLE></HEAD>\n";
 print "<body TEXT=\"#808080\" BGCOLOR=\"#000000\" LINK=\"#008080\"
VLINK=\"#008080\" ALINK=\"#808080\">\n";
 print "<!--All code is done by TheAlien on January 1st, 1998-->\n";
 print "<font SIZE=\"-1\" FACE=\"Arial\"><div align=\"right\">\n";

 print "<table COLS=\"2\" WIDTH=\"100%\">\n";
 print "<tr>\n";
 print "<td><strong><font face=\"Arial\" size=\"-1\"
Color=\"#FFFFFF\">)1998 TheAlien WebDesign</font></strong></td>\n";
 print "<td><a HREF=\"http://www.thealien.com\"
OnMouseOver=\"window.status='TheAlien.Com';return true\"
onMouseOut=\"window.status='This is TheAlien.Com';return true\"
target=\"_top\"><img SRC=\"/img/titlesm.jpg\" BORDER=\"0\" HEIGHT=\"30\"
WIDTH=\"150\" ALIGN=\"RIGHT\"></a></td>\n";
 print "</tr>\n";
 print "</table>\n";
 print "</div>\n";
 print "<CENTER><IMG SRC=\"/img/title4.gif\" ALT=\"Search
Results\"><br><IMG SRC=\"/img/title1.gif\"
ALT=\"TheAlien.Com\"><BR><FONT SIZE=\"\" COLOR=\"#FFFFFF\"
FACE=\"Arial\">Search Keywords: $FORM('searchstring')</FONT><BR><BR>\n";

 print "These are results of the search:<BR>\n";


 $counter =0;
 while (($line = &read_file("FILE1")) && ($counter < results)){
  @tabledata= split(/\s*\|\s*/,$line,$fields);
  &check_record;
  if ($found == 1){
    $counter++;
    &print_record;
  }
 }
 close(FILE1);
 if ($counter == 0) {
  print "<CENTER><H4>Sorry, I failed to find the keywords.</H4><BR>\n";
  print "Go Back to the <a href=\"index.html\"
onMouseOver=\"window.status='Try Again at The Search';return true\"
onMouseOut=\"window.status='Sorry unable to find The Search
Results...';retrun true\">SearchEngine</a></CENTER><br><br>\n";
 }
 print "<BR><BR><BR><HR><BR><FONT COLOR=\"#808080\">Thank for using the
PaRaNoRMaL Search. If there are any troubles let us know by <A
HREF=\"mailto:errors\@thealien.com?Subject=Search Engine Errors\"
onMouseOver=\"window.status='Search Engine Errors';return true\"
onMouseOut=\"window.status='TheAlien.Com Search Results';return
true\">E-Mail</a></FONT>.\n";
 print "</FONT></BODY></HTML>";
 exit;
}

#######
#Error#
#######
sub error {
 print "Location: http://www.thealien.com/search/error.html";
 exit;
}

###############
#Print Results#
###############
sub print_record {
 print "<BR><BR>\n";
 print "<TABLE BORDER COLS=2 WIDTH=\"100%\"
BGCOLOR=\"#008080\"><TR><TD><FONT SIZE=\"-1\"
FACE=\"Arial\"><B>".$linkdir."</B></FONT></TD><TD><FONT SIZE=\"-1\"
FACE=\"Arial\"><B><A HREF=".$linkurl."
onMouseOver=\"window.status='".$linktitle."';return true\"
onMouseOut=\"window.status='TheAlien.Com Search Results';return
true\">".$linktitle."</A></B></FONT></TD></TR><TR><TD
colspan=\"3\"><FONT FACE=\"Arial\" Size=\"-1\"
COLOR=\"#FFFFFF\">".$linkdescrip. "</FACE></TD></TR></TABLE>\n";
}
##############
#Check Record#
##############
sub check_record {
    # get the data from the record read from the file. $tabledata

   $linktitle = $tabledata[0];
   $linkdescrip = $tabledata[1];
   $linkwords = $tabledata[2];
   $linkdir   = $tabledata[3];
   $linkurl   = $tabledata[4];
   chop($linkurl);

    #build the search line with all fields we want to search in
    $searchline = $linktitle . " " . $linkdescrip . " " . $linkwords;


   #search by keywords
   # only perform the keyword search if the length of the search string
is greater than 2
   # don't think we want people to search for and  or or etc.
   $sfound = 0;
   $found = 0;
   $notfound = 1;

   $stlen = length($searchstring);
   if ($stlen > 1) {
       @words = split(/ +/,$searchstring);
        foreach $aword (@words) {
           if ($searchline =~ /\b$aword/i) {
                  $sfound = 1;
           }
           else {
                  $notfound = 0;
            }
         }
     }
    if ($sfound == 1 && $notfound == 1) {
        $found = 1;
     }

    # if search string is too small .. set found to 1
    if ($stlen <= 1) {
        $found = 1;
    }
    #if page doesn't have a title then return not found
    $tlen = length($linktitle);
    if ($tlen < 1) {
        $found = 0;
    }
}

############
#Parse Form#
############
sub parse_form {
 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 if (length($buffer) < 5) {
  $buffer=$ENV{'QUERY_STRING'};
 }

 @pairs = split(/&/, $buffer);
  foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $name =~ tr/+/ /;
  $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
  $FORM{$name} = $value;
 }
}

############
#Add Record#
############
sub add_record {
 $linktitle = $FORM{'linktitle'};
 $linkdescrip = $FORM{'linkdescrip'};
 $linkwords = $FORM{'linkwords'};
 $linkdir = $FORM{'linkdir'};
 $linkurl = $FORM{'linkurl'};

 &open_file("FILE1",">>",$filetemp)
 &write_file("FILE1",$linktitle. "|". $linkdescrip. "|" .$linkwords. "|"
 .$linkdir. "|" .$linkurl. "\n");
 close(FILE1);
 print "Location: http://www.thealien.com/search/add.html";
 exit;
}

###########
#Open File#
###########
sub open_file{
 local ($filevar, $filemode, $filename) =@_;
 open ($filevar, $filemode . $filename) || die (&error);
}

###########
#Read File#
###########
sub read_file{
 local ($filevar) =@_;
 <$filevar>;
}

############
#Write File#
############
sub write_file{
 local ($filevar, $line) =@_;
 print $filevar ($line);
}





------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1660
**************************************

home help back first fref pref prev next nref lref last post