[7736] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1361 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 23 13:07:19 1997

Date: Sun, 23 Nov 97 10:00:28 -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           Sun, 23 Nov 1997     Volume: 8 Number: 1361

Today's topics:
     Re: Check and automatically send a zip <petri.backstrom@icl.fi>
     Convert an array to hash? <designky@sonnets.dot.com>
     Re: Convert an array to hash? (Jason Gloudon)
     Re: Convert an array to hash? (Tad McClellan)
     core dumped with split (Edmund Grimley-Evans)
     Re: CPU Intensive code? <sbekman@iil.intel.com>
     Re: CPU Intensive code? (Jeremy D. Zawodny)
     Help grep! (Ryujiy)
     Re: Help grep! (Tad McClellan)
     How to update from 5.002 to 5.004? (Chang Y.C)
     Re: How to: push (condition ? @this : @that),$value; <devnull@nvg.org>
     Re: Is there a nice way to make MSWord print? (Jan Dubois)
     Is there a perl compiler that knows xsubs as well ? <shlomoa@iil.intel.com>
     Re: open(), seek() and email monitoring <andrewe@technologyXchange.com>
     peculiar warnings ??? <skraemer@iil.intel.com>
     Re: Perl / mSQL / Access (Andrew M. Langmead)
     Re: PerlScript under WinNT <petri.backstrom@icl.fi>
     Re: Quirky string matching problem (Jason Gloudon)
     reading reply email <nospam.tbsmith@mindspring.com>
     Re: reading reply email (Jeremy D. Zawodny)
     Re: Regex for three equal characters <r.goeggel@atos-group.de>
     Re: Regex for three equal characters <r.goeggel@atos-group.de>
     Re: Safe use of flock() -- was Re: giving up on flock (Andrew M. Langmead)
     Re: security questions (Jason Gloudon)
     sending daily email <nospam.tbsmith@mindspring.com>
     Re: sending daily email (Jeremy D. Zawodny)
     Simulation & modeling (Andy Leigh)
     Re: Win32 and Word (Jan Dubois)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Nov 1997 10:24:34 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Check and automatically send a zip
Message-Id: <3472A242.22F2@icl.fi>

Abigail wrote:
> 
> The Tufgars (tufgar@golden.net) wrote on 1541 September 1993 in
> <URL: news:347242E8.DED52F59@golden.net>:
> ++ I'm trying to write a perl script so that if everything checks out, perl
> ++ will automatiaclly start sending a zip to a persons browser without them
> ++ having to click on a link to recieve the file.  How would I do this?
> 
> Try ESP.

ESP tells me that we can probably expect that one click
is allowed (the one that launches the Perl script ;-)

And in that case the answer for "The Tufgars" is:

    send the appropriate HTTP response header with
    data such as:

        HTTP/1.0 200 OK 
        Content-type: application/x-zip-compressed

    then the script needs to open the ZIP file, 
    read the data and write it to the standard
    output, close and exit.

    (For details, see CGI.pm documentation - I assume
    that is what you want to use - and Perl docs
    regarding file input/output functions. If you
    can't figure it out, then come back with code
    samples of what you've tried, and how they
    behaved.)

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Sun, 23 Nov 1997 04:23:44 -0600
From: designky <designky@sonnets.dot.com>
Subject: Convert an array to hash?
Message-Id: <3478042F.D82327AB@sonnets.dot.com>

I am wondering is there an easy way to convert an array to hash with the array
values be the keys, and assign 1's to the hash values.

what i really want is to do this:
	%hash = split(/ /,$line)
is there an easy to split and put in a hash?

-----------------------------------------------------------------------------
Kang Soon Lai	skang_at_nori.lips.net	| "If there is any religion that would
http://www.tisl.ukans.edu/~skang/	| cope with modern scientific needs
(913) 385 5481				| it would be Buddhism."
Software Engineer			|		--Albert Einstein


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

