[8511] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2128 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 18 16:17:26 1998

Date: Wed, 18 Mar 98 13:00:38 -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           Wed, 18 Mar 1998     Volume: 8 Number: 2128

Today's topics:
    Re: ? retrieve meta tag information from a HTML documen <aas@sn.no>
        cgi FORMMAIL and images <dsutclif@ucsd.edu>
    Re: Chicago Perl Mongers <jdf@pobox.com>
    Re: compiling perl (Jason Gloudon)
    Re: compiling perl <brian@rickjames.sapien.net>
    Re: creating directories with cgi <mlepine@bellsouth.net>
    Re: Fastest way to grep through a file? (Jason Gloudon)
    Re: Fastest way to grep through a file? (Andrew M. Langmead)
        help with trace needed <galbmill@21st-century-comm.com>
        Help!  Can't find a newsbot! <roberta@cyberramp.net>
    Re: HI!PERL/CGI Websites? (brian d foy)
    Re: how to assign unix command options in perl (susan cassidy)
    Re: How to implement "timeouts" in perl? <jay@rgrs.com>
    Re: How to populate a 2D array from a file. (Jason Gloudon)
        How to use ftp commands after invoking 'ftp' from Perl? <jleduc@io.uwinnipeg.ca>
    Re: How to use ftp commands after invoking 'ftp' from P <jim.michael@gecm.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? <alleycat@scn.org>
    Re: Is there a "Newsgroup" for Newbies to Perl? (I R A Aggie)
    Re: Newbie-Help with simplest CGI program (I R A Aggie)
    Re: Optimizing a Perl Sendmail routine? (Greg Bacon)
    Re: parsing perl <rob@NOSPAMintr.net>
    Re: pattern matching dilemma (Craig Berry)
    Re: pattern matching dilemma <mlepine@bellsouth.net>
    Re: pattern matching dilemma <mlepine@bellsouth.net>
    Re: pattern matching dilemma <quentin@jihad.amd.com>
    Re: pattern matching dilemma <mlepine@bellsouth.net>
    Re: Perl Script Challange (brian d foy)
        Perl with form?? <buckwood@bigfoot.com>
    Re: Q about printf (susan cassidy)
        script error on web with perl <brian.charles@orst.edu>
    Re: Setting locale failed. <jhi@alpha.hut.fi>
    Re: SSL with LWP module?? <aas@sn.no>
    Re: Testing a perl "CGI" script <alleycat@scn.org>
    Re: Testing a perl "CGI" script (I R A Aggie)
    Re: Trimming a Variable <jkry3025@comenius.ms.mff.cuni.cz>
    Re: Wanted: email address gleaner (to use for 'good' no <jp@glpbooks.BADMAIL.com>
    Re: Wanted: email address gleaner <joneil@cks.ssd.k12.wa.us>
    Re: Wanted: email address gleaner <jp@glpbooks.BADMAIL.com>
    Re: Where can I get the PERL for Windows NT and 95? <mikei@ix.netcom.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 18 Mar 1998 08:59:37 +0100
From: Gisle Aas <aas@sn.no>
Subject: Re: ? retrieve meta tag information from a HTML document with Perl ?
Message-Id: <m3yay8ig46.fsf@furu.g.aas.no>

This is yet another way to do it:

sub extract_meta
{
   my($meta, $content) = @_;
   require HTML::HeadParser;
   my $p = HTML::HeadParser->new;
   $p->parse($content);
   return $p->header("X-Meta-$meta");
}

$content = <<'EOT';
<head><title>Foo><meta name="Description" content="....">

</head>...
EOT

print extract_meta("Description", $content);

-- 
Gisle Aas


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

Date: Wed, 18 Mar 1998 10:43:24 -0500
From: Dale Sutcliffe <dsutclif@ucsd.edu>
Subject: cgi FORMMAIL and images
Message-Id: <350FEB9C.27EEE156@ucsd.edu>

Anyone know of a formmail cgi (or similar) that can accept and send
images (jpegs) from an applet?



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

Date: 18 Mar 1998 10:05:01 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Chicago Perl Mongers
Message-Id: <en00vy3m.fsf@news.concentric.net>

petdance@maxx.mc.net (Andy Lester) writes:

> DONUTS AND DANCING GIRLS!  At EVERY meeting!

Well, that's it, I'm moving back.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
                                 But raised in Chicago


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

Date: Wed, 18 Mar 1998 19:47:48 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: compiling perl
Message-Id: <slrn6h094k.fjr.jgloudon@manitoba.bbn.com>

In article <3510178C.5F0F@corp.airmedia.com>, Matthew MacGibbon wrote:
>I remember a while back someone had come up with something that allowed
>you to create an executable from a perl script.  Does anyone know
>anything about that?  (or a perl 2 c converter?)

Go to www.perl.com. Search for perl compiler. It's not really a full
implementation. 

Jason Gloudon


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

Date: Wed, 18 Mar 1998 15:03:21 -0500
From: "Brian J.S. Miller" <brian@rickjames.sapien.net>
To: Matthew MacGibbon <matt@corp.airmedia.com>
Subject: Re: compiling perl
Message-Id: <35102889.C83DC5DC@rickjames.sapien.net>

Matthew MacGibbon wrote:
> I remember a while back someone had come up with something that allowed
> you to create an executable from a perl script.  Does anyone know
> anything about that?  (or a perl 2 c converter?)

call me crazy...but can't you just start the script with:
#!/path/to/perl

and the chmod +x the script?
brian


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

Date: Wed, 18 Mar 1998 20:01:46 GMT
From: Michael Lepine <mlepine@bellsouth.net>
Subject: Re: creating directories with cgi
Message-Id: <351029A2.10E71CF1@bellsouth.net>

It could be a permissions thing. Check the permissions on the directory where
you are running the script/cgi. Cgi's are run by the user associated with web
processes and have the permissions assigned to that username and resulting
group.

Mike

Fish wrote:

> Please excuse my ignorance but...
>
> I am trying to create a directory in a Web space from a cgi Perl script. Can
> I do this? I have tried using mkdir commands in the script using values
> returned from a form but I feel I am missing the point. Any advice please?
> It would be much appreciated. Thanks in advance.
>
> Fish





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

Date: Wed, 18 Mar 1998 20:10:14 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: Fastest way to grep through a file?
Message-Id: <slrn6h0aem.fjr.jgloudon@manitoba.bbn.com>

In article <6ep2p1$ad4@news.microsoft.com>, Ron Aaron wrote:
>
>Agent Hall wrote in message <6eot7l$6cus@cortez.sss.rpi.edu>...
>>I have a small program that has to open up several text data
>>files, and search through them for a particular string, and
>>return the number of times it sees the pattern.
>>
>>@data = <FILE>; # slurp!
>>$count = grep /$pattern/, @data;
>How about:
>    @counts = `grep -c $filelist`;
>
This is going to be faster than perl, but the while <STDIN> { } construction
is the fastest way to do it in perl for files as small as 20k, if your
hardware/operating system/stdio implementation does even a half way job of
prefetching and buffering data.

Jason Gloudon


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

Date: Wed, 18 Mar 1998 20:29:12 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Fastest way to grep through a file?
Message-Id: <Eq17Ko.Bqx@world.std.com>

hallm4@cortez.sss.rpi.edu (Agent Hall) writes:

>$count = grep /$pattern/, @data;
[stuff deleted]
> $count++, if /$pattern/;


The biggest performance boost you could make is to stop perl from
recompiling the regular expression each time. If the pattern doesn't
change during the course of the program, take a look at the /o
modifier in the perlre man page. If it does, then take a look at the
FAQ entry "How do I efficiently match many regular expressions at
once?" <URL:http://www.perl.com/CPAN/doc/
manual/html/pod/perlfaq6/How_do_I_eficiently_match_many_.html>

>is another way i've thought of. i assume since memory is faster than
>disk access, that perhaps reading it all in at once, and then doing 
>a search on the data would be faster. as opposed to reading a line,
>searching it, reading a line, etc.

But if you load huge amounts of data into memory, the OS is likely to
page some of the data to disk (virtual memory) so that you are at disk
speeds again. Also, perl's standard readline (the "<>" or diamond)
operator uses C stdio library. This reads data from disk in large
chunks, saves them, and passes them out a line at a time when
asked. Slurping the file in one pass and reading it a line at a time
probably result in the same number of read() system calls that access
the file. The difference is the file slurping one will perform them
close to the same time, while the readline one will intersperse them
throughout the program.

One more point, have you evey noticed the Benchmark module that is
included with perl? It is a great way of comparing the relative speeds
of small program snippets. See the Benchmark man page for details.

-- 
Andrew Langmead


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

Date: Wed, 18 Mar 1998 13:45:38 -0500
From: Mikhail Galbmillion <galbmill@21st-century-comm.com>
Subject: help with trace needed
Message-Id: <35101652.4EED@21st-century-comm.com>

Hello, 
I just started to use Perl  recently and haveno idea
where to start with the following problem:

I need to trace a user(user machine) who tries to add some
entry to the specific database table. The data is entered on
web page and is inserted to database using Oraperl.
I just need to keep track of users who use this web page.

Appreciate your help.
Thank you,
Mikhail Galbmillion
galbmill@21st-century-comm.com


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

Date: Wed, 18 Mar 1998 12:55:08 +0000
From: "Robert Aldridge" <roberta@cyberramp.net>
Subject: Help!  Can't find a newsbot!
Message-Id: <6ep54p$aiu$1@newshost.cyberramp.net>

I've been looking all over the place and haven't found it yet.  Hopefully
somebody here can help.

I need a script that I can run (activate) that will search specific sites
for news headlines,  then list them in a file with a URL link to the actual
news topic, or the main news site that it found the headline (if there is no
link to the actual article).  


Then I'd like it to produce a text file that I can include (via SSI) in an
HTML file with the Headlines that I approve linked to their appropriate URL.

Please let me know if you can help.  Thanks.
Robert Aldridge
roberta@cyberramp.net


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

Date: Wed, 18 Mar 1998 13:43:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HI!PERL/CGI Websites?
Message-Id: <comdog-ya02408000R1803981343140001@news.panix.com>
Keywords: from just another new york perl hacker

In article <350F1BDC.B9753246@synopsys.com>, Ani Bhutkar <abhutkar@synopsys.com> posted:

>Does anybody know how to solve this?
>I have an html online form. What should be the script to
>save my incoming data, in simple perl(cgi) format code?
>Does anybody know a good website for beginnners at perl/cgi.
>please suggest, your reply requested at :

the CGI Meta FAQ has references to both general CGI documentation
language specific documentation, including Perl references.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 18 Mar 1998 08:00:38 -0800
From: susanc@news.SanDiegoCA.ncr.COM (susan cassidy)
Subject: Re: how to assign unix command options in perl
Message-Id: <6eor36$13r@ssd3450.SanDiegoCA.NCR.COM>

In article <6ek5jt$17g@ccshst05.uoguelph.ca>,
Lalit Jairath <ljairath@wright.aps.uoguelph.ca> wrote:
>Hi all,
>
>how can i assign unix command options in perl?
>
>i do the following:
>
>$_ = `date -u +%B`;
>print;
>
>it does not work. it just prints B.
>
>any ideas?
>

I tried these variations on my system, and they all worked fine:

#!/usr/bin/perl
chomp($monval=`date -u '+%B'`);
print "month is $monval now\n";
$monval=`date -u '+%B'`;
print "month is $monval";
chomp($monval=`date -u +%B`);
print "month is $monval now\n";
$monval=`date -u +%B`;
print "month is $monval";
$_=`date -u +%B`;
print "month is $_";

patch [226] ./perltst
month is March now
month is March
month is March now
month is March
month is March


Does your date command work ok from the command line (unix) by itself?

Try putting the single quotes (that my man page for date recommends)
around the date format, as in my first example, and see if that helps.


-- 
Susan Cassidy
Remove xxx in replyto address when replying.


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

Date: 18 Mar 1998 15:28:42 -0500
From: Jay Rogers <jay@rgrs.com>
To: Marco Paganini <paganini@paganini.net>
Subject: Re: How to implement "timeouts" in perl?
Message-Id: <82n2eniw04.fsf@shell2.shore.net>

Marco Paganini <paganini@paganini.net> writes:
> I've run across a small problem in perl: Implementing timeouts.
> Basically, I have two cases: a) I need to `backtick` a program
> and make sure I won't lose control if it hangs, b) Do a "connect"
> call in a non-blocking way.
> 
> I've tried the simplest form: Using an eval block and a "die bla"
> with the alarm() call. Unfortunately, this causes problems due
> to non-reentrancy in certain kernel routines.

