[11634] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5234 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 26 12:07:27 1999

Date: Fri, 26 Mar 99 09:00:21 -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           Fri, 26 Mar 1999     Volume: 8 Number: 5234

Today's topics:
    Re: 'use'  or 'include' ? (Tad McClellan)
    Re: 'use'  or 'include' ? (Abigail)
    Re: Calculating the current time in London or GMT+x (Larry Rosler)
        comparing arrays <dwaller@precisiondrive.com>
        Currency Parsing <peter_yang@groton.pfizer.com>
    Re: Currency Parsing <jacklam@math.uio.no>
    Re: Currency Parsing <vince@oxxfordinfo.com>
    Re: Date/Time calculation: % through current month? <skilchen@swissonline.ch>
    Re: Date/Time calculation: % through current month? (Bill Moseley)
    Re: Date/Time calculation: % through current month? <skilchen@swissonline.ch>
        Dynamic images in web page question holbrng@thiokol.com
    Re: Help please - can't open .pl file <tavi367@ibm.net>
    Re: HELP: Confused about Hash Table. (Tad McClellan)
        How do I use POST from an HTML form (Jason L. James)
    Re: How to know that a pipe opened for writing is broke (Z. Todd Taylor)
    Re: MS Personal Web Server <tavi367@ibm.net>
        Obj: Help A beginner (should be a simple error) <olivier.maas@at-lci.com>
        Perl and Databases on NT. Which module to use (EXCHANGE:BRW2:S901)
    Re: Perl Error DBI.pm in @INC (Tad McClellan)
        Problem about REGULAR EXPRESSION (Ryan Ngi)
    Re: problem by using PERL & MySQL via DBI (Steve Linberg)
    Re: Q: how to evaluate a $var in a file you are reading (Tad McClellan)
    Re: regular expression <borger@ix.netcom.com>
    Re: Running a perl script as a daemon.... not_here@my-dejanews.com
        search .pl file, where I can send email for Win32 over  <designo@gmx.net>
        SRC: pvdb, a vi-aware front-end for the perl debugger <tchrist@mox.perl.com>
        Sys independent "Tue, 20 Aug 1996 14:25:27 GMT" ? (Jari Aalto+mail.perl)
    Re: Sys independent "Tue, 20 Aug 1996 14:25:27 GMT" ? (Larry Rosler)
    Re: Sys independent "Tue, 20 Aug 1996 14:25:27 GMT" ? (Jari Aalto+mail.perl)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 26 Mar 1999 04:09:07 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: 'use'  or 'include' ?
Message-Id: <jrifd7.p71.ln@magna.metronet.com>

Alexandre (alrope@zaz.com.br) wrote:

:  Please, wich is the difference between 'use'  and 'include' comands.


   'use' is a Perl keyword, and 'include' is not.

   So the difference between them is moot, as you can only 
   use one of them in Perl programs   :-)


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


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

Date: 26 Mar 1999 16:53:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: 'use'  or 'include' ?
Message-Id: <7dge2q$gbi$2@client2.news.psi.net>

Alexandre (alrope@zaz.com.br) wrote on MMXXXIII September MCMXCIII in
<URL:news:7detda$9mv$1@srv4-poa.nutecnet.com.br>:
-- Friends,
--
--  Please, wich is the difference between 'use'  and 'include' comands.


Easy. "use" is a Perl function, "include" isn't.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: Fri, 26 Mar 1999 08:42:59 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Calculating the current time in London or GMT+x
Message-Id: <MPG.116558e37c7888f49897d4@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7dfmfp$480$1@solti3.sdm.de> on 26 Mar 1999 10:11:05 GMT, 
Steffen Beyer <sb@sdm.de >says...
> In article <36FA5AD1.3EEE2C9@soton.sc.philips.com>,
>      Neil Johnson <neil.johnson@soton.sc.philips.com> wrote:
> > Californian daylight saving , I believe is very similar to British and
> > European daylight saving. The only difference is that in Britain and
> > Europe the clocks go forward a week earlier than California (28th March).
> > The clocks go back on the same date.
> 
> AFAIK, DST begins and ends also in the middle of a week in the U.S.
> 
> In Europe, however, switching always occurs on a weekend, in the night
> from saturday to sunday, at 2 o'clock (respectively, 3) in the morning.

AFAIK (and I *do* know, because I live there), DST in North America 
begins and ends on Sunday at 2 AM, becoming 3 AM (spring) or 1 AM (fall) 
respectively.  This year it is 4 April and 31 October.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 26 Mar 1999 08:20:58 -0600
From: Dave Waller <dwaller@precisiondrive.com>
Subject: comparing arrays
Message-Id: <36FB97CA.188649FA@precisiondrive.com>

I have two arrays that are built from a db querry that I
want to compare to several other arrays to find a closest
fit match.

The data is all floats and in a 8 X 8 array.  The data is 0
- 1 non-inclusive.

I have thought about several schemes to find the closest
match but they are all cumbersome.

Any sugestions??
-- 
Dave Waller
Precision Drive and Control

Distress, n.:
	A disease incurred by exposure to the prosperity of a
friend.
		-- Ambrose Bierce, "The Devil's Dictionary"


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

Date: Fri, 26 Mar 1999 09:05:30 -0500
From: Petet Yang <peter_yang@groton.pfizer.com>
Subject: Currency Parsing
Message-Id: <36FB942A.5679@groton.pfizer.com>

Hi. 


