[11544] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5144 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 16 00:07:41 1999

Date: Mon, 15 Mar 99 21:00:27 -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           Mon, 15 Mar 1999     Volume: 8 Number: 5144

Today's topics:
        /([_A-Za-z]\w*)(?!\s*=)/ <alex@kawo2.rwth-aachen.de>
    Re: A perl equivalent to filec? <alex@kawo2.rwth-aachen.de>
    Re: Complex Structure Question (Earl Hood)
    Re: Exact match, but Insensitive (Earl Hood)
    Re: Exact match, but Insensitive (Tad McClellan)
    Re: Finding end of line (Tad McClellan)
        help with pattern matching <khowe@performance-net.com>
    Re: help with pattern matching (brian d foy)
    Re: Help: Conditional use of packages in Perl <zenin@bawdycaste.org>
        how do I add values in a text delimited file? <tgj@snip..net>
    Re: how do I add values in a text delimited file? (Alastair)
    Re: how do I add values in a text delimited file? <partha@mihy.mot.com>
    Re: how do I add values in a text delimited file? <partha@mihy.mot.com>
    Re: How do you create an mSQL database... (brian d foy)
    Re: How do you create an mSQL database... <alex@kawo2.rwth-aachen.de>
    Re: install perl on home dir? <partha@mihy.mot.com>
        javascript garbler in PERL (my first perl script) <mfuerst@advancenet.net>
        Makefile question <prauz@sprynet.com>
    Re: Need Faster Approach (Earl Hood)
        Net::Telnet + passwd + Linux jsanjuan@hotmail.com
    Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%); <thrase@slip.net>
    Re: Newby question.. <partha@mihy.mot.com>
    Re: Reading Directory (Tad McClellan)
    Re: Reading Directory (Tad McClellan)
    Re: Reading Directory <alex@kawo2.rwth-aachen.de>
    Re: Reading Directory <msholund@bigfoot.com>
    Re: searching a flat file database (William Herrera)
    Re: Segmentation Fault (Tad McClellan)
    Re: Sendmail and Cc: field brandtr@my-dejanews.com
        SSI & Perl Script - Passing Variables (AKBishop)
    Re: SSI & Perl Script - Passing Variables (brian d foy)
        What is wrong with this piece of counter code? tatabu@my-dejanews.com
    Re: Where to start with Perl richb@ezl.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 16 Mar 1999 02:39:13 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
Subject: /([_A-Za-z]\w*)(?!\s*=)/
Message-Id: <36EE0AA1.8C819BA9@kawo2.rwth-aachen.de>

Guys,

please... it's 02:30 here in Germany... what am I doing wrong?
I would like to extract all function names from a MATLAB file:

++$func{$1} while (/([_A-Za-z]\w*)(?!\s*=)/g); # words not followed by =

But it does not work - "not followed by =" is ignored. However

++$vars{$1} while (/([_A-Za-z]\w*)(\s*=)/g);

works... What's the reason?

/Alex

PS: I know, I have to handle [x y] = in MATLAB also...

--
http://www.simplex.ru/pref.html


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

Date: Tue, 16 Mar 1999 03:25:50 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Nobody <nobody@dewpoint.eng.sun.com>
Subject: Re: A perl equivalent to filec?
Message-Id: <36EE158E.ABFDB27E@kawo2.rwth-aachen.de>

Nobody wrote:
> Example:  I type in "Sm" in the field, hit the ESC key and it will fill
> out to Smith and then subsequent engagement of the ESC key gives me:
> Smith, A
> Smith, Ann
> Smith, Arnold
> Smith, B
> Smith, Bill
> Smith, Bob
> Smith, Br
> Smith, Brian
> Smith, Bruce

Hi,

do you mean completion? Then it can be done with Term::Complete Perl module -
type "perldoc Term::Complete" to get more information. Something like:

use Term::Complete;
@list  = qw (Arnold Bill Bob Brian);
$input = complete (">", @list);

Regards
/Alex

--
http://www.simplex.ru/pref.html


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

Date: 16 Mar 1999 01:19:23 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Complex Structure Question
Message-Id: <7ckbir$fd0@news.service.uci.edu>

	[mailed & posted]
In article <x3ylnh2ensy.fsf@tigre.matrox.com>,
Ala Qumsieh  <aqumsieh@matrox.com> wrote:

