[13213] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 623 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 23 19:07:18 1999

Date: Mon, 23 Aug 1999 16:05:12 -0700 (PDT)
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, 23 Aug 1999     Volume: 9 Number: 623

Today's topics:
        "Odd number of elements in hash list" (error message) <biwillia@cisco.com>
    Re: "Odd number of elements in hash list" (error messag <sariq@texas.net>
    Re: "Odd number of elements in hash list" (error messag (Malcolm Ray)
    Re: "Odd number of elements in hash list" (error messag <biwillia@cisco.com>
    Re: $5 for 1st perl script that prints out most common  <garethr@cre.canon.co.uk>
    Re: Alt format for man pages? (Doran L. Barton)
    Re: Bizarre inconsistency <prfctbt@cris.com>
    Re: Bizarre inconsistency (Sam Holden)
    Re: Creating variables at runtime? (NOT naming a variab (Eric Bohlman)
        DBI:mysql error: install_driver (mysql) failed tjcox@my-deja.com
        DBM question (should be easy) <matt@betcha.net>
        Efficient Perl Scripting <admin@gatewaysolutions.net>
    Re: Efficient Perl Scripting <garethr@cre.canon.co.uk>
    Re: email address verification <cassell@mail.cor.epa.gov>
        file merged b_lucas@my-deja.com
    Re: GDBM Access in Perl <cassell@mail.cor.epa.gov>
        How to use a module???? <rcortes@alumnos.utfsm.cl>
    Re: lists and commas <makkulka@cisco.com>
    Re: lists and commas (Jeff)
    Re: lists and commas <cassell@mail.cor.epa.gov>
        Mulitple calls to the same perl script <sjfox@email.sjsu.edu>
    Re: Multi line pattern match <cassell@mail.cor.epa.gov>
    Re: Newbie IO::Socket question <admin@gatewaysolutions.net>
    Re: newbie,to loops,need simple ex. <cassell@mail.cor.epa.gov>
        newbie: need help,LEARNING FROM A BOOK zev0@my-deja.com
    Re: path to Absolute paths? <cassell@mail.cor.epa.gov>
        Perl e-mail handler <tonyboy@earthling.net>
    Re: Perl e-mail handler (Greg Bacon)
    Re: Recursing through directory headache (Ilya Zakharevich)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Mon, 23 Aug 1999 16:31:13 -0400
From: Bill Williams <biwillia@cisco.com>
Subject: "Odd number of elements in hash list" (error message)
Message-Id: <37C1AF91.4996CDC6@cisco.com>

Other than turning off "-w", is there a way to resolve this error
message?

Is this informational or is it actually telling me something useful
about my
hash list? (There really aren't an odd number, btw; it's an even
number).

-b



--
Thanks,
__________________________
Bill Williams
ERP Systems Administrator
Cisco Systems - RTP-IS





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

Date: Mon, 23 Aug 1999 15:56:33 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: "Odd number of elements in hash list" (error message)
Message-Id: <37C1B581.82EA0A00@texas.net>

Bill Williams wrote:
> 
> Other than turning off "-w", is there a way to resolve this error
> message?

Did you try it without '-w'?  What version of Perl?
 
> Is this informational or is it actually telling me something useful
> about my
> hash list?

Did you look in perldiag?

> (There really aren't an odd number, btw; it's an even
> number).

I don't believe you; however, if it really is even, then you've found a
bug.  You should report it.  Perhaps you should post code that
illustrates the problem.

- Tom


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

Date: 23 Aug 1999 21:23:12 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: "Odd number of elements in hash list" (error message)
Message-Id: <slrn7s3eu0.udl.M.Ray@carlova.ulcc.ac.uk>

On Mon, 23 Aug 1999 16:31:13 -0400, Bill Williams <biwillia@cisco.com> wrote:
>Other than turning off "-w", is there a way to resolve this error
>message?

Yes: fix the bug in your program!

>Is this informational or is it actually telling me something useful
>about my
>hash list? (There really aren't an odd number, btw; it's an even
>number).

Wanna bet?

First, when you get an error or warning message which you don't understand,
always consult perldiag.  But in this case it won't tell you much that
you don't already know.

You'd better believe Perl: if it says that there are an odd number of
elements in a hash assignment, there *are*.  But, depending on what
version of Perl you're running, it's easy to get this result from
a simple typo in the assignment.  If you're sure that you have an
even number of elements in the offending assignment, you may be making
one of the mistakes illustrated below:

$ cat hh
#!/usr/bin/perl -w

use strict;

my %a = [ 'a' => 'b' ];         # wrong
my %b = { 'a' => 'b' };         # wrong
my %c = ( 'a' => 'b' );         # right

__END__

$ ./hh
Odd number of elements in hash list at ./hh line 5.
Odd number of elements in hash list at ./hh line 6.
$ perl -v

This is perl, version 5.004_04 built for sun4-solaris

You can probably figure out what the two wrong lines are doing.  If not,
read perlref.  Later versions of Perl give a slightly more descriptive
warning message in these cases.

-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Mon, 23 Aug 1999 17:55:54 -0400
From: Bill Williams <biwillia@cisco.com>
Subject: Re: "Odd number of elements in hash list" (error message)
Message-Id: <37C1C369.8B693468@cisco.com>

Tom Briles wrote:

> Bill Williams wrote:
> >
> > Other than turning off "-w", is there a way to resolve this error
> > message?
>
> Did you try it without '-w'?  What version of Perl?
>
> > Is this informational or is it actually telling me something useful
> > about my
> > hash list?

Yes. Tried it without -w and it works without error messages - this is
Perl 5.005_03.

I would have been more concerned about this if the program wasn't doing
what
I wanted it to.  In other words, everything "appears" to works like it
should ... So obviously,
I am doing something wrong in my hash reference but it is not apparent to
me.

At the risk of appearing more inept, here is my logic. Open a text file
that has parameters in it like :

value1 = filename

then

----pseudo - code ------

while (<PFILE>){
        chomp;
            %parvals = split('=',$_);
            %parameters = (%parameters, %parvals);
    }
    $value1 = $parameters{value1};

----end pseudo-code-----

print $value1  prints "foo".

I guess I am going about this all wrong... what I really want is the
second column of values, so that I can  assign them properly.

Anyway....I will look at this again.

-b








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

Date: Mon, 23 Aug 1999 20:16:02 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: $5 for 1st perl script that prints out most common phrases
Message-Id: <siso5aw8vx.fsf@cre.canon.co.uk>

kragen@pobox.com (Kragen Sitaker) wrote:
> Here's a Perl script that will print all the N-word phrases in
> something, sorted by frequency.

It's easy to count phrases of various lengths simultaneously, perhaps
something like this:

    $MIN_WORDS = 2;   # Shortest phrase to count
    $MAX_WORDS = 20;  # Longest phrase to count
    $MIN_COUNT = 2;   # Number of occurrences to merit output

    @words = ('') x $MAX_WORDS;

    while (<>) {
      foreach (split) {
	shift @words;
	push @words, $_;
	foreach ($MIN_WORDS .. $MAX_WORDS) {
	  ++ $count{join ' ', @words[-$_ .. -1]};
	}
      }
    }

    printf "%5d  %s\n", $count{$_}, $_ foreach
      reverse sort { $count{$a} <=> $count{$b} }
      grep { $count{$_} >= $MIN_COUNT }
      reverse sort keys %count;

As an aside, the original poster's offer of money was out of order.
clpm is not a suitable agency for matching contractors with clients.
(And in any case, who'd take on a contract for $5?)

-- 
Gareth Rees


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

Date: 23 Aug 1999 17:04:06 -0600
From: fozz@xmission.xmission.com (Doran L. Barton)
Subject: Re: Alt format for man pages?
Message-Id: <7psk16$6nm$1@xmission.xmission.com>

deane_barker@my-deja.com writes:

>Is there anyway I can get the PERL man pages in
>some kind of word-processing format, like .DOC or
>.WPD, or even .RTF?

>I'm trying to print them out in HTML, but there
>just too much information to make it manageable.

Blasphemy! 

No really, the solution to this is simple: Use your browsers "Save As"
feature to save the file as HTML. Most word processing applications (even
the evil one) will import HTML. Then you can do whatever the hell you want!
:-)

-=Fozz

-- 
Doran L. Barton = fozz@xmission.com && http://www.xmission.com/~fozz/
** Dynamic web developer, Perl hacker.  Using the Internet since 1990. **
 "I have learned much more about Microsoft by using the Linux operating 
  system than I ever would have done by using Windows." - Neal Stephenson


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

Date: Mon, 23 Aug 1999 13:50:32 +0000
From: Perfect Beat <prfctbt@cris.com>
Subject: Re: Bizarre inconsistency
Message-Id: <37C15188.9AE5AF71@cris.com>

Thanks for your input Martien, however,I have already eliminated those
possibilities.




># no need to escape the . Besides, why do you escape one ., but not
># the other?
>my $fn = "./Html/new_releases/nr$old_date_fields[0]\.html";
>open(NR_NEW_RELEASES, ">$fn") || die "Cannot open $fn for write: $!";


As far as escaping the period, I found that was necessary to delimit the
end of the variable that begins with $, since the period and what
follows is not part of the variable name.



>Maybe this will give you some info on what is going wrong, and why.
>Maybe one of the directories you are trying to access doesn't exist.
>Maybe you program is running in a different place than you think it
>is, and maybe you should use absolute rather than relative paths. Who
>knows?

I have substitues other variable (including ones explicitly defined as
the value the my variable is assigned) and there is no problem. So I do
not think that this is a directory problem.



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

Date: 23 Aug 1999 21:47:56 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Bizarre inconsistency
Message-Id: <slrn7s3gdh.g9p.sholden@pgrad.cs.usyd.edu.au>

On Mon, 23 Aug 1999 13:50:32 +0000, Perfect Beat <prfctbt@cris.com> wrote:
>Thanks for your input Martien, however,I have already eliminated those
>possibilities.
>
>
>
>
>># no need to escape the . Besides, why do you escape one ., but not
>># the other?
>>my $fn = "./Html/new_releases/nr$old_date_fields[0]\.html";
>>open(NR_NEW_RELEASES, ">$fn") || die "Cannot open $fn for write: $!";
>
>
>As far as escaping the period, I found that was necessary to delimit the
>end of the variable that begins with $, since the period and what
>follows is not part of the variable name.

No you didn't, because it isn't. 

>>Maybe this will give you some info on what is going wrong, and why.
>>Maybe one of the directories you are trying to access doesn't exist.
>>Maybe you program is running in a different place than you think it
>>is, and maybe you should use absolute rather than relative paths. Who
>>knows?
>
>I have substitues other variable (including ones explicitly defined as
>the value the my variable is assigned) and there is no problem. So I do
>not think that this is a directory problem.

Then the variable does not have the value you think it has.

Do what was suggested and see what the error message is.

-- 
Sam

The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
	--Larry Wall


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

Date: 23 Aug 1999 22:58:14 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Creating variables at runtime? (NOT naming a variable as a string)
Message-Id: <7psjm6$ci3@dfw-ixnews6.ix.netcom.com>

Gary M. Greenberg (gary3g@my-deja.com) wrote:
: If I don't know how many variables I will need for any unpack
: statement, is there a way to automatically generate them,
: (perferably as an array of variables) at runtime?

Just unpack into an array (if you want to be able to refer to the 
elements by position) or a hash slice (if you want to be able to refer to 
them by name).



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

Date: Mon, 23 Aug 1999 21:01:14 GMT
From: tjcox@my-deja.com
Subject: DBI:mysql error: install_driver (mysql) failed
Message-Id: <7pscqe$mf7$1@nnrp1.deja.com>

Hello!

I am taking over a system which has
FreeBSD 2.22
MySQL 3.22.16 (binary dist. for FreeBSD)
DBI 1.06
DataDumper 2.10
DataShowTable 3.3
Msql-Mysql-modules 1.2017
Perl 5.004

and trying to get a web application to access the Mysql db.
All command line and mysql utilities work fine.  Perl itself
works fine.

But.......

when attempting to connect in the perl code it gives the following error
during the

dbh$->connect("DBI:mysql:$mydb",.....

-----------
install_driver(mysql) failed: Can't load
'/usr/local/lib/perl5/site_perl/i386-fr eebsd/auto/DBD/mysql/mysql.so'
for module DBD::mysql: Undefined symbol "___sstderr" in
perl:/usr/local/lib/perl5/site_perl/i386-
freebsd/auto/DBD/mysql/mysql.so
at /usr/local/lib/perl5/i386-freebsd/5.004/DynaLoader.pm line 155.

 at (eval 1) line 2

 at test.cgi line 36
-----------

Upon reviewing many a posting by you guys and searching the
documentation, mainly the README in the Msql-Mysql-modules directory
these are what we have looked into:

1.  The README suggests this error is caused by Perl being compiled in
something other than gcc.  We have checked our perl (perl -V) and it
looks as if gcc (version 2.7.2.1) was used during compilation.  It
assures us that Binary distributions of Mysql are done in gcc.  Thus,
this doesn't seem to be the problem.

2.  Other documentation, here, stated a solution was to go to the Msql-
Mysql-modules directory and recompile (tar,perl Mak.., make, make test,
 ..).  This did not work and further the make test gives us the same
error.

3.  We have tried the newer version Msql-Mysql-modules-1.2200.tar.gz
and this gave us the same error.

Help??
Does anyone have suggestions or seen this before?

The next step we can think of is to get the newest versions of gcc,
Perl, Mysql and on down the line and hope it works, but there must be a
way to fix this.

Thanks in advance,
TJ


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 23 Aug 1999 16:15:52 -0400
From: "Matt Baker" <matt@betcha.net>
Subject: DBM question (should be easy)
Message-Id: <7psa7m$9oa$1@autumn.news.rcn.net>

Here is what my books says to do to tie a HASH to a database on the Win32
platform.  (The code below is a direct pull from the book)
use Fcntl;
use SDBM_File;
tie %hash, "SDBM_File", 'data',O_RDWR|O_CREAT|O_EXCL,0644;
$hash{drink}='root beer';
untie %hash;

When I run this code it creates two files:  data.dir and data.pag  .
The problem is that although it creates the database files, it fails to put
any data in either of them.  They are 0kb in length.
What do I need to do to make this work?
Thanks...
matt





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

Date: Mon, 23 Aug 1999 15:08:43 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Efficient Perl Scripting
Message-Id: <rs3ae4v75u295@corp.supernews.com>

I just have a few questions about how to make
my programs more efficient.
I am self taught and have never seen the inside
of a perl programming classroom so be easy on
me. =)

Which is the most efficient loop for iterating through
an array(for, foreach, while)?
How does eval affect the speed and or efficiency of
a script?
What kind of a difference does BEGIN make?

If you know of a reference that will help me learn these
facts that would help tremendously.

Thanks,
Scott



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

Date: Mon, 23 Aug 1999 20:38:23 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: Scott Beck <admin@gatewaysolutions.net>
Subject: Re: Efficient Perl Scripting
Message-Id: <sipv0ew7uo.fsf@cre.canon.co.uk>

Scott Beck <admin@gatewaysolutions.net> wrote:
> I just have a few questions about how to make my programs more
> efficient.

The general approach to making programs efficient is the same for any
language.

First, don't worry too much about efficiency unless efficiency is an
important requirement of the system you're developing.  There are many
things that you can better spend your time on than efficiency
(e.g. reliability, robustness, portability, maintainability,
documentation).

Second, when efficiency turns out to be a concern, use a profiler to
find the bottlenecks.  (In Perl, use Devel::DProf.)

Third, a better algorithm will repay effort much more than local
tinkering with the code.  (For example, if you're computing the same
thing many times, can you memoize the function or pre-compute a table of
values?  If you're spending a lot of time reading and writing data to
the file system, can you find a way to keep the data in memory and batch
file system accesses?)

See the "Performance" chapter in "The Practice of Programming" by
kernighan and Pike.

Some Perl-specific remarks follow:

Perl is a language that is best used when programmer time is scarce and
system resources are plentiful.  I think that it's a poor choice in
other situations.  Consider Fortran for numeric algorithms and C for
system programming.  SWIG or XS can be used to glue foreign functions
into Perl modules.

Perl runs fastest when you're running "in core" as much as possible:
that is, getting the byte-code interpreter to do as much work as
possible.  This means that `foreach' and `grep' will run faster than
explicit iteration; that regular expressions, `split' and `tr' will run
faster than explicit character-by-character manipulation; that a hash
lookup will run faster than a search of another data structure.

-- 
Gareth Rees


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

Date: Mon, 23 Aug 1999 15:21:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: email address verification
Message-Id: <37C1C968.E2BB8E92@mail.cor.epa.gov>

Paul Falardeau wrote:
> 
> Hello,
> 
> I know I've seen this posted to this list before, but I just can't find
> it.

Well, you could go to deja.com and search for it.  I prefer
    http://www.deja.com/=dnc/home_ps.shtml
to avoid as much of their trashy interface as possible.
 
> Can somebody please post a snippet of code which will check the validity
> of an email address?  For example I want to return an error if someone
> enters something like jsmith@aol rather than jsmith@aol.com

[1] jsmith@aol is a legal e-mail address
[2] It is virtually impossible to do this, since there are
valid e-mail addresses which are not legal according to the
specs (hey, don't blame me!), and invalid e-mail addresses
which are technically legal.  For example, the following
is a real, legal e-mail address: *@qz.to  Really!  It belongs
to Eli The Bearded, who has posted in this ng on occasion.
However, Elmer_Fudd@aol.com may or may not be an actual
e-mail address, since you can't tell just from looking at it.
[3] If you check the archives at deja.com, you'll see this
has been beaten to death.
[4] Jeffrey Friedl wrote a regex to do this properly, and it
is about 4700 bytes long.
[5] At CPAN there is a script by Tom Christiansen which does
its level best to check that an address is legit and also
has an owner.  You might look into that program.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 21:13:40 GMT
From: b_lucas@my-deja.com
Subject: file merged
Message-Id: <7psdhn$mvf$1@nnrp1.deja.com>

i am trying to write a routine to take 2 inputs and merge it in a third
file. one line of each under the other. i am new to perl, so probably i
am doing it all wrong.  here is:
#!/usr/bin/perl -w
use strict;
$argnum = @ARGV;
if ($argnum < 2 || $argnum > 2) {
  print("Enter input filename:");
  $in = <STDIN>;
  chop($in);
  print("Enter output filename:");
  $out = <STDIN>;
  chop($out);}
else {
  $in = shift(@ARGV);
  $out = shift(@ARGV);}

open(inf, "$in") || die("Can't open input file:$!\n");
open(outf,">$out") || die("Can't open ouput file:$!\n");

my $in = <inf>;
my $out = <outf>;
while (defined($in) || defined($out)) {
    if (defined($in)) {
        print MERGE $line1;
        $in = <inf>;
    }
    if (defined($line2)) {
        print MERGE $line2;
	    $out = <outf>;
	}
}


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 23 Aug 1999 15:30:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: GDBM Access in Perl
Message-Id: <37C1CB8F.23F0ED72@mail.cor.epa.gov>

Jim Turner wrote:
> 
> First off, I appreciate the help so far... I'm further now, but either I'm
> missing something pretty fundamental here or I'm just not seeing the
> obvious.

Or perhaps the location of the docs is just not obvious
except to the already-informed.  Look at the perltie manpage.
Type this at a command prompt:
    perldoc perltie

[snip]
> modules.  There are routines that I seen talked about, but there are never any
> examples or futher discussion of them except what they are supposed to do.
> FETCH, STORE, DELELE, EXISTS... how does one use these?  Perl

You'll find the discussion you're looking for on these 
functions, along with helpful code.  If you want more,
go to www.perl.com, pick out the 'search' facility,
and enter 'database' or 'tie' or whatever terms seem
more relevant to you.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 06:16:19 -0400
From: Rodrigo =?iso-8859-1?Q?Cort=E9s?= <rcortes@alumnos.utfsm.cl>
Subject: How to use a module????
Message-Id: <37C11F73.7E4C2568@alumnos.utfsm.cl>

I have a perl script that need a module (Size.pm) but the server does'nt
support it..
How i can use this module???



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

Date: Mon, 23 Aug 1999 12:59:29 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: lists and commas
Message-Id: <37C1A821.627ABF7F@cisco.com>

[ Jeff wrote:

> I'm having trouble assigning a group of numbers to a list because some of
> the numbers contain formatting commas

use Text::CSV
--



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

Date: Mon, 23 Aug 1999 16:20:56 -0500
From: oshram@bells.net (Jeff)
Subject: Re: lists and commas
Message-Id: <oshram-2308991620560001@dfwms2.conspiracy.net>

In article <37C1A821.627ABF7F@cisco.com>, Makarand Kulkarni
<makkulka@cisco.com> wrote:

> > I'm having trouble assigning a group of numbers to a list because some of
> > the numbers contain formatting commas
> 
> use Text::CSV

I installed and looked at the docs for Text::CSV and it doesn't appear to
do what I want.  The values are not separated by commas - some values over
999 contain commas in between the digits which itself is the whole number
e.g.:
refer to the original post for more detailed info

$8,999.00  - I want to get 8999.00

-- 
jeff


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

Date: Mon, 23 Aug 1999 15:51:21 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: lists and commas
Message-Id: <37C1D069.A5409E1A@mail.cor.epa.gov>

Jeff wrote:
> 
> In article <37C1A821.627ABF7F@cisco.com>, Makarand Kulkarni
> <makkulka@cisco.com> wrote:
> 
> > > I'm having trouble assigning a group of numbers to a list because some of
> > > the numbers contain formatting commas
> >
> > use Text::CSV
> 
> I installed and looked at the docs for Text::CSV and it doesn't appear to
> do what I want.  The values are not separated by commas - some values over
> 999 contain commas in between the digits which itself is the whole number
> e.g.:
> refer to the original post for more detailed info
> 
> $8,999.00  - I want to get 8999.00

Well, this is what you had before:
    my @Items = m/\$(\d+\.\d+)/sg;

Without seeing the data I can't venture on how optimal this is.
But, assuming it is in the ballpark, you could just make this
change:

    my @Items = m/\$([,\d]+\.\d+)/sg;

That will read in $8,999.00 and give you 8,999.00 
which you could strip of commas later if you wanted to:

    @Items = map { tr/,//d } @Items;

However, it would also grab a sequence like $1,2,3,4,5.67
which you may not want.  So, if your data can have such
peculiarities in it, you'd need a more complex regex.
Something like:

    m/\$(\d{1,3}(?:,\d{3})*\.\d{2})/sg;

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 14:18:05 -0700
From: "Stephanie Fox" <sjfox@email.sjsu.edu>
Subject: Mulitple calls to the same perl script
Message-Id: <7psdqc$e3q$1@hades.csu.net>

I have a web form that calls a perl script. It is very likely that several
people submit the form at the same time. About 1 out of 50 times that
someone tries to apply, they get a 'Bad Request' error, and the script is
not called.

Is that because the script is in use?

Is there a way around this?

Thanks,
Stephanie




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

Date: Mon, 23 Aug 1999 15:13:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Multi line pattern match
Message-Id: <37C1C78D.327135EA@mail.cor.epa.gov>

Brian wrote:
> 
> I am having problems writing a regex to remove a multiline XML comment that
> looks like this
> 
> <MY-DOC><!--
> 
> CONVERTING SOURCE FILE bla bla bla
> 
> --><SECTION><STITLE>..... and so on
> 
> What I want to do is remove the XML comment. I know how to open the file etc
> etc, but can't seem to write a regex for the comment since it spans multiple
> lines. I have tried to use the /m and /s modifiers such as outline in the
> Perl Cook Book on page 173 but I still  can't seem to get it to work. Any
> insight would be greatly appreciated.

Well, without seeing your regex [and the code that gets
your XML into shape for the regex], it's pretty hard to 
guess what you're doing wrong.  

But arbitrary chunks of XML are too complicated for a 
little regex.  You ought to look into the XML::Parser 
module for general work.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 15:57:34 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Re: Newbie IO::Socket question
Message-Id: <rs3d9n8u5u263@corp.supernews.com>

Try this

 #!/usr/bin/perl
 use IO::Socket;

 $sock = new IO::Socket::INET (PeerAddr => 'jedi',
                               PeerPort => 6666,
                               Proto    => 'tcp',
                              );
 die "Socket could not be created. Reason: $!\n" unless $sock;
print $sock "Msg $_: How are you?\n\n";
@sock=(<$sock>);
close($sock);
print "Here is my response\n\n";
print @sock;
exit;
MN <mnarvaja@geocities.xyz.com> wrote in message
news:37C17747.DFF5E9F3@geocities.xyz.com...
> Hi,
> I'm using the IO module for socket connections. And I'm having some
> problems to resolve a simple client/server problem.
> I wrote a client and a server programs for send, receive and reply
> messages. And I can't make client program receive the answer from the
> server one. These are the codes :
>
> Client:
> #!/usr/bin/perl
> use IO::Socket;
>
> $sock = new IO::Socket::INET (PeerAddr => 'jedi',
>                               PeerPort => 6666,
>                               Proto    => 'tcp',
>                              );
> die "Socket could not be created. Reason: $!\n" unless $sock;
>
> foreach(1..10) {
>     $sock->send("Msg $_: How are you?\n");
>     $sock->recv($buf,100);
>     print "$buf\n";
> }
> close($sock);
>
>
> Server:
> #!/usr/bin/perl
> use IO::Socket;
> $SIG{CHLD} = sub {wait ()};
> $main_sock = new IO::Socket::INET (LocalHost => 'jedi',
>                                    LocalPort => 6666,
>                                    Listen    => 5,
>                                    Proto     => 'tcp',
>                                    Reuse     => 1,
>                                   );
> die "Socket could not be created. Reason: $!\n" unless ($main_sock);
>
> while ($new_sock = $main_sock->accept()){
>     $pid = fork();
>     die "Cannot fork: $!" unless defined($pid);
>     if ($pid == 0){
>         print "*** Child process begins\n";
>         while (defined ($buf = <$new_sock>)){
>             print ">>> $buf";
>             print $new_sock "You said: $buf\n";
>         }
>         print "*** Child process ends\n\n";
>         exit(0);
>     }
> }
> close($main_sock);
>
>
> Does anyone have any idea or workaround?
>
> Thanks in advanced,
> Marcelo
> mnarvaja@geocities.com
>
>
>
>
>



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

Date: Mon, 23 Aug 1999 15:27:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie,to loops,need simple ex.
Message-Id: <37C1CABD.6A54C4CD@mail.cor.epa.gov>

Ben Horowitz wrote:
> 
> need simple explanation,about loops

I think that you may benefit from the web tutorial at
    http://www.netcat.co.uk/rob/perl/win32perltut.html

The concept of 'loops' is so fundamental in computer
programming that almost all texts will assume you already
know about working with loops in some computer language
or other.  You may need to find an absolute-beginner
comp-sci text in some used book store.  I hope you
don't find this rude, but you'll really need to learn
about such concepts as arrays, loops, indices, regular
expressions, associative arrays, control statements,
etc., before you'll get much out of many Perl books.
And you'll have to learn something about the concepts
of OSes before a lot of the Perl material on sockets,
forking, etc., make much sense.  You'll probably want 
to learn about the CGI spec and HTTP so that you can
grok the Perl modules for writing better CGI scripts
too.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 21:09:39 GMT
From: zev0@my-deja.com
Subject: newbie: need help,LEARNING FROM A BOOK
Message-Id: <7psda7$mr8$1@nnrp1.deja.com>

I dont understand the concepts, of perl,when do you use " this and when
do you use 'this,.?2.) what means,exponentation,?and precedence?in
simple jargon,even a newbie will understand,. am learning from the book
perl 5 interactive course,i hope i can do it, with the communitys WEB
help!does any perl programmer want to help me with corresponding
through e-mail,?if i have any questions?on my journy,to become a perl,
programmer,! THANK YOU!!!!!!






Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 23 Aug 1999 15:09:55 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: path to Absolute paths?
Message-Id: <37C1C6B3.25ABD8C5@mail.cor.epa.gov>

Joonas Timo Taavetti Kekoni wrote:
> 
> Who can i do this in perl?
> shell $ cd /usr/bin ; pwd
> /1/usr/bin
> shell $ cd ~jkekoni ; pwd
> /1/home/jkekoni

Try typing this at a command prompt:

    perldoc -f chdir

Perl has a chdir() built in.  It won't automatically handle
the tilde as your home directory, since that is a function
of the shell, not your 'cd'.  But you can fake it if you
want to.
 
> if i just
> glob "/usr/bin" i get "/usr/bin".

That's right.  glob() is *not* a change-directory
command.  glob() does filename expansions.
 
> I know i can do it using the shell:
> $t='cd $foo;pwd ';

I assume you meant to put backticks in that statement.
That won't change the current directory of the process
from which you called it.

You may also want to look at the Cwd module.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 23 Aug 1999 18:17:46 -0400
From: "Anthony Lalande" <tonyboy@earthling.net>
Subject: Perl e-mail handler
Message-Id: <7pshac$5tv@tandem.CAM.ORG>

Greetings.

Can anyone tell me if there is a way to automatically invoke a perl
script to read a mail file (/var/spool/mail/) as soon as the file gets
writen to? (ie: incoming mail has been received)

Please reply directly to my e-mail address.

Thank you,
- Anthony L.


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

Date: 23 Aug 1999 22:38:01 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Perl e-mail handler
Message-Id: <7psig9$im0$1@info2.uah.edu>

In article <7pshac$5tv@tandem.cam.org>,
	"Anthony Lalande" <tonyboy@earthling.net> writes:

: Can anyone tell me if there is a way to automatically invoke a perl
: script to read a mail file (/var/spool/mail/) as soon as the file gets
: writen to? (ie: incoming mail has been received)

Instead of doing it that way, you might consider arranging for your MTA
to deliver incoming messages to your program.

What's your Perl question?

Greg
-- 
You can go a long way with a smile.  You can go a lot farther with a
smile and a gun.
    -- Al Capone


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

Date: 23 Aug 1999 20:26:33 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Recursing through directory headache
Message-Id: <7psapp$5i4$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Sean McAfee
<mcafee@waits.facilities.med.umich.edu>],
who wrote in article <Bx4w3.2798$J72.556228@news.itd.umich.edu>:
> >> >Well, it is me who wrote a significant part of the code you discuss.
> >> >And there is a lot of reason why not.
> 
> >> Okay, I give up.  Why not?
> >> I tested the code I posted, and it appeared to work as advertised.
> 
> >Effectively, you are iterating through a hash, while changing the
> >hash.  See
> >  perldoc -f each
> >on hints.
> 
> I don't see how.  Each time File::Find scans a directory, it slurps the
> entire contents into an array at once:
> 
> sub finddir {
> 	# ...
>     # Get the list of files in the current directory.
>     opendir(DIR,'.') || (warn("Can't open $dir: $!\n"), $bydepth || return);
>     my(@filenames) = readdir(DIR);

Me wrong, you right.  A lot of apologies...

The only excuse I have is that I expected that File::Find would behave
in a civilized way, but apparently the initial algorithm was optimized
for small directories.  And I wonder what is the threshold when
reading entries one-by-one would actually be more advantageous?

I would think that the current algorithm would not be able to handle
10mil entries or more.  But on a typical primitive Unix file system
you will not be able to create such a directory...  And my OS/2
machines have HPFS file systems, which do not handle directories with
100000 files well, you need HPFS386 for this...

Ilya


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 623
*************************************


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