I have just started to use Perl for a short time. I tried to parse a
currency number, like $100. However, $ sign is a reserved word for Perl.
How can I escape this sign to get the number?? Need help!

Code:
>$str = "$100";
>print $str;

It displays nothing.


Thanks,


Peter Yang

petery77@aol.com


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

Date: Fri, 26 Mar 1999 15:53:17 +0100
From: Peter John Acklam <jacklam@math.uio.no>
Subject: Re: Currency Parsing
Message-Id: <36FB9F5D.BC3737AE@math.uio.no>

Petet Yang wrote:
> 
> Code:
> >$str = "$100";
> >print $str;
> 
> It displays nothing.

Use 

    $str = '$100';

or

    $str = "\$100";

Peter

-- 
Peter J. Acklam - jacklam@math.uio.no - http://www.math.uio.no/~jacklam



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

Date: Fri, 26 Mar 1999 15:20:37 GMT
From: "Vincent P. Mautone" <vince@oxxfordinfo.com>
Subject: Re: Currency Parsing
Message-Id: <9BNK2.65186$rs2.18847424@client.news.psi.net>

Hi,

 $str = "\$100";

Vince

Petet Yang <peter_yang@groton.pfizer.com> wrote in message
news:36FB942A.5679@groton.pfizer.com...
>Hi.
>
>
>I have just started to use Perl for a short time. I tried to parse a
>currency number, like $100. However, $ sign is a reserved word for Perl.
>How can I escape this sign to get the number?? Need help!
>
>Code:
>>$str = "$100";
>>print $str;
>
>It displays nothing.
>
>
>Thanks,
>
>
>Peter Yang
>
>petery77@aol.com




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

Date: Fri, 26 Mar 1999 01:12:38 +0100
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Date/Time calculation: % through current month?
Message-Id: <7dg43m$qdc$1@news.swissonline.ch>

Tony Bowden schrieb in Nachricht <922430578.108520@news.tibus.net>...
>David L. Cassell <cassell@mail.cor.epa.gov> wrote:
>: Well, an easy way to do end_of_month - start_of_month is to populate an
array
>: with the number of seconds in each month.  That way you won't have to
use
>: timelocal() and localtime() so often.
>
>: @end_to_start=(31,28,31,30,31,30,31,31,30,31,30,31);  # number of days
>: $end_to_start[1]=29 if ($year % 4 == 0);   # works between 1901 and 2099
>: @end_to_start *= 24*60*60;                 # and now it's in secs
>
>
>Interesting ...
>
>It goes against the grain slightly to build an array that I'll only need
>one elemet of, especially as I'll still have to do one call to find out
>what month it currently is, so it all boils down to which is 'better',
>between pre-building the seconds in every month, or dealing with December
>to January rollovers. I haven't benchmarked, but I'd guess the second
>is quicker, and to my mind, more elegant.
>
More elegant: maybe.
Quicker: no. Take a look at what timelocal does and you know why.

btw. is it clear how many seconds a month has? What about march and october
where DST starts or ends?

benchmark results:
use Benchmark;
use Time::Local;

my $time = time();
sub var1 {
  my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
      localtime($time);
  my @days_in_month = (31,28,31,30,31,30,31,31,30,31,30,31);
  $days_in_month += 1 if ($year % 4 == 0);
  my $one_day = 24 * 60 * 60;
  my $curr = ($mday - 1) * $one_day
             + $hour * 3600 + $min * 60 + $sec;
  my $end  = $days_in_month[$mon]  * $one_day;
  return $curr / $end;
}

sub var2 {
  my ($month, $year) = (localtime(my $now = $time))[4, 5];
  my $this = timelocal(0, 0, 0, 1, $month, $year);
  ++$month > 11 and ($month, $year) = (0, $year + 1);
  my $next = timelocal(0, 0, 0, 1, $month, $year);
  return ($now - $this) / ($next - $this);
}

timethese(1 << $ARGV[0], {
  var_1 => \&var1,
  var_2 => \&var2,
});

print var1(), "\n";
print var2(), "\n";

==>
Benchmark: timing 65536 iterations of var_1, var_2...
     var_1:  5 wallclock secs ( 4.88 usr +  0.00 sys =  4.88 CPU)
     var_2: 29 wallclock secs (28.40 usr +  0.00 sys = 28.40 CPU)
0.807889411589008
0.808976745924929

The difference in the calculated result is due to the fact that timelocal
respects the DST settings: the month march has not 31*86400 seconds but
only 31*86400 - 3600.

(If you use timegm instead of timelocal, then the first variant is only
slightly faster than the second.)

--
Samuel Kilchenmann
skilchen@swissonline.ch







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

Date: Fri, 26 Mar 1999 06:34:15 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Date/Time calculation: % through current month?
Message-Id: <MPG.11653ab8c58765f99896f7@206.184.139.132>