>% perl -w
>my %hash;
>$hash{'a'} = 'a';
>$hash{'a'}{'b'} = 'b';
>print "$hash{'a'} and $hash{'a'}{'b'}.\n";
>__END__
>a and b.
>
>But, under 'use strict' it complains:
>
>Can't use string ("a") as a HASH ref while "strict refs" in use at - line 4.
>
>IMHO, the behaviour (without use strict) is broken. The result should
>be something like:
>
>HASH(0xb851c) and b.

When "use strict;" is specified, you cannot use symbolic references.
I.e.  When you do not specify it, doing "$hash{'a'}{'b'}" causes Perl
to dereference $hash{'a'} as a symbolic reference (since you assigned a
value to $hash{'a'} in the previous statement).  When "strict" is
active, this behavior is not allowed.

I think you are expecting Perl to override the 'a' assignment with an
auto-created hash reference.  However, Perl does not work this way.
Perl sees you have a value for $hash{'a'} and tries "cast" it to how
you use it.  It is like how Perl converts a scalar value between
numbers and strings depending on how you use it.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: 16 Mar 1999 01:27:26 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Exact match, but Insensitive
Message-Id: <7ckc1u$fms@news.service.uci.edu>

	[mailed & posted]
In article <36EDA30A.A5EDB2F1@xs4all.nl>,
Frank de Bot  <debot@xs4all.nl> wrote:

>How can I search for an exact match, but insensitive.

Use the lc, or uc, operator.