Both IO::Socket::INET and Net::Telnet allow you to connect with a
timeout.  However, both use alarm() within an eval to timeout the
connect.

I've never heard of anyone having a "non-reentrant" problem as you
describe.  I'd think you could only have a problem of that nature
using threads?

The latest version of IO::Socket on CPAN doesn't use alarm() to
timeout a connect, rather it uses a sequence of non-blocking I/O and
select().  I don't think this technique is very portable across OSes,
however it may work for you if the others don't.

Additionally, Net::Telnet has the capability to timeout on read or
write.  Here's how to do your first question:

    $pid = open PH, "$program |"
	or die $!;
    
    ## Create $ph and associate it with PH
    use Net::Telnet ();
    $ph = Net::Telnet->new(Fhopen  => \*PH,
			   Timeout => 10);
    $ph->errmode("return");
    
    ## Look for not hung indicator from program, time-out if too long.
    while (! $ph->eof) {
	$ph->waitfor('/string indicating not hung/');
	if ($ph->timed_out) {
	    warn "program not responding: $program\n";
	    kill 1, $pid;
	    last;
	}
    }
    
    close PH;

--
Jay Rogers
jay@rgrs.com


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

Date: Wed, 18 Mar 1998 20:30:10 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: How to populate a 2D array from a file.
Message-Id: <slrn6h0bk1.fjr.jgloudon@manitoba.bbn.com>