In article <7dg43m$qdc$1@news.swissonline.ch>, skilchen@swissonline.ch 
says...
> my $time = time();
> sub var1 {
>   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
>       localtime($time);
>   my @days_in_month = (31,28,31,30,31,30,31,31,30,31,30,31);
>   $days_in_month += 1 if ($year % 4 == 0);
                 ^^^
                 ^^^
-- 
Bill Moseley mailto:moseley@best.com


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

Date: Fri, 26 Mar 1999 14:55:45 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Date/Time calculation: % through current month?
Message-Id: <RdNK2.5851$8c4.29013908@news.magma.ca>

Bill Moseley schrieb in Nachricht ...
>In article <7dg43m$qdc$1@news.swissonline.ch>, skilchen@swissonline.ch
>says...
>> my $time = time();
>> sub var1 {
>>   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
>>       localtime($time);
>>   my @days_in_month = (31,28,31,30,31,30,31,31,30,31,30,31);
>>   $days_in_month += 1 if ($year % 4 == 0);
>                 ^^^
>                 ^^^
Yes i know, but since cancelling articles doesn't really work, i didn't
even try that. I knew that somebody would see the mistake. It evidently
should be
$days_in_month[1] += 1 if ($year % 4 == 0);
(yes the leapyear-check is too simplistic, but i don't care for this simple
example)

I don't think that my silly mistake influences the benchmark results and
the difference in the calculated result to the version using timelocal.

but anyway: sorry about the mistake,
--
Samuel Kilchenmann
skilchen@swissonline.ch




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

Date: Fri, 26 Mar 1999 15:29:43 GMT
From: holbrng@thiokol.com
Subject: Dynamic images in web page question
Message-Id: <7dg94p$s97$1@nnrp1.dejanews.com>

I am building a special banner script which is called within <IMG> tags in a
html document.  I can make a banner show up here fine, but I was wondering if
it is possible to make different banners rotate on a static html page using
this method, and if so, how.

<img src="http://somewhere.com/cgi-bin/rotate.pl?id=47552" </img>


thanks

Nic
motox@mail.relia.net

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


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

Date: Fri, 26 Mar 1999 10:47:49 -0500
From: "tavi" <tavi367@ibm.net>
Subject: Re: Help please - can't open .pl file
Message-Id: <36fbab97@news1.us.ibm.net>

Perl.exe is not a GUI application.

You will need to goto the command prompt and CD into the directory that
holds your scripts and run them from the command line...

    C:\myPerl\scripts\>perl test.pl

This will open the Perl exe for you and run the script and the output will
display itself in the command window.


>*NOTE* - If it was written for unix you may need to alter the first line #!
>to point to your perl.exe


This is only needed if your running Apache server on Win32m, IIS (PWS)
doesn't care.

I have all my scripts with the UNIX path so I can move them from my NT to my
SUN with no chages.

Walter





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

Date: Fri, 26 Mar 1999 03:17:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP: Confused about Hash Table.
Message-Id: <4qffd7.p71.ln@magna.metronet.com>


[ please limit your line lengths to the customary 70-72 characters,
  else it gets hard to read after being quoted a few times...
]


KEhlar (KEhlarQUASH@SPAMMERtheglobe.com) wrote:
: In article <jc5bd7.3a3.ln@magna.metronet.com>, tadmc@metronet.com says...
: > KEhlar (KEhlarQUASH@SPAMMERtheglobe.com) wrote:
: > 
: > : I can create a hash table with code like this one:
: > 
: > :  $index = 0;
: > :  foreach $element (@list1) {
: > :   $hash1{$index} = $element;
: > :   $index++;
: > :  }
: > 
: > 
: >    Well OK, but that looks like an array (indexed by a number)
: >    masquerading as a hash (indexed by a string) to me.
: > 
: > 
: > : OR like this one:
: > 
: > :  %hash1 = ('1', 'element1', '2', 'element2'....so on);
: > 
: > 
: >    The first one defined $hash1{0}, this one does not...

: I only used above as examples of ways to create a hash table.  The code that I 
: actually wrote is more complicated and contained names and email addresses as 
: key/value, so an array would not be an appropriate type to use.  Of course if I 
: wanted to write a code like above (where the key is basically the index) I would 
: use an array instead of a hash table.


   The "key is basically the index" is how hashes work!

   They just use strings instead of numerical indexes.


: > : In the latter, I can actually split the hash using the "," as the delimiter.  
: >
: >    Eh?

: That was my mistake, I should have had the second hash shown as below:

:  %hash1 = ('1,element1', '2,element2'....so on);


   When assigning a list to a hash like that, perl expects the
   list element to be in *pairs*.

   Elements at even "positions" (0, 2, 4...) are used as keys,
   elements at odd positions are used as values.

   So what you have in %hash now is the same as if you had done:

      $hash{1,element1'} = '2,element2';

   I'm quite certain that that is not what you want, but I still
   cannot devine what it is that you _do_ want...


: Then I can split it:

:  foreach (@hash1) {
            ^^^^^^

    You have never put anything into an array named @hash1.

    @hash1 and %hash1 are not related to each other in any way.


:     ($num,$ele)=split /,/;
:         print "$num has $ele\n";
:  }

: Is it more clear what I mean now?


   No it isn't.

   You should probably try and make a real, short, and complete
   program that illustrates your question, instead of code
   snippets that don't fit together.


: My question is basically WHAT would I use (if I can at all) to split the hash 
: table created with the first method the way I did with the one created with the 
: second method.


   I'm just not getting your intent.

   Code please.


: >    Are you processing Perl source code or something?

: I don't understand your question.  


   You said you wanted to split on commas.

   I could see no commas to split on, other than in your hash
   assignment code.

   I was just casting about trying to figure out what commas
   you were talking about.


: I hope this was not meant as a condecending 
: remark coming from a professional consultant.  


   It was not.

   I was trying to help you split on commas, but I couldn't see any
   commas to split on...

   When I am condescending it is usually much more blatant than that  :-)


:If it was, it was uncalled for.  


   Don't get your undies in a bundle.

   You should expect some consternation when you ask to split on
   commas yet don't show any commas...


: I'm new at Perl and simply needed some help.  Everyone started from the buttom, 
: even those who are experts today.


   That is why I have answered innumerable question on this newsgroup
   for the last several years.

   I like helping folks become Perl programmers. It's Good For Them  :-)


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


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

Date: Fri, 26 Mar 1999 08:44:57 GMT
From: jason@jamesjl.demon.co.uk (Jason L. James)
Subject: How do I use POST from an HTML form
Message-Id: <36fb47f7.22495177@news.demon.co.uk>

I am writing a script that requires the user to specify
a file on their local machine.  This file needs to be
processed by the perl script.  The HTML seems
quite easy with the new type=file in V4.0 of HTML.
The documentation I have says that I must use
method=post and not method=get since using
get only sends the file name and not the file
itself.

My question then is how do I find the info that
is returned from the HTML form?  What is its
format? Where is it stored? Howq do I read that 
into my perl script?

Any help on this matter will be greatly appreciated.

Regards

Jason James
jasonj@rwdata.co.uk
jason@jamesjl.demon.co.uk


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

Date: 26 Mar 1999 16:07:16 GMT
From: todd.taylor@pnl.gov (Z. Todd Taylor)
Subject: Re: How to know that a pipe opened for writing is broken? (perlfaq does not   give the answer)
Message-Id: <7dgbbk$lnn2@bbs2.pnl.gov>


In article <36FB4A58.9808B88E@itmasters.com>, "Patrice M.I. Parmentier" <ppa@itmasters.com> writes:
> Look at the very simple (wrong) script:
> 
> DO NOT EXPLAIN ME WHY IT DOES NOT WORK (perlfaq does).
> I want to know how to change this script in order it does what i would
> want (see below).

I don't think you read all of perlfaq8:

  Why doesn't open() return an error when a pipe open fails?
 
    It does, but probably not how you expect it to. On systems that
    follow the standard fork()/exec() paradigm (eg, Unix), it works
    like this: open() causes a fork(). In the parent, open() returns
    with the process ID of the child. The child exec()s the command
    to be piped to/from. The parent can't know whether the exec()
    was successful or not - all it can return is whether the fork()
    succeeded or not. To find out if the command succeeded, you have
    to catch SIGCHLD and wait() to get the exit status. You should
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    also catch SIGPIPE if you're writing to the child -- you may not
    ^^^^^^^^^^^^^^^^^^
    have found out the exec() failed by the time you write. This is
    documented in the perlipc manpage.

You're catching only one of those:

> ##################################################
> SIG{PIPE} = sub {
>  print "SIGPIPE called...\n";
>  exit (-666);
> };
> 
> $pid = open (HPIPE, "| buggything") or die "Cannot pipe buggything\n";
> 
> print "pid = $pid\n";
> 
> $n = 0;
> while (1)
> {
>  print HPIPE $n++ . "\n";
>  print "$n\n";
> }
> ####################################################

Hope that helps.

--Todd
-- 
Z. Todd Taylor
Pacific Northwest National Laboratory
Todd.Taylor@pnl.gov
Why do you say you're buckled up, when really you're buckled down?




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

Date: Fri, 26 Mar 1999 10:39:00 -0500
From: "tavi" <tavi367@ibm.net>
Subject: Re: MS Personal Web Server
Message-Id: <36fba98e@news1.us.ibm.net>

HD wrote in message <7d8u2f$epc$1@news.vossnet.de>...
>I have problems, to run a PERL-script on the MS Personal Web Server
>in the CGI-BIN-directory. Error-Code "501".
>
>Can some kind soul please help me get this running?


M$ does not have a CGI-BIN directory. It has a scripts dir.

Did you make this dir?
If yes:
  - Is this dir in the wwwroot dir?
    - if yes, then just tell the server to run scripts in there

  - Is it a sibling of wwwroot?
    - if yes:
       - did you tell the server that this is a new (virtual) dir?
       - then just tell the server to run scripts in there

If No, I have no idea.

Walter







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

Date: Fri, 26 Mar 1999 15:33:37 +0100
From: Olivier Maas <olivier.maas@at-lci.com>
Subject: Obj: Help A beginner (should be a simple error)
Message-Id: <36FB9AC1.781634D5@at-lci.com>

Hello,
I am a student starting to study perl in order to create dynamic html
pages, But there must be a very BASIC error I keep doing for even simple
exercices wont work...

I work with IE and Netscape, I dled the last perl version 5.09, my files
are recognized as perl files because a display opens (both in IE and
Netsc saying that I am going to run a program)... BTW is there any way
to make that window not appear?

I created an html file :

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<BODY>

<A HREF="file://c:/NewArbor/prems.pl"> test </A>
</body>
</html>


and a .pl file:
#!/bin/perl

use CGI ;
$html= new CGI ;
print $html->header ;
#constructing HTML file

 print "<HTML>\n";
 print "<HEAD>\n";
 print "<TITLE>titre de la page renvoyie</TITLE>\n";
 print "</HEAD>\n";
 print "<BODY>\n";
 print "\n";
 print "<H1>Mon premier exemple</H1>\n";
 print "\n";
 print "</BODY>\n";
 print "</HTML>\n";

-------------------------------end there

I can see an MSDOS window (1/4th of a second... :( quite hard to debug)

when the lines with $html are commented:
I can see the file printing in the dos window, but not in the HTML
browser, as I would like to

when they are not, I get to :
(offline mode: enter name=value pairs on standard input)

I can then type what I want, but did not find a way other than ctrl-C or
Z to go out...

I am sure My error is a big one, but I cannot figure it out...

Any help welcome...
please also reply by  mail at
mailto:maas@ensae.fr
thanks

olivier Maas



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

Date: Fri, 26 Mar 1999 09:27:11 -0500
From: "Stallan, Tony (EXCHANGE:BRW2:S901)" <stallan@americasm01.nt.com>
Subject: Perl and Databases on NT. Which module to use
Message-Id: <36FB993E.59A51900@americasm01.nt.com>

Hi folks,

Just after some quick advice.

I have Perl/Apache running on NT and am currently using Win32::ODBC to
connect to an Oracle database. Is this the best module to use or should
I be using something else such as DBI/DBD::Oracle.

My Perl scripts only peform Select/Update commands and I am currently
achieving 0.28 secs connection times using Microsoft's Oracle ODBC
driver. The SQL commands peform at similiar speeds in other applications
such as SQL*Plus.

I suppose my real concern is how this system will perform under multiple
concurrent connections (10-20 users).

Thanks in advance for your help

Tony Stallan
Clearview Systems Inc.






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

Date: Fri, 26 Mar 1999 04:18:38 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Error DBI.pm in @INC
Message-Id: <edjfd7.p71.ln@magna.metronet.com>

Simon Ng (simon_ng@twtsg.com.sg) wrote:

: I can't seem to some perl to run and was return with this message.
: Can anybody explain. 


   The documentation that came with your perl can explain.

   The answer should already be on your hard disk somewhere.

   The 'perldiag.pod' doc describes all of the messages that perl
   might issue.

   For yours it says:

--------------
=item Can't locate %s in @INC

(F) You said to do (or require, or use) a file that couldn't be found
in any of the libraries mentioned in @INC.  Perhaps you need to set the
PERL5LIB or PERL5OPT environment variable to say where the extra library
is, or maybe the script needs to add the library name to @INC.  Or maybe
you just misspelled the name of the file.  See L<perlfunc/require>.
--------------


: I think i may need to install some kind of DBI module.


  It may already be installed, but be in a non-standard place.


: If so then where can i download from.


   http://www.perl.com/CPAN/modules/by-module/DBI/


: Can't locate DBI.pm in @INC (@INC contains: C:\PERL\lib C:\PERL\site\lib .)
: at C:\Inetpub\scripts\simple.pl line 3.
: BEGIN failed--compilation aborted at C:\Inetpub\scripts\simple.pl line 3.


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


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

Date: Fri, 26 Mar 1999 16:23:45 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: Problem about REGULAR EXPRESSION
Message-Id: <351a7eb3.20074681@news.inet.co.th>

There is $sentence= "aaabbbcccaaakkkdddeeeaaa";

I want to pull "bbbccc"  out of the sentence.
i use $sentence=~m/aaa(\S*)aaa/;

the command will pull bbbcccaaakkkdddeee out
but i want only bbbccc

please suggest an easy simple way to do it.


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

Date: Fri, 26 Mar 1999 11:02:59 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: problem by using PERL & MySQL via DBI
Message-Id: <linberg-2603991102590001@ltl1.literacy.upenn.edu>

In article <01be778f$b9ed06e0$0a02a8c0@INFO>, "Ralf Berlau"
<Ralf.Berlau@Bigfoot.de> wrote:

[snip]

> Whats wrong, any idea?

Typo.

> $dbh = DBI=>connect ($dsn,$user,$pass);
            ^
Should be:

$dbh = DBI->connect ($dsn,$user,$pass);

Otherwise it looks fine on visual inspection.  I didn't test anything
though, so there could be other stuff.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Fri, 26 Mar 1999 04:03:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Q: how to evaluate a $var in a file you are reading in?
Message-Id: <7hifd7.p71.ln@magna.metronet.com>

Ian M. Veach (ivo@scsr.nevada.edu) wrote:

: I've got a file I'm reading, and I want to take all %%$vals%% and
: actually spit out the VALUE of the variable $vals.


   Perl FAQ, part 4:

      "How can I expand variables in text strings?"


: Which will separate the HTML chaff from the variable name, but how do I
: not print my_title or $my_title, but the VALUE of $my_title?  I can
: brute force it with a

:     if ($2 = "my_title") { print "$my_title" };


   You have managed to fit 4 problems into a single line of code.

   Very efficient  :-)


   1) = is an assignment. You cannot assign to the read-only $2 variable

      Perhaps you meant == instead?


   2) If you meant == then you are using the wrong operator, since
      == tests the equality of numbers but you are testing a
      _string.

      You use eq to compare strings, not ==


   3) You should use single quotes unless you need one of the 
      "extra" things that double quotes provide (interpolation):


   4) You should not use double quotes where they are not needed
      and are misleading.



   So that line of code would be ever so much better written this way:

      if ($2 eq 'my_title') { print $my_title };

   Or

      print $my_title if $2 eq 'my_title';


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


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