For example:

	if ("astring" eq lc $astring) {
	...

If you are talking about the regex domain, TIMTOWTDI, but something
like the following could work:

	/\bastring\b/i

I.e.  You need to defined you regex to include word boundary
cases to avoid finding partial word matches.  Read the perlre
manpage to find out more about other zero-width assertions that
may help you.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Mon, 15 Mar 1999 14:32:04 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Exact match, but Insensitive
Message-Id: <k7njc7.a36.ln@magna.metronet.com>

Frank de Bot (debot@xs4all.nl) wrote:
: How can I search for an exact match, but insensitive.
: I know you can compare strings on 2 ways:
: if ($a eq "X") { }  and  ($a =~ /X/i)  I the second case I can chose if
: it must be capital sensitive or not. But I can't with the first one.
: Example:

: This is the Input  : LITTLE  . In the database is " little " (Lower
: Case) . I don't want it "react" on Lit, but only Little or LITTLE or
: LiTtLe .


   Then anchor both ends of the pattern match:

      $a =~ /^little$/i;
             ^      ^
             ^      ^

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


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

Date: Mon, 15 Mar 1999 14:16:29 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Finding end of line
Message-Id: <damjc7.126.ln@magna.metronet.com>

George (fred222@mauimail.com) wrote:
: In article <7cjj51$84a$1@nnrp1.dejanews.com>, mmartina@my-dejanews.com wrote:

: > I an trying to scan characters in one at a time using getc().  This is working
: > but I an unable to determine when I hit the end of line character.  I am
: > running perl5 on a HP Unix machine.  Any suggestions.

: I could be horribly wrong, but I think the end-of-line "character" is
: actually two characters (backslash-n, or "\n") 


   You are correct, you are horribly wrong.


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


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

Date: Mon, 15 Mar 1999 22:27:34 -0400
From: "Kevin Howe" <khowe@performance-net.com>
Subject: help with pattern matching
Message-Id: <6kjH2.13528$134.133925@tor-nn1.netcom.ca>

Hi, can someone please help me with the following:

The Variable:
$var = "<on>this  <off>..........<on>that  <n>  <off>..........<on>
more<off>";

What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
located between the <on><off> pairs in this string. Below is what I want to
end up with

$var = "<on>this<off>...<on>that<off>...<on>more<off>";

I have tried many different pattern matches but I can't seem to get a handle
on this one.

Any help would be much appreciated,
Kevin Howe




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

Date: Mon, 15 Mar 1999 23:11:51 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: help with pattern matching
Message-Id: <comdog-ya02408000R1503992311510001@news.panix.com>

In article <6kjH2.13528$134.133925@tor-nn1.netcom.ca>, "Kevin Howe" <khowe@performance-net.com> posted:

> $var = "<on>this  <off>..........<on>that  <n>  <off>..........<on>
> more<off>";
> 
> What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
> located between the <on><off> pairs in this string. Below is what I want to
> end up with
> 
> $var = "<on>this<off>...<on>that<off>...<on>more<off>";

how about:

$line = "<on>this  <off>.....<on>that  <n>  <off>....<on>more<off>";

$line =~ s/<n>//g;
$line =~ s/<on>\s*(.*?)\s*<off>/<on>$1<off>/g;

print $line

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: 16 Mar 1999 04:23:43 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Help: Conditional use of packages in Perl
Message-Id: <921558490.678885@thrush.omix.com>

[posted & mailed]

edward@echarge.com wrote:
: I've got a strange problem that I hope somebody can help me with.  I'm
: trying to find some way to conditionally include particular packages in
: Perl. I tried something like the following but it didn't work.
:
: if (condition is true)
:   use package1;
: else
:   use package2;

	if (condition is true) {
	    eval 'use Package1;';
	}
	else {
	    eval 'use Package2;';
	}

: It appears that Perl simply ignores the if statements and imports both
: packages regardless.  Please let me know if anyone has a solution.  Thanks
: in advance.

	perldoc -q "What's the difference between require and use?"

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Mon, 15 Mar 1999 20:16:25 -0800
From: "TinP" <tgj@snip..net>
Subject: how do I add values in a text delimited file?
Message-Id: <7ckb5i$oju$1@news1.fast.net>

Hi,
Does anyone know how I can add the values of a text delimited file?

For example the file looks like this:

Tom | 2 | 2 | 3 |1 | 4
Bill   | 3 | 4 | 2 | 1 | 6
Sue | 8 | 2 | 1 | 5 | 3

I want to be able to add up the values and print the name and the added
value to another text file.
There would only be about 5 values plus the name on each line.

The results would look like this:

Tom | 12
Bill   | 16
Sue  |19

Thanks in advance.

Tom





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

Date: Tue, 16 Mar 1999 00:50:43 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: how do I add values in a text delimited file?
Message-Id: <slrn7ercjn.de.alastair@calliope.demon.co.uk>

TinP <tgj@snip..net> wrote:
>Hi,
>Does anyone know how I can add the values of a text delimited file?

perldoc -f split

will take you a long way towards your goal.

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Tue, 16 Mar 1999 09:46:51 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
Subject: Re: how do I add values in a text delimited file?
Message-Id: <36EDDB33.4CE9F895@mihy.mot.com>

Maybe you can try

open(FILE, "<file") or die "cannot open file";
while(defined($line=<FILE>)) {
    chomp $line;
    @list = split(/\|/, $line);
    $name = shift @list;
    $sum = 0;
    foreach $num (@list) {
        $sum += $num;
    }
    print "$name | $sum\n"; # use another file if u like
}
close FILE;

HTH
-Partha

TinP wrote:

> Hi,
> Does anyone know how I can add the values of a text delimited file?
>
> For example the file looks like this:
>
> Tom | 2 | 2 | 3 |1 | 4
> Bill   | 3 | 4 | 2 | 1 | 6
> Sue | 8 | 2 | 1 | 5 | 3
>
> I want to be able to add up the values and print the name and the added
> value to another text file.
> There would only be about 5 values plus the name on each line.
>
> The results would look like this:
>
> Tom | 12
> Bill   | 16
> Sue  |19
>
> Thanks in advance.
>
> Tom





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

Date: Tue, 16 Mar 1999 09:46:30 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: TinP <tgj@snip..net>
Subject: Re: how do I add values in a text delimited file?
Message-Id: <36EDDB1E.8552184F@mihy.mot.com>

Maybe you can try

open(FILE, "<file") or die "cannot open file";
while(defined($line=<FILE>)) {
    chomp $line;
    @list = split(/\|/, $line);
    $name = shift @list;
    $sum = 0;
    foreach $num (@list) {
        $sum += $num;
    }
    print "$name | $sum\n"; # use another file if u like
}
close FILE;

HTH
-Partha

TinP wrote:

> Hi,
> Does anyone know how I can add the values of a text delimited file?
>
> For example the file looks like this:
>
> Tom | 2 | 2 | 3 |1 | 4
> Bill   | 3 | 4 | 2 | 1 | 6
> Sue | 8 | 2 | 1 | 5 | 3
>
> I want to be able to add up the values and print the name and the added
> value to another text file.
> There would only be about 5 values plus the name on each line.
>
> The results would look like this:
>
> Tom | 12
> Bill   | 16
> Sue  |19
>
> Thanks in advance.
>
> Tom





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

Date: Mon, 15 Mar 1999 20:24:06 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How do you create an mSQL database...
Message-Id: <comdog-ya02408000R1503992024060001@news.panix.com>

In article <01be6f33$f69dbb20$51e5b0c7@bcs.newaygo.mi.us>, "Steve Swett" <swett@ncats.net> posted:

> I've seen lots of documentation on how to Connect to a database, how to
> create/update table, how to Disconnect, etc. -- but how do you initially
> create the database?

> Can you do that outside of Perl with some kind of Unix command?  Do you
> have to do it inside a CGI script?

see the msql documentation that came with the msql server.  you'll want 
to read about the msqladmin command. 

> (My web pages are on my ISP's Unix server and their Unix expert, who went
> off to college, is no longer
> available.)

there's always http://www.hughes.com, the main site for msql.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Tue, 16 Mar 1999 02:45:26 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: John Stanley <stanley@skyking.OCE.ORST.EDU>
Subject: Re: How do you create an mSQL database...
Message-Id: <36EE0C16.A1C9FD5D@kawo2.rwth-aachen.de>

> Alex Farber  <alex@kawo2.rwth-aachen.de> wrote:
> I have yet to see a program
> >that really needs to create a database (is table not enough?)
> 
> And where do you think tables live if not in a database?

Sure, but normally you create a database manually and then let 
your scripts play with it (creating/dropping/updating tables,
making queries and so on). But like I said, what's the point 
of keeping data belonging to *one* project/problem in different 
created/dropped databases??

/Alex

--
http://www.simplex.ru/pref.html


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

Date: Tue, 16 Mar 1999 09:32:37 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: gadesign*nospam*@crl.com
Subject: Re: install perl on home dir?
Message-Id: <36EDD7DD.15C78709@mihy.mot.com>

Just get the latest version and start installing. During the 'configure'
process, when used interactively, you can set the installation path or see
the README files.

HTH
-Partha

gadesign*nospam*@crl.com wrote:

> Hello,
>
> I am wondering what file I need to edit so that I can install a version
> of perl in my home directory.. (I want to have the latest version, which
> the server does not) Thanks.





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

Date: Mon, 15 Mar 1999 22:48:46 -0600
From: Michael Fuerst <mfuerst@advancenet.net>
Subject: javascript garbler in PERL (my first perl script)
Message-Id: <36EDE2AE.2EE9E8E@advancenet.net>


I'm finishing up a perl script to obfuscate (what a funny word)
scripts embedded in html page.     (Done as a small, but
reasonably non trivial excercise to learn perl basics and
to garble a script I'm working on.)
If interested in getting a copy email me.     I tested it on
a rather large script and it seems to work well.
It will  (a) remove comments and  (b) convert  user defined
names (functions, variables
and properties) to x..... where .... is a random number.
You may specify names which you do not want encrypted.

--
If this post is a question to a newsgroup, please also reply to me
if you can.   Thanks.

Michael Fuerst
802 N Broadway
Urbana IL 61801

217 239 5844 (H)
    352 6511 (D)




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

Date: Tue, 16 Mar 1999 02:34:06 +0000
From: prauz <prauz@sprynet.com>
Subject: Makefile question
Message-Id: <36EDC31E.EB626874@sprynet.com>


Hi,

It's not really a perl question, but I'm not sure which newsgroup it
really belongs to.

I have a Makefile and what I'd like to do is remake all targets, that
depend on a set of files. In other word:  there might be a bunch of
files that are updated since the last make, but I only want to remake
the targets that are depemdant on files I specify.

Thanks,

Balazs



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

Date: 16 Mar 1999 01:00:44 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Need Faster Approach
Message-Id: <7ckafs$es1@news.service.uci.edu>

	[mailed & posted]
In article <7ck0hd$krn$1@nnrp1.dejanews.com>,
 <frogsmock@my-dejanews.com> wrote:

>However,
>what I'm hoping for is a faster way (impossible?) to get to the 75,000th item
>instead of splitting off each preceding item.

Have looked into using index()/rindex()?

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Tue, 16 Mar 1999 03:34:00 GMT
From: jsanjuan@hotmail.com
Subject: Net::Telnet + passwd + Linux
Message-Id: <7ckjf8$5q3$1@nnrp1.dejanews.com>



 Hi Everyone !

 I'm doing a script that will enable users on a Linux (Red Hat 5.0) box
 to change their passwords over the web.  To do this, I'm using Net::Telnet,
 the script will telnet to localhost, execute 'passwd' then change the
 user's password.

 What I would like to do is that when passwd says that the user has given
 a "BAD PASSWORD", I would be able to capture that error message and
 transmit that error back to the user;  How do I do that in Net::Telnet .. I
 have here a snippet from my code ..

    #  give new password
    $telnet->waitfor('/ *password: $/i');
    $telnet->print($newpass);

    #  confirm new password
    $telnet->errmode(&err_handler);

    #  see if bad password ... if this times out ..we go to the
    #  error handler (and means there was an error)
    ($prematch, $match) = $telnet->waitfor('/ *password: $/i');
    $telnet->print($newpass);

    sub err_handler  {
            #  i would like to be able to capture the error message
            #  given by passwd and relay it back to the user through
            #  the web
    }


   Thanks in advance.


   Sincerely,

   Joshua L. San Juan

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 19:31:18 -0800
From: Paul Cameron <thrase@slip.net>
To: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%);
Message-Id: <36EDD086.9A86E39@slip.net>

"Steven T. Hatton" wrote:

> Hi,
>

You asked for it, now you're going to receive 2000 or so replies.

> I'm trying to lean DBD::Informix and perl the hard way.  I am trying to
> read the test scripts that came with the package.  The one I am
> currently concerned with is InformixTest.pm, v 58.1 by Johnathan
> Leffler.   From that script I found a line that doesn't make a lot of
> sense to me:

Learn Perl the easy way. Buy The Book like everyone else did :-)