In article <slrn6h038h.52r.bet@ritz.mordor.net>, Bennett Todd wrote:
>1998-03-18-16:28:17 Jim Smith:
>>However trying to populate the array from a file (ex 2) doesn't work
>>because each reference always points to the same area of memory.
>
>Use a lexically local variable (with "my"):
>
>	while (<TABLE>) {
>		my(@ar) = split /,/;
>		push @tab, \@ar;
>	}
>

[ ] could also be used like [ @ar ]. What is contained within [ ] does not
need to be an anonymous array.

  while (<TABLE>) {
     my(@ar) = split /,/;
     push @tab, [ @ar ];
  }


Jason Gloudon 


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

Date: Wed, 18 Mar 1998 12:31:20 -0600
From: Cornhol - io <jleduc@io.uwinnipeg.ca>
Subject: How to use ftp commands after invoking 'ftp' from Perl?
Message-Id: <351012F7.3F244610@io.uwinnipeg.ca>

I'm trying to write a Perl script to 'ftp' to a location and 'get' a
selection of files.
I can invoke the ftp command using  system('ftp'); but I can't figure
out how to send
other commands like 'open' or 'get', 'cd' etc. to the "ftp>" prompt.

Any help would be greatly appreciated...
Jeremy



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

Date: Wed, 18 Mar 1998 14:03:28 -0500
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: How to use ftp commands after invoking 'ftp' from Perl?
Message-Id: <35101A80.2876@gecm.com>

Cornhol - io wrote:
> 
> I'm trying to write a Perl script to 'ftp' to a location and 'get' a
> selection of files.
> I can invoke the ftp command using  system('ftp'); but I can't figure
> out how to send
> other commands like 'open' or 'get', 'cd' etc. to the "ftp>" prompt.

You can do it that way by using a source file containing the commands
you wish to execute, but the syntax of of the shell command is platform
dependent.

A better solution is to use Net::FTP.

Cheers,

Jim


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

Date: Wed, 18 Mar 1998 09:31:47 -0800
From: Beeb <alleycat@scn.org>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <35100503.433D1225@scn.org>