Date: Fri, 26 Mar 1999 06:54:42 -0800
From: David Borger <borger@ix.netcom.com>
To: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: regular expression
Message-Id: <36FB9FB2.14261B93@ix.netcom.com>

I, too, am new to Perl and really appreciated this response.  I do not currently
have a problem similar to the original poster, but the care with which Mr. Cassell
responded and anotated the original code was instructive nonetheless.  Every time I
have learned a new computer language one of the first comments I hear is that the
best way to learn is to read the code of others.  Well commented code is obviously
best for this.  Expertly analyzed and annotated code is better still.  Thanks a lot
for your effort.  I hope this is standard practice for this group

Dave

David L. Cassell wrote:

> rheinman@my-dejanews.com wrote:
> > Very new to Perl, and several hours on CPAN, this group, etc hasn't turned up
> > an answer to what is certainly a simple problem.
>
> They're all simple.. once you know how.  But you've done well so far.
> In particular, your Subject line on your post was informative and targeted
> your problem.
>
> > The following perl program is trying to read a file and replace occurences of
> > 'brown' with 'red':
> >
> > #! /opt/perl5/bin/perl -w
>
> Good!  Always use that -w flag.  I put 'use strict;' as my second line too.
>
> > use diagnostics;
> > $value = "initialize";
>
> You can drop this line.  See comments below.
>
> > open(FH, "< input.file") || die "cannot open input file: $!";
> > open(HH, "> output.file") || die "cannot open output file: $!";
>
> Checking the success of your opens.  Very good.  I personally prefer
> to use 'or' instead of '||' since 'or' has lower precedence.  That lets
> me drop the parens and just write:
>    open FH, "<input.file" or die "cannot open input file: $!";
> The $! is good too.
>
> > $inline = <FH>;
> > while (defined($inline = <FH>)){
> >    $value = s/brown/red/g;
>
> Okay.  Here's the problem.  You assigned the value of the line to
> $inline, but you're trying to do the subst on $value.  And you're using
> '='.  When you want to do a subst on a variable, use the pattern binding
> operator =~ like this:
>      $inline =~ s/brown/red/g;
>
> And also: if you want to make sure you match 'brown' but not 'brownies'
> or 'lowbrown' or 'Eric Debrowner', then read about the nifty \b assertion.
>      $inline =~ s/\bbrown\b/red/g;
> \b is a zero-width assertion that matches at a word boundary, meaning it
> matches _in_between_ the word and the non-word.
>
> >    select HH; # and write record
> >    print "$value \n";
>
> You can just write this as:
>      print HH "$value";
> Note: no comma between filehandle and list.  No \n after $value.  Why not?
> You never chopped the newline off the line when you read it in - you didn't
> need to.  So it's still there, ready to print out for you.
>
> > }
> > [errors snipped]
> >
> > What I need to do eventually is to be able to do multiline replacements in a
> > file, ie:
> >
> > this is sentence one
> > and this is the next sentence
> > of this paragraph
> >
> > would become just:
> >
> > of this paragraph
>
> Get the first part working, and then check out the following features:
> $/    (the input line separator)
> s///m
> s///s
>
> If you can't figure out how to get your multiline replacer working,
> come on back and ask for more help.
>
> David
> --
> David L. Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician





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