> $dbname = $dbname . '@' . $dbhost if ($dbhost && $dbname !~ m%[/@]%);

Doesn't look too bad so far. Should probably have used the .= operator
though.

> Obviously this is an assignment of a concatonated string to $dbname.
> This assignment only works if ($dbhost && $dbname !~ m%[/@]%) evalueates
> to true.  I assume that  $dbhost evaluates to true if it is declared(?)
> and non-zero.  Is this right?

Yes. If it's not declared, then if C<use strict> (or is that -w ?) is in
use, the script
will break in a run-time error (presuming $dbhost has been declared
somewhere).

Hey, I could be wrong. I didn't write the damn language.

> I also assume $dbname !~ m%[/@]%
> evaluates to true if $dbname does not match  m%[/@]%.  What I completely
> don't understand is " m%[/@]% "   What the heck does this mean?

This is using the *m*atch operator, using % signs instead of backslashes (/)
as
delimiters. This is perfectly legal.

The rest is obvious. Read perlre. Match if $dbname does not contain a
backslash and 'at' character. So it would fail for "blah@foo", "blah/foo",
but match
for "moo.dog";

Hope this helps,

Paul.



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

Date: Tue, 16 Mar 1999 09:41:11 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: "Raymond C. Jender" <rcj@lucent.com>
Subject: Re: Newby question..
Message-Id: <36EDD9DF.76A04105@mihy.mot.com>

