[24442] in Perl-Users-Digest
Perl-Users Digest, Issue: 6625 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 29 14:05:42 2004
Date: Sat, 29 May 2004 11:05:05 -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 Sat, 29 May 2004 Volume: 10 Number: 6625
Today's topics:
ANN: List::SkipList v0.63 release <mutantrob_NOSPAM_@verizon.net>
Announce OpenOffice::OODoc 1.106 <oodoc@genicorp.fr>
ANNOUNCE: Spreadsheet::WriteExcel 2.01 <jmcnamara@cpan.org>
Re: Another Dereference Post by me (Peter Scott)
Re: create directory ... <tadmc@augustmail.com>
decode_entities possible bug? <rbell001824@earthlink.net>
Device::Gsm v1.33 released to CPAN <cosimo@cpan.org>
Re: file read/write synchronization: advice needed <tadmc@augustmail.com>
Re: Login to MS Exchange to send e-mail <ywwong_hk@hotmail.com>
Re: Login to MS Exchange to send e-mail <grante@visi.com>
Re: Login to MS Exchange to send e-mail <joe@jretrading.com>
Nested Foreach and Closure (mt35)
Re: Nested Foreach and Closure <usenet@morrow.me.uk>
Re: Obtaining matched (sub)string (Michael T. Davis)
Re: regexp hangs script <norfernuman@yahoo.com>
Setting ENV varibles by calling a shell script within a <as@no-span.org>
Re: Setting ENV varibles by calling a shell script with <tadmc@augustmail.com>
UK Social research job to suit Excel programmer (not ne <buzzard@urubu.freeserve.co.uk>
Re: Why is this upload script not working <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 May 2004 21:52:57 GMT
From: Robert Rothenberg <mutantrob_NOSPAM_@verizon.net>
Subject: ANN: List::SkipList v0.63 release
Message-Id: <HyH4yB.FKD@zorch.sf-bay.org>
Version 0.63 of List::SkipList has been uploaded to PAUSE, and should
soon appear on a CPAN mirror near you.
NAME
List::SkipList - Perl implementation of skip lists
REQUIREMENTS
Perl 5.6.1 is required.
The following non-standard modules are required:
enum
Carp::Assert is no longer required. However, the assertions can
be uncommented for debugging.
SYNOPSIS
my $list = new List::SkipList();
$list->insert( 'key1', 'value' );
$list->insert( 'key2', 'another value' );
$value = $list->find('key2');
$list->delete('key1');
DESCRIPTION
This is an implementation of skip lists in Perl. What are "skip
lists"?
Skip lists are a probabilistic data structure that seem likely
to supplant balanced trees as the implementation method of
choice for many applications. Skip list algorithms have the same
asymptotic expected time bounds as balanced trees and are
simpler, faster and use less space.(*)
Skip lists are similar to linked lists, except that they have
random links at various levels that allow searches to skip over
sections of the list, like so:
4 +---------------------------> +----------------------> +
| | |
3 +------------> +------------> +-------> +-------> +--> +
| | | | | |
2 +-------> +--> +-------> +--> +--> +--> +-------> +--> +
| | | | | | | | |
1 +--> +--> +--> +--> +--> +--> +--> +--> +--> +--> +--> +
A B C D E F G H I J NIL
A search would start at the top level: if the link to the right
exceeds the target key, then it descends a level.
More information is available in the module documentation.
(*) Bill Pugh, inventor of skip lists. Quoted from WikiPedia
<http://en.wikipedia.org/wiki/Skip_list>
REVISION HISTORY
Changes since v0.60:
0.63 Fri May 28 2004
- The default value of P is now 0.25, which appears to yield
better results in tests.
* renamed _random_level to _new_node_level
- SIZE_THRESHOLD/SIZE_LEVEL now decrease with deletions
- additional minor optimizations and code cleanup
- optimizations of Header and Null node types
- updated tests
- Benchmark: re-commented-out delete test for Tree::RedBlack
(which was accidentally uncommented in v0.62)
0.62 Tue May 18 2004
- fixed typo in (commented-out) assertion
- additional minor optimizations and code cleanup
- updated tests
- corrected README
0.61 Mon May 17 2004
* find no longer returns a finger in array context
* header is now a special subclass of List::SkipList::Node
- added special Null subclass of Header
- added null() method to return global null node
- a lot of minor code optimizations
- added comments
- maximum level of new nodes changed so that it is based on size
of list
- updated Benchmark.txt file
A detailed revision history is in the Changes file included with
this distribution.
CAVEATS
Skip lists are non-deterministic. Because of this, bugs in programs
that use this module may be subtle and difficult to reproduce without
many repeated attempts.
AUTHOR
Robert Rothenberg <rrwo at cpan.org>
LICENSE
Copyright (c) 2003-2004 Robert Rothenberg. All rights reserved. This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
------------------------------
Date: Thu, 27 May 2004 14:42:30 GMT
From: "OpenOffice::OODoc Project" <oodoc@genicorp.fr>
Subject: Announce OpenOffice::OODoc 1.106
Message-Id: <HyH4xx.FJK@zorch.sf-bay.org>
OpenOffice::OODoc 1.106 is available today at
http://search.cpan.org/dist/OpenOffice-OODoc
OpenOffice::OODoc is a Perl library providing high-level methods for
OpenOffice.org document processing. It allows a lot of read/write
operations in various areas such as text content, images, page layout,
styles.
OpenOffice::OODoc operates directly against the OpenOffice files, so
it doesn't depend on the API of the OpenOffice.org desktop software et
can run on any Perl 5.8.x platform.
------------------------------
Date: Wed, 26 May 2004 23:48:19 GMT
From: John McNamara <jmcnamara@cpan.org>
Subject: ANNOUNCE: Spreadsheet::WriteExcel 2.01
Message-Id: <HyH4xo.FIv@zorch.sf-bay.org>
======================================================================
ANNOUNCE
Spreadsheet::WriteExcel version 2.01 has been uploaded to CPAN.
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel
======================================================================
NAME
Spreadsheet::WriteExcel - Write formatted text and numbers to a
cross-platform Excel binary file.
======================================================================
CHANGES
This version is a MAJOR revision to Spreadsheet::WriteExcel. The
format of the Excel file that it produces has been updated from
Excel 5 to Excel 97. This allows support for long, 32k character
strings and Unicode.
DUE TO THE MAJOR INTERNAL CHANGES IT IS RECOMMENDED THAT YOU TEST
THIS UPGRADE FULLY BEFORE DEPLOYING IT.
Also note that this version can be 1.5 to 2 times slower than
previous versions and the write_comment() method has been
temporarily removed. These issues will be fixed in later releases.
+ Changed the default Excel format to Excel 97.
+ Added support for strings up to 32767 character.
+ Added support for Unicode strings.
+ Improved speed in relation to pre-release versions.
However, it is still slower than the 1.xx versions.
+ Improved OpenOffice support.
+ Added more examples: diag_border.pl, indent.pl,
unicode.pl, unicode_japan.pl, unicode_list.pl
+ Changed the distro dir structure.
- Temporarily removed write_comment() support since the Excel 5
version isn't compatible with Excel 97+.
======================================================================
DESCRIPTION
The Spreadsheet::WriteExcel module can be used create a cross-
platform Excel binary file. Multiple worksheets can be added to a
workbook and formatting can be applied to cells. Text, numbers,
formulas and hyperlinks and images can be written to the cells.
The Excel file produced by this module is compatible with
Excel 97, 2000, 2002 and 2003.
The module will work on the majority of Windows, UNIX and
Macintosh platforms. Generated files are also compatible with the
Linux/UNIX spreadsheet applications Gnumeric and OpenOffice.
The generated files are not compatible with MS Access.
This module cannot be used to read an Excel file. See
Spreadsheet::ParseExcel or look at the main documentation for some
suggestions.
This module cannot be used to write to an existing Excel file.
======================================================================
SYNOPSIS
To write a string, a formatted string, a number and a formula to
the first worksheet in an Excel workbook called perl.xls:
use Spreadsheet::WriteExcel;
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("perl.xls");
# Add a worksheet
$worksheet = $workbook->addworksheet();
# Add and define a format
$format = $workbook->addformat(); # Add a format
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
# Write a formatted and unformatted string
$col = $row = 0;
$worksheet->write($row, $col, "Hi Excel!", $format);
$worksheet->write(1, $col, "Hi Excel!");
# Write a number and a formula using A1 notation
$worksheet->write('A3', 1.2345);
$worksheet->write('A4', '=SIN(PI()/4)');
======================================================================
REQUIREMENTS
This module requires Perl 5.005 (or later), Parse::RecDescent and
File::Temp
http://search.cpan.org/search?dist=Parse-RecDescent
http://search.cpan.org/search?dist=File-Temp
======================================================================
AUTHOR
John McNamara (jmcnamara@cpan.org)
--
------------------------------
Date: Sat, 29 May 2004 13:27:35 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Another Dereference Post by me
Message-Id: <bd0uc.619619$Ig.266118@pd7tw2no>
In article <40B78D79.FCDA6DBA@earthlink.net>,
Mike Flannigan <mikeflan@earthlink.net> writes:
>Then what I really want is to sort by the 5th column that looks
>like "381715N0930417W", keeping in mind that there are
>duplicate values in that column.
[snip]
>my @sorted =
> map $_->[0],
> sort { $b->[1] cmp $a->[1] }
> map [$_, /(.*)/ ? $1 : die "$_"],
> @data;
I am having a hard time guessing what this type of sorting of
two-dimensional data is buying you. You'll end up with a list
sorted by latitude but with longitude all over the place.
I can only think of marginally useful esoteric purposes for that
so far.
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: Sat, 29 May 2004 07:26:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: create directory ...
Message-Id: <slrncbh0av.o0e.tadmc@magna.augustmail.com>
BreadWithSpam@fractious.net <BreadWithSpam@fractious.net> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> writes:
>
>> What's wrong with the builtin function mkdir?
>
> FWIW, I usually use File::Path's mkpath as well.
You snipped the context.
Martien's comment applied to code that looked like this (ie. not your code):
system("mkdir $dir")
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 29 May 2004 17:00:22 GMT
From: Richard Bell <rbell001824@earthlink.net>
Subject: decode_entities possible bug?
Message-Id: <wk3uc.13699$4A6.12679@attbi_s52>
decode_entities does not appear to decode this text
<span class="linksep1">•</span>
The sequence • is left untouched.
Is this correct/expected behavior, a bug, or what?
Thanks for any help.
R
------------------------------
Date: Wed, 26 May 2004 19:33:29 GMT
From: Cosimo Streppone <cosimo@cpan.org>
Subject: Device::Gsm v1.33 released to CPAN
Message-Id: <HyH4wx.ux8@zorch.sf-bay.org>
Version 1.33 of Device::Gsm perl extension has been released to CPAN,
and should be available at your local CPAN mirror in a day or two.
Changes
-------------
1.28 => 1.33
Wed May 26 13:52:43 CEST 2004
- added delete_sms() method. For now, works only in PDU mode.
- fixed messages() newline regex split pattern
- modified send sms in text mode to cope with slower/older devices
- modified message read method to set pdu mode before executing
What it is?
------------
Device::Gsm is perl extension to talk to your gsm mobile phone
via serial port, bluetooth, irda, ... and reads/writes sms messages,
reads battery level, signal, imei(serial) number, makes calls,
and everything is allowed by the GSM AT+C command set.
It works at least on Windows, Linux, Solaris and *BSD systems.
Prerequisites
-------------
+ working perl installation >= 5.005_03
+ Device::Modem (most recent version is fine)
+ Device::SerialPort (or Win32::SerialPort for Windows systems)
+ a gsm mobile phone, or oem device, compliant with AT+C GSM
command set (nearly every model is AT+C compliant)
Installation
------------
This module installs like all other good old perl modules:
$ perl Makefile.PL
$ make
$ make test
$ make install
Licensing terms
---------------
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
Use it at your own risk, and without ANY warranty!
For any need of commercial support and/or licensing, please contact
me directly: Cosimo Streppone <cosimo@cpan.org>
------------------------------
Date: Sat, 29 May 2004 07:22:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: file read/write synchronization: advice needed
Message-Id: <slrncbh03u.o0e.tadmc@magna.augustmail.com>
Ben Morrow <usenet@morrow.me.uk> wrote:
>
> Quoth qcg2222@yahoo.com (Junpei):
>> problem: I have a program A that writes (overwrite) to a file 5
>> times/second (the results of a realtime calculation); i want several
>> other programs B through E to occasionally read that file to see what
>> the current results are (I only need the current results). how do i
>> keep the programs B to E from trying to read while program A is
>> writing? or is there a better solution than writing to a file? hoping
>> for an easy solution... i'm on linux.
>
> perldoc -f flock
See also:
perldoc -q "\block"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 30 May 2004 00:00:30 +0800
From: "Y W Wong" <ywwong_hk@hotmail.com>
Subject: Re: Login to MS Exchange to send e-mail
Message-Id: <c9adch$1sjv$1@news.hgc.com.hk>
I understood the SMTP and POP3 description.
But it doesn't answer my question.
I am asking how to login like MS Outlook, not by POP3 or SMTP.
Hope that someone know what I am asking for.
"Grant Edwards" <grante@visi.com> ¦b¶l¥ó
news:slrncbeip2.fsp.grante@grante.rivatek.com ¤¤¼¶¼g...
> On 2004-05-28, Y W Wong <ywwong_hk@hotmail.com> wrote:
>
> >>> Anyone know that how can I login to a MS Exchange server using
> >>> my corporate e-mail account to send a e-mail. I use to do some
> >>> automatic job and send the result to my colleagues in my
> >>> corporation. I am using a RH9 Linux box and prefer to use Perl
> >>> or shell script to do that.
> >>
> >> Ask your exchange admin to start the SMTP-, and IMAP- or
> >> POP3-connectors on the Exchange Server. Then use the usual
> >> mail-modules available from CPAN.
> >
> > I just want to act as a simple script type MS Outlook to send
> > text mail. Anyone know how ?
>
> Yes. You've just been told how. What part of the answer
> didn't you understand?
>
> --
> Grant Edwards grante Yow! Hey, waiter! I
want
> at a NEW SHIRT and a PONY
TAIL
> visi.com with lemon sauce!
------------------------------
Date: 29 May 2004 17:11:48 GMT
From: Grant Edwards <grante@visi.com>
Subject: Re: Login to MS Exchange to send e-mail
Message-Id: <40b8c454$0$17252$a1866201@newsreader.visi.com>
In article <c9adch$1sjv$1@news.hgc.com.hk>, Y W Wong wrote:
>> >>> Anyone know that how can I login to a MS Exchange server using
>> >>> my corporate e-mail account to send a e-mail. I use to do some
>> >>> automatic job and send the result to my colleagues in my
>> >>> corporation. I am using a RH9 Linux box and prefer to use Perl
>> >>> or shell script to do that.
>> >>
>> >> Ask your exchange admin to start the SMTP-, and IMAP- or
>> >> POP3-connectors on the Exchange Server. Then use the usual
>> >> mail-modules available from CPAN.
>> >
>> > I just want to act as a simple script type MS Outlook to send
>> > text mail. Anyone know how ?
>>
>> Yes. You've just been told how. What part of the answer
>> didn't you understand?
>
> I understood the SMTP and POP3 description. But it doesn't
> answer my question. I am asking how to login like MS Outlook,
> not by POP3 or SMTP.
You can't. Outlook uses a proprietary, undocumented protocol
to talk to Exchange server. The only way to send mail w/o
using SMTP is to run you application under Windows and use the
COM interface to Outlook and send mail using Outlook itself.
You said that what you want to do is use a simple script
interface to send text e-mails. That is about as far from
being "like Outlook" as you can get. :)
--
Grant Edwards grante Yow! HOORAY, Ronald!! Now
at YOU can marry LINDA
visi.com RONSTADT too!!
------------------------------
Date: Sat, 29 May 2004 18:29:42 +0100
From: Joe <joe@jretrading.com>
Subject: Re: Login to MS Exchange to send e-mail
Message-Id: <LZ21AXRGiMuAFwL$@jretrading.com>
In message <40b8c454$0$17252$a1866201@newsreader.visi.com>, Grant
Edwards <grante@visi.com> writes
>In article <c9adch$1sjv$1@news.hgc.com.hk>, Y W Wong wrote:
>
>>
>> I understood the SMTP and POP3 description. But it doesn't
>> answer my question. I am asking how to login like MS Outlook,
>> not by POP3 or SMTP.
>
>You can't. Outlook uses a proprietary, undocumented protocol
>to talk to Exchange server. The only way to send mail w/o
>using SMTP is to run you application under Windows and use the
>COM interface to Outlook and send mail using Outlook itself.
>
The protocol is called MAPI. Search for this on the Net to get a feel
for the ease of interfacing with it.
--
Joe
------------------------------
Date: 29 May 2004 06:53:07 -0700
From: mt35@linuxmail.org (mt35)
Subject: Nested Foreach and Closure
Message-Id: <2763816a.0405290553.57d5e469@posting.google.com>
Hello,
I'm trying to pass a lexical variable down from one subroutine to
another. I have read perlfaq7 on closure (among others) and grasp the
concept for the situation they gave, however I think I'm trying to do
something else entirely. Also I'm only two weeks old in perl so if I'm
going about this in totally the wrong way pointers on the right way to
go are appreciated.
I have an array of an ipfilter log (@fwlog) and a separate array of 10
addresses (@hirate), each of which will have an entry in the ipfilter
log more than 15 times. I want to make an additional array (@hirate1)
of the full log entry foreach address, thus weeding out all entries
that do not correspond to the 10 address array (@hirate).
The original code with no closure performed on it:
foreach (@hirate) {
$y = $_;
foreach (@fwlog) {
push (@hirate1, $_) if ($_ =~ $y);
}
}
Example Variables:
$y = 192.168.1.81
@fwlog = Jan 4 03:01:02 host0 ipmon[51]: 03:01:01.088578 xl0 @0:1 b
192.168.1.81,1047 -> 192.168.1.100,53 PR udp len 20 61 OUT
The original problem I was having was @hirate1 would come out with a
count of approx. 3000 when the original firewall log had a count of
approx 1900.
Here is what I tried:
foreach (@hirate) {
$y = $_;
$q = max($y);
&$q();
sub max {
return sub {
foreach (@fwlog) {
push (@hirate1, $_) if ($_ =~ $y);
}
}
}
}
However, this brings back approx 3000 entires as well? Do I have some
syntax wrong or am I way off point?
Thanks,
-SLM
------------------------------
Date: Sat, 29 May 2004 15:37:05 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Nested Foreach and Closure
Message-Id: <c9aan1$d2j$1@wisteria.csv.warwick.ac.uk>
Quoth mt35@linuxmail.org (mt35):
> Hello,
>
> I'm trying to pass a lexical variable down from one subroutine to
> another. I have read perlfaq7 on closure (among others) and grasp the
> concept for the situation they gave, however I think I'm trying to do
> something else entirely. Also I'm only two weeks old in perl so if I'm
> going about this in totally the wrong way pointers on the right way to
> go are appreciated.
>
> I have an array of an ipfilter log (@fwlog) and a separate array of 10
> addresses (@hirate), each of which will have an entry in the ipfilter
> log more than 15 times. I want to make an additional array (@hirate1)
> of the full log entry foreach address, thus weeding out all entries
> that do not correspond to the 10 address array (@hirate).
>
> The original code with no closure performed on it:
>
If you are trying to use closures you *certainly* need to be using
lexical variables. In any case, you should have
use strict;
use warnings;
at the top of your program.
my @hirate1;
> foreach (@hirate) {
> $y = $_;
for my $y (@hirate) {
> foreach (@fwlog) {
> push (@hirate1, $_) if ($_ =~ $y);
push @hirate1, $_ if /$y/;
> }
> }
>
> Example Variables:
> $y = 192.168.1.81
> @fwlog = Jan 4 03:01:02 host0 ipmon[51]: 03:01:01.088578 xl0 @0:1 b
> 192.168.1.81,1047 -> 192.168.1.100,53 PR udp len 20 61 OUT
>
> The original problem I was having was @hirate1 would come out with a
> count of approx. 3000 when the original firewall log had a count of
> approx 1900.
Obviously you are ending up with entries from @fwlog in @hirate1 more
than once; run it with a small data set to see.
> Here is what I tried:
>
> foreach (@hirate) {
> $y = $_;
> $q = max($y);
> &$q();
>
> sub max {
> return sub {
> foreach (@fwlog) {
> push (@hirate1, $_) if ($_ =~ $y);
> }
> }
> }
> }
>
> However, this brings back approx 3000 entires as well? Do I have some
> syntax wrong or am I way off point?
I'm not quite sure what you expected this to achieve... some points
unrelated to your problem:
You should not define (named) subs inside loops.
Your sub name 'max' is... confusing.
You should avoid global variables where you don't need them.
Your 'foreach (@fwlog)' loop is what grep is designed to do.
So you could rewrite as:
sub look_for {
my $y = shift;
return sub {
return grep /$y/, @_;
};
}
my @hirate1;
for (@hirate) {
push @hirate1, look_for($_)->(@fwlog);
}
or use map:
my @hirate1 = map { look_for($_)->(@fwlog) } @hirate;
However, there is no point in having a closure here: you might as well
have simply written:
sub look_for {
my $y = shift;
return grep /$y/, @_;
}
my @hirate1 = map { look_for $_, @fwlog } @hirate;
at which point it becomes clear that look_for is simply grep.
I would code this problem like this:
# create a regex that matches any entry in @hirate
my $hirates = join '|', map { qr/\Q$_/ } @hirate;
# find the entries in the log that match
my @hirate1 = grep /$hirates/, @fwlog;
which won't return any entry in @fwlog more than once.
Ben
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: 29 May 2004 16:11:54 GMT
From: DAVISM@er6.eng.ohio-state.edu (Michael T. Davis)
Subject: Re: Obtaining matched (sub)string
Message-Id: <c9acoa$35o$1@charm.magnus.acs.ohio-state.edu>
In article <slrncbed8h.gld.tadmc@magna.augustmail.com>, Tad McClellan
<tadmc@augustmail.com> writes:
>Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>
>> (Are there any spam crap any longer that spells out "viagra" in
>> cleartext?)
>
>
>He may be working on "normalized" words, so his code _may_ be useful.
That is, in fact, what I'm doing. The case I provided was just a
simplification.
>
>
>--
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
Regards,
Mike
--
Michael T. Davis | Systems Specialist: ChE,MSE
E-mail: davism@er6.eng.ohio-state.edu | Departmental Networking/Computing
-or- DAVISM+@osu.edu | The Ohio State University
http://www.er6.eng.ohio-state.edu/~davism/ | 197 Watts, (614) 292-6928
------------------------------
Date: Sat, 29 May 2004 11:50:53 GMT
From: norfernuman <norfernuman@yahoo.com>
Subject: Re: regexp hangs script
Message-Id: <xO_tc.74109$NV5.5369@newssvr25.news.prodigy.com>
Tore Aursand wrote:
> On Sat, 29 May 2004 00:35:29 +0000, norfernuman wrote:
>
>>foreach my $flag (@form_flags) {
>>
>> foreach $_ ($q->param()) {
>> if ( $_ =~ /(^\w+_)/ ) {
>> if ( $1 eq $flag ) {
>> s/^\w+_//g; #### this make script hang
>> print "$_ : " . $q->param($_) . "<p>\n";
>> }
>> }
>> }
>>
>>}
Thanks
>
> Don't set the $_ variable. Let Perl itself take care of that;
>
> foreach my $flag ( @form_flags ) {
> foreach ( $q->param() ) {
> if ( /(^\w+_)/ ) {
> if ( $1 eq $flag ) {
> s/^\w+_//g;
> print "$_ : " . $q->param( $_ ) . "<p>\n";
> }
> }
> }
> }
>
>
------------------------------
Date: Sat, 29 May 2004 11:55:41 -0400
From: ad <as@no-span.org>
Subject: Setting ENV varibles by calling a shell script within a perl program
Message-Id: <pan.2004.05.29.15.55.40.436093@no-span.org>
I need to make some system calls to other programs from a perl program
and those programs that are being called have some environment
variable dependencies that are set by a shell script program. So I
have to call this shell script to set up (export bunch of variables)
environment variables so that the other program that I call can run
fine.
If all possible, I am trying to avoid writing another shell program
that call the other shell program prior to my perl program since I
have lots of variable combination that my perl program can run with
and do not want to have all the variable validated with this extra
shell program so that it can call my perl program.
In the following example, I tried both "system" and "``" (backtricks)
but none of them worked.
---- Shell Program ------------
#!/bin/sh
export T1=test1
export T2=test2
export T3=test3
export T4=test4
---- End Of Shell Program -----
----- My Test Perl Program ----
#!/usr/bin/perl
use warnings;
use strict;
#system(". ./myShell.sh"); # Tried both
`. ./myShell.sh`;
print "T1 = $ENV{T1}\n"; # Prints blank
print "T2 = $ENV{T2}\n"; # Prints blank
print "T3 = $ENV{T3}\n"; # Prints blank
print "T4 = $ENV{T4}\n"; # Prints blank
----- End Of Perl Program ----
Thanks for the help and suggestions in advance.
------------------------------
Date: Sat, 29 May 2004 11:13:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Setting ENV varibles by calling a shell script within a perl program
Message-Id: <slrncbhdks.p5a.tadmc@magna.augustmail.com>
ad <as@no-span.org> wrote:
>
> I need to make some system calls to other programs from a perl program
> and those programs that are being called have some environment
> variable dependencies that are set by a shell script program. So I
> have to call this shell script to set up (export bunch of variables)
^^^^^^^
> environment variables so that the other program that I call can run
> fine.
No you don't.
You can set env vars in Perl via the %ENV hash.
Any external processes (child) you start will inherit their env from
the Perl program (parent).
> If all possible, I am trying to avoid writing another shell program
> that call the other shell program prior to my perl program since I
> have lots of variable combination that my perl program can run with
> and do not want to have all the variable validated with this extra
> shell program so that it can call my perl program.
If you want access to those env vars in your Perl program, then
wrapping it in a sh program is what you should do.
I don't think I understand what your objection to that approach is.
Why is that not a good solution?
> #system(". ./myShell.sh"); # Tried both
If you just want to launch programs that make use of those env vars,
and don't need them in your Perl program, then just set them in
the same (sub) process:
system '. ./myShell.sh; other_prog';
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 29 May 2004 14:39:24 +0100
From: "Duncan Smith" <buzzard@urubu.freeserve.co.uk>
Subject: UK Social research job to suit Excel programmer (not necessarily VBA)
Message-Id: <c9a3jn$t3r$1@newsg4.svr.pol.co.uk>
http://www.man.ac.uk/news/vacancies/research.html#581
Apologies if this is an inappropriate post for this group.
Duncan Smith
------------------------------
Date: Sat, 29 May 2004 14:13:53 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Why is this upload script not working
Message-Id: <2hrdb8Fg9qjoU1@uni-berlin.de>
Ben Morrow wrote:
> Quoth Gunnar Hjalmarsson <noreply@gunnar.cc>:
>>
>> if ($file =~ /^([\w.-]+)$/) {
>> $file = $1;
>
> This is still wrong; had he actually read my last post this would
> have been clear...
>
> $file is a CGI file upload object. You need to use a different
> variable for the untainted filename.
Thanks for the correction. I forgot about the special nature of the
$file variable.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 6625
***************************************