I agree that those who have become proficient in Perl forget how obtuse
Perl appears at first.  Since most newbies are using it for CGI, what is
really needed is a SHORT online tutorial that EXPLICITLY, without
assuming Perl familiarity, goes thruough the basics of using Perl to
write a simple CGI script.  

Bob B.

> To expect
> a beginner to digest code like:
> 
>     s/^\\$a/\x\\$a/g;
> 
> without so much as an explanation is not only absurd, it's down right rude.


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

Date: Wed, 18 Mar 1998 15:34:11 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <fl_aggie-1803981534110001@aggie.coaps.fsu.edu>

In article <35100503.433D1225@scn.org>, Beeb <alleycat@scn.org> wrote:

+ I agree that those who have become proficient in Perl forget how obtuse
+ Perl appears at first.  Since most newbies are using it for CGI, what is
+ really needed is a SHORT online tutorial that EXPLICITLY, without
+ assuming Perl familiarity, goes thruough the basics of using Perl to
+ write a simple CGI script.  

Those sorts of folks really shouldn't a) be writing CGI applications,
and b) using perl to do it.

Perl will cheerfully hand them enough rope to hang themselves, and there
are plenty of individuals who would be willing to exploit weaknesses
in CGI scripts to use and abuse systems.

Remember, the system that you save may well be your own.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Wed, 18 Mar 1998 14:41:53 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Newbie-Help with simplest CGI program
Message-Id: <fl_aggie-1803981441530001@aggie.coaps.fsu.edu>

In article <350fdde2.0@katana.randori.com>, "Doug Evans" <doug@ccinet.com>
wrote:

+ I got an error, from both, that says, "Can't find string terminator
+ "End_of_Multiline_Text" anywhere before EOF at C:\PERL\bin\howdy.pl line 2.

You left of a " or ' somewhere or other.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: 18 Mar 1998 20:48:55 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Optimizing a Perl Sendmail routine?
Message-Id: <6epbvn$f72$2@info.uah.edu>

[Posted and mailed]

In article <MPG.f79b52440793b42989688@news.greatbasin.net>,
	mknutson@websolution.com (Mick Knutson) writes:
: I create an array of 250 addresses and the use a for loop to create a 
: Bcc. to each address.
: Is there a qucker, more efficient way to send an e-mail to a large list 
: of users?

Be sure to put sendmail in bulk mode (which enables some of sendmail's
code optimized especially for bulk mailing):

    for (@addresses) {
        chomp;
        open MAIL, "| /usr/lib/sendmail -t";

        print MAIL "From: mknutson@websolution.com\n",
                   "To: Very Important Committee (list suppressed)\n",
                   "Bcc: $_\n",
                   "Precedence: bulk\n",  ## this is the key
                   "\n",
                   "this is the message.\n";

        close MAIL;
    }

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 18 Mar 1998 15:41:38 -0500
From: Rob Collins <rob@NOSPAMintr.net>
To: Zenin <zenin@archive.rhps.org>
Subject: Re: parsing perl
Message-Id: <35103182.71C61609@NOSPAMintr.net>

Thanks for all the help and interest, everyone.

Zenin wrote:

[snip]

> Rob Collins <rob@NOSPAMintr.net> wrote:
> : By what you say below, do you mean there are no rules which, when applied to a
> : block of text, can determine if the syntax is correct?
>
>         Of course there is:
>
>         if ( system ("perl -ce '$perlcode' > /dev/null 2>&1") == 0) {
>             print "Perl code syntax is ok\n";
>         } else {
>             print "Perl code has syntax errors\n";
>         }
>
>         :-)

 (*grin*)  that's a pretty novel idea.

[snip]

> : and that those
> : op-code syntax-rules cannot for whatever reason be translated upstream, to perl
> : code/text.
>
>         Once it's compiled into a parse tree (op-codes), the "text" is thrown
>         out...I don't understand what you meen by "upstream"... "to perl
>         code/text"?

Yeah, that's what I meant.

>         Again, it would *really* help if we knew *why* you wanted to parse
>         perl code without using perl.  The only reasons I can see are:

[snip]