You forgot to escape the "." in the pattern to split
use :split(/\./,"12345.678");

HTH
-Partha

Raymond C. Jender wrote:

> OK, all I'm trying to do is take a number: 12345.6789 (notice the
> decimal point)
> I want to set a variable to the number left of the decimal point.
> (12345)
> I've tried split, but apparently I'm having trouble reading the many
> tutorials and Perl
> books I've looked in. The use of split below comes right out of one of
> them.
>  (I'm sure there are a bunch of bugs in these few lines)
>
> Here is the code:
>
> #!/usr/bin/perl
> $temp=2264996672;
> $temp1=($temp/256);
> print "\n";
> print "Temp = $temp\n"; # looks good
> print "\n";
> print "Temp1 = $temp1\n"; # looks good too
> @quot = split(/./,$temp1);
> print $quot[0]; # Not good
>
> Thanks.





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

Date: Mon, 15 Mar 1999 14:02:29 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading Directory
Message-Id: <5gljc7.126.ln@magna.metronet.com>

Patrick Sinclair (ps96@ecs.soton.ac.uk) wrote:

: How can I make a perl script that acts more or less like a "dir" or "ls"
: command?


   perldoc -f opendir

   perldoc -f stat


   http://www.dejanews.com/home_ps.shtml

   search comp.lang.perl.misc for articles with 'ls' in the Subject
   find 117 matches...


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


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

Date: Mon, 15 Mar 1999 14:30:43 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading Directory
Message-Id: <35njc7.a36.ln@magna.metronet.com>

Mark Sholund (msholund@bigfoot.com) wrote:
: This is off the top of my head but I think the general idea is there.

: #!/usr/bin/perl


   You have a bug on the very first line!

   Type 'man perl' and have a look at the very first thing
   mentioned in the "BUGS" section...


: ($dir = $ARGV[0]) || ($dir = ".");


   That is more idiomatically written as:

      $dir =  $ARGV[0] || '.';

   Easier on the eyes too  :-)


