[7074] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 702 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 7 21:17:19 1997

Date: Mon, 7 Jul 97 18:06:39 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 7 Jul 1997     Volume: 8 Number: 702

Today's topics:
     Re: How do I Use Perl to edit part of a file but not ov <rootbeer@teleport.com>
     Re: How to add users to .htpasswd (Shane)
     Re: How to add users to .htpasswd <rootbeer@teleport.com>
     Re: How to add users to .htpasswd (Craig Bennett)
     Re: How to capitalize first letter of a sentence? (A. Deckers)
     Re: how to install modules (Nathan V. Patwardhan)
     How to make the same changes to many files. (Patrick Baldwin)
     Re: How to return an image from perl <jbokma@caiw.nl>
     Re: How to return an image from perl <me@anon.com>
     Re: I just dont't get this -- opening a new filehandle topaz56@one.net
     Re: I just dont't get this -- opening a new filehandle <rootbeer@teleport.com>
     Re: I just dont't get this -- opening a new filehandle (Tad McClellan)
     Re: IF Problem (Clay Irving)
     Re: Installing libwww-perl-5.10 on perl 5.004_01 fo NT  <aas@bergen.sn.no>
     Re: Installing libwww-perl-5.10 on perl 5.004_01 fo NT  <aas@bergen.sn.no>
     Re: Irregular Expression <Harald.Joerg@mch.sni.de>
     Is it possible to build a static Perl? <stenzel@pixel-gmbh.de>
     Keep track of context with Perl/regexp? <aol@sorona.se>
     Re: Keep track of context with Perl/regexp? <ajohnson@gpu.srv.ualberta.ca>
     Looping throught 2 files simultaneously while searching (Tony K. Olsen)
     Re: Looping throught 2 files simultaneously while searc (Andrew M. Langmead)
     Maker 2.00 uploaded to CPAN <pritikin@interramp.com>
     Re: Memory problem with reading file (Megan Webb)
     Metrics Mavin
     Re: Net::NNTP missing newsgroups? <c.evans@clear.net.nz>
     Re: Newbie help - Simple Guestbook Questions <rootbeer@teleport.com>
     Re: No output <pkirlin@tjhsst.edu>
     Re: ODBC @@identity problem Christoph_Stiefeling@mercer.ca
     Oraperl - latest version?? <salisbur@fsl.noaa.gov>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 7 Jul 1997 08:48:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Colin Burn-Murdoch <colin@tubl.demon.co.uk>
Subject: Re: How do I Use Perl to edit part of a file but not overwrite it all
Message-Id: <Pine.GSO.3.96.970707084750.9019T-100000@kelly.teleport.com>

On Mon, 7 Jul 1997, Colin Burn-Murdoch wrote:

> how do I take part of a file and change it?  

It sounds as if you want this entry from the FAQ. Hope this helps!

    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq5/
          How_do_I_change_one_line_in_a_fi.html

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 07 Jul 1997 16:58:45 GMT
From: zatezalo.2@osu.edu (Shane)
Subject: Re: How to add users to .htpasswd
Message-Id: <33c11f7b.6866022@achilles.medctr.ohio-state.edu>

dbonner@cs.bu.edu (David Bonner) wrote:

>Vince Betro (vinbetro@vantek.net) wrote:
>: How do I add users and passwords to an .htpasswd file using the htpasswd
>: program?  I am using a PERL script on a UNIX server.
>
>Uhm...not exactly the right newsgroup to be posting to, unless it's a
>specific question about Perl.  All that aside, I'm assuming you're using
>ncsa or apache.  This comes from issuing a 'htpasswd -h' command:
>
>Usage: htpasswd [-c] passwordfile username
>The -c flag creates a new file.
>
>Try looking at the server company's web site for more info on access
>restriction.

I think what the original poster was trying to ask is "How does one
use the binary htpasswd to update/change/add users to a
htpassword-created password file via a Perl script."

So-as to let people add themselves, online, perhaps.

I recall someone re-doing the htpasswd program itself so as to be able
to do this -  I couldn't find any past posts relating to it however.


--
zatezalo.2@osu.edu
http://www.ecaetc.ohio-state.edu/shane


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