>         Perl code editor...this is a noble, but hopeless cause.  Even if you
>         write it in perl (best choice, I'd say), you'd have never ending
>         problems parsing perl code correctly.  Yes, Emacs and others come
>         close, but nothing is perfect.  This is because, "Nothing but perl
>         can parse perl".

Well dam! That's what I'd hoped to do, too.  To be specific, I don't really care if
the code would execute; I wanted that too, but it isn't necessary.  I need something
to check if any given block of code cannot be legal.  As long as some given block of
code could be legal (assuming the functions are called correctly and all that jazz),
I can play with it.



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

Date: 18 Mar 1998 18:50:44 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: pattern matching dilemma
Message-Id: <6ep525$pmp$1@marina.cinenet.net>

Michael Lepine (mlepine@bellsouth.net) wrote:
: I am using the following code to limit an archive web site so that it
: only contains the ten most recent feature entries.
: 
:  while($_ = <IN>) {

Just 'while (<IN>) {' has the same effect and is safer (as it expands to 
'while (defined($_ = <IN>)) {').

:    if ($entry_area_flag) {
:         /^.*<li>.*?/i && do {  # count list items in archive

The portions outside <li> in this pattern are meaningless.  The first 
part '^.*' will match zero or more 'anythings' before the <li>, while the 
last part '.*?' will always match the zero-width boundary just after 
<li>.  You should use just '/<li>/i', which achieves your apprent goal of 
matching <li> anywhere in the line.

:                                 $archive_entries++;
:                                 if ($archive_entries >= 10) {

Why not combine the previous two lines into

  if (++$archive_entries >= 10) {

:                                         next; # if 10 list items, don't
: print
:                                 }

A more Perlish way to do this is:

  next if (++$archive_entries >= 10);

:                          }
:         /^.*</ul>.*?/i && do {  # end of archive list entries

Same comments as above on '^.*' and '.*?' being unnecessary.  The problem 
you mention below is caused by the unescaped / in </ul>; notice that / is 
also your pattern delimiter.  Either change delimiters (e.g., m!!), or 
escape the internal / (e.g., <\/ul>).

:                                 undef $entry_area_flag;

Setting it to 0 is better for a flag; undefining it will lead to undefined
value warnings when you test it under -w.  You are using -w, right? 

:                                 print "Entries: $archive_entries\n" if
: $DEBUG;
:                           }
:    }
:     print FILE $_;

Can be abbreviated as just 'print FILE;' if you're into terseness. :)

:     /^.*NEW_ARCHIVE_ENTRIES.*/ && do {

Again, '^.*' and '.*' are useless.

:                                      print FILE $New_Entry;
:                                      $archive_entries++;
:                                      $entry_area_flag = 1;
:                                   }
:  }
: 
: For some reason I get a syntax error with the second pattern matching
: sequence in the code ( /^.*</ul>.*?/ ). No matter what I replace the
: search pattern with, I get an error. Can someone please help me figure
: out a way around this?

See above.

HTH!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 18 Mar 1998 19:08:22 GMT
From: Michael Lepine <mlepine@bellsouth.net>
Subject: Re: pattern matching dilemma
Message-Id: <35101D1E.BD1EFDAC@bellsouth.net>

I wondered about the slash, so I replaced the pattern to match with
other characters to no avail. I did make the changes you suggested;
however, I still get an error ( basically the same one as before ):

perl -c feat*
syntax error at feature_archive_updt.pl line 145, near "m|^.*</ul>.*?|i"

syntax error at feature_archive_updt.pl line 166, near "}"
feature_archive_updt.pl had compilation errors.

Maybe this will help diagnose the problem.

Thanks for helping.

Mike

Quentin Fennessy wrote:

> >>>>> "ML" == Michael Lepine <mlepine@bellsouth.net> writes:
>
>     ML> For some reason I get a syntax error with the second pattern
>     ML> matching sequence in the code
>
> Your fragment:
>
>         /^.*</ul>.*?/i && do {  # end of archive list entries
>
> You are using too many slashes '/'.  There are three in your
> example, rendering the syntax ambigous.
>
> Try this
>
>        m|^.*</ul>.*?|i && do {
>
> It would be helpful if you posted your error messages
> along with your code sample.
>
> --
> Quentin Fennessy                        AMD, Austin Texas
> Secret hacker rule #11 - hackers read manuals





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

Date: Wed, 18 Mar 1998 19:28:51 GMT
From: Michael Lepine <mlepine@bellsouth.net>
Subject: Re: pattern matching dilemma
Message-Id: <351021EB.5BC6F2A0@bellsouth.net>

Thank you for the help and tips. I am trying to become wiser to the ways of
perl. I admit she's a woman with many secrets, you just have to know how and
what to ask of her. I am updating my code to reflect the changes you
suggested.

Thanks,
Mike

Craig Berry wrote:

> Michael Lepine (mlepine@bellsouth.net) wrote:
> : I am using the following code to limit an archive web site so that it
> : only contains the ten most recent feature entries.
> :
> :  while($_ = <IN>) {
>
> Just 'while (<IN>) {' has the same effect and is safer (as it expands to
> 'while (defined($_ = <IN>)) {').
>
> :    if ($entry_area_flag) {
> :         /^.*<li>.*?/i && do {  # count list items in archive
>
> The portions outside <li> in this pattern are meaningless.  The first
> part '^.*' will match zero or more 'anythings' before the <li>, while the
> last part '.*?' will always match the zero-width boundary just after
> <li>.  You should use just '/<li>/i', which achieves your apprent goal of
> matching <li> anywhere in the line.
>
> :                                 $archive_entries++;
> :                                 if ($archive_entries >= 10) {
>
> Why not combine the previous two lines into
>
>   if (++$archive_entries >= 10) {
>
> :                                         next; # if 10 list items, don't
> : print
> :                                 }
>
> A more Perlish way to do this is:
>
>   next if (++$archive_entries >= 10);
>
> :                          }
> :         /^.*</ul>.*?/i && do {  # end of archive list entries
>
> Same comments as above on '^.*' and '.*?' being unnecessary.  The problem
> you mention below is caused by the unescaped / in </ul>; notice that / is
> also your pattern delimiter.  Either change delimiters (e.g., m!!), or
> escape the internal / (e.g., <\/ul>).
>
> :                                 undef $entry_area_flag;
>
> Setting it to 0 is better for a flag; undefining it will lead to undefined
> value warnings when you test it under -w.  You are using -w, right?
>
> :                                 print "Entries: $archive_entries\n" if
> : $DEBUG;
> :                           }
> :    }
> :     print FILE $_;
>
> Can be abbreviated as just 'print FILE;' if you're into terseness. :)
>
> :     /^.*NEW_ARCHIVE_ENTRIES.*/ && do {
>
> Again, '^.*' and '.*' are useless.
>
> :                                      print FILE $New_Entry;
> :                                      $archive_entries++;
> :                                      $entry_area_flag = 1;
> :                                   }
> :  }
> :
> : For some reason I get a syntax error with the second pattern matching
> : sequence in the code ( /^.*</ul>.*?/ ). No matter what I replace the
> : search pattern with, I get an error. Can someone please help me figure
> : out a way around this?
>
> See above.
>
> HTH!
>
> ---------------------------------------------------------------------
>    |   Craig Berry - cberry@cinenet.net
>  --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
>    |      Member of The HTML Writers Guild: http://www.hwg.org/
>        "Every man and every woman is a star."





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

Date: 18 Mar 1998 14:15:12 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: pattern matching dilemma
Message-Id: <ximbtv3bvsf.fsf@jihad.amd.com>

>>>>> "ML" == Michael Lepine <mlepine@bellsouth.net> writes:

    ML> I wondered about the slash, so I replaced the pattern to match
    ML> with other characters to no avail. I did make the changes you
    ML> suggested; however, I still get an error ( basically the same
    ML> one as before ):

    perl -c feat*
    syntax error at feature_archive_updt.pl line 145, near "m|^.*</ul>.*?|i"

    syntax error at feature_archive_updt.pl line 166, near "}"
    feature_archive_updt.pl had compilation errors.

I suggest you run with `-w' and `use strict' and `use splain'
(if you are not already).
 
Without seeing lines 148 and 166 (and others) I don't
think I can add more.

Try to reproduce the problem with a few lines of code, and post
those lines.  Include the input, the expected output and
error messages.  You will find the debugger is very useful
for this sort of thing.  (perl -d -e 1) (my favorite shell!)

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Wed, 18 Mar 1998 20:18:33 GMT
From: Michael Lepine <mlepine@bellsouth.net>
Subject: Re: pattern matching dilemma
Message-Id: <35102D91.7A1B8E5F@bellsouth.net>

Much appreciated. If I can't figure it out in the next hour, I'll break up the
code as suggested and post.

Mike

Quentin Fennessy wrote:

> >>>>> "ML" == Michael Lepine <mlepine@bellsouth.net> writes:
>
>     ML> I wondered about the slash, so I replaced the pattern to match
>     ML> with other characters to no avail. I did make the changes you
>     ML> suggested; however, I still get an error ( basically the same
>     ML> one as before ):
>
>     perl -c feat*
>     syntax error at feature_archive_updt.pl line 145, near "m|^.*</ul>.*?|i"
>
>     syntax error at feature_archive_updt.pl line 166, near "}"
>     feature_archive_updt.pl had compilation errors.
>
> I suggest you run with `-w' and `use strict' and `use splain'
> (if you are not already).
>
> Without seeing lines 148 and 166 (and others) I don't
> think I can add more.
>
> Try to reproduce the problem with a few lines of code, and post
> those lines.  Include the input, the expected output and
> error messages.  You will find the debugger is very useful
> for this sort of thing.  (perl -d -e 1) (my favorite shell!)
>
> --
> Quentin Fennessy                        AMD, Austin Texas
> Secret hacker rule #11 - hackers read manuals





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

Date: Wed, 18 Mar 1998 13:45:28 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl Script Challange
Message-Id: <comdog-ya02408000R1803981345280001@news.panix.com>
Keywords: from just another new york perl hacker

In article <MPG.f783dcf45edb06698968f@newsrv.capital.ge.com>, sporty@webcreate.net (Sporty) posted:
>What I am looking for is someone to take the two files 
>I am trying to test (guestbook.html and guestbook.cgi) 
>and see if they do work. If they do, then I am sure it 
>is nothing wrong with my files.

i'm always "sure" there's nothing wrong with my code, and i'm
mostly wrong. :)

use the -w switch to turn on warnings, "use strict" to clean
up your programming style, and check the syntax with `perl -c`.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Wed, 18 Mar 1998 21:42:41 +0100
From: Buckwood <buckwood@bigfoot.com>
Subject: Perl with form??
Message-Id: <351031C1.2E128933@bigfoot.com>

Hi!
Can anyone help me!! I need some help with how to recive a form with a
perl script, and I dont know how many form entities there are??

Anders



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

Date: 18 Mar 1998 09:14:01 -0800
From: susanc@news.SanDiegoCA.ncr.COM (susan cassidy)
Subject: Re: Q about printf
Message-Id: <6eovcp$175@ssd3450.SanDiegoCA.NCR.COM>

In article <6emp5n$fgv$1@cronkite.ocis.temple.edu>,
Stan Horwitz <stan@thunder.temple.edu> wrote:
>Perhaps someone can help me figure out what wrong with a printf statement
>I am using. I am a newbie Perl 5 programmer and I have read through the
>various Perl docs including the FAQ and other resources on the wonderful
>Web site at http://www.perl.com, but nothing there seemed appropriate for
>my situation. I looked through my Perl Programming manual and a book I
>have on learning Perl, all to no avail. 
>
>The problem is so simple, I am sure I must be missing something incredibly
>obvious. I can't seem to get a two digit number to print out as two digits
>with printf regardless of whether I treat it as a string or as an integer.
>The number always prints with 3 leading zeros.  I have tried treating the
>number as a string, as in: 
>
>  $x = "03";
>  printf OUTFILE ("%2s", $x);
>
>I have tried treating it as an integer as in:
>
>  $x = 3;
>  printf OUTFILE ("02%d", $x);
>
>I also tried using the standard unformatted print with x$ as a string and
>integer. No matter which way I print the $x, the result always comes out
>as "0003" when it should be "03" in my output file. I even tried adding
>some junk characters onto the right of the string as a test as in $x =
>"03ss" and those extra zeroes still appear in the output file. When I
>print to STDOUT, the output is correct, but not when I print to a text
>file. 
>
>Does anyone have any ideas why?
>

Are you really printing out more than one value, the first of which is
00, and the second of which is 03? I notice you are not outputting a
line terminator (\n), so when you look at the file, you will see
all the values on one line.

Also, as someone pointed out, your syntax is wrong in the second example.

Try this exact program (you can change the output filename, of course),
and see what happens:

#!/usr/bin/perl
open (OUTFILE, ">/tmp/tempout")|| die "cannot open /tmp/tempout, status $!";
@ testdata=("02","03","04","05");
foreach $testval (@testdata) {
  printf OUTFILE ("%02d\n",$testval);
}
close OUTFILE;

Then look at the output:
patch [275] pg /tmp/tempout
02
03
04
05
(EOF):

The format specification %02d tells it to use at least 2 digits, with
leading zeroes.  If the number is longer than 2 digits (e.g. 1007), not
counting leading zeroes, it will use as many digits as necessary.

Hope this helps.

-- 
Susan Cassidy
Remove xxx in replyto address when replying.


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

Date: Wed, 18 Mar 1998 11:42:38 -0800
From: Brian Charles <brian.charles@orst.edu>
Subject: script error on web with perl
Message-Id: <351023AE.524CC9B4@orst.edu>

Hi,
I have the following script which works, but on the web it returns a
"Internal Service Error"
Why? I would like it to redirect to somewhere. How do I do that?
Yes, I do realize this is more of a CGI question, but that newsgroup
does not seem to be functioning.
Thanks


#!/usr/bin/perl

require "cgi-lib.pl";

&ReadParse(*form_data);


        open(DB,">>surveyresults"); #open file for appending
        print DB "$form_data{'i_copy_neg'},";
        print DB "$form_data{'i_portraiture'},";
        print DB "$form_data{'i_documentary'},";
        print DB "$form_data{'i_specimen'},";
        print DB "$form_data{'i_dupes'},";
        print DB "$form_data{'i_clr_cpy'},";
        print DB "$form_data{'i_comp_slides'},";
        print DB "$form_data{'i_scanning'},";
        print DB "$form_data{'i_comp_manip'}\n";
        close DB;



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

Date: 18 Mar 1998 22:06:35 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Setting locale failed.
Message-Id: <oeeemzzpxv7.fsf@alpha.hut.fi>


"Brian J.S. Miller" <brian@rickjames.sapien.net> writes:
> so where do you actually SET the locale?

In UNIX systems usually in your shell's startup files:
Depending on your shell, files like .profile, .cshrc, .login,
 .z*, ...  in your home directory.  You might try

egrep 'LC|LANG' .??*

but that will fail if your system support has setup some
indirect shell startup files.  Better ask your system support.

> ~> locale -a
> POSIX
> de
> fr
> it
> ko
> nl
> no
> pl
> pt
> sl
> sv

As you had "us" I suggest "POSIX" of those.  This you can do adding
something like 'LC_ALL=POSIX;export POSIX' or 'setenv LC_ALL POSIX'
to your shell startup file.  Whatever that is, I don't know, ask your
system support if you don't know.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: 18 Mar 1998 21:16:35 +0100
From: Gisle Aas <aas@sn.no>
Subject: Re: SSL with LWP module??
Message-Id: <m37m5rn49o.fsf@furu.g.aas.no>

neal@make-a-store.com writes:

> I know it is possible to retrieve a URL using the HTTPS protocol with LWP but
> I can't find any documentation on how to set this up.  I am using Perl
> 5.004_04 on IRIX5.3 and libwww-perl-5.20.

  1) Get, compile and install SSLeay-0.6.6.
     ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL/
  2) Get Crypt::SSLeay from CPAN: perl Makefile.PL; make; make install
  3) If you don't allready have libwww-perl install it like 2)
  4) perl -MLWP::Simple -e 'getprint "https://some.secure.server.com"'

