[25126] in Perl-Users-Digest
Perl-Users Digest, Issue: 7376 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 8 09:05:23 2004
Date: Mon, 8 Nov 2004 06:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Nov 2004 Volume: 10 Number: 7376
Today's topics:
[ANNOUNCE] Apache::SessionManager 1.03 <enrico@sorcinelli.it>
[ANNOUNCE] Filter-Crypto 1.00 (Steve Hay)
Re: Array -> Reference to Hash of Arrays <do-not-use@invalid.net>
Re: Binary files in PERL? <vek@station02.ohout.pharmapartners.nl>
Re: Common file operations <bik.mido@tiscalinet.it>
Convert::yEnc 1.02 released <swmcd@TheWorld.com>
Extract a number from a string. (Adam)
Re: Extract a number from a string. <wyzelli@yahoo.com>
Re: Extract a number from a string. (Anno Siegel)
FAQ 4.28: How do I change the Nth occurrence of somethi <comdog@panix.com>
Re: Firefox broswer staring Perl CGI <tadmc@augustmail.com>
Re: Firefox broswer staring Perl CGI <ithinkiam@gmail.com>
Re: Firefox broswer staring Perl CGI <1usa@llenroc.ude.invalid>
how greedy is nongreedy in regexp ? <pilsl@goldfisch.at>
Re: how greedy is nongreedy in regexp ? <vek@station02.ohout.pharmapartners.nl>
Re: how greedy is nongreedy in regexp ? (Anno Siegel)
Net::Telnet connection status (juky)
Re: OT (Re: casting question) (Anno Siegel)
Re: Solaris taking over Perl ownership <do-not-use@invalid.net>
Re: Spam-free Mailto.pl or similar prog? <noreply@gunnar.cc>
Re: Spam-free Mailto.pl or similar prog? <usenet_05_08_2004@stuartmoore.org.uk>
Re: Spam-free Mailto.pl or similar prog? <wyzelli@yahoo.com>
Re: sub refs in qq strings <tadmc@augustmail.com>
Re: Upload meter for a CGI perl script <ineverreadanythingsenttome@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 7 Nov 2004 22:57:31 GMT
From: Enrico Sorcinelli <enrico@sorcinelli.it>
Subject: [ANNOUNCE] Apache::SessionManager 1.03
Message-Id: <I6v4I6.9Hp@zorch.sf-bay.org>
The uploaded file
Apache-SessionManager-1.03.tar.gz
has entered CPAN as
file: $CPAN/authors/id/E/EN/ENRYS/Apache-SessionManager-1.03.tar.gz
size: 30712 bytes
md5: 85b412074edde465fcf291a1fef0e5e2
Changes from previous version
-----------------------------
* Adopted dotted-quad/mask syntax (eg "192.168.0.0/16") when setting
SessionManagerIPExclude IP exclusion list
+ Added remote IP in debug messages
+ Added new cookpod section: "Apache::SessionManager WITH CGI::Builder"
! Substituted each STDERR prints with $r->log_error mod_perl API calls
! Bug fix: SessionManagerHeaderExclude skips check when header or its value
is undefined
! Tested also with latest Apache/mod_perl release (2.0.52/1.99_17)
See perldoc Apache::SessionManager for module documentation and use
See perldoc Apache::SessionManager::cookpod for more info about module use
Any comment and/or criticism are welcome :-)
by
- Enrico
------------------------------
Date: Mon, 1 Nov 2004 17:24:46 GMT
From: steve.hay@uk.radan.com (Steve Hay)
Subject: [ANNOUNCE] Filter-Crypto 1.00
Message-Id: <I6v4G8.1EHE@zorch.sf-bay.org>
The uploaded file
Filter-Crypto-1.00.tar.gz
has entered CPAN as
file: $CPAN/authors/id/S/SH/SHAY/Filter-Crypto-1.00.tar.gz
size: 93909 bytes
md5: 82a643c15acd4493bf1bba5920b156cc
NAME
Filter::Crypto - Create runnable Perl files encrypted with OpenSSL libcrypto
SYNOPSIS
# Encrypt a Perl script using the crypt_file script; run it as usual:
$ crypt_file --in-place hello.pl
$ hello.pl
# Create a PAR archive containing an encrypted Perl script; run it as usual:
# (This example assumes that you also have PAR installed)
$ pp -f Crypto -M Filter::Crypto::Decrypt -o hello hello.pl
$ hello
DESCRIPTION
This distribution provides the means to convert your Perl files into an
encrypted, yet still runnable, format to hide the source code from casual
prying eyes.
This is achieved using a Perl source code filter. The encrypted files,
produced using the Filter::Crypto::CryptFile module automatically have one
(unencrypted) line added to the start of them which loads the
Filter::Crypto::Decrypt module. The latter is a Perl source code filter
which decrypts the remaining (encrypted) part of the Perl file on-the-fly
when it is run.
These two modules can be built and installed separately, so it is possible
to setup two separate Perl installations: one containing the
Filter::Crypto::CryptFile module to be used for encrypting your Perl files,
and another containing only the Filter::Crypto::Decrypt module for
distributing with your encrypted Perl files so that they can be run but not
easily decrypted.
Encrypted files can also be produced more conveniently using the crypt_file
script, or (if you also have the PAR module available) using the
PAR::Filter::Crypto module. The latter can be utilised by the standard PAR
tools to produce PAR archives in which your Perl files are encrypted. The
Filter::Crypto::Decrypt module (only) can also be automatically included in
these PAR archives, so this is perhaps the easiest way to produce
redistributable, encrypted Perl files.
The actual encryption and decryption is performed using one of the symmetric
cipher algorithms provided by the OpenSSL libcrypto library.
PREREQUISITES
OpenSSL (any version), or SSLeay version 0.6.0 or later.
The latest version of OpenSSL is available from http://www.openssl.org/.
Perl version 5.6.0 or later.
The latest version of Perl is available from http://www.perl.com/.
There are no non-standard Perl modules required by the two main modules in
this distribution (Filter::Crypto::CryptFile and Filter::Crypto::Decrypt),
but the crypt_file script and the PAR::Filter::Crypto module both require
File::Temp
which is only a standard Perl module from Perl version 5.6.1 onwards
(crypt_file only requires it when run with the "-e tempfile" option), and
the PAR::Filter::Crypto module also requires
PAR::Filter
which is part of the PAR distribution.
A standalone distribution of the File::Temp module, as well as the PAR
distribution, are both available from CPAN (http://www.cpan.org/).
------------------------------
Date: 08 Nov 2004 09:43:58 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Array -> Reference to Hash of Arrays
Message-Id: <yzdsm7kwx0x.fsf@invalid.net>
Eric Schwartz <emschwar@pobox.com> writes:
> Argh, to quote (possibly apocryphally) Niels Bohr: "That isn't right.
> It's not even wrong!"
It seems to be more often attributed to Wolfgang Pauli.
------------------------------
Date: 08 Nov 2004 09:12:23 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: Binary files in PERL?
Message-Id: <slrncoue9r.ul.vek@station02.ohout.pharmapartners.nl>
On Sun, 07 Nov 2004 05:58:41 GMT,
Jürgen Exner <jurgenex@hotmail.com> wrote:
> Benjamin Khoo wrote:
>> i would like to find out how to write a binary file in PERL
>>
>> most of the readme and tutorial online only deal with writing ASCII
>> files.
>
> Are you really on an OS that differentiates between binary and text files?
> Then you may want to check
> perldoc -q binary: "How do I handle binary data correctly?"
> perldoc -f binmode
>
Also: perldoc -f pack for ideas about how to create data to write to the
binary file.
Villy
------------------------------
Date: Mon, 08 Nov 2004 09:38:04 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Common file operations
Message-Id: <raauo01qh10sg2rbdmukbf8uphfss0nqs5@4ax.com>
On Sat, 06 Nov 2004 23:15:26 -0500, "Shmuel (Seymour J.) Metz"
<spamtrap@library.lspace.org.invalid> wrote:
>> {
>> local $,=',';
>> print "@ARGV\n";
>> }
>
>But would it be as clear?
IIRC the original code was
print '@ARGV=(',join(',',@ARGV),")\n";
so, even if readability/clarity is to a large extent a personal
matter, I would say: YES. However it is worth pointing out that indeed
the advantage for a single string is not so relevant, but since you
were printing many entries like that, you *may* have earned much by
wrapping the whole section in a block and locally setting the relevant
variables there:
{
local ($\, $,)=("\n", ',');
print "\@ARGV=(@ARGV)";
...
print "\@DIRS=(@DIRS)";
...
}
>>Huh?!? Are you running Perl6?
>
>You're right; I need parentheses around the comparisons.
Another good reason for not retyping code, but to paste instead, as
people often suggest here.
>>Moreover, out of curiosity: why " \n" instead of "\n"?
>
>Typo. I meant
>
> elsif (@dirs>1) {
> die "$dir matches multiple directory names:\n",
> ' ', join("\n ",@dirs),"\n";
>
>Which indents for readability.
Personally I don't see any usefulness in that, but I'm not contending
your claim since I understand that it's something depending solely on
one's taste.
>>All in all I'd rewrite the whole fragment as:
>> @dirs or die "`$dir' doesn't match any directory name\n";
>> die "`$dir' matches multiple directory names:\n",
>> map "$_\n", @dirs if @dirs>1;
>
>What is the reason for mixing styles here, as opposed to putting the
>tests on the same ends?
No good reasons, I'm afraid. Again, a matter of personal tastes: I'm
not bothered by the mixing of styles and OTOH I like to use logical
operator's short circuiting but I like it better with some constructs
and I like it less with some others. All in all the example code
snippet quoted above 'sounds good' which is fine for me. If you prefer
to avoid any mix of styles and cosider that more elegant, of course
I'm not contending that in any way...
BTW: I'm not golfing, but I'm lazy and since
@dirs or die "`$dir' doesn't match any directory name\n";
and
die "`$dir' doesn't match any directory name\n" unless @dirs;
'sound just as good' but the latter costs a few more keystrokes, I've
probably instinctively chosen the former. Of course another
possibility (amongst the seemingly infinite ones) could have been "if
!@dirs", but hey, that would have costed me pressing the shift key!
Jokes apart, in these situations *generally* I prefer C<unless>. But
then this is yet another one of those matters of personal
preferences...
>>No, I suggested you to search 'WARNING' in perldoc perlre.
>
>That's how I got the text I quoted, in
>
> =head1 DESCRIPTION
> =head2 Warning on \1 vs $1
>
>It seemed more relevant than the text in
>
> =head1 DESCRIPTION
> =head2 Regular Expressions
>
>since I wasn't using $&, $' or $`.
Well, whatever, 'WARNING' ne 'Warning'. It was relevant though in that
you were concerned in possible performance issues with "my solution"
as opposed to "your solution" and mine was not capturing while yours
was: in fact you weren't "using $&, $' or $`", but indeed you were
using $1. Also I wrote that you *may* have been interested; since you
were concerned about performance issues anyway.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 2 Nov 2004 03:28:02 GMT
From: Steven W McDougall <swmcd@TheWorld.com>
Subject: Convert::yEnc 1.02 released
Message-Id: <I6v4Gr.18E2@zorch.sf-bay.org>
Convert::yEnc 1.02 has been released to CPAN.
>From the README:
Convert/yEnc version 1.02
======================
A yEnc decoder, with database of file parts
Convert::yEnc decodes yEncoded files and writes them to disk. File
parts are saved to a temporary directory; when all parts of a file
have been received, the completed file is moved to its final location.
Convert::yEnc maintains a database of partially received files, called
the RC database. The RC database is loaded from disk when a
Convert::yEnc object is created, and saved to disk when the object is
DESTROY'd.
CHANGES
1.02 2004 Oct 28
Convert::yEnc
- fixed a warning
Convert::yEnc::Entry.pm
- fixed a warning
t/Decoder.t
- invoke $Config{perlpath}, not 'perl'
t/Entry.t
- more tests
1.01 2003 Nov 26
Convert::yEnc
- fixed _complete()
- use warnings
Convert::yEnc::Decode.pm
- go faster
- use warnings
Convert::yEnc::RC.pm
- use warnings
Convert::yEnc::Entry.pm
- use warnings
1.00 2002 Nov 13
Initial version
TODO
XS implementation of Convert::yEnc::Decoder::_line
CRCs
Encoding
Send suggestions, bugs, etc. to swmcd@world.std.com
ACKNOWLEDGMENTS
Laurent Caprani <laurent.caprani@laposte.net>
Jason Hudgins <thanatos@incantations.net>
Eric Young <eay@pobox.com>
John Gilbert <jgilbert@biomail.ucsd.edu>
COPYRIGHT AND LICENCE
Copyright (C) 2002-2004 Steven McDougall.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
------------------------------
Date: 8 Nov 2004 02:40:03 -0800
From: adam_cheney@hotmail.com (Adam)
Subject: Extract a number from a string.
Message-Id: <214d0889.0411080240.23a9c5bc@posting.google.com>
Hi All,
Apologies if this is laughably simple, but it's been a long time since
I've used Perl, and I seem to suffer from Homer Simpson's problem:
every time I learn something new, it pushes old stuff out.
I'm trying to extract a number from a line of text returned by a
license-checking command. I open a pipe to the command, and read
through each line that is returned. When I find the text "Maximum..."
or "Current..." I want to extract and store the number in that line. I
tried using something like this to start with:
$lic_usage{$lic_type}{$max} = /\d+/ if (/Maximum/);
$lic_usage{$lic_type}{$cur} = /\d+/ if (/Current/);
Of course, this only stores a 1 ('True') when it finds the string, and
I want it to record the actual digits.
Help!
Cheers - Adam...
------------------------------
Date: Mon, 08 Nov 2004 10:54:26 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Extract a number from a string.
Message-Id: <CfIjd.27076$K7.12840@news-server.bigpond.net.au>
"Adam" <adam_cheney@hotmail.com> wrote in message
news:214d0889.0411080240.23a9c5bc@posting.google.com...
> Hi All,
>
> Apologies if this is laughably simple, but it's been a long time since
> I've used Perl, and I seem to suffer from Homer Simpson's problem:
> every time I learn something new, it pushes old stuff out.
>
> I'm trying to extract a number from a line of text returned by a
> license-checking command. I open a pipe to the command, and read
> through each line that is returned. When I find the text "Maximum..."
> or "Current..." I want to extract and store the number in that line. I
> tried using something like this to start with:
>
> $lic_usage{$lic_type}{$max} = /\d+/ if (/Maximum/);
> $lic_usage{$lic_type}{$cur} = /\d+/ if (/Current/);
You need to capture the numbers IF there is a match...
if (/Maximum/){$lic_usage{$lic_type}{$max} = $1 if (/(\d+)/)};
Because there are two conditionals involved (you don't want to assign from
$1 et al unless there was a match) I would write it like the above, or
perhaps less ambiguously like:
if (/Maximum/){
$lic_usage{$lic_type}{$max} = $1 if (/(\d+)/);
}
Check in perlre for info on the capturing parens.
--
Wyzelli
{{${^_sub}=sub{scalar reverse shift}}{$_={${^_reverse}=>
{${^_scalar}=>{${^_shift}=>{${^_sub}=>{${^_print}=>{}}}}}}
}{s{.*}{rekcaH lreP rehtona tsuJ}}{print("@{[&${^_sub}($_)]}")}}
------------------------------
Date: 8 Nov 2004 12:08:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Extract a number from a string.
Message-Id: <cmnnjc$de7$2@mamenchi.zrz.TU-Berlin.DE>
Adam <adam_cheney@hotmail.com> wrote in comp.lang.perl.misc:
> Hi All,
>
> Apologies if this is laughably simple, but it's been a long time since
> I've used Perl, and I seem to suffer from Homer Simpson's problem:
> every time I learn something new, it pushes old stuff out.
>
> I'm trying to extract a number from a line of text returned by a
> license-checking command. I open a pipe to the command, and read
> through each line that is returned. When I find the text "Maximum..."
> or "Current..." I want to extract and store the number in that line. I
> tried using something like this to start with:
>
> $lic_usage{$lic_type}{$max} = /\d+/ if (/Maximum/);
> $lic_usage{$lic_type}{$cur} = /\d+/ if (/Current/);
>
> Of course, this only stores a 1 ('True') when it finds the string, and
> I want it to record the actual digits.
Too few parentheses in some places, more than needed in others.
( $lic_usage{ $lic_type}{ $max}) = /(\d+)/ if /Maximum/;
The parentheses around the left side of "=" put the right side
in array context. That makes the regex return the list of captured
matches. The parentheses around "\d+" in the regex capture the
digits. The condition of a statement-modifying "if" doesn't need
parentheses.
Of course, the value of $lic_usage{ $lic_type}{ $max} must be checked
before use, there is no guarantee that the statement ever assigns
anything.
Anno
------------------------------
Date: Mon, 8 Nov 2004 11:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 4.28: How do I change the Nth occurrence of something?
Message-Id: <cmnjp5$kff$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
4.28: How do I change the Nth occurrence of something?
You have to keep track of N yourself. For example, let's say you want to
change the fifth occurrence of "whoever" or "whomever" into "whosoever"
or "whomsoever", case insensitively. These all assume that $_ contains
the string to be altered.
$count = 0;
s{((whom?)ever)}{
++$count == 5 # is it the 5th?
? "${2}soever" # yes, swap
: $1 # renege and leave it there
}ige;
In the more general case, you can use the "/g" modifier in a "while"
loop, keeping count of matches.
$WANT = 3;
$count = 0;
$_ = "One fish two fish red fish blue fish";
while (/(\w+)\s+fish\b/gi) {
if (++$count == $WANT) {
print "The third fish is a $1 one.\n";
}
}
That prints out: "The third fish is a red one." You can also use a
repetition count and repeated pattern like this:
/(?:\w+\s+fish\s+){2}(\w+)\s+fish/i;
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Mon, 8 Nov 2004 00:33:13 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Firefox broswer staring Perl CGI
Message-Id: <slrncou4p9.1s4.tadmc@magna.augustmail.com>
Jerry Preston <g-preston1@ti.com> wrote:
> I just checked out some of my Perl CGI scripts that work fine using IE and
> Netscape and I find that Firefox is lost or I am.
> When I do a view page source the following starts the code:
>
><?xml version="1.0" encoding="iso-8859-1"?>
><!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>
> What am I missing?
You are missing a question.
Is there something wrong?
Did you want to ask a question about that wrong something?
What did you expect to happen? What is happening instead?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 08 Nov 2004 13:09:06 +0000
From: Chris Cole <ithinkiam@gmail.com>
Subject: Re: Firefox broswer staring Perl CGI
Message-Id: <pan.2004.11.08.13.09.04.958034@gmail.com>
On Mon, 08 Nov 2004 06:55:04 +0000, John Bokma wrote:
> Jerry Preston wrote:
>
>> I just checked out some of my Perl CGI scripts that work fine using IE
>> and Netscape and I find that Firefox is lost or I am. I start my
>> scripts with the following:
>>
>> print $query->header();
>
> ^^^^ defaults to XHTML
>
>> <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html
>> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> ^^^^^
So what? XHTML is a perfectly valid way of creating web pages (CGI or
otherwise). I have no problems with firefox displaying perl CGI using the
default XHTML output.
>> What am I missing?
>
> -no_xhtml
> By default, CGI.pm versions 2.69 and higher emit XHTML
> (http://www.w3.org/TR/xhtml1/). The -no_xhtml pragma disables this
> feature.
>
> Hence:
>
> use CGI qw/:standard -no_xhtml/;
>
> or use
>
> my $cgi = new CGI;
> print $cgi->header( 'text/html' );
Neither of these are necessary... The problem is due to something else.
To the OT. You're far too vague in your message. Please repost with any
errors dsiplayed in FF and a complete example of code that shows your
problem so that we can test it also.
> I recommend calling the thingy $cgi instead of $query, printing html to
> a query sounds odd to me.
It may sound odd to you, but makes sense to me. CGI is often a DB
front-end so a cgi query *to the db* is perfectly reasonable in this case.
Chris.
------------------------------
Date: 8 Nov 2004 13:49:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Firefox broswer staring Perl CGI
Message-Id: <Xns959B59C51906Dasu1cornelledu@132.236.56.8>
John Bokma <postmaster@castleamber.com> wrote in
news:Xns959B95662B83castleamber@130.133.1.4:
> Jerry Preston wrote:
>
>> I just checked out some of my Perl CGI scripts that work fine using IE
>> and Netscape and I find that Firefox is lost or I am. I start my
>> scripts with the following:
>>
>> print $query->header();
...
>
> my $cgi = new CGI;
> print $cgi->header( 'text/html' );
>
> I recommend calling the thingy $cgi instead of $query, printing html to
> a query sounds odd to me.
But you are not printing to a query, you are printing to STDOUT :)
Sinan
------------------------------
Date: Mon, 08 Nov 2004 11:50:55 +0100
From: peter pilsl <pilsl@goldfisch.at>
Subject: how greedy is nongreedy in regexp ?
Message-Id: <418f4f93$1@e-post.inode.at>
the following substitution does not what I want. So I ask myself where
the knot in my brain is this time.
I want to clean up urls and make a/b/c/../e/f => a/b/e/f
$a="a/b/c/../e/f";
$a=~s,/(.*?)/\.\./,/,;
print $1,"\n",$a,"\n"
which gives:
b/c
a/e/f
Thats still to greedy to me ;) my desired match would be "c"
Is there a way to achieve this? Maybe some look-behind-hack? I'm not
familiar with this.
My alternative approach would be to simply split the whole stuff and
iterate throught it. This approach - however - seems to be more
costintensive than I'd like it to be.
thnx,
peter
--
http://www2.goldfisch.at/know_list
------------------------------
Date: 08 Nov 2004 11:07:33 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: how greedy is nongreedy in regexp ?
Message-Id: <slrncoukrl.1ii.vek@station02.ohout.pharmapartners.nl>
On Mon, 08 Nov 2004 11:50:55 +0100,
peter pilsl <pilsl@goldfisch.at> wrote:
>
>
> the following substitution does not what I want. So I ask myself where
> the knot in my brain is this time.
>
> I want to clean up urls and make a/b/c/../e/f => a/b/e/f
>
> $a="a/b/c/../e/f";
> $a=~s,/(.*?)/\.\./,/,;
> print $1,"\n",$a,"\n"
>
> which gives:
>
> b/c
> a/e/f
>
The leftmost match is always preferred over any other match. The
non-greediness would show up if you for example matched
"a/b/c/../e/f/../x/y/z/../";
>
> Thats still to greedy to me ;) my desired match would be "c"
> Is there a way to achieve this? Maybe some look-behind-hack? I'm not
> familiar with this.
>
> My alternative approach would be to simply split the whole stuff and
> iterate throught it. This approach - however - seems to be more
> costintensive than I'd like it to be.
>
>
Try match a slash followed by one or more non-slashes followed by a slash
and two dots and a slash.
$a="a/b/c/../e/f";
$a=~s,/([^/]+)/\.\./,/,;
print $1,"\n",$a,"\n"
Villy
------------------------------
Date: 8 Nov 2004 11:55:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how greedy is nongreedy in regexp ?
Message-Id: <cmnmr2$de7$1@mamenchi.zrz.TU-Berlin.DE>
peter pilsl <pilsl@goldfisch.at> wrote in comp.lang.perl.misc:
>
>
> the following substitution does not what I want. So I ask myself where
> the knot in my brain is this time.
>
> I want to clean up urls and make a/b/c/../e/f => a/b/e/f
The standard module File::Spec has canonpath() to do this. Since
canonpath() does a logical cleanup without looking at a physical
file system, it should work for URLs.
Anno
------------------------------
Date: 8 Nov 2004 05:50:24 -0800
From: juklingos@yahoo.com (juky)
Subject: Net::Telnet connection status
Message-Id: <bbb366ed.0411080550.72ad669f@posting.google.com>
Hi all,
I'm using a Net::Telnet to send some commands to a router.
What I need to check now is my connection status after I sent any
commands. In some cases when I upload the router with particular
command it resets the connection and I must login again.
How can I do it?
Here my code:
....
...
my $session = Net::Telnet->new(Host => $rt,
Timeout => 30);
{login part}
while ...... {
$session->print($command);
($output,$a)=$session->waitfor(Match => '/#/');
}
Thanks.
Juky
------------------------------
Date: 8 Nov 2004 13:22:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: OT (Re: casting question)
Message-Id: <cmnrvh$f50$1@mamenchi.zrz.TU-Berlin.DE>
daniel kaplan <nospam@nospam.com> wrote in comp.lang.perl.misc:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
> news:Xns9599AA7E62326asu1cornelledu@132.236.56.8...
>
> >You like to directly go to personal insults. This behavior
> > will not make me any more charitable towards you. As the saying goes,
> > once is happenstance, twice coincidence, thrice is enemy action. You have
> > gone way beyond three.
>
> i'm sorry sinan, what was this then that you wrote?
>
> >>You could not have been much of a C programmer not knowing the
> >>difference between casting and dereferencing.
>
> go look in the mirror...and tell me who threw out personal insults
That's not an insult, it's an observation based on what you wrote.
(I had the same impression.)
To refute it, show that you *do* know the difference. Complaining
about rudeness won't convince anyone.
Anno
------------------------------
Date: 08 Nov 2004 10:15:06 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Solaris taking over Perl ownership
Message-Id: <yzdoei8wvl1.fsf@invalid.net>
krakle@visto.com (krakle) writes:
> Perl language. Perl code. perl interputer.
What's the matter with you? The name of the program which interprets
Perl code is manifestly "perl", not "Perl". /usr/bin/perl, for example,
or /usr/local/bin/perl, not /usr/bin/Perl. (You can rename it that way,
I guess, but then you can rename it to donaldduck too.)
------------------------------
Date: Mon, 08 Nov 2004 09:28:49 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Spam-free Mailto.pl or similar prog?
Message-Id: <2v8pa2F2i0ibfU1@uni-berlin.de>
Madra Rua wrote:
> My old mailto.pl script will not work on iPower's web hosting site. I
> searched for a replacement and found the interesting web site below.
> Does anyone know what the latest situation is and do they have a
> complete mailto.pl with redirection.
Note that questions about ready-to-go scripts are off topic in this
group, which is for discussing Perl programming.
Anyway, the Perl module CGI::ContactForm
(http://www.gunnar.cc/contactform/readme.html) was written with the
spammers' harvesters in mind, is platform independent, and should serve
your needs.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 08 Nov 2004 10:08:10 +0000
From: Stuart Moore <usenet_05_08_2004@stuartmoore.org.uk>
Subject: Re: Spam-free Mailto.pl or similar prog?
Message-Id: <cmngi3$f1o$1@gemini.csx.cam.ac.uk>
Madra Rua wrote:
> Greetings Gurus.
>
> Excuse the dated material. I have been away from scripting for about 6 years
> now and it's very rusty. My old mailto.pl script will not work on iPower's
> web hosting site. I searched for a replacement and found the interesting web
> site below. Does anyone know what the latest situation is and do they have a
> complete mailto.pl with redirection. I believe the iPower site is Unix or a
> variant of it.
You seem to have quoted one, along with several options in other
languages. What more do you need?
------------------------------
Date: Mon, 08 Nov 2004 11:01:40 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Spam-free Mailto.pl or similar prog?
Message-Id: <omIjd.27106$K7.16455@news-server.bigpond.net.au>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns959AEBCF31CC3asu1cornelledu@132.236.56.8...
> "Madra Rua" <madra@rua.net> wrote in
> news:F5Cjd.8469$O11.1837@newsread3.news.pas.earthlink.net:
>
>> Greetings Gurus.
>
> Oh-oh!
??
>> Excuse the dated material.
>
> Which material? Do you mean the binary attachment? Don't post binary
> attachments.
(at least not here anyway)
Fair enough...
>> I have been away from scripting for about 6 years
>
> Why not keep it that way?
My mother always used to say "If you don't have anything nice to say, don't
say anything at all."
Did I just ignore my mother's advice?
--
Wyzelli
??
------------------------------
Date: Mon, 8 Nov 2004 07:32:11 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: sub refs in qq strings
Message-Id: <slrncoutar.3f9.tadmc@magna.augustmail.com>
John Bokma <postmaster@castleamber.com> wrote:
> I don't get the interpolation thingy.
perldoc -q 'function calls'
How do I expand function calls in a string?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 8 Nov 2004 01:48:48 -0800
From: "David Filmer" <ineverreadanythingsenttome@hotmail.com>
Subject: Re: Upload meter for a CGI perl script
Message-Id: <TKednUzuL8hA3BLcRVn-oQ@comcast.com>
I don't think it's possible to do a "meter" (ie, a graphical slider) because
CGI.pm does not know the expected size of the file in advance. It is
possible, however, to do a progress indicator where the client sees the
total number of bytes (or KB or MB or whatever you like) received so far
(and, at least this gives some sense of progress during a very large upload,
and this seems more specifically what the OP was looking for). It requires a
little bit of JavaScript as well, though. You could do this in the main
browser window or a pop-up window (but pop-ups can be problematic with
modern browsers that might be set to disallow them).
Here are some code fragments from an ancient CGI that I wrote years ago. The
use of subroutine prototypes isn't really correct, and it uses
"intermediate" variables that I've since come to avoid, and there are some
other questionable programming practices, but hey, it works....
This is assuming the CGI inherits a multipart form that includes a parameter
such as this (for uploading up to eight files at once; this occurs within a
table (gads, these days I would use CSS)):
for (1..8) {
print Tr({-align => 'center'}, td({-colspan => '3'}, filefield(-name =>
'file', -size => '60')))
}
Now you can handle that upload such as this:
use Number::Format qw/number_format/; #or use sprintf, but I'm too lazy to
remember the syntax
#first, we need a named textfield that JavaScript will use to provide
message updates...
#... this is a form, BUT one that will be "filled out" by the program, not
by the client...
print
start_form ({name=>'status'}),
center(textfield ({name=>'info', -size => 80})), br(),
end_form();
#now upload the file - standard CGI.pm stuff, except we add a call to a
subroutine to update the message field...
foreach $file(param('file')) { #allows for more than one file uploaded at
a time
$file =~ s/^\s+//; $file =~ s/\s+$//;
next unless $file;
$_ = $file;
s!\\!/!g; #Convert DOS \ to UNIX /
s!/+$!!; #Strip off trailing / if any
s/\.zip$/.zip/i; #make sure it's lowercase .zip (if applicable), for
various reasons
s!^.*/!!; #Strip off path, if any
s/\.z$/\.Z/; #change .z extension (if any) to uppercase, for various
reasons
$localfile = &UniqID.".$_"; #supply your own method for uniqueness -
maybe an IO::All call?
$localfile =~ s/[^\w\.\-]/_/g; #Change funny characters to underscore
open (OUTFILE, ">$localfile") || die "Unable to open for write:
$localfile\n";
$count = 0;
while ($bytesread=read($file, $buffer, 1024)) { #1K increments
$count += $bytesread; $count2 = format_number (($count / 2**20), 2,
2); #megabytes
print OUTFILE $buffer;
&Progress("Receiving $file ($count2 MegaBytes received so far)");
#this is where the magic happens!
}
$size = (stat($localfile))[7];
&Progress("File $file Received - $size bytes");
}
sub Progress() {
#This simply updates the named form-field (using JavaScript) with
whatever message we wish...
my $message = shift;
print "<script language='JavaScript'>",
"document.status.info.value=' $message';",
"</script>";
}
Cheers!
"Sean Berry" <sean@buildingonline.com> wrote in message
news:bwxjd.120416$hj.27962@fed1read07...
>I was toying with the idea of making an upload progress meter for a perl
>script I have that usually takes somewhere in the neigborhood of 20M files.
>I figured I could have a popup that takes as an argument the four digit
>sequence number CGI.pm creates when uploading a file, then check the file
>size and report it. Then, this window could update periodically, say every
>2 seconds.
>
> But, how can I get access to the $sequence variable used in creating files
> in the tmp dir like /tmp/CGItemp3323 ????
>
> I don't want to go screwing around with CGI.pm, but see no other way of
> getting this number.
>
> Any help here is appreciated.
>
>
>
------------------------------
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 7376
***************************************