Date: Mon, 7 Jul 1997 15:43:48 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Craig Bennett <theclyde@autobahn.mb.ca>
Subject: Re: How to add users to .htpasswd
Message-Id: <Pine.GSO.3.96.970707153617.10643N-100000@kelly.teleport.com>

On Mon, 7 Jul 1997, Craig Bennett wrote:

> Subject: Re: How to add users to .htpasswd

> Mmm...  I would love to be able to do that.  

Then you'll be happy to learn that there's something for you in the
modules list. Look for the HTTPD-Tools. 

> if there was some way to make a person log in once per session
> with their name and e-mail, I would love to find it.

Oh, you can't do _that_. But you could ask nicely. And if they don't do 
what you want, you can deny them access. :-)  Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 07 Jul 1997 19:18:30 GMT
From: theclyde@autobahn.mb.ca (Craig Bennett)
Subject: Re: How to add users to .htpasswd
Message-Id: <33c13f65.22050622@news.autobahn.mb.ca>

On Mon, 07 Jul 1997 16:58:45 GMT, zatezalo.2@osu.edu (Shane) wrote:

>I think what the original poster was trying to ask is "How does one
>use the binary htpasswd to update/change/add users to a
>htpassword-created password file via a Perl script."
>
>So-as to let people add themselves, online, perhaps.
>

Mmm...  I would love to be able to do that.  I am fooling around with
trying to set up some sort of user registration for the page I am making
now, and if there was some way to make a person log in once per session
with their name and e-mail, I would love to find it.





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

Date: 3 Jul 1997 17:26:22 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: How to capitalize first letter of a sentence?
Message-Id: <slrn5rno5u.ju8.deckers@news.rediris.es>

In <33bbd01e.12175477@news.upei.ca>,
	Dico Reyers <dico@peionline.com> wrote:
>	
>Hello there...
>
>I am wondering how to capitalize the first letter of a sentence.
[...]

#/usr/bin/perl -w

my $s = 'i think so';

print "\u$s\n";

__END__

You want to look at \u, \l, \U, \L and \E in man perlre (or perldoc
perlre).

>Please email any help to dico@peionline.com

No, please read the group.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: 7 Jul 1997 12:20:42 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: how to install modules
Message-Id: <5pqmuq$q7p@fridge-nf0.shore.net>

coogan@earthlink.net wrote:
: I am trying to install the image size module into my perl library. I
: would like to know how to use the makefile.pl before I start mucking
: about with copying files.

Did you read the README and/or INSTALL files that were included with
the module?  If not, the INSTALL file generally includes four lines
like:

	perl Makefile.PL
	make
	make test
	make install

If you're installing this module locally (i.e, - in your own working
area - you don't have root privs), do:

	perl Makefile.PL PREFIX=/your/base/directory/to/install

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 7 Jul 1997 22:20:08 GMT
From: pbaldwin@mrst.com (Patrick Baldwin)
Subject: How to make the same changes to many files.
Message-Id: <slrn5s2quq.rbl.pbaldwin@spectre.mrst.com>


A common task I have run into working in sysadmin is making the
same set of changes to the same file on different machines.

For example, the fstab or the auto.direct need to be changed on all 
machines when a mounted filesystem moves, goes offline, or is added.

Is there an existing Perl tool to do this sort of thing?  
If this tool exists, where is it?

I've looked through the CPAN archives and the majority of Web sites
a MetaCrawler search turned up on the subject, but I may have missed
someplace.

Thanks for your time,
-P. Baldwin




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

Date: 3 Jul 1997 19:56:06 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: How to return an image from perl
Message-Id: <01bc87eb$45b0a4c0$c30ab2c2@Tschai>



Morten Simonsen <mortensi@idt.ntnu.no> wrote in article
<5pg8cs$dmo@due.unit.no>...
> Hi
> 
> I have seen several counters that uses the img-tag to run a script
which
> apparently returns an image. I want to know how you can return an
image
> an how it is possible to use the img-tag to do this. If somebody
got
> any code which demonstrates this, I would love to see it.
> 
> Morten Simonsen
> 

<IMG SRC="/cgi-bin/thescript.cgi">

thescript.cgi:

#!/usr/local/bin/perl

$| =1;		# no buffering

print "Content-type: image/gif\n\n";