Date: Fri, 26 Mar 1999 15:22:25 GMT
From: not_here@my-dejanews.com
Subject: Re: Running a perl script as a daemon....
Message-Id: <7dg8n5$rs5$1@nnrp1.dejanews.com>

In article <7dedl5$ti0$1@reader1.reader.news.ozemail.net>,
  "Diggy Tim" <tim@diggy.com> wrote:
> Something has stumped me for a long time, It always seemed to be a simple
> thing to do for me.. But so far I have been unable to do it.
>
> How do I go about running a perl script from the command line and have it
> sit in the background and not die when I log out.
>
> OS is Solaris 2.5 - 2.7.
>
> Cheers,
> Tim
>

use nohup:
  %nohup myprog.pl

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


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

Date: Fri, 26 Mar 1999 15:33:58 +0100
From: "Rovetto Stefan" <designo@gmx.net>
Subject: search .pl file, where I can send email for Win32 over GMX-Mail Gateway
Message-Id: <7dg60f$r5t$1@news.swissonline.ch>

Hello
I'm looking for a .pl file, where I can send email for Win32 over GMX-Mail
Gateway or other free gateways.
Example:
I have a feedback.htm site. The people fill out this page and press send.
Now I will resceve an email with all data. I need only two things.
1) .pl file (example with description for modification)
2) An example of feedback.htm
Thanks for your tip or adress, where I can find this.
With kind regards. Steve. (Please post and email me your answer)
( designo@gmx.net )




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

