[9187] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2804 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 4 05:07:56 1998

Date: Thu, 4 Jun 98 02:00:29 -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           Thu, 4 Jun 1998     Volume: 8 Number: 2804

Today's topics:
    Re: -d ? 3 : 7 is ambiguous, how comes? (Larry Rosler)
    Re: -d ? 3 : 7 is ambiguous, how comes? (Ronald J Kimball)
        accessing files on another server <soetensi@se.bel.alcatel.be>
    Re: accessing files on another server <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Any kind of help is hard to find. (Ronald J Kimball)
        anybody installed perl in VMS? (GEMINI)
    Re: Batch files? <mander@loginet.com>
    Re: Can I email with attachements <bowlin@sirius.com>
        Child processes with Perl <tims@dcs.state.ar.us>
    Re: GIFgraph problems <jurgen@pallas.tid.es>
        help me to install perl on WinNT <yingxue@ee.tamu.edu>
    Re: ISO: Perl script that will index site for search en <jasmatt@es.co.nz>
        Member Registration/Login CGI Script Help <sfalk@nospam.gte.net>
    Re: Misuse of email addressers of posters to c.l.p.m. <metcher@spider.herston.uq.edu.au>
        More GIFgraph problems <jurgen@pallas.tid.es>
    Re: mystified by interaction between \Q and @ in patter (Ronald J Kimball)
    Re: novice question: improving this code? <quednauf@nortel.co.uk>
    Re: Perl DBI + Postgres? (Michael Fuhr)
    Re: Perl, ODBC and OLE help <gmorgan@photographics.co.uk>
        Remote site retrival tstranger@my-dejanews.com
    Re: Seeking HTML::FormatPS module (Periat Henri)
    Re: setting a uid <qdtcall@esb.ericsson.se>
        Strange results from a script... (Jon-o Addleman)
    Re: Strange results from a script... (brian d foy)
    Re: Use of HTML, POD, etc in Usenet (was: Re: map in vo <qdtcall@esb.ericsson.se>
    Re: very quick s/// question (Ronald J Kimball)
        Vim5 "quickfix" mode as a Perl IDE <stevegt@TerraLuna.org>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 3 Jun 1998 21:21:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: -d ? 3 : 7 is ambiguous, how comes?
Message-Id: <MPG.fdfc0998b2ca3e3989686@hplntx.hpl.hp.com>

In article <vrwwax29p2.fsf@raptor.IRO.UMontreal.CA>, 
pinard@iro.umontreal.ca says...
 ... 
> The `history' in the shell is useful, as it helped me retracing my
> mistake :-).  I did try:
> 
> 	perl -e '$x[1,2,3]=7;print $x[3]'
> 
> while I should have tried:
> 
> 	perl -e '@x[1,2,3]=7;print $x[3]'
> 
> From this incorrect experiment, I drawed (sp?) an incorrect conclusion.
 ...

Make that 'retracing my mistakeS :-).'  $x[3] is undefined in either 
case.  Surely you meant $x[2].  And you would probably be wise to type 
'perl -ew' instead of 'perl -e' in any case.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Thu, 4 Jun 1998 01:22:32 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: -d ? 3 : 7 is ambiguous, how comes?
Message-Id: <1da2m5k.1a6eihm1kuga5cN@bay1-466.quincy.ziplink.net>

Francois Pinard <pinard@iro.umontreal.ca> wrote:

>   -d ? 3 : 7
>   print if ?^From?
> 
> I'm not sure this is really fortunate.  If I wrote:
> 
>   -d ? 3 : 7 ?
> 
> then, and only then, it would make sense to interpret that -d is given the
> result of the match as a directory name to test.  I did not write a pattern.

Except that the matching ? does not have to be on the same line, so the
parser would have to parse the entire file to determine which operation
you wanted to use, and even then it would probably still be ambiguous.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 04 Jun 1998 09:17:48 +0200
From: Inge Soetens <soetensi@se.bel.alcatel.be>
Subject: accessing files on another server
Message-Id: <35764A1C.35A7@se.bel.alcatel.be>

Hi,


Suppose I want to access a text-file on a certain webserver.
To view the file in a browser, I can just just http://path/file.txt

But if I want to open this txt-file , how can I do this in perl ?

Is there a possibility to say :

	open (FILE, "http://path/file.txt")   ??

Or is there a solution to this ?

Can somebody please give me some examples also ?


Thanks


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

Date: 04 Jun 1998 09:34:42 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: accessing files on another server
Message-Id: <7xsollk4bx.fsf@beavis.vcpc.univie.ac.at>

Re: accessing files on another server, Inge
<soetensi@se.bel.alcatel.be> said:

Inge> Hi, Suppose I want to access a text-file on a certain
Inge> webserver.  To view the file in a browser, I can just
Inge> just http://path/file.txt

Inge> But if I want to open this txt-file , how can I do
Inge> this in perl ?

LWP is your friend.

perldoc LWP::UserAgent and LWP::Simple

-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.


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

Date: Thu, 4 Jun 1998 01:22:40 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Any kind of help is hard to find.
Message-Id: <1da2mkq.1k9uk3e1a8uc8wN@bay1-466.quincy.ziplink.net>

Michael Dore <michaeldore@hotmail.com> wrote:

> I have noticed that all the help that is proffered on most questions,
> especially from new users, is usually returned in the form of "LOOK IT
> UP".  It is mostly assumed that we have not looked it up, or are too
> lacking in intelligence to figure it out.

And that assumption is almost always correct.


Why is it that so many new programmers are incapable of reading Perl's
documentation?

1-617-555-2816

Call me up, and I will read the Camel book to you.

:-P

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 4 Jun 1998 05:42:06 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: anybody installed perl in VMS?
Message-Id: <6l5c3e$ptg$1@netnews.csie.NCTU.edu.tw>

hi all,
  I'd like to install perl under VMS. however,
I am not familiar with VMS, so I didn't make it.
I followed the readme.vms in perl source,
got MMK(for make), and run MMK/descrip=[.vms]DESCRIP.MMS
but... the following messages appear. so what should I do with it?
or anybody has binary code that I can install directly? (the machine
is DEC alpha)
thanks in advance.

%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
\\
%DCL-W-UNDSYM, undefined symbol - check validity and spelling
\\
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
\\
%DCL-W-NULFIL, missing or invalid file specification - respecify
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
\\
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
\\
%DCL-W-UNDFIL, file has not been opened by DCL - check logical name
%DCL-W-UNDSYM, undefined symbol - check validity and spelling
 \LINE\
%DCL-E-INVIFNEST, invalid IF-THEN-ELSE nesting structure or data
%inconsistency
%MMK-F-ERRUPD, error status %X1003894A occurred when updating target
%CONFIG.H


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

Date: Wed, 3 Jun 1998 22:21:09 -0700
From: "Matthew Andersen" <mander@loginet.com>
Subject: Re: Batch files?
Message-Id: <6l5aoj$adn$1@dns2.serv.net>

You should be able to use:

system("batch.bat", "batch attributes");

This will not spawn a new window, but run it, then complete the script.   If
you want to open a new window use:

system("start", "cmd /c batch.bat")

Hope this helps.

Douglas Nusbaum wrote in message <3575BD5C.CF2EBC86@ix.netcom.com>...
>Is it possible to run a batch file from a perl script?
>If so, could someone send me some sample code.
>
>Code.
>more code(file.bat)
>more code
>





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

Date: Wed, 03 Jun 1998 22:23:56 -0700
From: Jim Bowlin <bowlin@sirius.com>
Subject: Re: Can I email with attachements
Message-Id: <35762F6C.130A4675@sirius.com>

Guy Doucet wrote:
> 
> I am running Perl scripts on my Novell Web Server. I am just starting to
> use a JMerril's SENDSMTP.PL script to send e-mails. It seems to work,
> but I was wondering if there is a way to include an attachment.
> 
> Sorry if I am posting in the wrong group, but if anyone here is doing
> this I would appreciate your help. If I should search on the RFC822
> specifications, does anyone know where I can get them.
> 
> Sincerely,
> Guy Doucet

I just wrote a module to do this.  I had it email itself to you.

-- Jim Bowlin


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

Date: Wed, 03 Jun 1998 23:28:40 -0500
From: Tim Stoddard <tims@dcs.state.ar.us>
Subject: Child processes with Perl
Message-Id: <35762277.761D523B@dcs.state.ar.us>

I have a perl script that executes a shell script in the backgroud like
this:

system "/home/tims/somescript &";

The perl script continues to process while the shell script does other
things.  The perl script eventually calls nineteen different shell
scripts that all run in the background.  After the perl script starts
all the shell scripts I would like it wait until all the shell scripts
finish processing before the perl script terminates.  Is there any way
for the perl script to keep track of its children processes?





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

Date: Thu, 04 Jun 1998 09:24:08 +0200
From: Jurgen Koeleman <jurgen@pallas.tid.es>
Subject: Re: GIFgraph problems
Message-Id: <35764B97.E521D246@pallas.tid.es>

Brian,

Thank you for your help. The hacked function was just the
fix I needed to solve the problem.

Thanks,

Jurgen



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

Date: Thu, 4 Jun 1998 01:16:00 -0500
From: Yingxue Li <yingxue@ee.tamu.edu>
Subject: help me to install perl on WinNT
Message-Id: <Pine.SOL.3.96.980604010531.26700B-100000@eesun3.tamu.edu>


I  tried to install Perl5.002 on my WinNT PC(using Gurusamy
Saraty's binary version from www.perl.com), but failed at the last step
and the error message was like:
  Copying distribution from ... to ...
  Can't spawn "cmd.exe": No such file or directory
  Copy failed!: No such file or directory.
However I can install it on a Win95 PC.
Can you help me to solve the problem? Thank you very much!

Li



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

Date: Thu, 04 Jun 1998 16:21:38 -0700
From: Matt McKenzie <jasmatt@es.co.nz>
To: Andreas <andreas@gson.com>
Subject: Re: ISO: Perl script that will index site for search enging.
Message-Id: <35772C02.7BFBB36@es.co.nz>

Xavatoria II 1.2b by Fluid Dynamics

ftp://ftp.xav.com/search.txt

Andreas wrote:
> 
> I need to index a newspaper site for quicker searchability, anyone know
> of a perl script that will do this ... or any suggestions?
> 
> Please reply through e-mail.
> 
> - Andreas

--
Matt McKenzie, Creator and Administrator
Perl Crawler - http://perlsearch.hypermart.net
               http://perlsearch.fsn.net


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

Date: Wed, 3 Jun 1998 22:05:58 -0700
From: "Steven Falk" <sfalk@nospam.gte.net>
Subject: Member Registration/Login CGI Script Help
Message-Id: <6l5c2r$bci$1@gte2.gte.net>

I am looking for a CGI script that for registering new users and logging in
registered users to a secure site.  Any ideas for a shrink-wrapped script or
one that I can pay to have customized?  Thanks.




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

Date: Thu, 04 Jun 1998 14:22:56 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Misuse of email addressers of posters to c.l.p.m.
Message-Id: <35762120.CF5D77D8@spider.herston.uq.edu.au>

To make matters worse, he [Missert] has already posted this same message
to c.l.p.m.  Like, we were all just dying to read it again.

-- 
Jaime Metcher

Larry Rosler wrote:
> 
> [posted and emailed]
> 
> "Thomas P. Missert" <thomas@net1plus.com> wrote to me by email...
<snip Thomas Missert's recruitment email> 
> You are going to make many posters to this newsgroup very angry by using
> their email addresses in this fashion.  If you want to use the Usenet for
> recruiting, post to the suitable 'jobs' group and use the keyword 'Perl'.
> 
> --
> Larry Rosler
> Hewlett-Packard Laboratories
> lr@hpl.hp.com


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

Date: Thu, 04 Jun 1998 10:20:19 +0200
From: Jurgen Koeleman <jurgen@pallas.tid.es>
Subject: More GIFgraph problems
Message-Id: <357658C2.3A70694B@pallas.tid.es>

I encountered some more problems with the GIFgraph module.

In the following example I want an Y-axis starting with 0,
and with the labels 1000, 2000, 3000, 4000 and 5000.
So I set y_min_value=0 and y_tick_number=5.

====================
#!/usr/bin/perl
use GIFgraph::lines;
@data = (
  [ "4/6"  , "1"   , "2" ],
  [ 2222 , 40    , 555 ]
  );
$g = new GIFgraph::lines();
$g->set('x_ticks' => 1,
 'y_max_value' => 5000,
 'y_min_value' => 0,
 'y_tick_number' => 5,
 );
$g->plot_to_gif( "/tmp/plotfile", \@data);
system("xv /tmp/plotfile");
unlink("/tmp/plotfile");

exit 0;
====================

This script gives me the following labels on the Y-axis:

   30, 1024, 2018, 3012, 4006, 5000.

Why 30 i.s.o. 0 and why does it show an additional X-axis
for Y = 30? Where did I go wrong?

In addition I would like that the data points start on
the Y-axis, i.e. the X-axis label 4/6 just underneath the
Y-axis and 2222 as a point plotted on the Y-axis.
Is there a way to do that?

Thanks in advance,


Jurgen Koeleman




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

Date: Thu, 4 Jun 1998 01:22:42 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: mystified by interaction between \Q and @ in pattern
Message-Id: <1da2nx8.1gst9ak5bu0n0N@bay1-466.quincy.ziplink.net>

Rahul Dhesi <c.c.eiftj@83.usenet.us.com> wrote:

>    if ($str =~ /\Qdhesi\@rahul.net\E/) {
>       print "match\n";
>    }
> 
> The above fragment compiles just fine, but does not match, because
> (presumably) the embedded backslash is converted to a literal backslash
> due to the \Q .. \E.

This was not a problem in perl5.002.  I would suggest reporting this
with the perlbug program.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 04 Jun 1998 09:36:06 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: novice question: improving this code?
Message-Id: <35765C75.8701EF00@nortel.co.uk>

Mark-Jason Dominus wrote:

> In article <brinton-0306980914230001@p026.intchg3.net.ubc.ca>,
> Ralph Brands <brinton@unixg.ubc.ca> wrote:
> >     I am not  a programmer, but have been able to develop a perl script
> >that does the following:
>
> Congratulations!  You're now a programmer.  You might as well admit it.
>
> If you're likely to be searching the same file repeatedly, a good
> strategy is to build an index database.  The best way to do that is to
> do some research and to use someone else's search programs.  Check
> around.  (I'd recommend one, but I don't know the answer myself.)



> ..........(big, thorough explanation)......
>

Superb answer. Thanks for that! (Hell, you might as well publish it :)

--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________





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

Date: Thu, 04 Jun 1998 05:53:03 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Perl DBI + Postgres?
Message-Id: <6l5cno$gqk@flatland.dimensional.com>

ap874@torfree.net (Nick Carter) writes:

> Does anyone have experience with running Perl DBI as an interface to the
> Postgres RDBMS?  I can get Postgres running fine by itself, but for some
> reason, when I try to use Perl's DBI to talk to it, I am not getting too
> much luck.  Basically I get errors when I do a call such as:
>
> DBI->install_driver("Pg"); or
> DBI->connect(..., ..., ...);

What do you have where you've written "..."?  What errors do you receive?
You've left out the information we need to help solve your problem.

I have a few machines with the following config:

    Perl 5.004_04
    DBI 0.93
    DBD::Pg 0.72
    PostgreSQL 6.3.2

So far these systems are working fine.  One system has a database with
a few hundred thousand records and I'm populating it with more data right
now, which should bring it up to 2-3 million records.  No problems so
far, but I'm keeping my fingers crossed anyway :-)

Here's a simple script to open a database and fetch all records
in a table:

    #!/usr/local/bin/perl -w

    use DBI;

    $dbh = DBI->connect("dbi:Pg:dbname=mydatabase", "username", "password")
        or die $DBI::errstr;

    $sth = $dbh->prepare("select * from mytable") or die $dbh->errstr;
    $sth->execute or die $dbh->errstr;
    while (@row = $sth->fetchrow_array) {
        print "@row\n";
    }
    $sth->finish;

    $dbh->disconnect;

> Talking of Postgres, is it worth wasting my time with it? or should I just
> get Oracle instead?

What are your requirements?  How much money do you have?  What kind of
support do you need?  The answers to these questions will be your
guide.  If your requirements are simple and/or you don't have much
money, PostgreSQL or MySQL might be sufficient.  If you're a large
corporation with deep pockets implementing some major system, you might
prefer to go with a more powerful database and get a support contract.
It's free and easy to set up PostgreSQL, however, so I'd recommend
checking it out for a little while to see if it meets your needs.  By
tomorrow morning I should know whether it meets mine :-)

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Thu, 4 Jun 1998 08:32:26 +0100
From: "Glenn Morgan" <gmorgan@photographics.co.uk>
Subject: Re: Perl, ODBC and OLE help
Message-Id: <6l5i6e$jmo$1@news.u-net.com>

>Have you thought about storing the JPEG file on the web server, and the
>LOCATION/URL of the JPEG in the database?  Sounds easier to me, but I
>don't know all of the details of your project...
>

The images I want to store are thumbnails of much larger graphics that are
actually accessed via a stored path as you suggest.  The reason I was
interested in storing these images in the database is for ease of access.  I
can do a single query on the db and retrieve all the info for a particular
graphic in one, also as an experiment to see how well storing graphics in
the db works.  The company I work for have in the region of 50,000 images
stored on our system.  Each graphic can have multiple versions and it would
be far simpler to store each version in a new row of a db than having to
fiddle around generating unique file names for each one and then trying to
resolve naming etc.  I am using Access at present just for testing but
intend to install a full-on db engine if things pan out as I hope.  If you
have any other suggestions regarding the graphics I would be interested in
hearing them too.

Thanks for the response





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

Date: Thu, 04 Jun 1998 06:52:57 GMT
From: tstranger@my-dejanews.com
Subject: Remote site retrival
Message-Id: <6l5g89$lv$1@nnrp1.dejanews.com>

Hi, I'm relatively new to CGI programming and I was wondering if  any of you
could give me and advice or just tell me how it could be done(In perl). What
I need is to download a Web page from a remote server and then save it on the
local server. Any help would be greatly appriciated.
Thank you
-Serge

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 4 Jun 1998 08:37:19 GMT
From: periat@ens.ascom.ch (Periat Henri)
Subject: Re: Seeking HTML::FormatPS module
Message-Id: <6l5mbv$iev$1@ascomax.hasler.ascom.ch>

In article <mike_murphy-ppk-2905981416200001@nppkm606.us.nortel.com>, mike_murphy-ppk@nortel.com (Michael Murphy) writes:
>I've purchased the Perl Resource Kit by O'Reilly and in the module
>reference and the module listing there is a reference to  a module named
>HTML::FormatPS.  I've looked on the CD and CPAN and can't find it.  Does
>anyone know anything about this module and know where I can get it.  Any
>help would be appreciated.
>
>TIA,
>Mike
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>~ Mike Murphy              ~ Nortel                   ~
>~  my opinions are my own  ~ Raleigh, North Carolina  ~
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hi Mike

HTML::FormatPS and HTML::FormatText are part of HTML-Tree.
You can find it on any CPAN site in .../modules/by-module/HTML .

Henri




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

Date: 04 Jun 1998 09:47:40 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: setting a uid
Message-Id: <isaf7twqub.fsf@godzilla.kiere.ericsson.se>

Jeremy Hill <hilljere@pilot.msu.edu> writes:

> 	Does anyone know how I could conveniently 
> change uid's in a script that runs as root, such as

Yes, the perlvar manpage knows. 
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Thu, 04 Jun 1998 04:49:55 GMT
From: jaddle@po-box.mcgill.ca (Jon-o Addleman)
Subject: Strange results from a script...
Message-Id: <357625d4.48695895@news.nbnet.nb.ca>

	I'm trying to make a DB, and in the searching code, I have
this little bit:

SEARCHING: {
	if($Record{'FirstName'}	!~ /$in{'FirstName'}/){$Match=0; last
SEARCHING;};
	if($Record{'LastName'}	!~ /$in{'LastName'}/){$Match=0; last
SEARCHING;};
	if($Record{'Email'}	!~ /$in{'Email'}/){$Match=0; last
SEARCHING;};
	$nothing=0;
}

%in contains the search criteria, and %Record is the record that's
currently being looked at.

This works fine if all fields are filled out, or if only the first one
is blank. However, if either of the others are blank, it won't work.
I've tried putting them in different orders, etc, and now have no idea
what's wrong with it. Can anyone see anything? I can post the rest of
this sub, if it'd help at all.... TIA!

Jon-o Addleman


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

Date: Thu, 04 Jun 1998 01:50:29 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Strange results from a script...
Message-Id: <comdog-ya02408000R0406980150290001@news.panix.com>
Keywords: from just another new york perl hacker

In article <357625d4.48695895@news.nbnet.nb.ca>, jaddle@po-box.mcgill.ca (Jon-o Addleman) posted:

>        I'm trying to make a DB, and in the searching code, I have
>this little bit:
>
>SEARCHING: {
>        if($Record{'FirstName'} !~ /$in{'FirstName'}/){$Match=0; last
>SEARCHING;};
>        if($Record{'LastName'}  !~ /$in{'LastName'}/){$Match=0; last
>SEARCHING;};
>        if($Record{'Email'}     !~ /$in{'Email'}/){$Match=0; last
>SEARCHING;};
>        $nothing=0;
>}
>
>%in contains the search criteria, and %Record is the record that's
>currently being looked at.
>
>This works fine if all fields are filled out, or if only the first one
>is blank. However, if either of the others are blank, it won't work.
>I've tried putting them in different orders, etc, and now have no idea
>what's wrong with it. Can anyone see anything? I can post the rest of
>this sub, if it'd help at all.... TIA!


some things to remember:  

   * for a null regex, m// will use the last succesfully matched
   pattern not hidden by an inner block is used.  this could
   mess up your

   * variables interpolated in a pattern may contain regex
   meta-characters

here's what i think that you may be trying to do:

   $match = 1 
        if (
               ( defined($in{'FirstName'}) and 
                 $Record{'FirstName'} =~ /\Q$in{'FirstName'}\E/ )

               and

               ( defined($in{'LastName'}) and 
                 $Record{'LastName'} =~ /\Q$in{'LastName'}\E/ )

               and

               ( defined($in{'FirstName'}) and 
                 $Record{'FirstName'} =~ /\Q$in{'FirstName'}\E/ )

         );

of course, if you want to find exact matches, you can do away with
the m//'s to make it a lot simpler:

   $match = 1 
        if (
                $Record{'FirstName'} eq $in{'FirstName'} and
                $Record{'LastName'}  eq $in{'LastName'}  and
                $Record{'Email'}     eq $in{'Email'}

         );

and it's not that much tougher to add case insensitivity (and this
is one of at least four ways that i can think of to do it)

   $match = 1 
        if (
                lc $Record{'FirstName'} eq lc $in{'FirstName'} and
                lc $Record{'LastName'}  eq lc $in{'LastName'}  and
                lc $Record{'Email'}     eq lc $in{'Email'}

         );


if you only want some of the conditions to be true, change 'and'
to 'or' in whichever way will satisfy the necessary logic.  you 
may want to use an if-elsif-else construct instead.

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 T-shirts! <URL:http://www.pm.org/tshirts.html>
go tar go!


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

Date: 04 Jun 1998 10:21:07 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
Message-Id: <is4sy1wpak.fsf@godzilla.kiere.ericsson.se>

ehood@geneva.acs.uci.edu (Earl Hood) writes:

> Now we are getting into the realm of MIME, and we know how some people
> feel about MIME postings on the USENET (at least in some newsgroups).

Well, the people who complain about MIME rarely (if ever) know what
they're talking about. They rightly complain about butt-ugly multipart 
postings, but that has about as much to do with MIME as ascii has to
do with 300-character lines and 45-line sigs. 
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Thu, 4 Jun 1998 01:22:46 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: very quick s/// question
Message-Id: <1da2pfp.hz1bt1z8b8rvN@bay1-466.quincy.ziplink.net>

Matt Knecht <hex@voicenet.com> wrote:

> $pattern = "a b c d e    ";
> 
> timethese(1_000_000, {
>     'regex'       =>  ' $pattern =~ s/(\w)\s(?=\w)/$1\*$2/g',
>     'regex_o'     =>  ' $pattern =~ s/(\w)\s(?=\w)/$1\*$2/go',
>     'procedural'  =>  ' $pattern = join('*', split(/\s/, $pattern))'
> });

After the first execution of the first code snippet, $pattern no longer
has any internal whitespace in it.  The remaining 2_999_999 executions
don't have much to do.

The /o is pointless, as the search pattern does not change.

And, as someone already pointed out, the embedded single quotes in your
procedural code snippet mess things up.

use Benchmark;

$str = "a b c d e    ";

timethese(1_000_000, {
  'regex'       => '($str2 = $str) =~ s/(\w)\s(?=\w)/$1\*$2/g',
  'procedural'  => '$str2 = join("*", split(/\s/, $str))',
});


Benchmark: timing 1000000 iterations of procedural, regex...
procedural: 49 secs (48.97 usr  0.00 sys = 48.97 cpu)
     regex: 84 secs (84.83 usr  0.00 sys = 84.83 cpu)


-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 04 Jun 1998 06:29:08 GMT
From: Steve Traugott <stevegt@TerraLuna.org>
To: guenter@arithmos.com
Subject: Vim5 "quickfix" mode as a Perl IDE
Message-Id: <6l5erj$upc$1@nnrp1.dejanews.com>

I wanted to use VIM 5.X (www.vim.org) as a Perl IDE, so I tried something like
what Guenter tried (below), and it didn't work either.  I didn't ever figure
out what the original problem was, but the following settings and script work
great instead.

This, along with VIM 5.X's syntax-driven color highlighting, embedded Perl
interpreter, and good multi-buffer management make VIM a *fantastic* tool for
doing large-project Perl development.

Thank you VIM crew!!!

Steve


 .vimrc
======
version 5.0
vnoremap # X^V^H#
inoremap # X^V^H#
set cinkeys=0{,0},:,!^F,o,O,e
"set cinkeys=0{,0},:,0#,!^F,o,O,e
set errorformat=%f:%l:\ %m
set hidden
set history=500
set makeprg=perl\ %\ 2>&1\ \\^V|\ error_reformat
set shiftwidth=2
set smartindent
set viminfo='50
syntax on

~/bin/error_reformat
====================
#!perl
# Steve Traugott stevegt@terraluna.org
# Wed Jun  3 23:14:36 PDT 1998
#
# reformats perl compiler errors for consumption by VIM 5
#
# use these in your .vimrc:
# set errorformat=%f:%l:\ %m
# set makeprg=perl\ %\ 2>&1\ \\^V|\ error_reformat
#

while(<>)
{
  /(.*) at (.*) line (\d+)(.*)/ && do
  {
    $message = $1 . $4;
    $file = $2;
    $line = $3;

    print "$file:$line:$message\n";
    next;
  };
  print;
}


guenter@arithmos.com wrote in comp.editors:
> I thought I'd try out Vim's quickfix mode for my programming language of
> choice, perl.  I ':source' these lines:
>         set makeprg=perl\ -w\ %
>         set shellpipe=2>&1\|tee\ /tmp/perlerr
>         set errorfile=/tmp/perlerr
>         set errorformat=%m\ at\ %f\ line\ %l\%*[,.]
> and now I can say ':make' while editing a perl script and it runs
> perl.  When I say ':cf' it reads in the errorfile and shows the first
> error on the command line at the bottom - so far so good.
> However, it doesn't jump to the indicated line as I would expect from
> the help text.
> E.g. when I am editing file 'x', do a ':make' and a ':cf', and the error
> says
>         Missing right bracket at ./x line 87, at end of line
> then I expected Vim to jump to line 87 since I am in the right file.
> Am I doing something wrong or did I just misunderstand the help
> information?

> If I can get it to jump to the right line, then the next thing to do is
> write a perl post processor that finds the column number so I can jump
> to the exact spot.


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

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

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