What do you have problems with?

-- 
Gisle Aas


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

Date: Wed, 18 Mar 1998 09:24:40 -0800
From: Beeb <alleycat@scn.org>
Subject: Re: Testing a perl "CGI" script
Message-Id: <35100358.975F202A@scn.org>

If your ISP is using Unix, you MUST make sure the ".CGI" program is in a
the proper text format, most DOS and Windows text editor produce files
not compatible with unix for executable files.  When you upload your CGI
file, give it a different extension (like .dos) and then use Telnet to
execute the following program from your cgi-bin directory:

  fromdos < whatever.dos >whatever.cgi

Next, you must mark the file as executable:

  chmod 755 whatever.cgi

Then it may surprise you and actually work!

Justin Wills wrote:

> Sporty wrote:
> 
> > I would like to know if someone would be willing to
> > test a perl CGI script. I have done my best to put it
> > together and use it on my web page. It is a guestbook
> > that will send me e-mail when someone leave a message.
> >
> > My ISP has given me a cgi-bin directory on their
> > server and "swears" it has the proper permissions.
> >
> > What I am looking for is someone to take the two files
> > I am trying to test (guestbook.html and guestbook.cgi)
> > and see if they do work. If they do, then I am sure it
> > is nothing wrong with my files.

> > Thank you for your time
> >
> > Sporty
> > sporty@webcreate.net


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