Date: 26 Mar 1999 08:44:19 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pvdb, a vi-aware front-end for the perl debugger
Message-Id: <7dgbtm$9h9$1@nntp.Stanford.EDU>

If you're running X11 and use vi as your editor, this may interest you.
It's something that I used to use a lot back in perl4 days, but which I
never bothered to get working again in the last five years or so.  

Try calling this program as you would the perl debugger.  Besides the
main debugger window, you also get two extra windows: one for program
I/O and one for vi on the file(s) being debugged.  It is easier to demo
than it is to explain.  :-)

This code is quite obviously "prototype-caliber", if you know what I mean.
It has the look of something I just cobbled together somewhat haphazardly,
because, in fact, that's what I did.  Note the many XXX warnings.
There's a lot of room for code clean-up, robustness testing, and
portability enhancements here.  But even so, it works on all my systems
(SunOS, Linux, BSD), and it's sure nice to have it back again, even if
it should happen to be tied together with old string and smelly glue.

--tom

#!/usr/bin/perl
# pvdb, a vi-aware front-end for the perl debugger 
# tchrist@perl.com
# v2.0-alpha, Fri Mar 26 08:43:48 MST 1999

use strict;
use POSIX qw(setsid);   # XXX: called unnecessarily sometimes
use Config;   		# XXX: called unnecessarily sometimes

$ENV{PATH} .= ":/etc";
my $FIONREAD;
my $TIOCSTI;