open(FILE, "yourimage.gif") || die;

while(<FILE>) { print; }

close(FILE);


John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827





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

Date: Fri, 04 Jul 1997 15:29:25 -0700
From: Chris Hostetter <me@anon.com>
Subject: Re: How to return an image from perl
Message-Id: <33BD7945.5F51E561@anon.com>

> <IMG SRC="/cgi-bin/thescript.cgi">
> 
> thescript.cgi:
> 
> #!/usr/local/bin/perl
> 
> $| =1;          # no buffering
> 
> print "Content-type: image/gif\n\n";
> 
> open(FILE, "yourimage.gif") || die;
> 
> while(<FILE>) { print; }
> 
> close(FILE);

while this example is kinda silly for one static image, it is also silly
for any quantity of N static images of which you want 1, because you can
also just say;

print "Location: yourimage.gif\n\n";

and then your script never has to mess with opening the file, the www
server will do it for you.

(i happen to know more than a few scripts that use this trick for
creating "status boards" with colored lights... the board is made in an
HTML table, and then each "LED" is an image tag which calls a script,
which returns 
	"Location: /images/status-lights/$status\n\n" 
where $status is "red.gif", or "green.gif", etc..)


however: i beleive the point of the question was a www counter, in which
N = 10 (the number of digits), and you want k digits (in a sort of image
concatination)

for that, neiher of the above mentioned methods will work.

However, i'm farely certain i recall a few perl modules that let you do
all sorts of image manipulation (like croping images, and merging
images, and converting images) and i'm sure if you go to www.perl.com
you will find what you are looking for somewhere in CPAN

(i'd put good money on "Image::Manip")

---

------------------------ The Hoss Man ---  "c4"
-------------------- Chris M Hostetter --      --Deep Blue
---------- hossman@uclink3.berkeley.edu -  "Resign!"
http://www.rescomp.berkeley.edu/~hossman/      --Gary Kasparov


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

Date: Thu, 03 Jul 1997 23:41:10 GMT
From: topaz56@one.net
Subject: Re: I just dont't get this -- opening a new filehandle
Message-Id: <33bc37f0.341392705@news.mindspring.com>

On Mon, 30 Jun 1997 04:11:39 +0200, link@tss.no (Terje Bless) wrote:

>In article <8cu3ihcrx0.fsf@gadget.cscaper.com>,
>    Randal Schwartz <merlyn@stonehenge.com> wrote:
>
>>Please get CGI.pm.  Read it.  Use it.
>
>LOL.
>I think this is one of the reason I love Perl. In which other programming
>language does the notion of /reading/ an extension library not strike
>relative inepts with a sense of great fear? :-)
>
>-- 
>Party? Party, lord? Yes, lord. Right away, lord.
>        - Beopunk Cyberwulf

I appreciate all the help several members of this group have so
graciously passed along...   Now, please explain to me how
I will use cgi.pm on a virtual server w/ only Perl 4 available.

What a bunch of assholes...
=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=
                 tporter@dtool.com     			
		 Thomas Porter, Ph.D.
	         THE DIGITAL TOOL GROUP
		 http://www.dtool.com

	   "Never attribute to malloc
that which can be adequately explained by stupidity"
=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
	


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

Date: Thu, 3 Jul 1997 18:32:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: topaz56@one.net
Subject: Re: I just dont't get this -- opening a new filehandle
Message-Id: <Pine.GSO.3.96.970703182454.6445Y-100000@kelly.teleport.com>

On Thu, 3 Jul 1997 topaz56@one.net wrote:

> I appreciate all the help several members of this group have so
> graciously passed along...   Now, please explain to me how
> I will use cgi.pm on a virtual server w/ only Perl 4 available.

You write a nice letter like this to the operators of the virtual server. 

    "Dear Ladies and Gentlemen, 

	I would like to call your attention to the fact that your server
    currently offers only Perl version four. Since its release,
    version five has been more thoroughly tested and debugged than 
    version four ever was. In fact, it's so much more reliable that
    version four is no longer even supported. Version 5.004 is the
    current version, and it takes only two commands to compile it on
    most systems. Since I'm sure that you would like to remain a
    player in the competitive field of virtual server providers,
    I heartily encourage you to install 5.004 as soon as practicable.

    Thank you.