Date: Wed, 18 Mar 1998 15:38:12 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Testing a perl "CGI" script
Message-Id: <fl_aggie-1803981538120001@aggie.coaps.fsu.edu>

In article <35100358.975F202A@scn.org>, Beeb <alleycat@scn.org> wrote:

+ If your ISP is using Unix, you MUST make sure the ".CGI" program is in a
+ the proper text format, most DOS and Windows text editor produce files
+ not compatible with unix for executable files.

True. But if you use FTP to do the dirty work, make sure it does it all,
and set the transfer type to 'text'. It will do the Right Thing for the
text files.

+   chmod 755 whatever.cgi 
+ Then it may surprise you and actually work!

Or you can use the perl syntax checker to check it:

% perl -c _script_name_

And if you use the CGI.pm module to handle the CGI communications,
then you can run it from the command line in interactive mode.

A Most Excellent Feature!

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Wed, 18 Mar 1998 21:00:48 -0800
From: Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
Subject: Re: Trimming a Variable
Message-Id: <3510A680.1115@comenius.ms.mff.cuni.cz>

Jonathan Stowe wrote:
> 
> $variable =~ /^(.{1,3})/;
> 
> $variable_with_no_more than_3_characters = $1;
> 
> to get up to three from the beginning.  You could likewise anchor to
> the end ($) of the string to get the last three characters.  It
> becomes a bit more difficult to get three characters from an arbitrary
> position within the string using a regexp unless you have some known
> pattern to anchor it. (although no doubt some seasoned RE-mongers
> could provide one.) 