: open(DIR,$dir);
  ^^^^

   opendir(DIR, $dir) || die "could not open the '$dir' directory $!";


: @files = readdir(DIR);
: print "@files\n;
: exit 0;


   There are three lines that look OK to me  :-)


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


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

Date: Tue, 16 Mar 1999 02:51:32 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Patrick Sinclair <ps96@ecs.soton.ac.uk>
Subject: Re: Reading Directory
Message-Id: <36EE0D84.B510275@kawo2.rwth-aachen.de>

Patrick Sinclair wrote:
> 
> How can I make a perl script that acts more or less like a "dir" or "ls"
> command?

Hi,

you may want to look at "Perl Power tools" project 
web page at http://language.perl.com/ppt/

/Alex

--
http://www.simplex.ru/pref.html


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

Date: Mon, 15 Mar 1999 23:23:01 -0500
From: Mark Sholund <msholund@bigfoot.com>
Subject: Re: Reading Directory
Message-Id: <36EDDCA5.B444BE38@bigfoot.com>

Like I said, it was off the top of my head.

Tad McClellan wrote:

> Mark Sholund (msholund@bigfoot.com) wrote:
> : This is off the top of my head but I think the general idea is there.
>
> : #!/usr/bin/perl
>
>    You have a bug on the very first line!
>
>    Type 'man perl' and have a look at the very first thing
>    mentioned in the "BUGS" section...
>
> : ($dir = $ARGV[0]) || ($dir = ".");
>
>    That is more idiomatically written as:
>
>       $dir =  $ARGV[0] || '.';
>
>    Easier on the eyes too  :-)
>
> : open(DIR,$dir);
>   ^^^^
>
>    opendir(DIR, $dir) || die "could not open the '$dir' directory $!";
>
> : @files = readdir(DIR);
> : print "@files\n;
> : exit 0;
>
>    There are three lines that look OK to me  :-)
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas



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

Date: Tue, 16 Mar 1999 04:14:11 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: searching a flat file database
Message-Id: <36edd5bd.83376672@news.rmi.net>

On Mon, 15 Mar 1999 00:16:29 -0800, Paul Cameron <thrase@slip.net>
wrote:

>> You need to read the perlfaq6 FAQ on this under
>> /perl/html/lib/pod/perlfaq6.html#How_do_I_efficiently_match_many_
>>
>> The AND is easy if you can keep the order the same, just link the
>> phrase in a regex that allows stuff between the words in the search.



>What do you mean ? When you say AND, you mean boolean and ? What are you and'ing together ? What
>'order' are you talking about ? What phrase are you linking ? What kind of regex are you generating ?
>Does it have any nasty exponential backtracking properties ? Do you often have conversations without
>any context whatsoever ? :-)

If %data is a tied hash of 50000 records with values of size between
500 and 50000 bytes and $s1, $s2, ... $sn are n sclalars which may be
seen in any order in any given hash value, find the fastest way to
find:

a)  the boolean AND of $s1 ... $sn where these can be in any order in
given record's value (TRUE if _all_ $s1 ... $sn are in the record in
any order)

b) the same, for boolean OR.

My current solution takes 5 to 10 seconds to search a 60 meg database
on Perl 5/Apache  running on a Pentium 200 MMX with 32 meg. Too slow
once things get really big by next year :(


>1) You have an array of words which you want matched in a string,
>   in the order the words are in the array.

Nope.

>
>2) You have an array of words, and you want all words to be matched in the
>   string

Yep.
>
>Well, you could split the string by anything not a character, stuff all the words in a hash, and check
>if each word you want searched for exists in this hash, or you could simply do what is in perlfaq6 (the
>example from MRE).
>
>Or you could look on page 181 of PCB for nice tutorial on it.
>