# XXX: this gets (at least :-) called twice
($FIONREAD, $TIOCSTI) = get_config(); 

if (defined $ARGV[0] && $ARGV[0] eq '-v') {
    shift;
    slave_vi(@ARGV);
} else {
    run_debugger(@ARGV);
} 
exit;

my(
    $file,
    $fifo,
    $iopid,
    $xtpid,
    $kidpid,
    $tty,
    @kidpids,
);

sub run_debugger { 
    $file = shift || die "usage: $0 file [args]\n";
    -r $file or die "can't read $file: $!";

    $fifo = "/tmp/pvd-fifo.$$";
    unlink $fifo;
    $SIG{INT} = 'IGNORE';
    #system("mknod $fifo p") and die "mknod failed";
    system("mkfifo $fifo") and die "mknod failed";  # XXX: wrong path?

    unless (defined ($iopid = fork)) {
	die "can't fork: $!";
    } 
    unless ($iopid) {
	POSIX::setsid();
	exec "xterm",   -ah,		# keep cursor bright
			-wf,		# wait to remap; XXX: doesn't work?
			-fg	=> 'Navy',
			-bg	=> 'Plum',
			-n 	=> "pvdb i/o",
			-T 	=> "pvdb i/o", 
			-fn     => "6x10",
			-geom	=> "85x25+3+4",
			-e 	=> 'sh', '-c', qq{
			    tty > $fifo; 
			    sleep 10000000;
			}; 

	die "can't exec xterm: $!";
    } 
    push @kidpids, $iopid;

    open(FIFO, "< $fifo");
    $tty = <FIFO>;
    close FIFO;

    unless (defined ($xtpid = fork)) {
	die "can't fork: $!";
    } 
    unless ($xtpid) {
	POSIX::setsid();  # wish I remembered why I did this
	exec "xterm",   
			-ah,
			-wf,
			-fg		=> 'Red',
			-bg		=> 'LightSkyBlue1',
			-n 		=> "pvdb edit",
			-T 		=> "pvdb edit", 
			-fn         	=> "6x10",
			-geom		=> "85x55+349+4",
			-e 		=> $0, "-v", $fifo;
	die "can't exec xterm: $!";
    } 

    push @kidpids, $xtpid;

    $| = 1;

    # i hate having to hide, but the compiler sees this on both runs
    # otherwise
    eval q{
	END { 
	    local $SIG{CHLD} = 'IGNORE';
	    unlink $fifo;
	    kill "TERM" => @kidpids;  # kill them; kill them all!
	}
    };
    die if $@;

    $SIG{CHLD} = sub {
	unless (wait() == -1) { 
	    print "Whoops, that debugger just exited.\n" ;
	    exit;
	}
    }; 

    unless (defined ($kidpid = open(KID, "-|"))) {
	die "can't fork: $!";
    } 

    open(FIFO, ">$fifo") || die "can't open $fifo: $!";
    select((select(FIFO), $| = 1)[0]);

    unless ($kidpid) { 
	$ENV{PERLDB_OPTS} = "LineInfo=$fifo";
	$SIG{INT} = 'DEFAULT';  # still needed?
	open(STDOUT, ">$tty") || die "can't open $tty: $!";
	open(STDERR, ">$tty") || die "can't open $tty: $!";
	open(STDIN,  "<$tty") || die "can't open $tty: $!";
	# XXX: darned -emacs kills readline!
	exec $^X, '-dS', $file, '-emacs', @_;
	die "Can't exec debugger: $!";  # XXX: went to other tty
    } 

    push @kidpids, $kidpid;
    while ($_ = getline(*KID)) {
	chomp;
	my($file, $line) = /^(?:\032\032)?(.*?):(\d+):(\d+)/;
	unless ($file =~ /\beval\b/) {
	    print FIFO "$file $line\n";
	}
    } 

}

# I've simply decided that stdio is not a friend of mine.
sub getline {
    my $fh = $_[0];
    my $buf = '';
    my $long = pack("L", 0);
    for (;;) { 
	my $smask = '';
	vec($smask, fileno($fh), 1) = 1;
	my $ok = select($smask, undef, undef, $buf ? 0.25 : undef);
	if (!$ok) {
	    return $buf if $buf;
	    warn "select: $!";
	    next;
	} 
	ioctl($fh, $FIONREAD, $long) or die "can't FIONREAD: $!";
	my $count = unpack("L", $long);
	die "count is empty" unless $count =~ /\d/;
	my $chars = '';
	sysread($fh, $chars, $count);
	$buf .= $chars;
	if ($buf =~ /DB<\d+> $/ or $buf =~ /\n/) { # XXX: no more DB< ?
	    return $buf;
	} 
    }
} 

sub slave_vi {
    my($tty,
       $pid, 
       $fifo,
    );

    unless (@_ == 1 and -p ($fifo = shift)) { die "usage: $0 fifo"; }

    my $editor = $ENV{EDITOR} || 'vi';

    $SIG{TTOU} = 'IGNORE';

    chomp($tty = `tty`);
    open(TTY, "+> $tty") || die "no /dev/tty: $!";
    die "can't fork: $!" unless defined ($pid = fork);
    unless ($pid) {
	exec $editor;
	die "can't exec $editor";
    }
    jam (":set ro\n");   # read only
    jam (":set nu\n");   # line numbers
    open (FIFO, $fifo) || die "can't open $fifo: $!";

    my $oldfile = '';
    kill "WINCH" => $pid;  # must resize cause xterm is confused

    eval q{
	END { unlink $fifo }
    };

    while (<FIFO>) {
	unless (s/^\032\032//) { 
	    print "GOT REGULAR INPUT: $_";   # XXX: what's this?
	    next; 
	} 
	chomp;
	my($file, $line) = split /:/;
	if ($file ne $oldfile && $file !~ /\beval\b/) {
	    # XXX: sometimes "unknown command" errors; why?
	    jam(":n +$line $file\n");  
	    $oldfile = $file;
	} else {
	    jam("${line}G");
	} 
    } 
}