> What a bunch of assholes...

Now, now. That's no way to talk about the folks who provide you with web
services! :-)

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 7 Jul 1997 13:41:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: I just dont't get this -- opening a new filehandle
Message-Id: <j9drp5.cp6.ln@localhost>

topaz56@one.net wrote:

: What a bunch of assholes...


I guess you don't expect to be asking any more perl questions then?

That is a pretty effective way of ensuring that large numbers of
people will never see another of your posts.

The sound of all those killfile keys being pressed is deafening...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 7 Jul 1997 07:42:02 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: IF Problem
Message-Id: <5pqkma$im7@panix.com>

In <5pp6qk$8rh$1@brokaw.wa.com> "James Steven" <jsteven@sirris.com> writes:

>What's wrong with this IF Statement? Every time it executes it runs the
>first IF case, I've tried everything!

>if ($subdname=="my.yagoo.com")  {
              ^^
Perhaps you intended to use 'eq' to compare strings? The '==' operator
compares numbers. The statement should be:

 if ($subdname eq "my.yagoo.com") {

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 07 Jul 1997 19:48:00 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Installing libwww-perl-5.10 on perl 5.004_01 fo NT - problems
Message-Id: <hhge6u52n.fsf@bergen.sn.no>

joshaugh@uk.oracle.com (Jamie O'Shaughnessy) writes:

> Thanks, that worked fine. The tests won't run on Win32 either as they rely on
> #! being interpreted at the beginning of the file, but I can run the tests by
> hand. Everything seems to install OK though.

Patches that make the LWP test suite work on Win32 will be accepted.

-- 
Gisle Aas <aas@sn.no>


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

Date: 07 Jul 1997 14:49:06 +0000
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Installing libwww-perl-5.10 on perl 5.004_01 fo NT - problems
Message-Id: <hsoxqkjdp.fsf@bergen.sn.no>

joshaugh@uk.oracle.com (Jamie O'Shaughnessy) writes:

> I'm having problems installing libwww-perl-5.10 on perl 5.004_01 on NT (3.51).
> I've installed perl OK, and the required libnet-1.0505, Data-Dumper-2.07,
> MD5-1.7, MIME-Base64-2.01.
> 
> perl makefile.pl does it's stuff OK, it seems, but when running the makefile
> (nmake) it gives:
> 
>         ..\perl -e 'use Config; chdir q{blib\script}; foreach (qw(GET HEAD
> POST)
> ) {'  -e 'unlink "$_";'  -e 'system("$Config{\"lns\"} lwp-request $_") && die;
> }
> '
> Can't find string terminator "'" anywhere before EOF at -e line 1.
> NMAKE : fatal error U1077: '..\perl' : return code '0xff'
> Stop.
> 
> I've tried by hand to fix this by editing the makefile and the above perl. I've
> pretty much succeeded, but the problem seems to be that "lns" in Config does
> not have a value. What is "lns" and what's the above part of the makefile
> supposed to be doing?

$Config{\"lns\"} is usually "ln -s".  It makes a symbolic link.

The above part makes the lwp-request program available as the aliases
GET HEAD and POST.  Making the makefile with "perl Makefile.PL -n"
should get rid of this section.

-- 
Gisle Aas <aas@sn.no>


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

Date: Fri, 04 Jul 1997 15:18:03 +0000
From: Harald Joerg <Harald.Joerg@mch.sni.de>
To: Art Blair <blair@sf73.dseg.ti.com>
Subject: Re: Irregular Expression
Message-Id: <33BD142B.1C0B@mch.sni.de>

Art Blair wrote:
> 
> Lets say I want to find all instances of foobar in the following text:
> 
> the magic woid is foobar
> with a fontchange it's (foo)\bold(bar)
> bar food is crude.
> 
> and I even want to find any instance where there might be
> up to 10 characters of junk between foo & bar (like in a
> postscript file) as in the 2nd line.
> [...] I know there will only be up to 10 chars
> of junk between foo & bar. It seems like
> /foo.{0,10}?bar/
> would work but it doesn't match any of them.

What the heck did you do? I did the following:
---------------------------------------------------
@t = ("the magic woid is foobar"
     ,"with a fontchange it's (foo)\\bold(bar)"
     ,"bar food is crude."
     );

for (@t) {
    if (/foo.{0,10}?bar/)  {print "Found '$&'\n";}
}

$_  =  join "\n",@t;
while (/foo.{0,10}?bar/gs) {print "Found '$&'\n";}
---------------------------------------------------
Which prints:
---------------------------------------------------
Found 'foobar'
Found 'foo)\bold(bar'
Found 'foobar'
Found 'foo)\bold(bar'
---------------------------------------------------
I'm using Perl 5.003 either (Win3.11, Intel-486).

-- 
Oook,
--haj--


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

Date: Fri, 04 Jul 1997 19:58:55 +0200
From: Jochen Stenzel <stenzel@pixel-gmbh.de>
Subject: Is it possible to build a static Perl?
Message-Id: <33BD39DF.5964@pixel-gmbh.de>

Hello,

is there a way to translate a Perl module and build a static version of
Perl including it?
I failed to make a version with included PerlMagick. According to the
Camel Book, I tried
to call "make perl" and "make perl LINKTYPE=static", but the result is
still adynamically
linked executable (as reported by "file ./perl"). Second, I tried to
modify the makefile
by adding a -static option to the gcc linker call but this failed
because of a static version
of the dl library. Is there a static libdl.a, and where could I get it?
Or what should I do
to get a static executable?

Thank you for any suggestion or help

		J. Stenzel, jochen.stenzel@pixel.spacenet.de


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

Date: 3 Jul 1997 18:34:02 GMT
From: "Andreas Olsson" <aol@sorona.se>
Subject: Keep track of context with Perl/regexp?
Message-Id: <01bc87de$db7fb340$9bd2eb82@Andreas.lu.se>

Hello!

I can't figure out how to solve this problem proper, please help me.
I have this text-fragment:

\textbf{this is bold and \textit{this is bold and italic} only bold}

The output should look like this:

<embold>this is bold and <emit>this is bold and italic</emit> only
bold</embold>

I've tried this code:

s#\\textbf{(.*?)}#<embold>$1</embold>#gs;
s#\\textit{(.*?)}#<emit>$1</emit>#gs;

The problem is of course that in the first expression I find the end-brace
for the italic and not for the bold. One solution is to change place of the
expressions, but that is not always possible, we could have had bold inside
an italic instead. Also, there's the possibilty of having multiple
brace-pairs within the text I want to extract, so this is just a special
case of a general problem.
The basic problem is that I, in some way, have to keep track of the context
and select the correct end-brace of several choices to stop.

Thanks in advance

/Andreas Olsson, aol@sorona.se
Sorona AB, Sweden


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

Date: Thu, 03 Jul 1997 18:40:13 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
To: Andreas Olsson <aol@sorona.se>
Subject: Re: Keep track of context with Perl/regexp?
Message-Id: <33BC385D.6EE23B1E@gpu.srv.ualberta.ca>

! Hello!
! 
! I can't figure out how to solve this problem proper, please
! help me.  I have this text-fragment:
! 
! \textbf{this is bold and \textit{this is bold and italic}
! only bold}
! 
! The output should look like this:
! 
! <embold>this is bold and <emit>this is bold and
! italic</emit> only bold</embold>
! 
! I've tried this code:
! 
! s#\\textbf{(.*?)}#<embold>$1</embold>#gs;
! s#\\textit{(.*?)}#<emit>$1</emit>#gs;
! 
! The problem is of course that in the first expression I find
! the end-brace for the italic and not for the bold. One
! solution is to change place of the expressions, but that is
! not always possible, we could have had bold inside an italic
! instead. Also, there's the possibilty of having multiple
! brace-pairs within the text I want to extract, so this is
! just a special case of a general problem.
! 
! The basic problem is that I, in some way, have to keep track
! of the context and select the correct end-brace of several
! choices to stop.

the following may be something along the lines of what you 
need---it assumes you'll be reading in paragraphs at a time
by setting $/ to "", it then performs substitutions on the
tagged text from the inside out:

#!/usr/bin/perl -w
$/="";
%mapping=(
   textit => "emit",
   textbf => "embold",
   textsc => "smcaps",
   );
   
while (<DATA>) {
   1 while s#\\(\w+){((?:[^{}\\]|\\{|\\})*)}#&translate($1,$2)#eg;
   print;
}

sub translate {
   my ($tag,$text)=@_;
   my $new_tag=$mapping{$tag};
   return "<$new_tag>$text</$new_tag>";
}
__DATA__
this is a test string with \textbf{bold text},
\textit{italicized text} and \textsc{text in
small caps}---no big deal.

\textbf{now we have nested \textit{italics 
inside} of bold text, and also nested
\textsc{small caps} too}...and now
\textsc{lets \textit{try \textbf{triple
nested}}} text.

and as a bonus, thanks to Jeffrey Friedl's book, we
even \textbf{allow escaped \{ and \} within our
tags}.
############end of script########

Essentially, we make a mapping hash from your
original (latex perhaps) tags to your new tags.
We read in a chunk of text and apply our
substitution on it until the regex fails to match.

the regex finds something like \tag{ and puts the
tag into $1, then it matches everything that is NOT
a { or a } unless escaped with a backslash into $2 (it also
matches the ending '}') --- $1 and $2 are passed to the
'translate' subroutine where the mapping of the tag ($1) is
retrieved from $mapping{$tag} and the open and close versions
are wrapped around the matched $text ($2).

It works from the inside out so to speak, first translating
all non-nested top-level 'tagged' text, and all inner-most
nested 'tagged' text, then it translates the next outer level
of nested 'tags' until it reaches the toplevel.

this is only minimally tested against the DATA shown and may
require some fine tuning to suit your particular purposes.
(and, since this is perl, there are likely other ways of
doing this as well :-)

regards
andrew


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

Date: Sun, 06 Jul 97 18:29:42 GMT
From: tkolsen@bosox.demon.co.uk (Tony K. Olsen)
Subject: Looping throught 2 files simultaneously while searching -- Help Requested!
Message-Id: <868213745.17988.0.nnrp-2.c2de345e@news.demon.co.uk>

Hi Everyone,

        I have a problem that most of you have probably already
experienced while doing any perl programming but I am at a loss trying
to figure out why it isn't working as it seems to be pretty simple.

        I have 2 text files, the first one being a subset file of the
second one which is the master file.  The subset file is in exactly
the same format as the master file.  What I am attempting is to
merge the information into the master but I want to see if the
the information already exists in the master prioring to doing this,
so I don't write duplicate records.

        Here is some pseudo-code of my algorithmic approach to this
solution.

open subset_file for reading or die
open master_file for reading or die

while subset_file
  chop the CR
  string_2_search = current record

  while master_file
    if (/string_2_search/)
      print record

  return to beginning of master_file so that not at end of file   
      
close subset_file
close master_file       

        Now, the algorithm works fine and the first one is found and
all others in the subset_file are the string_2_search each time 
through the loop but all attempts to get back to the beginning of
the master file fail.  I have tried the tell and seek functions as
discussed in the faq and the perl books but it never seems to leave
the end of file (I have tested for it and it definitely is at end
of file).  I have tried opening and closing the file but obviously
this is not the solution.

        Any ideas would be greatly appreciated.  Thanks in advance.

        Cheers.

       ___
      (_B_)__
     ~(@ @)~
+-oOOo-(_)-oOOo-------------------------------------------------+
| "I played before the greatest fans in baseball, the Boston    |
| fans, and I know what you're going to say about that: Old     |
| Teddy Ballgame loved those fans, all right." --- Ted Williams |
+----------------+----------------------------------------------+
| Tony K. Olsen  | URL:   http://www.bosox.demon.co.uk          |
| Cheltenham, UK | Email: mailto:tkolsen@bosox.demon.co.uk      |
+----------------+----------------------------------------------+


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

Date: Sun, 6 Jul 1997 19:38:49 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Looping throught 2 files simultaneously while searching -- Help Requested!
Message-Id: <ECwx8p.Mq5@world.std.com>

tkolsen@bosox.demon.co.uk (Tony K. Olsen) writes:

>        Now, the algorithm works fine and the first one is found and
>all others in the subset_file are the string_2_search each time 
>through the loop but all attempts to get back to the beginning of
>the master file fail.  I have tried the tell and seek functions as
>discussed in the faq and the perl books but it never seems to leave
>the end of file (I have tested for it and it definitely is at end
>of file).  I have tried opening and closing the file but obviously
>this is not the solution.

On some unix systems, reaching end of file sets error bits that need
to be cleared by FileHandle::clearerr(). (Others are more reasonable
and will seek()ing will clear the error bits as well.)

Your final statement "I have tried opening and closing the file but
obviously >this is not the solution." puzzled me, because opening the
file as one of the first things in the outer loop and closing it as
one of the last things in the loop should work.

while(defined $subset_line = <SUBSET_FILE>) {
   open MASTER_FILE, $master_file_name or die;
   while(defined $master_line =  <MASTER_FILE>) {
    print if $subset_line eq $master_line;
   }
  close(MASTER_FILE); # would be implicitly closed on next open anyway.
}

But then, maybe you should look at other things as well. Is
subset_file small enough to be kept in memory? If so, maybe have two
seperate loops instead of a nested loop. (Also, you're text says that
you want all the unique items from either, but your code seems to
print only items common to both. I went by what you said in your text.)


while(<SUBSET_FILE>) { # load a hash for each record in subset file.
 $subset{$_} = 1;
}

while(<MASTER_FILE>) {
  print;               # everything in the master list is valid.
  delete $subset{$_};  # if in the subset file as well, delete duplicate.
}

# all of master printed, and %subset hold only new records
print %subset;
-- 
Andrew Langmead


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

Date: 6 Jul 1997 20:07:47 GMT
From: Joshua Pritikin <pritikin@interramp.com>
Subject: Maker 2.00 uploaded to CPAN
Message-Id: <5potuj$l9i$1@nadine.teleport.com>

Name           DSLI  Description                                  Info
-----------    ----  -------------------------------------------- -----
Maker          bdpO  Yet Another Make Replacement                 JPRIT


Why yet another make?  I have never found a make program that I
thought was flexible enough and easy enough.  In fact, a year of two
ago I wrote a make package similar to this one but it turned out to
have some design flaws and I ended up discarding it.  Here are some
features that make this maker unique:

o  Rules have two phases of execution.  Once when they are added
to the rule tree and once when they are executed.  The complete power
of perl is available at both times.  Rules do not need to be written
only in terms of pattern matching.  This makes for more organic, 
intelligent behavior.

o  The reliance of the rule selection engine is kept to an absolute
minimum.  Be-files state exactly what to do in a direct procedural
fashion.  The full power of perl is available to factor out duplicate
information.

I have little hope of seeing this module gain widespread use.
/bin/make is far too entrenched, even if an alternative is superior in
all respects.  Furthermore, as more people start using Perl and Java,
makefiles will become a headache of the past.




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

Date: 7 Jul 1997 22:46:01 GMT
From: mwebb@mail.usyd.edu.au (Megan Webb)
Subject: Re: Memory problem with reading file
Message-Id: <5prrj9$g8m@metro.usyd.edu.au>

Tom Phoenix <rootbeer@teleport.com> writes:

>On 7 Jul 1997, Megan Webb wrote:

>>  I have a data file that is 27.5 Meg of ascii data,

>>  Even this peaks at 200 Meg

>>          @row=<TASK>;

>>  What is happening?

>You're reading your entire dataset into memory, and it takes up a lot of
>space. If you can process it one record at a time, you'll have much less
>memory load.

>Another way to deal with this sort of thing is by using a tied variable to
>access the data from disk. Although this sounds slow, if you're already
>using virtual memory and swapping, it's probably not so bad! 

>Hope this helps!

>-- 
>Tom Phoenix           http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
>Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/

Thanks for your comments Tom.

I am aware that I am reading the whole data set into memory with
this section of code. On the machine I am running this even the
200 Meg is not a problem. 

What I am questioning is why a 27 meg ascii file requires 200 Meg
when read in this way. I could accept a slight increase, but this
is a 10x increase!!

Is there a memory leak?

This is using perl version 5.003


Megan


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

Date: Sun, 06 Jul 1997 22:29:17 GMT
From: Mavin
Subject: Metrics
Message-Id: <767cd$e1d11.314@news.psrinc.com>

Great Site URL:http://www.psrinc.com/metsys.htm




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

Date: 07 Jul 1997 22:03:16 +1200
From: Carey Evans <c.evans@clear.net.nz>
Subject: Re: Net::NNTP missing newsgroups?
Message-Id: <87205bkwm3.fsf@psyche.evansnet>

scott@2tp.com (Scott Thomason) writes:

> Argh! I'm trying to write a simple news filter, and as a first step I
> tried to use Net::NNTP to simply list all the groups I was interested
> in. Using the following script to connect to news.execpc.com for
> groups alt.humor.*, I get the following results. Unfortunately, the
> list is incomplete; only about half the newsgroups show up.

[snip]

> $ng = $nh->newsgroups("$p_ng");

Do all the newsgroups have descriptions?  Try:

  $ng = $nh->active("$p_ng");

instead.  (Also, this depends on your news server supporting wildcards
on LIST ACTIVE, but I guess since you get some, it must do.)

-- 
                Carey Evans  <*>  c.evans@clear.net.nz

		      "Deliver.  Where's that?"


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

Date: Sun, 6 Jul 1997 12:10:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ZBrett <zbrett@aol.com>
Subject: Re: Newbie help - Simple Guestbook Questions
Message-Id: <Pine.GSO.3.96.970706120436.2360B-100000@kelly.teleport.com>

On 5 Jul 1997, ZBrett wrote:

> The problem seems to be getting the "..." (quotations) for the html to
> print without perl "seeing " them.

You can either use different quotes, or you can escape the quote marks.

    $foo = "I've \"escaped\" the quote marks with backslashes.";

    $bar = 'Here, on the other hand, I\'ve used "different" quotes.';

    $baz = qq(Quoting'll be easier if you use the "right"
	quotes for the right job. perlop(1) tells about
	these, in which the nested parens are no problem.);

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 03 Jul 1997 15:40:01 -0400
From: Phil Kirlin <pkirlin@tjhsst.edu>
To: dkubilo@oxnardsd.org
Subject: Re: No output
Message-Id: <33BC0010.BA9FF0B4@tjhsst.edu>

Dan Kubilos wrote:

> I have installed Selena Sol's Keyword Search script on my NCSA server
> running on a Sun Sparc 1.
>
> The script resides(as per instructions) in /<webserver>/cgi-bin/Search
>
> When I run the script from the command line it kicks out perfect HTML
>
> However when I call it from a web page I get an error 500.
>
> The error_log shows
>
> httpd:  script  produced no output.    ????
>
> I have double checked permissions -- nothing.
>
> Suggestions??

   Did you remember to output the magical content line?

print "Content-type: text/html\n\n";

This line tells the web browser that the following document is HTML.



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

Date: Thu, 03 Jul 1997 18:28:42 -0600
From: Christoph_Stiefeling@mercer.ca
Subject: Re: ODBC @@identity problem
Message-Id: <867961704.17905@dejanews.com>

As far as I know @@identity is a SQL Server global variable (i.e. not
ODBC compatible). Unless you are using a SQL Server database this command
may not work. Unfortunately, my only suggestion for a solution is not to
use identity datatypes and instead maintain the ids in a table (i.e.
manage the identity columns yourself).

Best of luck,
Chris Stiefeling


In article <33B75AB1.1FC0@istvax.ist.lu>,
  Folscheid Bob <folscheid_b@istvax.ist.lu> wrote:
>
> ODBC @@identity problem
> Hello,
>
> I am using Perl 32 for NT, and Win32:ODBC
>
> The command
>
> $db->Sql("select @@identity");
>
> after an insert command fails,
>
> what is the problem, has anyone a solution
>
> Bob Folscheid
>
> Email: folscheid_b@istvax.ist.lu

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Thu, 03 Jul 1997 22:00:12 +0000
From: David Salisbury <salisbur@fsl.noaa.gov>
Subject: Oraperl - latest version??
Message-Id: <33BC20EC.528C@fsl.noaa.gov>

I need to install oraperl soon, and am wondering what the
latest version is.  The latest version I've found is 2.4, 
but from what I can tell, this seems to be at least 3 years 
old.  Can anyone tell me if there's a bigger and better version
out there, and maybe where it is hiding?

thanx for any help.

Dave


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

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 702
*************************************

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