Date: 23 Nov 1997 15:50:33 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Convert an array to hash?
Message-Id: <659jc9$dqo$3@daily.bbnplanet.com>

designky (designky@sonnets.dot.com) wrote:
: I am wondering is there an easy way to convert an array to hash with the array
: values be the keys, and assign 1's to the hash values.

: what i really want is to do this:
: 	%hash = split(/ /,$line)

%hash = map {  $_ => 1  } split (/ /,$line);

man perlfunc and lookup map for an explanation.

Jason Gloudon


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

Date: Sun, 23 Nov 1997 09:02:41 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Convert an array to hash?
Message-Id: <hig956.bs.ln@localhost>

designky (designky@sonnets.dot.com) wrote:
: I am wondering is there an easy way to convert an array to hash with the array
: values be the keys, and assign 1's to the hash values.

: what i really want is to do this:
: 	%hash = split(/ /,$line)
: is there an easy to split and put in a hash?


   foreach $key (split / /,$line) {
      $hash{$key} = 1;
   }

OR

   %hash = map  {($_, 1)} split(/ /, $line);


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 23 Nov 1997 14:13:56 GMT
From: etg10@cl.cam.ac.uk (Edmund Grimley-Evans)
Subject: core dumped with split
Message-Id: <659dn4$9mp$1@lyra.csx.cam.ac.uk>

Is there a good reason for the following?

$ perl5 -e 'split /(a)|(b)/,"a";' 
Memory fault - core dumped

How can I avoid the conditions that make this happen?

I want to be able to tokenise the input in a robust and general
manner and I'm beginning to think that I can't use split for
this, unfortunately, but will have to reimplement something
very similar with m/^.../ in a loop ...

Edmund


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

Date: Sun, 23 Nov 1997 12:52:30 +0200
From: Bekman Stanislav <sbekman@iil.intel.com>
To: "Jeremy D. Zawodny" <jzawodn@wcnet.org>
Subject: Re: CPU Intensive code?
Message-Id: <34780AEE.5656@iil.intel.com>

Jeremy D. Zawodny wrote:
> >My perl cgi-script has been shoutdowned by my ISP, the reason CPU heavy
> >code!
> 
> Sounds like your ISP needs to look at something like CGIWRAP.

They will not do it :-(
 
> >I have a simple counter script based on Matt's well known script (it uses
> >'fly' to concatenate basic digit images to one real image number)
> 
> Who is Matt and what is Fly?

That's the guy who wrote a lot of cgi-bin scripts in perl and released
to the public domain
I said everyone use it -- since many scripts running in the world are
his creations
(Not all of them so :-) his DB of scripts at
http://www.worldwidemart.com/scripts/