>But, come to think of it, you should probably already know how to do that, since you referred the other
>person to perlfaq6.
>

I want something faster. This is a BIG database that is growing by 30
megs a month. I want someting that takes phrases in quotes like
matching "John Smith" AND pencil and "ballpoint pen" when present in
the database in any order. The way I do it now is to loop through the
match for each $s1 ... $sn which is slower than I like.

Any way of just modifying the hash method to take arbitrary phrases
and combinations? At some point I suspect adding to the hash yet more
data eventually takes more time than just re-looping through another
regular expression, but I do not know really when that occurs in Perl.


And I am certain there are ways of doing this I've not yet thought of
or read about.

---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.


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

Date: Mon, 15 Mar 1999 14:13:45 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Segmentation Fault
Message-Id: <95mjc7.126.ln@magna.metronet.com>

Bill Moseley (moseley@best.com) wrote:
: In article <7cjoaa$57t$4@client2.news.psi.net>, abigail@fnx.com says...
: > Bill Moseley (moseley@best.com) wrote on MMXXI September MCMXCIII in
: > <URL:news:MPG.1155e8fabac20a339896db@206.184.139.132>:
: > !! I have a Perl CGI script that redirects STDERR to a log file.
: > !! 
: > !! I have 'Segmentation Fault' entered in my log file on a line by itself.  
: > !! No other helpful info was provided.  It doesn't show up very often.
: > !! 
: > !! Anyone know what I'm being told?  Is that a perl problem, and anything I 
: > !! can fix within my script?
: > 
: > 
: > How should we know? You don't give any information, except for a line
: > without context in soem log file.

: Well, perhaps the error looks familiar to someone else?  But I appreciate 
: the response, anyway.  I don't have any ideas either.  I'd be more 
: verbose if I could, but as I explained, it's just a message that shows up 
: on STDERR once in a while, and no other info is offered.

: I'm not doing anything odd with memory that I know of or, at least, 
  ^^^

   But maybe "somebody else" is.

   I'd take a careful look at system(), qx//, and pipe opens in
   my Perl program to see what other players are involved.


: anything that Perl complains about -- so perhaps some odd rare bug with 
: perl or Apache (it's running as a CGI script)?

: What do you do when you receive an odd error message that you don't 
: understand, that doesn't happen very often, doesn't supply any context, 
: and it's in the STDERR output from a 150K script?  


   Pray.

   (I trust you mean 150K of Perl code rather than a 150K Perl script...)


: I'm ignoring it, 
: mostly, but trying to stir up some ideas where I might look, if anywhere, 
: in my script.  Seems like clpm might be a good choice where to ask.  No?


   The p5p are pretty good at running down "core dump" type
   bugs. I would suspect perl _last_.

   Does it dump core BTW?


: Is Perl generating that message?


   The messages that perl might issue are all documented in
   the perldiag.pod man page.

   That message isn't in there, therefore it is not coming from perl.



   It is coming from the OS.

   Could be that some C code is walking off the end of an array.

   Could be any of a few dozen other things though too...


   Time to start dropping in some warn() statements here and there
   so you can start narrowing the context a bit...


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


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

Date: Tue, 16 Mar 1999 02:00:38 GMT
From: brandtr@my-dejanews.com
Subject: Re: Sendmail and Cc: field
Message-Id: <7cke01$tn$1@nnrp1.dejanews.com>

I have found that using the Mail::Sendmail module is the best tool for sending
email from Perl. I started out using a pipe to Sendmail as you are doing and
then tried the SMTP module. Sending mail has become a lot more complex than
making a socket connect to the SMTP port and using the SMTP protocol to send
mail.
Good Luck!
Rich

> Hi all, I'm trying to send email through a perl script using sendmail to
> multiple people. I'm trying to use the "Cc:" field but I only get the
> email sent to the first person on the list. Is there a sendmail resource
> on the web I don't know about? Thanks.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 16 Mar 1999 02:01:13 GMT
From: akbishop@aol.com (AKBishop)
Subject: SSI & Perl Script - Passing Variables
Message-Id: <19990315210113.29834.00000625@ngol07.aol.com>

I have a product database with status (in stock, on order, etc.) and pricing. 
We update this database regularly.  Currently, we have product pages that are
just HTML pages.  When prices change, we have to go through each changed page
and edit.  What I want to do is instead of having a hard-coded price have an
SSI that gets the price.  I can do <!--#exec cgi="/cgi-bin/products/price.pl"
-->  Then the price.pl script would load the database, grab the price and spit
it back out to appear in the HTML page.  My only problem is how to pass the SKU
to price.pl.  Each product page is /products/[some_dir]/product_sku.html  .  So
If I get ahold of the page that is calling the script via SSI, then I can get
the sku from that.  Or if I could somehow pass the sku as a variable to the
script.

This may not be the best way of doing things, but it's the only way (w/o
reformatting all the pages and my database) I can think of.