$variable =~ /^.{10}(.{1,3})/;
$var = $1; 

> In these cases substr() is probably a good bet.

Agreed.
> 
> Have fun
> 
> /J\
> Jonathan Stowe

Jenda


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

Date: Wed, 18 Mar 1998 15:58:25 +0000
From: Jeff Potter <jp@glpbooks.BADMAIL.com>
Subject: Re: Wanted: email address gleaner (to use for 'good' not spam!)
Message-Id: <350FEF21.2E9F@glpbooks.BADMAIL.com>

 ...Just thought I'd add that.

I'm trying to make a book for a newsgroup based on its post archives.
But I have to contact each poster and show them the post I want to
reprint and ask permission. How to do this? It seems like an existing
address gleaner would be a good start. Know of any?

-- 

Jeff Potter   jp@glpbooks.BADMAIL.com   delete '.BADMAIL' to reply
***"Out Your Backdoor": Friendly Magazine of DIY Adventure and Culture
       http://www.glpbooks.com/oyb ... with new bookstore & bulletin board


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

Date: Wed, 18 Mar 1998 11:02:05 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: jp@glpbooks.BADMAIL.com
Subject: Re: Wanted: email address gleaner
Message-Id: <35101A2D.5E97FACC@cks.ssd.k12.wa.us>



Jeff Potter wrote:

> As I posted, I have a big archive of newsgroup posts that I'd like to autoreply
> to all email addresses within. I need to ask permission to reprint their
> posts. (The request would also auto-include their post text.) I want to publish
> a book that makes the very helpful info of this newsgroup more widely
> available. Sounds like a good use for a 'gleaner' to me! :)
>

Sounds like SPAM to me.


---
Jerome O'Neil (joneil@cks.ssd.k12.wa.us)
Seattle Public Schools  (http://www.ssd.k12.wa.us)
Information Services    (Who I don't speak for)




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

Date: Wed, 18 Mar 1998 15:55:53 +0000
From: Jeff Potter <jp@glpbooks.BADMAIL.com>
Subject: Re: Wanted: email address gleaner
Message-Id: <350FEE89.5AB9@glpbooks.BADMAIL.com>

Jerome O'Neil wrote:
> 
> Jeff Potter wrote:
> 
> > As I posted, I have a big archive of newsgroup posts that I'd like to autoreply
> > to all email addresses within. I need to ask permission to reprint their
> > posts. (The request would also auto-include their post text.) I want to publish
> > a book that makes the very helpful info of this newsgroup more widely
> > available. Sounds like a good use for a 'gleaner' to me! :)
> >
> 
> Sounds like SPAM to me.

Do you call posts from your mom spam, too? Please, give a reason as
to why the above might be spam. ---It's a specific response to a specific
post. It's *ontopic* to both the newsgroup and the specific posts involved.
Unless you're against books being created from NG archives, there's nothing
'spamlike' about my quest. If you're against such activity, that's one thing.
But posts about the subject are absolutely not spam. Unless you know
netiquette otherwise? 

-- 

Jeff Potter   jp@glpbooks.BADMAIL.com   delete '.BADMAIL' to reply
***"Out Your Backdoor": Friendly Magazine of DIY Adventure and Culture
       http://www.glpbooks.com/oyb ... with new bookstore & bulletin board


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

Date: Wed, 18 Mar 1998 14:36:56 -0500
From: Lyubov Ignatovsky <mikei@ix.netcom.com>
Subject: Re: Where can I get the PERL for Windows NT and 95?
Message-Id: <35102258.FF7241@ix.netcom.com>

try www.activestate.com

Husky wrote:

> If I want to test my perl scripts in IIS on NT or PWS on Win95.
> Where can I get the perl software for these OS?
> Thanks...





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

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

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