[24352] in Perl-Users-Digest
Perl-Users Digest, Issue: 6541 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 8 00:10:40 2004
Date: Fri, 7 May 2004 21:10:17 -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 Fri, 7 May 2004 Volume: 10 Number: 6541
Today's topics:
Regular expression questions (Hung Truong)
Re: Regular expression questions <usenet@morrow.me.uk>
Re: Regular expression questions <invalid-email@rochester.rr.com>
Re: Regular expression questions (Jay Tilton)
Re: Set Permanent ENV variables on Windows <1usa@llenroc.ude>
Spreadsheet::WriteExcel <sean_berry@cox.net>
Re: Spreadsheet::WriteExcel <sean_berry@cox.net>
Re: Spreadsheet::WriteExcel <invalid-email@rochester.rr.com>
Re: Trapping warnings <usenet@morrow.me.uk>
Re: Using $1, $2 ... but don't know in which order <usenet@morrow.me.uk>
using NET::FTP (Virginia Walters)
Re: using NET::FTP <thepoet_nospam@arcor.de>
web application testing (Charlie)
Why does chomp leave newlines? (Mark Healey)
Re: Why does chomp leave newlines? (David Efflandt)
Re: Why does chomp leave newlines? (Mark Healey)
Re: Why does chomp leave newlines? <invalid-email@rochester.rr.com>
Re: Why is this simple script not sending email? <krahnj@acm.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 May 2004 18:35:27 -0700
From: skyfaye@yahoo.com (Hung Truong)
Subject: Regular expression questions
Message-Id: <805c863b.0405071735.1561e4b2@posting.google.com>
Hi,
I'm new at this regular expression. How can I do a match for strings that
1) contain three (or more) pairs of double letters
2) have an even number of 'a's
Thanks,
Hung
------------------------------
Date: Sat, 8 May 2004 01:44:28 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Regular expression questions
Message-Id: <c7he1s$9fb$1@wisteria.csv.warwick.ac.uk>
Quoth skyfaye@yahoo.com (Hung Truong):
> Hi,
>
> I'm new at this regular expression. How can I do a match for strings that
> 1) contain three (or more) pairs of double letters
/(?: (.)\1 .* ){3}/x
If you actually mean 'letter' (i.e., a string like '{{' shouldn't match)
then you want
/(?: ([[:alpha:]]) \1 .* ){3}/x
> 2) have an even number of 'a's
/^ [^a]* (?: a [^a]* a [^a]* )* $/x
If you want to do both at once you're best off combining them with Perl
logic, rather than trying to write one regex.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Sat, 08 May 2004 01:52:50 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Regular expression questions
Message-Id: <409C3D6C.2050507@rochester.rr.com>
Hung Truong wrote:
...
> I'm new at this regular expression. How can I do a match for strings that
> 1) contain three (or more) pairs of double letters
> 2) have an even number of 'a's
>
...
> Hung
>
Homework time, huh? You can find what you're looking for in:
perldoc perlre
in the section titled "Regular Expressions". Just type that line at
your operating system's command prompt and read up.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 08 May 2004 03:10:13 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Regular expression questions
Message-Id: <409c4c0b.16541405@news.erols.com>
skyfaye@yahoo.com (Hung Truong) wrote:
: I'm new at this regular expression. How can I do a match for strings that
: 1) contain three (or more) pairs of double letters
Depending on whether 'xxx' should be considered to have one set of doubled
letters or two, you could say:
print "has three or more pairs of letters" if 3<=(()=/(.)\1/g);
or:
print "has three or more pairs of letters" if 3<=(()=/(.)(?=\1)/g);
: 2) have an even number of 'a's
print "has an even count of the letter 'a'" unless (()=/a/g)%2;
------------------------------
Date: 7 May 2004 22:29:37 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Set Permanent ENV variables on Windows
Message-Id: <Xns94E2BC213E7EDasu1cornelledu@132.236.56.8>
spamtotrash@toomuchfiction.com (Kevin Collins) wrote in
news:slrnc9nvv5.99i.spamtotrash@doom.unix-guy.com:
> In article <e7774537.0405071224.69c35870@posting.google.com>, Prabh
> wrote:
>> Hello all,
>> Could anyone tell me how to set a Windows environment permanently?
>> I need to set the PATH variable from my Perl script and any changes I
>> make to this variable last only for the duration of my script's
>> running.
>>
>> I realize Perl inherits a copy of the system ENV. and any changes
>> made to it are temporary, but heres my question, the install programs
>> for various products, Windows Installers, .msis, Setup.exes all make
>> permanent changes to the PATH variable when the product is installed.
>> Obviously, the changes made by these installers are permanent.
>>
>> I just want to replicate this process from Perl.
>> Could anone give me some pointers, please?
>>
>> Thanks for your time,
>> Prab
>
...
> So, I searched my registry with regedit for "environment" and found
> the key:
>
> HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session
> Manager\Environment
>
> Which has a entry called "Path" containing the system's defailt PATH
> setting.
>
> So, if you want to change it system-wide, this is a good place to do
> that....
No it is not. Needs to be done in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
\Environment
if you want it system-wide. But, the current user may not have the
correct rights. Not all of us run XP as Administrators, you know.
I do not know the OP's main purpose. But, if this is an installation
related issue, then appending to the user's path is appropriate. OTOH,
this sort of task is probably better handled using one of the free
installers which would give the user to properly undo the changes made
during installation.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Fri, 7 May 2004 18:23:12 -0700
From: "Sean Berry" <sean_berry@cox.net>
Subject: Spreadsheet::WriteExcel
Message-Id: <ODWmc.85741$Jy3.46975@fed1read03>
Is there a way of opening a preformatted excel file, then write to empty
cells in the table.
I have a table with various formulas, cell and text colors, borders, etc.
But, the data is in a 28 x 170 sized chunk of the sheet. This will be a big
pain to code so I was looking for a shortcut.
Is is possible to parse the .xml file and use the values within instead of
just the data?
TIA
------------------------------
Date: Fri, 7 May 2004 19:11:16 -0700
From: "Sean Berry" <sean_berry@cox.net>
Subject: Re: Spreadsheet::WriteExcel
Message-Id: <TkXmc.86509$Jy3.41406@fed1read03>
Spreadsheet::ParseExcel::SaveParser;
Found it.
"Sean Berry" <sean_berry@cox.net> wrote in message
news:ODWmc.85741$Jy3.46975@fed1read03...
> Is there a way of opening a preformatted excel file, then write to empty
> cells in the table.
>
> I have a table with various formulas, cell and text colors, borders, etc.
> But, the data is in a 28 x 170 sized chunk of the sheet. This will be a
big
> pain to code so I was looking for a shortcut.
>
> Is is possible to parse the .xml file and use the values within instead of
> just the data?
>
> TIA
>
>
------------------------------
Date: Sat, 08 May 2004 02:19:29 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Spreadsheet::WriteExcel
Message-Id: <409C43AA.1000606@rochester.rr.com>
Sean Berry wrote:
> Is there a way of opening a preformatted excel file, then write to empty
> cells in the table.
>
> I have a table with various formulas, cell and text colors, borders, etc.
> But, the data is in a 28 x 170 sized chunk of the sheet. This will be a big
> pain to code so I was looking for a shortcut.
Well, one way would be to use Excel itself via the Win32::OLE module.
Another way might be to use the Spreadsheet::ParseExcel module to read
the "preformatted Excel file", and then use Spreadsheet::WriteExcel to
write a new Excel file. Another way would be with the
Spreadsheet::ParseExcel::SaveParser module, which will do a
read-modify-write. What will give the greatest mileage in the long run?
Probably Win32::OLE.
>
> Is is possible to parse the .xml file and use the values within instead of
> just the data?
What .xml file? Do you mean .xls ? Or are you referring to
Spreadsheet::WriteExcel::FromXML (if so, how do you get the XML file?)?
And what do you mean by "values within" versus "just the data"? What
you're trying to say isn't at all clear to me. If you want to parse an
XML file, check CPAN for modules with XML and Parse in their names.
...
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Fri, 7 May 2004 22:31:17 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Trapping warnings
Message-Id: <c7h2nk$53k$1@wisteria.csv.warwick.ac.uk>
Quoth Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>:
> If it happens with 'use warnings', then either
>
> my ($p,$r,$h);
> {
> no warnings qw/uninitialized/;
> ($p,$r,$h) = $e->do_request('GET', $path, undef);
> }
>
> or trapping the __WARN__ signal with
my ($p, $r, $h);
{
> local SIG{__WARN__} = sub {
> ...
> do something with the warning message in $_[0]
> ...
> }
> my($p,$r,$h) = $e->do_request('GET', $path, undef);
}
>
> will perhaps do what you want.
Or, if it is old code that predates 'warnings',
my ($p, $r, $h);
{
local $^W;
($p, $r, $h) = ...;
}
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: Fri, 7 May 2004 22:40:53 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Using $1, $2 ... but don't know in which order
Message-Id: <c7h39l$53k$2@wisteria.csv.warwick.ac.uk>
Quoth roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson):
> In article <c7g9hh$itc$1@canopus.cc.umanitoba.ca>,
> Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
>
> : while ( my ($foo, $bar) = $_->{extractsub} ) {
> : # etc
> : }
>
> Opps, typo. I meant
>
> my $sref = $_->{extractsub};
>
> while ( my ($foo, $bar) = &$sref($text) ) {
> # etc
> }
Or simply
while ( my ($foo, $bar) = $_->{extractsub}() ) {
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
/Alcestis/) [ flame, and falls out of sight. ] ben@morrow.me.uk
------------------------------
Date: 7 May 2004 16:17:11 -0700
From: vwalters@accelrys.com (Virginia Walters)
Subject: using NET::FTP
Message-Id: <a905e599.0405071517.1d84b2a8@posting.google.com>
Hi all,
I am new to perl and I am trying to use the NET::FTP command to first
connect to a proxy server that must be given a userid and password and
then do another NET:FTP to a public database server. Here is my code
however I continue to get the following error message:
yntax error at /ds01/install/s92mw01/SeqStore/DataServeRDB/util/ftp_util.pl
lin
e 297, near ""Cannot create ftp connection to Proxy server $proxyhost
$@\n";"
Execution of /ds01/install/s92mw01/SeqStore/DataServeRDB/util/ftp_util.pl
aborte
d due to compilation errors.
Here is the code
$ftp1 = Net::FTP->new($proxyhost, (Passive=>0, Debug=>$DEBUG) or die
"Cannot c
reate ftp connection to Proxy server $proxyhost $@\n";
$ftp1->login($proxyuser, $proxypasswd) or die "Cannot login to proxy
server $@
\n";
$ftp = Net::FTP->new("$ftphost", @firewall, @NetFtpArgs) or
die "Cannot connect to $ftphost\n";
$ftp->login($login,$pwd) or die "Cannot login to $ftphost\n";
print LOGFILE "logged in to $ftphost\n";
$loginTime = time();
if ( $accType =~ /master/ ) {
$ftp->cwd(ds_autoupdate) or
die "Cannot find directory ds_autoupdate on server $ftphost\n";
} elsif ( $accType =~ /taxonomy/ ) {
$ftp->cwd(tax_update) or
die "Cannot find directory tax_update on server $ftphost\n";
} elsif ( defined $remoteDir ) {
$ftp->cwd($remoteDir) or
die "Cannot find remote directory $remoteDir on server
$ftphost\n";
}
$ftp->binary or die "Cannot set transfer type to binary\n";
print LOGFILE "Connection complete\n";
} # end sub Connect
thanks in advance for any help
Virginia
------------------------------
Date: Sat, 8 May 2004 01:51:06 +0200
From: "Christian Winter" <thepoet_nospam@arcor.de>
Subject: Re: using NET::FTP
Message-Id: <409c2156$0$10905$9b4e6d93@newsread2.arcor-online.net>
"Virginia Walters" wrote:
> Hi all,
>
> I am new to perl and I am trying to use the NET::FTP command to first
> connect to a proxy server that must be given a userid and password and
> then do another NET:FTP to a public database server. Here is my code
> however I continue to get the following error message:
>
> yntax error at
/ds01/install/s92mw01/SeqStore/DataServeRDB/util/ftp_util.pl
> lin
> e 297, near ""Cannot create ftp connection to Proxy server $proxyhost
> $@\n";"
> Execution of /ds01/install/s92mw01/SeqStore/DataServeRDB/util/ftp_util.pl
> aborte
> d due to compilation errors.
>
> Here is the code
> $ftp1 = Net::FTP->new($proxyhost, (Passive=>0, Debug=>$DEBUG) or die
> "Cannot create ftp connection to Proxy server $proxyhost $@\n";
You're obviously missing the closing round bracket
for the new() method after "Debug=>$DEBUG)".
HTH
-Christian
------------------------------
Date: 7 May 2004 17:50:44 -0700
From: cji_work@yahoo.com (Charlie)
Subject: web application testing
Message-Id: <1dc70d61.0405071650.2ef26918@posting.google.com>
Hi folks,
There is a web application that I am working on now, it was written in
PERL, the backend DB is postgresql, and it runs on LINUX. One of
issues that I am looking at is the performance. We want to know the
behaviour it looks like when it is hit by the maximum users. The
machine that I can use for testing is a win2K PC, and my extra budget
for that testing is 0.
All I need to know is in which direction I may go.
1. find some existing tools to do the test?
That may be easiest way to go. If it is, Any kind of tools your guys
may recommend ?
2. write some code in perl to do the simulation.
I was thinking about that, and I have found the Module called
"Mechanize" in perl that helps users to access the web. The problem I
have now is how I can simulate certain amount of persons to access
the web in a limited of time ? In other words, I want to see in that
limited of time, that amount of users accessing the application
smoothly while under the same condition, in the same amount of time,
more users' accessing, will mess up the server? how can I implement it
? What the structure might be ? !!!
3. for whatever way I choose, how can I tell the "bottle neck" is not
because of the test tool I am using, but is of the application itself
?
Thanks very much for the help!
Charlie Ji
------------------------------
Date: Sat, 08 May 2004 00:50:57 GMT
From: die@spammer.die (Mark Healey)
Subject: Why does chomp leave newlines?
Message-Id: <VP2SpNyJrzMZ-pn2-JhtrLfnW9dF5@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
First some fragments
I get the array thusly:
13 @searchTerms=split(/\n/,$queryHash{"searchText"});
I later print it:
40 sub printSearchTerms
41 {
42 foreach(@searchTerms)
43 {
44 chomp;
45 print ("$_<BR>\n");
46 }
47 }
And yet I get:
point loma
<br>
mission hills
<br>
hillcrest
<br>
bankers hill
<br>
university heights<br>
What's up?
--
Mark Heaely
marknews(at)healeyonline(dot)com
------------------------------
Date: Sat, 8 May 2004 01:49:09 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Why does chomp leave newlines?
Message-Id: <slrnc9of4k.frk.efflandt@typhoon.xnet.com>
On Sat, 08 May 2004 00:50:57 GMT, Mark Healey <die@spammer.die> wrote:
> First some fragments
>
> I get the array thusly:
>
> 13 @searchTerms=split(/\n/,$queryHash{"searchText"});
>
> I later print it:
>
>
> 40 sub printSearchTerms
> 41 {
> 42 foreach(@searchTerms)
> 43 {
> 44 chomp;
> 45 print ("$_<BR>\n");
> 46 }
> 47 }
>
> And yet I get:
>
> point loma
><br>
> mission hills
><br>
> hillcrest
><br>
> bankers hill
><br>
> university heights<br>
>
> What's up?
perldoc -f chomp
It removes the input record separator ("$/") based the OS it is running
on. If newlines in your data are CR-LF and default newlines in your OS
are not, then you may need to set $/ = "\015\012"; before using chomp for
that.
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: Sat, 08 May 2004 02:26:28 GMT
From: die@spammer.die (Mark Healey)
Subject: Re: Why does chomp leave newlines?
Message-Id: <VP2SpNyJrzMZ-pn2-g58JOiUgmtw2@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
On Sat, 8 May 2004 01:49:09 UTC, efflandt@xnet.com (David Efflandt)
wrote:
> On Sat, 08 May 2004 00:50:57 GMT, Mark Healey <die@spammer.die> wrote:
> > First some fragments
> >
> > I get the array thusly:
> >
> > 13 @searchTerms=split(/\n/,$queryHash{"searchText"});
> >
> > I later print it:
> >
> >
> > 40 sub printSearchTerms
> > 41 {
> > 42 foreach(@searchTerms)
> > 43 {
> > 44 chomp;
> > 45 print ("$_<BR>\n");
> > 46 }
> > 47 }
> >
> > And yet I get:
> >
> > point loma
> ><br>
> > mission hills
> ><br>
> > hillcrest
> ><br>
> > bankers hill
> ><br>
> > university heights<br>
> >
> > What's up?
>
> perldoc -f chomp
>
> It removes the input record separator ("$/") based the OS it is running
> on. If newlines in your data are CR-LF and default newlines in your OS
> are not, then you may need to set $/ = "\015\012"; before using chomp for
> that.
Sinct this suppoded to be a CGI script and I don't know what os'es
are going to be making requests is there any way to set $/ to several
different possibilities such as CRLF, CR alone or LF alone?
I'd still like a function that removes all leading and trailing
whitespace. I suppose I could do it with regexps but that would be
kind of ugly.
------------------------------
Date: Sat, 08 May 2004 02:46:03 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Why does chomp leave newlines?
Message-Id: <409C49E3.6000008@rochester.rr.com>
Mark Healey wrote:
> On Sat, 8 May 2004 01:49:09 UTC, efflandt@xnet.com (David Efflandt)
> wrote:
>
>
>>On Sat, 08 May 2004 00:50:57 GMT, Mark Healey <die@spammer.die> wrote:
...
> Sinct this suppoded to be a CGI script and I don't know what os'es
> are going to be making requests is there any way to set $/ to several
> different possibilities such as CRLF, CR alone or LF alone?
No. The value of $/ is a string, not a regexp. Unless you do something
like [untested]:
{local $/;$/="\n";chomp}
{local $/;$/="\r";chomp}
{local $/;$/="\r\n";chomp} #not needed?
#etc?
>
> I'd still like a function that removes all leading and trailing
> whitespace. I suppose I could do it with regexps but that would be
> kind of ugly.
Why ugly? It should be simple [untested]:
sub trim{
my $s=shift;
$s=~/^\s*//;
$s=~/\s*$//;
return $s;
}
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 08 May 2004 04:01:14 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Why is this simple script not sending email?
Message-Id: <409C5B88.B171C12A@acm.org>
David Efflandt wrote:
>
> On 7 May 2004 11:16:11 -0700, fastjack <robnhood00@aol.com> wrote:
> > #My email is in the "To: " line. just not listed below for spam reasons.
>
> One reason your script does not work is because "@domain" and "@test" are
> list variables when in enclosed in double quotes, so your addresses are
^^^^^^^^^^^^^^
Perl doesn't have list variables, just scalars, arrays and hashes.
perldoc -q "What is the difference between a list and an array"
John
--
use Perl;
program
fulfillment
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V10 Issue 6541
***************************************