Does anyone have any ideas?

Thanks

AKBishop@aol.com


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

Date: Mon, 15 Mar 1999 22:16:59 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: SSI & Perl Script - Passing Variables
Message-Id: <comdog-ya02408000R1503992216590001@news.panix.com>

In article <19990315210113.29834.00000625@ngol07.aol.com>, akbishop@aol.com (AKBishop) posted:

> I have a product database with status (in stock, on order, etc.) and pricing. 
> We update this database regularly.  Currently, we have product pages that are
> just HTML pages.  When prices change, we have to go through each changed page
> and edit.  What I want to do is instead of having a hard-coded price have an
> SSI that gets the price.  I can do <!--#exec cgi="/cgi-bin/products/price.pl"
> -->  Then the price.pl script would load the database, grab the price and spit
> it back out to appear in the HTML page.  My only problem is how to pass the SKU
> to price.pl.  Each product page is /products/[some_dir]/product_sku.html  .  So
> If I get ahold of the page that is calling the script via SSI, then I can get
> the sku from that.  Or if I could somehow pass the sku as a variable to the
> script.
> 
> This may not be the best way of doing things, but it's the only way (w/o
> reformatting all the pages and my database) I can think of.

if the prices change infrequently, it's far better to regenerate the
page once, then serve that, rather than making the server look up
the same price every time.  you could use a template file with which 
you simply replace the price and status.

but these things have been discussed many times already :)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Tue, 16 Mar 1999 02:32:38 GMT
From: tatabu@my-dejanews.com
Subject: What is wrong with this piece of counter code?
Message-Id: <7ckfs5$2me$1@nnrp1.dejanews.com>

My counter log file gets corrupted all the time.
What is wrong with this code? I would appreciate
your help.

Thank you!

@@-->>> Soulis
tatabu@ministre.net

#################
open (LOG, "$logpath");
flock (LOG, 2);
@data = <LOG>;
flock (LOG, 8);
close(LOG);

$url = "<tr><td align=\"right\"><a
href=\"$ENV{'DOCUMENT_URI'}\">$ENV{'DOCUMENT_URI'}</a>:</td>"; $count = 0;
$pad = "%.$pad"."d"; open (LOG, ">$logpath"); flock (LOG, 2); foreach
$line(@data) {	if ($line =~ /$url/) {	$line =~ /<td>(.*)<\/td>/;  $count =
$1;  $count++;	$count = sprintf($pad, $count);  print LOG
"$url<td>$count</td></tr>\n";  }  elsif ($count == 0 && substr($line,0,8) eq
"</table>") {  $count++;  $count = sprintf($pad, $count);  print LOG
"$url<td>$count</td></tr>\n";  print LOG "$line";  }  else { print LOG
"$line"; } } flock (LOG, 8); close(LOG); ###############

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 16 Mar 1999 01:38:29 GMT
From: richb@ezl.com
Subject: Re: Where to start with Perl
Message-Id: <7ckcmk$vp8$1@nnrp1.dejanews.com>

 I learned Perl by reading the book "Learning Perl" by Randle Schwartz and
worked all the examples. Then I bought "Perl in a Nutshell". Two very good
books. If you have programmed in C, you won't have a problem picking it up. 
I was a REXX programmer in a previous life and I've programmed in C and C++.
Perl makes things much easier to do than any other language I've used. Good
Luck! Rich

> Hi,
>
> At the risk of getting smart-alec replies, does anyone have any good
> starting points for someone wanting to learn Perl.  I have a good handle
> of UNIX (awk, grep, sed), some C/C++ and have heard nothing but good
> things about Perl.  I would like to enhance my data manipulation
> capabilities and productivity among other things.
>
> Thanks in advance,
>
> ..Tom

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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