# XXX: knows that TTY is open 
sub jam {
    for (split(//, $_[0])) {
        ioctl(TTY, $TIOCSTI, $_) || die "bad TIOCSTI: $!";
    } 
} 

sub get_config {
    use Config;
    if ($Config{archname} =~ /^i\d86-linux$/) {
	return (0x541b, 0x5412)
    } 
    elsif ($Config{archname} =~ /^OpenBSD.i\d86-openbsd$/) {
    	return (0x4004667f,0x80017472);
    } 
    elsif ($Config{archname} =~ /^sun4-sunos$/) {   # real sunos, not solaris
    	return (0x4004667f,0x80017472);  # coincidence? :-)
    }
    else {
	warn "No predefined sys values found";
    } 

    eval { require "sys/ioctl.ph" };
    my $fion = eval { &FIONREAD };
    my $tioc = eval { &TIOCSTI };
    if (2 == grep {defined} $fion, $tioc) {
	return ($fion, $tioc);
    } 
    print STDERR "No FIONREAD and TIOCSTI found in sys/ioctl.ph -- compiling...";
    my $cfile = "/tmp/fiotio";
    open(CSRC, "> $cfile.c") || die "can't open $cfile.c: $!";
    eval q{ END { unlink($cfile, "$cfile.c") } };
    print CSRC <<'EOF';
#include <sys/ioctl.h>
main() {
printf("%#x\n%#x\n", FIONREAD, TIOCSTI);
exit(0);
} 
EOF
    close CSRC or die "can't close $cfile.c: $!";
    system("cc -o $cfile $cfile.c")
	and die "can't compile $cfile.c";
    ($fion, $tioc) = split ' ', `$cfile`;
    die "can't run $cfile $fion $tioc: $?" if $?;
    print STDERR " using FIONREAD=$fion TIOCSTI=$tioc\n";
    return map { hex } ($fion, $tioc);

} 
-- 
Eighty percent of air pollution comes from plants and trees.
                --Ronald Reagan, famous movie star


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

Date: 26 Mar 1999 16:54:29 +0200
From: jari.aalto@poboxes.com (Jari Aalto+mail.perl)
Subject: Sys independent "Tue, 20 Aug 1996 14:25:27 GMT" ?
Message-Id: <ptr4sn8mhcq.fsf@sinivuokko.i-have-a-misconfigured-system-so-shoot-me>



	I'm generating a meta tag to my webpages,and I'd like to
	know what is the system independent way to generate standad
	date string:

		Tue, 20 Aug 1996 14:25:27 GMT

	
<META http-equiv="Expires" content="Tue, 20 Aug 1996 14:25:27 GMT">

	I'd like to know a method that works in Win32 and all unix versions.
	Is there a perl module for this?

	jari


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

Date: Fri, 26 Mar 1999 08:06:41 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sys independent "Tue, 20 Aug 1996 14:25:27 GMT" ?
Message-Id: <MPG.1165506bf8ce27fe9897d3@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <ptr4sn8mhcq.fsf@sinivuokko.i-have-a-misconfigured-system-so-
shoot-me> on 26 Mar 1999 16:54:29 +0200, Jari Aalto+mail.perl 
<jari.aalto@poboxes.com >says...
> 	I'm generating a meta tag to my webpages,and I'd like to
> 	know what is the system independent way to generate standad
> 	date string:
> 
> 		Tue, 20 Aug 1996 14:25:27 GMT
> 	
> <META http-equiv="Expires" content="Tue, 20 Aug 1996 14:25:27 GMT">
> 
> 	I'd like to know a method that works in Win32 and all unix versions.
> 	Is there a perl module for this?

Will two lines of code do instead of a module?

	gmtime =~ /(...)( ...)( ..)( .{8})( ....)/;
	print "$1,$3$2$5$4 GMT";

You can, of course, specify a Unix-epoch time argument for gmtime(), and 
you can replace my dots by more specific patterns if you are paranoid.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com


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

Date: 26 Mar 1999 18:19:29 +0200
From: jari.aalto@poboxes.com (Jari Aalto+mail.perl)
Subject: Re: Sys independent "Tue, 20 Aug 1996 14:25:27 GMT" ?
Message-Id: <ptr1zicmdf2.fsf@sinivuokko.i-have-a-misconfigured-system-so-shoot-me>

jari.aalto@poboxes.com (Jari Aalto+mail.perl) writes:

> 
> 
> 
> 	I'm generating a meta tag to my webpages,and I'd like to
> 	know what is the system independent way to generate standad
> 	date string:
> 
> 		Tue, 20 Aug 1996 14:25:27 GMT
> 
> 	
> <META http-equiv="Expires" content="Tue, 20 Aug 1996 14:25:27 GMT">
> 
> 	I'd like to know a method that works in Win32 and all unix versions.
> 	Is there a perl module for this?

I forgot to mention, that I don't want current date, but a date
that is, say 2 months away from current date. That requires a
time manipulation package?

Then it makes the Expires Tag useful :-)

jari


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

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

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