> >All I added is some code, which uses
> >use URI::URL ();
> >use CGI qw(:standard);
> >
> >I checked -- it takes 5-15% CPU (looked at the 'top' util) for a few
> >seconds but the site's traffic is heavy so the counters runs every few
> >seconds...
> 
> Yeah. Reading, parsing, and compiling those modules will certainly add
> some overheard.
> 
> >How can I fix it? Or how can I look what are the CPU intensive parts?
> 
> Several options:
> 
> (1) Prune out unnecessary code.
There is no unnecessary code :-(

> (2) Use a persistent counter (one that is always in memory, or runs in
> the web server process). Something along the lines of FastCGI.
> (3) Use a compiled (rather than interpreted) counter.
Yep, but I like to program in perl. I know C but I've never written a
cgi in C.

> I'm not sure why the 'fly' part is. So, it's safe to say that not
> everyone uses it.

Fly is a little util written in C that takes separate images and
concatenate them in one, so in case of counter it picks the basic digits
(images) and glue them together to make a whole image

Is there any way I can benchmark the different parts of script to find
out the bottleneck!

______________________________________________________________________
Stas Bekman     mailto:sbekman@iil.intel.com [just another webmaster]
Linux Installation Party [Technion] http://instaparty.israel.eu.org/
Home Page:      http://www.eprotect.com/stas
A must visit: 	http://www.eprotect.com/stas/TULARC (Java,CGI,PC,Linux)
Linux-il Home:  http://www.linux.org.il/


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

Date: Sun, 23 Nov 1997 17:32:00 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: CPU Intensive code?
Message-Id: <347867a4.149051074@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Sun, 23 Nov 1997 12:52:30 +0200, Bekman Stanislav
<sbekman@iil.intel.com> wrote:

>Jeremy D. Zawodny wrote:
>> >My perl cgi-script has been shoutdowned by my ISP, the reason CPU heavy
>> >code!
>> 
>> Sounds like your ISP needs to look at something like CGIWRAP.
>
>They will not do it :-(

Thought of finding a new ISP?
 
>> >I have a simple counter script based on Matt's well known script (it uses
>> >'fly' to concatenate basic digit images to one real image number)
>> 
>> Who is Matt and what is Fly?
>
>That's the guy who wrote a lot of cgi-bin scripts in perl and released
>to the public domain
>I said everyone use it -- since many scripts running in the world are
>his creations
>(Not all of them so :-) his DB of scripts at
>http://www.worldwidemart.com/scripts/

Hm. Lots of flash at that site. The isn't anything to write home
about. This Matt guy sure likes to re-invent the wheel.

I also noticed several broken links on the site promoting his book.
What a joke.

[snip]

>> >How can I fix it? Or how can I look what are the CPU intensive parts?
>> 
>> Several options:
>> 
>> (1) Prune out unnecessary code.
>There is no unnecessary code :-(

Then look for faster ways to do what the existing code does, I
suppose.

>> (2) Use a persistent counter (one that is always in memory, or runs in
>> the web server process). Something along the lines of FastCGI.

Since you didn't say anything here, I assume it's not an option,
either?

>> (3) Use a compiled (rather than interpreted) counter.
>Yep, but I like to program in perl. I know C but I've never written a
>cgi in C.

Well, you may want to look at the Perl compiler. Or you may want to
brush up on your C skills.

>> I'm not sure why the 'fly' part is. So, it's safe to say that not
>> everyone uses it.
>
>Fly is a little util written in C that takes separate images and
>concatenate them in one, so in case of counter it picks the basic digits
>(images) and glue them together to make a whole image
>
>Is there any way I can benchmark the different parts of script to find
>out the bottleneck!

Sure. Use the benchmark library.

% perldoc benchmark

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 23 Nov 1997 15:45:17 GMT
From: ryujiy@aol.com (Ryujiy)
Subject: Help grep!
Message-Id: <19971123154500.KAA22753@ladder02.news.aol.com>

Hello All!

I am a beginner and have a quesiton.  I want to search a string from a file, so
I tried to use UNIX's grep command.

$string = `grep "ABC" filename`

However, it did not work, so how can I pass parameters to grep command?  Or is
there any better way to accomplish this task?  In my final vaersion of program
both "ABC" and filename must be variables

Thanks!  I apprecieate any advice.

Ryuji

ryujiy@aol.com


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

Date: Sun, 23 Nov 1997 10:31:36 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help grep!
Message-Id: <8pl956.ua1.ln@localhost>

Ryujiy (ryujiy@aol.com) wrote:

: I am a beginner and have a quesiton.  I want to search a string from a file, so
: I tried to use UNIX's grep command.

: $string = `grep "ABC" filename`

: However, it did not work, 
           ^^^^^^^^^^^^^^^

Uhh. What does that mean?

Did not compile?
Compiled with warnings (since all good Perl programmers use the -w switch)
Compiles but won't run.
Runs but appears to do nothing.
Runs but does not do the right thing
Runs but finds too few matches
Runs but finds too many matches
Gets stuck in an infinite loop
Treats all of the lines as a single string.
Finds only the last match in the file
Dumps core
Something else?


: so how can I pass parameters to grep command?  Or is

As you did above should work fine (though the double quotes are not needed,
and a semicolon at the end of the statement is needed (usually)).


: there any better way to accomplish this task?  In my final vaersion of program
: both "ABC" and filename must be variables

: Thanks!  I apprecieate any advice.


Try putting the results into an array instead, or tell us what the
hell 'did not work' means.

Diagnosing a problem without being told the symptoms is futile...


   @ABCs = `grep "ABC" filename`;


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Sun, 23 Nov 1997 20:30:42 +0800
From: g853116@oz.nthu.edu.tw (Chang Y.C)
Subject: How to update from 5.002 to 5.004?
Message-Id: <34781f4b.80144902@news.ee.nthu.edu.tw>

Hello All! This is my first time to post article in here!
I touch perl recently and i am very interesting about it !!
Few days ago, I'v install the perl5.002 on SGI,but today i found that
the latest version of perl is 5.004, so i found  and download it.
But the problem is that I don't know how to update it? The perlfaq
seems not mention about this.I have tried to install it again, but it
still shows version 5.002 when i type perl -v, why?
Can anyone tell me how to update it?  
Thanks a lot!! 
--
Chang Y.C
National Tsing Hua University, Hinschu, Taiwan.
Engineering & System Science Dep.
Email: g853116@oz.nthu.edu.tw
test


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

Date: 23 Nov 1997 16:51:10 GMT
From: Salve J Nilsen <devnull@nvg.org>
Subject: Re: How to: push (condition ? @this : @that),$value;
Message-Id: <659mtu$d1s$1@due.unit.no>

And then, Toutatis suddenly uttered...

[deleted]

> I'd like to write something like
> push (condition ? @this : @that),$value;
> But then something that works. map ik ok as well, as long as it's _short_.

what about....

  push(($condition ? @this : @that), $value);


- Salve Nilsen
-- 
#!/usr/local/bin/perl
$_ = 'Sometimes I have dreams, dreams where I wish my email address was
                        president@whitehouse.gov
but, alas - it is only...'; s/.*?ent/sjn/s; s/whi.*/pvv.org\n/s; print;


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

Date: Sun, 23 Nov 1997 13:21:42 GMT
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Is there a nice way to make MSWord print?
Message-Id: <347c1193.4754526@news3.ibm.net>

[mailed and posted]

Diamand@btinternet.com (Luke Diamand) wrote:

>I'd like to persuade Microsoft Word to print out a 
>document for me (from a perl script, of course) - and
>make it print to a specific file.
>
>I've got as far as using OLE to fire up word, open 
>the document and print to the default printer, but
>the last part defeats me.
>
>Any ideas?
>
>Luke Diamand

YOu just have to specify the "PrintToFile" and "OutputFileName" parameters on
the PrintOut() method call. In the currently released version you have to also
specify all optional parameters in between. In the next version (0.05) of
Win32::OLE you can write it much more comfortably as (tested with Word 8.0a):

-------------------------------------------------------------------
use strict;
use Win32::OLE qw(With);
use Win32::OLE::Const 'Microsoft Word';

my $word = Win32::OLE->new('Word.Application', 'Quit')
  or die "Couldn't run Word";

$word->Documents->Open("i:/tmp/ole/test.doc");

With($word->Options, UpdateFieldsAtPrint => 1, 
                     PrintBackground     => 0);

$word->PrintOut({Range          => $wdPrintAllDocument, 
                 PageType       => $wdPrintAllPages,
		 PrintToFile    => 1, 
                 OutputFileName => "i:/tmp/ole/test.prn"});
-------------------------------------------------------------------

This should be included in the new libwin32 release that Sarathy is currently
preparing. If you need this urgently, then I could send you a tarball of just
the OLE stuff (ca. 30 KB).

In script driven printing it is advisable to disable background printing.
Otherwise you might see some dialog from Word/Excel that the printing is not yet
done when you close the document or the application.

-Jan


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

Date: Sun, 23 Nov 1997 11:05:01 +0200
From: Shlomo Anglister <shlomoa@iil.intel.com>
Subject: Is there a perl compiler that knows xsubs as well ?
Message-Id: <3477F1BD.63DE@iil.intel.com>

Hi
	Is there a perl2C or perl to executable ( in unix ) that handles
	xsubs ?

Shlomo Anglister


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

Date: Sun, 23 Nov 1997 19:38:02 +0800
From: Andrew Ellerton <andrewe@technologyXchange.com>
Subject: Re: open(), seek() and email monitoring
Message-Id: <3478159A.1DDC5E2D@technologyXchange.com>

Neil Briscoe wrote:
> 
> In article <3475561B.F18CBAC7@technologyXchange.com>,
> andrewe@technologyXchange.com (Andrew Ellerton) wrote:
> 
> > Hi all,
> >
> > I'm trying to write some code to monitor email spool files and do
> > anything once new email is received.
> >
> > Although the approach may be wrong, I'm presently trying this code
> > virtually straight out of Programming Perl:
> >
> > for (;;) {
> >         while (<SPOOL>) {
> >
> >                 process_in_whatever_way();
> >         }
> >         sleep $for_a_while;
> >         seek SPOOL, 0, 1; # reset end-of-file error
> > }
> >
> > Is the sleep-then-seek method a reasonable way to handle this? If anyone
> > has any suggestions on an alternative, and/or the use of Mail::Header to
> > extract header information, I'd be most thankful.
> >
> 
> Hmm, a couple of questions.  First - whats SPOOL?  Would I be right in
> supposing you'd opened it with an opendir() - in which case you'd want
> seekdir() - or is it a single mail drop point that you're seeking.

:) Sorry about that. No, SPOOL is the file in the spool directory where
email messages are accumulating. I have attached a much more complete
version of the code below so that it makes a bit more sense. 

--

use Mail::Header;

$account = 'andrewe'; # answering machine for
andrewe@technologyXchange.com

monitor($account);



sub monitor {
	my $who = shift;
	my $for_a_while = 60;

	# Figure out the email spool file to monitor
	$SPOOL = "/spool/$who";

	warn "monitoring $who. Spoolfile = $SPOOL\n";

	# Create a header object. This will be useful for extracting
	# useful information out of messages as they arrive.
	$header = new Mail::Header;

	open SPOOL or die "Can't open spoolfile $SPOOL.\n";

	for (;;) {
		warn "Checking...";
		LINE: while (<SPOOL>) {
	
			# skip lines until a new message starts
			next LINE if ($_ !~ /^From /);

			# extract the header lines from this message
			$header->read(\*SPOOL);

			# Process the message
			if ($header->tags()) {
				
				warn "\n";
				warn "From: ", $header->get('From');
				warn "To: ", $header->get('To');
				warn "Subject: ", $header->get('Subject');
				warn "Date: ", $header->get('Date');
				warn "\n";
				warn "Send answer to ", $header->get('From'), " addressed from the
answering machine of ", $header->get('To'), "\n\n";

				# Other processing would go in here.
			} else {

				warn "Data in $SPOOL not interpreted as email.\n";
			}

			
			$header->empty; # get ready for next message.
		}

		# all messages (if any) have been processed
		warn "No more messages.\n"; 

		# is there an alternative for this?
		sleep $for_a_while;

		seek SPOOL, 0, 1; # reset end-of-file error
	}
}


--


> 
> If the latter, then I wouldn't do it like that.  I'd get rid of the outer
> for() loop and call the script every so often with cron or at.

Very good point. The reason I thought a forever loop would be
appropriate is becuase the "answering machine" type applications (like
this is sort-of intended to be) seem to reply very quickly, as if
they're constantly monitoring the stream. 

I agree though - calling the program by cron/at would certainly be much
simpler than my current approach!

I had thought of emulating the behaviour of tail -f. What do you think
of that idea? Aside from the cron-style scheduling of a process, is it
possible (or wise?) to block on further input into the file, tail -f
appears to? 

I've also noticed that tail -f will note when the file has become
shorter (e.g. the user downloaded their mail) by saying "input has been
truncated"; yet I haven't been able to emulate this in perl yet. Any
ideas?



> 
> More information please, and I might be able to give you a better answer

I hope this is more informative. 
Thanks again; any help is most appreciated.

Regards,
Andrew


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

Date: Sun, 23 Nov 1997 11:52:33 +0200
From: Sefi Kraemer <skraemer@iil.intel.com>
Subject: peculiar warnings ???
Message-Id: <3477FCE1.41C6@iil.intel.com>

Hi,

I can't figure out how to get rid of the following warnings.
I run perl5.001 .
I appreciate your advice.

Thanks,

Sefi.


lines executed by 'eval':
-------------------------
print SRC "           EL                     \n";
$ia_add = " DATA   \'h1A \'h2B \'h3C \'h4D \'h5E \'h6F ";
printf SRC "           %s\n" , $ia_add ;


persistant warnings:
--------------------
Bare word found where operator expected at (eval 110) line 1, near "'h1A
'h2B"
        (Missing operator before h2B?)
String found where operator expected at (eval 110) line 1, near "h2B
'h3C '"
        (Do you need to predeclare h2B?)
Bare word found where operator expected at (eval 110) line 1, near "'h3C
'h4D"
        (Missing operator before h4D?)
String found where operator expected at (eval 110) line 1, near "h4D
'h5E '"
        (Do you need to predeclare h4D?)
Bare word found where operator expected at (eval 110) line 1, near "'h5E
'h6F"
        (Missing operator before h6F?)


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

Date: Sun, 23 Nov 1997 17:20:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl / mSQL / Access
Message-Id: <EK4063.D6E@world.std.com>

"Martin Williams" <info@welnet.co.uk> writes:

>How do I get my perl script to read my Access database using mSQL ?

I have a little bit of a tough time imagining how you have things set
up. The only thing that I can come up with is:

An Access database having tables that are linked to an mSQL database
using ODBC, and you want to use perl on the Windows machine to
manipulate the database.

If so, I'd probably skip the Access part entirely and use the perl
ODBC module to connect to the mSQL database directly.

<URL:http://www.perl.com/CPAN/modules/by-module/Win32/Win32odbc_v970208.zip>

You could also use this to talk to the Access database, and let Access
handle what and where the tables are.


If you want the perl script to run on the machine running mSQL
(probably a unix box, right?) then you might want to take a look at
the mSQL module, but then I can't see how the MS Access part fits in.

If none of these work, can you fill us in a little better on how
things are set up (which machine you want to run perl from, which
machine is running mSQL, and which machine is running Access, and how
the three are connected)

-- 
Andrew Langmead


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

Date: Wed, 19 Nov 1997 10:36:22 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: PerlScript under WinNT
Message-Id: <3472A506.4DC5@icl.fi>

Jeremy D. Zawodny wrote:
> 
> If you believe that the *browser* is supposed to run your code, you
> have a fundamental misunderstanding of how CGI scripts work!

FYI:

However, if PerlScript is installed on the client/browser
machine, you are supposed to be able to download Perl code 
embedded in an HTML page and have it execute on the client 
(just like JavaScript provided the browser is MS Internet
Explorer and it is ActiveWare/ActiveState Perl for Win32 + 
PerlScript that's installed on the client).

I haven't tried it myself yet, but that's the idea (the
other purpose of ActiveState's PerlScript is to run it
on a server embedded in Microsoft's ASP - Active Server
Pages - code, which is a mix of HTML and server-side
script written in VBScript, JavaScript/JScript and other
script engines - such as PerlScript ;-).

With CGI, of course, it is all run on the web server as
you say, and not downloaded to the client. Ever (if the
web server is configured correctly).

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 23 Nov 1997 15:21:09 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Quirky string matching problem
Message-Id: <659hl5$dqo$1@daily.bbnplanet.com>

Eddie Toon (etoon@asdweb.com) wrote:
: I recently began a project involving flatfile databases for a simple
: web project. The customer's hosting services doesn't provide for any
: more efficient options, so I'm limited to small scripts with no background
: processes. The following section of my 'search.cgi' script seems to only
: work
: for the 'title' attribute. I've attempted to use several different
: methods, and
: all of my colleagues and I agree that this certainly should work:

    if( (($data{'last'} ne "") && ($last =~ /\Q$data{'last'}\E/) ) ||
        (($data{'title'} ne "") && ($title =~ /\Q$data{'title'}\E/) ) ||
        (($data{'category'} ne "") && ($category =~ /\Q$data{'category'}\E/) )
 )

Try using the above. Your strings may have metacharacters in them which
cause your matches to fail.

Jason Gloudon


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

Date: Sun, 23 Nov 1997 02:51:41 -0600
From: Todd Smith <nospam.tbsmith@mindspring.com>
Subject: reading reply email
Message-Id: <3477EE9D.FDEA71FE@mindspring.com>

i need to know how a script can read reply emails and get the subject,
sender, and body out of them,
like people do to unsubscribe from mail groups.

--
-----------------------------------------------------
Take the "nospam." off my email address to email me.

-Todd Smith




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

Date: Sun, 23 Nov 1997 17:37:57 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: reading reply email
Message-Id: <347a69de.149621274@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Sun, 23 Nov 1997 02:51:41 -0600, Todd Smith
<nospam.tbsmith@mindspring.com> wrote:

>i need to know how a script can read reply emails and get the subject,
>sender, and body out of them,
>like people do to unsubscribe from mail groups.

Sounds like you want some of the Mail::* modules. Check CPAN.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sun, 23 Nov 1997 12:42:03 +0100
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: Regex for three equal characters
Message-Id: <6594te$916$1@news.pop-stuttgart.de>


Dean Jenkins wrote:
>Markus Bubendorf wrote:
>
>> I'm looking for a regex which matches three or more consecutive equal
>> characters. Any ideas?
>
>
>So how about /.{3,}/
>


/.{3.}/ match 3 or more any characters (except \n), but not 3 equal
characters.

I prefer  /(.)\1{2,}/

Ronald




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

Date: Sun, 23 Nov 1997 12:42:03 +0100
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: Regex for three equal characters
Message-Id: <6595rg$9ah$1@news.pop-stuttgart.de>


Dean Jenkins wrote:
>Markus Bubendorf wrote:
>
>> I'm looking for a regex which matches three or more consecutive equal
>> characters. Any ideas?
>
>
>So how about /.{3,}/
>


/.{3.}/ match 3 or more any characters (except \n), but not 3 equal
characters.

I prefer  /(.)\1{2,}/

Ronald




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

Date: Sun, 23 Nov 1997 17:06:01 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Safe use of flock() -- was Re: giving up on flock
Message-Id: <EK3zI1.846@world.std.com>

Mark Mielke <markm@nortel.ca> writes:

>aml@world.std.com (Andrew M. Langmead) writes:
>> Mark Mielke <markm@nortel.ca> writes:
>> >Oh yeah... Tom... I just found a section in the manpage that says that:
>> 
>> >            To avoid the possibility of mis-coordination, Perl
>> >            flushes FILEHANDLE before (un)locking it.
>> >                                        (man perlfunc - flock)
>> but what if the flush fails?

>If the flush() fails... how do you think the close() will succeed?
>seriously :-)

But if the close() fails then you still have the lock, and anything
you do to handle the situation is done with the file still
locked.

If you unlock first, then close, and the close() fails, then other
processes may try to lock the file, and then have their other file I/O
calls (read/write/flush/close) fail as well.
-- 
Andrew Langmead


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

Date: 23 Nov 1997 15:39:32 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: security questions
Message-Id: <659ink$dqo$2@daily.bbnplanet.com>

: Chown sets the uid of the script.  Some http servers set a default uid for
: scripts that are launched by the server, often to user "nobody", so that the
: script doesn't have any rights.  If you set the uid of the perl script to the
: owner, with the chown command, it will cause the running perl script to have
: owner rights.  This means that you could give files fewer permission settings,
: perl could read the files, but the http server could not.
: "

This isn't correct. I'm sure the folks on a UNIX or CGI group will correct 
it, and suggest using a CGI-Wrapper or less preferably "setuid" scripts.

Jason Gloudon


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

Date: Sun, 23 Nov 1997 02:49:25 -0600
From: Todd Smith <nospam.tbsmith@mindspring.com>
Subject: sending daily email
Message-Id: <3477EE15.3CD385C2@mindspring.com>

I need to know a way to active a script randomly, but at least 1 day
between activations. This script will be on a web server sending email
(not spam).

--
-----------------------------------------------------
Take the "nospam." off my email address to email me.

-Todd Smith




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

Date: Sun, 23 Nov 1997 17:37:35 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: sending daily email
Message-Id: <34796985.149532296@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Sun, 23 Nov 1997 02:49:25 -0600, Todd Smith
<nospam.tbsmith@mindspring.com> wrote:

>I need to know a way to active a script randomly, but at least 1 day
>between activations. This script will be on a web server sending email
>(not spam).

I'd suggest that one way to do it would involve using sleep() for a
random number of seconds. Of course, you'll have to manipulate the
randomness of numbers to fit into your constraints.

I suppose you could dynamically re-write a crontab file after each
execution. That might be fun.

Or you could hack the source to cron and implement it yourself.

There have to be 20 ways to do this...

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sun, 23 Nov 1997 09:56:59 GMT
From: andy@legion.demon.co.uk (Andy Leigh)
Subject: Simulation & modeling
Message-Id: <3476a48e.527680@news.demon.co.uk>

I'm curious to know if anyone has built any Discrete-event simulations
using Perl. I know there are lots of languages well suited to such an
enterprise, but I'm a lousy programmer, and don't have time to learn
another language (I'm not exactly sparkling at Perl)

I've had a look through a news archive and CPAN, but can't see any
relevant references. If you've done some experimenting or I've missed
an obvious thread, please let me know.

--
Andy Leigh


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

Date: Sun, 23 Nov 1997 13:22:00 GMT
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Win32 and Word
Message-Id: <347a102d.4396662@news3.ibm.net>

[mailed and posted]

Steve.Riddle@NetSpace.Bentley.com (Steve Riddle) wrote:

>I have been trying to write a beginner script for doing some minor
>manipulations to a Microsoft Word document using Perl under WindowsNT.
>I have reviewed the examples delivered that work with Excel and have
>researched many of the links at the Perl home page. The enclosed
>script opens an instance of Word and displays the application, but I
>have not seen any other activity. Any kick-starts will be much
>appreciated.
>
>
>    use OLE;
>
>    $WordApp = CreateObject OLE 'Word.Application' || die $!;
>    $WordApp->{'Visible'}=1; 
># Everything works up to this point - a word instance is created and 
># displayed
>
># None of these statements appear to do anything
>    $WordApp->FileOpen('testfile.doc');
>    $WordApp->AppMaximize(); 
>    $WordApp->Insert('This is a test'); 

Do you happen to use Word 8.0 (from Office 97)? The method names you are using
look like Word 6.0/7.0 methods. They are still available in Word 8.0 through the
WordBasic compatibility object:

    $WordApp->WordBasic->FileOpen('testfile.doc');

etc. But for new code I would strongly recommend to switch to the new methods
names. Look into the "Visual Basic Reference for Word" help file to find them.
This help file is not automatically installed when you do a standard
installation; you have to add it explicitly during custom setup.

-Jan


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

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

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