[29523] in Perl-Users-Digest
Perl-Users Digest, Issue: 767 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 18 00:09:42 2007
Date: Fri, 17 Aug 2007 21:09:07 -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, 17 Aug 2007 Volume: 11 Number: 767
Today's topics:
Re: about CGI <tadmc@seesig.invalid>
can't get out of infinite while loop <rsarpi@gmail.com>
Re: can't get out of infinite while loop <glex_no-spam@qwest-spam-no.invalid>
Re: can't get out of infinite while loop <rsarpi@gmail.com>
Re: FAQ 6.16 How do I efficiently match many regular ex <bik.mido@tiscalinet.it>
Re: Gaa! UNIX hack tries PPM and fails! sln@netherlands.co
Re: Gaa! UNIX hack tries PPM and fails! usenet@DavidFilmer.com
Re: Gaa! UNIX hack tries PPM and fails! sln@netherlands.co
grep unexpected output <user@example.net>
Re: grep unexpected output <wahab-mail@gmx.de>
Re: grep unexpected output <mritty@gmail.com>
OT: well-formed XML (was Re: Gaa! UNIX hack tries PPM a <tadmc@seesig.invalid>
Re: Perl Search Help mihirtr@gmail.com
Re: Rename Perl Process (Jens Thoms Toerring)
Re: Sending a "status" <stoupa@practisoft.cz>
Re: Using Subroutines with CGI::Session::MySQL? <paduille.4061.mumia.w+nospam@earthlink.net>
Re: well-formed XML (was Re: Gaa! UNIX hack tries PPM a <stoupa@practisoft.cz>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Aug 2007 23:37:42 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: about CGI
Message-Id: <slrnfccc63.44e.tadmc@tadmc30.sbcglobal.net>
joker <attackack@yahoo.com> wrote:
> Thanks a lot to all.
>
>
>
> A word to Bryan
>
> Really my english is so important??
When 2 out of the 3 people that replied had a problem understanding
it, then yes, it is important.
A question cannot be answered until it has first been understood.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 17 Aug 2007 20:14:53 -0000
From: monk <rsarpi@gmail.com>
Subject: can't get out of infinite while loop
Message-Id: <1187381693.277472.100050@i13g2000prf.googlegroups.com>
Need your help please.
This is what it does:
---------------------------
This script takes files out of one directory. Moves the files out of
the source_dir, puts them into a bridge_dir, adds extension tmp while
there, then moves the files into the destination_dir removing the tmp
extension. It checks the source_dir for new files every 10 seconds.
To get into the infinite loop, I write to a file the "on" status
(1).
If it finds the "on" status (1), gets into the loop until that
condition changes.
It reads the file every time it gets into the loop to see if the
condition changed to "off" (0). When you send the --red switch, it
will write to a file the "off" status (0);
However, the second time it tries to read the file, it complains
saying that the file does not exist. What the hell? it just read a
second ago? Why is it saying that the file isn't there? the file is
there.
If you have a better way to get out of the loop please let me know.
I need wisdom and enlightenment.
Output
--------------
$ perl trafficLight.pl --green
writing switch on
switch on written
reading status file
condition equals 1
getting into loop
inside of loop pass. Reading status file
ready to sleep for 10 seconds
inside of loop pass. Reading status file
Uncaught exception from user code:
No such file or directory at trafficLight2007817.pl line 145.
main::do_Green() called at trafficLight2007817.pl line 60
<code>
#!/usr/bin/perl
use warnings;
use strict;
use File::Copy;
use diagnostics;
use Getopt::Long;
use Time::localtime;
my $status_file = "trafficLight.status";
my $switch_on = "1";
my $switch_off = "0";
my $source_dir_path = "/home/monk/source_dir";
my $destination_dir_path = "/home/monk/destination_dir";
my $bridge_path = "/home/monk/bridge";
my $PICKUP_INTERVAL = 10; #seconds expressed in integers
my $extension = ".tmp"; #extension added to files while on the
bridge. It can be *.tmp
#define parameters for the help menu
my $help = "";
my $green = "";
my $red = "";
GetOptions( 'help' => \$help, 'green' => \$green, 'red' => \$red );
if ($help) {
printHelp();
exit;
}
elsif ($green) {
do_Green();
exit;
}
elsif ($red) {
do_Red();
exit;
}
else {
printHelp();
exit;
}
sub printHelp {
my $help = q{
Description:
Processes files from one directory to another.
Parameters:
--help [ -h ] [ --h ] : prints this help
--green [ -g ] [ --green ] : process the files
--red [ -r ] [ --red ] : stop processing files killing
the process
Usage: perl traffic_light.pl [--help\-h\--h] [--green\-g\--g] [--red\-r
\--r]
};
print $help;
}
#write status ON to a file for green light
print "writing switch on\n";
sleep 7;
open( SWITCH, "> $status_file" ) or die "Problem writing to
$status_file file...$!";
print SWITCH $switch_on;
close(SWITCH);
print "switch on written\n";
sleep 7;
my $condition;
sub do_Green {
#flush my buffers
#$| = 1;
print "reading status file\n";
sleep 5;
open( SWITCH, $status_file ) or die "Process has been exited already
$!";
while (<SWITCH>) {
chomp;
$condition = $_;
}
close SWITCH;
print "condition equals $condition\n";
print "getting into loop\n";
sleep 7;
while ( $condition == 1 ) {
print "inside of loop pass. Reading status file\n";
sleep 5;
open( SWITCHAGAIN, $status_file ) or die $!;
while (<SWITCHAGAIN>) {
chomp;
$condition = $_;
}
close (SWITCHAGAIN);
#set up dirhandles
opendir( SOURCEDIR, $source_dir_path )
or die "Problem accessing the source directory...$!";
#get in there
chdir $source_dir_path;
#put files in an array skipping the . and .. files
my @xfiles = grep !/^\./, readdir(SOURCEDIR);
#we close the dirhandle
closedir(SOURCEDIR);
foreach (@xfiles) {
move( $_, $bridge_path ) or die "Nothing really to worry about.
Files are moving.";
}
###################
#add tmp extension
opendir( BRIDGEDIR, $bridge_path )
or die "Problem passing files to the bridge directory...$!";
chdir $bridge_path;
my @bridge_files = grep !/^\./, readdir(BRIDGEDIR);
my $old_filename;
#we rename each file individually
foreach (@bridge_files) {
#work only on the files ending in tmp
if ( $_ !~ m/$extension$/ ) {
$old_filename = $_;
rename( $old_filename, $_ . $extension ) or die $!;
}
}
#closing to avoid contamination on next process
closedir BRIDGEDIR;
######################
#move files from the bridge to the destination directory
#NOTE that they go into destination directory with the tmp extension
opendir( BRIDGEDIR, $bridge_path )
or die "Problem getting files off the bridge directory...$!";
chdir $bridge_path;
my @target_files = grep !/^\./, readdir(BRIDGEDIR);
#we move each file individually
foreach (@target_files) {
move( $_, $destination_dir_path ) or die $!;
}
closedir BRIDGEDIR;
#########################
#now let us remove the tmp extension.
#on the destination directory
opendir( DESTINATIONDIR, $destination_dir_path )
or die "Problem accessing files on the destination directory...
$!";
chdir $destination_dir_path;
my @destination_files = grep !/^\./, readdir(DESTINATIONDIR);
#we rename each file individually
foreach my $file (@destination_files) {
#work only on the files ending in tmp
if ( $file =~ m/$extension$/ ) {
#just remove the artificial tmp extension [incl dot] added while
on the bridge
my $extension_length = length($extension);
#my $new_filename = substr( $file, 0, -4 );
my $new_filename = substr( $file, 0, -$extension_length );
rename( $file, $new_filename ) or die $!;
}
}
closedir DESTINATIONDIR;
print "ready to sleep for $PICKUP_INTERVAL seconds\n";
#picks up files every x seconds
sleep $PICKUP_INTERVAL;
}
print "got out of the loop exiting now";
exit(0);
}
sub do_Red {
#if currently program executing
if (-e $status_file){
#write process id to a file to kill it later when needed.
print "writting status off";
sleep 5;
open( SWITCH, "> $status_file" ) or die "Problem writing to
$status_file file...$!";
print SWITCH $switch_off;
close(SWITCH);
print "status off written";
sleep 5;
print "removing remnant files if still there (possibly move up)\n";
unlink $status_file or die "$! File removed already";
}
print "leave in peace\n";
exit(0);
}
</code>
------------------------------
Date: Fri, 17 Aug 2007 16:53:22 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: can't get out of infinite while loop
Message-Id: <46c618d2$0$10296$815e3792@news.qwest.net>
monk wrote:
> Need your help please.
>
> This is what it does:
> ---------------------------
> This script takes files out of one directory. Moves the files out of
> the source_dir, puts them into a bridge_dir, adds extension tmp while
> there, then moves the files into the destination_dir removing the tmp
> extension. It checks the source_dir for new files every 10 seconds.
>
> To get into the infinite loop, I write to a file the "on" status
> (1).
>
> If it finds the "on" status (1), gets into the loop until that
> condition changes.
> It reads the file every time it gets into the loop to see if the
> condition changed to "off" (0). When you send the --red switch, it
> will write to a file the "off" status (0);
>
> However, the second time it tries to read the file, it complains
> saying that the file does not exist. What the hell? it just read a
> second ago? Why is it saying that the file isn't there? the file is
> there.
Likely due to one of your many 'chdir'. Print the current
working directory along with the filename, in the error.
Maybe a bit shorter example would help. We don't need to see
your usage, and options, just the shortest amount of code
showing the problem.
> If you have a better way to get out of the loop please let me know.
Simply create the file or remove the file, then test for its existence.
No need to write/read it.
------------------------------
Date: Sat, 18 Aug 2007 01:46:02 -0000
From: monk <rsarpi@gmail.com>
Subject: Re: can't get out of infinite while loop
Message-Id: <1187401562.826463.33940@l22g2000prc.googlegroups.com>
> Likely due to one of your many 'chdir'. Print the current
> working directory along with the filename, in the error.
You da man!!
yeap...it was tripping out with the many chdir
I just put an absolute path for the file containing the new
status :off/on
And the debugging statements helped me determine that.
Sometimes I just don't see the forest for the trees.
That was a very basic mistake on my part. Now I'll get some sleep.
Thanks again.
------------------------------
Date: Sat, 18 Aug 2007 00:33:05 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <nb8cc312qi3sg2jmlmh19nv2b29ng3rc9q@4ax.com>
On Fri, 17 Aug 2007 21:40:06 +0200 (CEST), Jim Cochrane
<allergic-to-spam@no-spam-allowed.org> wrote:
>Yes, I thought it was something like that. Too bad there are no
>lint-like tools to help keep documentation consistent. [English is a
>language - shouldn't we be able to compile it? :=)]
I don't know, but I suppose that the following quotation, however
harsh, may shed some light and induce a meditation:
: The problem with defending the purity of the English language is that
: English is about as pure as a cribhouse whore. We don't just borrow
: words; on occasion, English has pursued other languages down alleyways
: to beat them unconscious and rifle their pockets for new vocabulary.
: - James Nicoll
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: Fri, 17 Aug 2007 21:08:19 -0700
From: sln@netherlands.co
Subject: Re: Gaa! UNIX hack tries PPM and fails!
Message-Id: <50scc3d7tcors8lcork29ogl1ivm561l4q@4ax.com>
On Fri, 17 Aug 2007 12:36:36 +0200, Christian Winter <thepoet_nospam@arcor.de> wrote:
Yeah, the xml is valid at least. From RxParse 1.1:
<?xml version="1.0" encoding="UTF-8"?>
<SOFTPKG NAME="Crypt-SSLeay" VERSION="0,53,0,0">
<TITLE>Crypt-SSLeay</TITLE>
<ABSTRACT>OpenSSL glue that provides LWP https support</ABSTRACT>
<AUTHOR>Joshua Chamas <josh (at) chamas dot com></AUTHOR>
<IMPLEMENTATION>
<OS NAME="MSWin32" />
<ARCHITECTURE NAME="MSWin32-x86-multi-thread-5.8" />
<CODEBASE HREF="Crypt-SSLeay.tar.gz" />
<PROVIDE NAME="Crypt::SSLeay" VERSION="0.51" />
<PROVIDE NAME="Crypt::SSLeay::Conn" />
<PROVIDE NAME="Crypt::SSLeay::CTX" />
<PROVIDE NAME="Crypt::SSLeay::Err" />
<PROVIDE NAME="Crypt::SSLeay::MainContext" />
<PROVIDE NAME="Crypt::SSLeay::X509" />
<PROVIDE NAME="Net::SSL" VERSION="2.77" />
</IMPLEMENTATION>
</SOFTPKG>
C:\perl rptest.pl
new parse _: SCALAR ref
--------------------
xmldecl_h _: version = 1.0
encoding = UTF-8
--------------------
char _:
--------------------
start _: SOFTPKG
NAME = Crypt-SSLeay
VERSION = 0,53,0,0
--------------------
char _:
--------------------
start _: TITLE
--------------------
char _: Crypt-SSLeay
--------------------
end _: /TITLE
--------------------
char _:
--------------------
start _: ABSTRACT
--------------------
char _: OpenSSL glue that provides LWP https support
--------------------
end _: /ABSTRACT
--------------------
char _:
--------------------
start _: AUTHOR
--------------------
char _: Joshua Chamas <josh (at) chamas dot com>
--------------------
end _: /AUTHOR
--------------------
char _:
--------------------
start _: IMPLEMENTATION
--------------------
char _:
--------------------
start _: OS
NAME = MSWin32
end _: /OS
--------------------
char _:
--------------------
start _: ARCHITECTURE
NAME = MSWin32-x86-multi-thread-5.8
end _: /ARCHITECTURE
--------------------
char _:
--------------------
start _: CODEBASE
HREF = Crypt-SSLeay.tar.gz
end _: /CODEBASE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Crypt::SSLeay
VERSION = 0.51
end _: /PROVIDE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Crypt::SSLeay::Conn
end _: /PROVIDE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Crypt::SSLeay::CTX
end _: /PROVIDE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Crypt::SSLeay::Err
end _: /PROVIDE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Crypt::SSLeay::MainContext
end _: /PROVIDE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Crypt::SSLeay::X509
end _: /PROVIDE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Net::SSL
VERSION = 2.77
end _: /PROVIDE
--------------------
char _:
--------------------
end _: /IMPLEMENTATION
--------------------
char _:
--------------------
end _: /SOFTPKG
the code took:0.0440998 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU)
>usenet@DavidFilmer.com wrote:
>> I'm a UNIX hack, but I want to run Web Scraping Proxy on a Windows box
>> that does not have internet access (I'm scraping local pages). So I
>> installed ActivePerl. So far, so good.
>>
>> But WSP needs some old SSLeay crypto modules. ActiveState doesn't
>> supply crypto modules (http://aspn.activestate.com/ASPN/Downloads/
>> ActivePerl/PPM/Repository) but they kindly provide a link to the
>> University of Winnipeg, specifically mentioning the two modules I
>> require (Crypt-SSLeay and Net_SSLeay).
>>
>> Since I don't have web access on the target PC then I am looking for a
>> PPM file so I can do a local install.
>>
>> I found where the plain PPMs are supposedly published:
>> http://theoryx5.uwinnipeg.ca/ppms/x86
>>
>> And I downloaded the one I need: http://theoryx5.uwinnipeg.ca/ppms/x86/Crypt-SSLeay.tar.gz
>>
>> What I expected to find therein was a file named whatever.ppm that I
>> could run ppm against. But the tarball contains a directory structure
>> that looks like this:
>>
>> [.....]
>> drwxrwxrwx 0 0 0 Dec 26 12:20:22 2006 blib/html/site
>> drwxrwxrwx 0 0 0 Dec 26 12:20:22 2006 blib/html
>> -rw-rw-rw- 0 0 0 Dec 26 12:19:22 2006 blib/lib/auto/Crypt/
>> SSLeay/.exists
>> drwxrwxrwx 0 0 0 Dec 26 12:19:22 2006 blib/lib/auto/Crypt/
>> SSLeay
>> drwxrwxrwx 0 0 0 Dec 26 12:19:22 2006 blib/lib/auto/Crypt
>> drwxrwxrwx 0 0 0 Dec 26 12:19:22 2006 blib/lib/auto
>> [.....]
>>
>> There is no README or anything telling me what to do with this. Is
>> this a PPM? Am I supposed to just unroll this somewhere on my Windows
>> box? Where? What is this thing?
>>
>> Can anybody help a poor UNIX hack figure this out?
>
>The .tar.gz you downloaded is the "binary storage" for the ppm package,
>holding the modules and scripts belonging to the package, but there is
>no such thing as a file with a .ppm extension.
>
>A ppm package consists of a .tar.gz file for the binaries and a .ppd
>file ("Perl Package Description", proprietary XML format) with a
>description of installation source, namespaces, actions and additional
>scripts.
>
>So to install a module offline you usually need the .tar.gz and the
>.ppd, and for most of them you get a zip archive containing those
>two for offline installation.
>
>And that's exactly where your problem begins. Normaly you could fetch
>an offline version from http://theoryx5.uwinnipeg.ca/ppms/bundles/
>and be happy, but due to a number of reasons (export laws concerning
>cryptography in the United States of Paranoia, to force the neccessary
>disclaimer on the enduser and to follow the bundling prohobitions, and
>license issues with SSLeay itself that force all binary distributions
>to display credits to the authors) the Crypt::SSLeay binary module
>contains an install script that fetches the two library files separately
>via the web.
>
>However, there's no restriction you can't work around:
>
>- Download the .tar.gz file (you did that already)
>
>- Open the install_ssl script in your browser at
> http://theoryx5.uwinnipeg.ca/ppms/scripts/install_ssl
> and carefully read the legal disclaimer contained therein
>
>- Download the needed libraries and copy them into the bin directory
> of your target Perl installation
> http://theoryx5.uwinnipeg.ca/ppms/scripts/ssleay32.dll
> http://theoryx5.uwinnipeg.ca/ppms/scripts/libeay32.dll
>
>- Download the package description file from
> http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd and save
> it in the same directory as the .tar.gz, then open it in your
> text editor and change it to read:
><?xml version="1.0" encoding="UTF-8"?>
><SOFTPKG NAME="Crypt-SSLeay" VERSION="0,53,0,0">
> <TITLE>Crypt-SSLeay</TITLE>
> <ABSTRACT>OpenSSL glue that provides LWP https support</ABSTRACT>
> <AUTHOR>Joshua Chamas <josh (at) chamas dot com></AUTHOR>
> <IMPLEMENTATION>
> <OS NAME="MSWin32" />
> <ARCHITECTURE NAME="MSWin32-x86-multi-thread-5.8" />
> <CODEBASE HREF="Crypt-SSLeay.tar.gz" />
> <PROVIDE NAME="Crypt::SSLeay" VERSION="0.51" />
> <PROVIDE NAME="Crypt::SSLeay::Conn" />
> <PROVIDE NAME="Crypt::SSLeay::CTX" />
> <PROVIDE NAME="Crypt::SSLeay::Err" />
> <PROVIDE NAME="Crypt::SSLeay::MainContext" />
> <PROVIDE NAME="Crypt::SSLeay::X509" />
> <PROVIDE NAME="Net::SSL" VERSION="2.77" />
> </IMPLEMENTATION>
></SOFTPKG>
>
>- Open a dos-box in the directory and run "ppm install Crypt-SSLeay.ppd"
>
>HTH
>-Chris
------------------------------
Date: Sat, 18 Aug 2007 00:04:03 -0000
From: usenet@DavidFilmer.com
Subject: Re: Gaa! UNIX hack tries PPM and fails!
Message-Id: <1187395443.247221.251150@i38g2000prf.googlegroups.com>
On Aug 17, 3:36 am, Christian Winter <thepoet_nos...@arcor.de> wrote:
[what may be the clearest and best reply I have ever seen in usenet!]
Wow, Chris - thanks for the great answer! That's exactly what I
needed to know, and your clear and excellent instructions made it very
easy for me to get this done. Now that I see the solution, I'm glad I
decided to post the question here - I would have NEVER figured that
out!
FWIW, for those who stumble upon this thread seeking the same thing -
installing the second module (Net::SSLeay) was similar but with one
gotcha. Here is the ppd file I hacked up to do it:
<?xml version="1.0" encoding="UTF-8"?>
<SOFTPKG NAME="Net_SSLeay.pm" VERSION="1,30,0,0">
<TITLE>Net_SSLeay.pm</TITLE>
<ABSTRACT>Perl extension for using OpenSSL</ABSTRACT>
<AUTHOR>Sampo Kellomaki</AUTHOR>
<IMPLEMENTATION>
<OS NAME="MSWin32"/>
<ARCHITECTURE NAME="MSWin32-x86-multi-thread-5.8"/>
<CODEBASE HREF="Net_SSLeay.pm.tar.gz"/>
<PROVIDE NAME="Net::SSLeay" VERSION="1.30"/>
</IMPLEMENTATION>
</SOFTPKG>
(indended for usenet readability, but don't have any leading spaces on
your first line)
The gotcha was from the original XML file
http://theoryx5.uwinnipeg.ca/ppms/Net_SSLeay.pm.ppd
The <AUTHOR> tagset in that file looks like this:
<AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
(domain obfuscated as a courtesy to the author)
ppm wouldn't build (and the error message was not very instructive).
I think the '@' was the problem. Anyway, after much head-scratching
(and acting on a pure hunch) I removed the e-mail address from my .ppd
and it built just fine.
The tarball is here: http://theoryx5.uwinnipeg.ca/ppms/x86/Net_SSLeay.pm.tar.gz
If you have already copied the two .dll files per Chris' instructions
then you need only download the tarball and hack up the .ppm file to
be able to install Net::SSLeay with ppm.
Thanks again, Chris!
------------------------------
Date: Fri, 17 Aug 2007 20:59:34 -0700
From: sln@netherlands.co
Subject: Re: Gaa! UNIX hack tries PPM and fails!
Message-Id: <nircc3pm5k8ktcnmrd4a59ttujjob9839p@4ax.com>
On Sat, 18 Aug 2007 00:04:03 -0000, usenet@DavidFilmer.com wrote:
No errors using RxParse 1.1. It must be valid xml !!
<?xml version="1.0" encoding="UTF-8"?>
<SOFTPKG NAME="Net_SSLeay.pm" VERSION="1,30,0,0">
<TITLE>Net_SSLeay.pm</TITLE>
<ABSTRACT>Perl extension for using OpenSSL</ABSTRACT>
<AUTHOR>Sampo Kellomaki</AUTHOR>
<IMPLEMENTATION>
<OS NAME="MSWin32"/>
<ARCHITECTURE NAME="MSWin32-x86-multi-thread-5.8"/>
<CODEBASE HREF="Net_SSLeay.pm.tar.gz"/>
<PROVIDE NAME="Net::SSLeay" VERSION="1.30"/>
</IMPLEMENTATION>
</SOFTPKG>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\>perl rptest.pl
new parse _: SCALAR ref
--------------------
xmldecl_h _: version = 1.0
encoding = UTF-8
--------------------
char _:
--------------------
start _: SOFTPKG
NAME = Net_SSLeay.pm
VERSION = 1,30,0,0
--------------------
char _:
--------------------
start _: TITLE
--------------------
char _: Net_SSLeay.pm
--------------------
end _: /TITLE
--------------------
char _:
--------------------
start _: ABSTRACT
--------------------
char _: Perl extension for using OpenSSL
--------------------
end _: /ABSTRACT
--------------------
char _:
--------------------
start _: AUTHOR
--------------------
char _: Sampo Kellomaki
--------------------
end _: /AUTHOR
--------------------
char _:
--------------------
start _: IMPLEMENTATION
--------------------
char _:
--------------------
start _: OS
NAME = MSWin32
end _: /OS
--------------------
char _:
--------------------
start _: ARCHITECTURE
NAME = MSWin32-x86-multi-thread-5.8
end _: /ARCHITECTURE
--------------------
char _:
--------------------
start _: CODEBASE
HREF = Net_SSLeay.pm.tar.gz
end _: /CODEBASE
--------------------
char _:
--------------------
start _: PROVIDE
NAME = Net::SSLeay
VERSION = 1.30
end _: /PROVIDE
--------------------
char _:
--------------------
end _: /IMPLEMENTATION
--------------------
char _:
--------------------
end _: /SOFTPKG
the code took:0.144737 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU)
C:\>
>On Aug 17, 3:36 am, Christian Winter <thepoet_nos...@arcor.de> wrote:
>[what may be the clearest and best reply I have ever seen in usenet!]
>
>Wow, Chris - thanks for the great answer! That's exactly what I
>needed to know, and your clear and excellent instructions made it very
>easy for me to get this done. Now that I see the solution, I'm glad I
>decided to post the question here - I would have NEVER figured that
>out!
>
>FWIW, for those who stumble upon this thread seeking the same thing -
>installing the second module (Net::SSLeay) was similar but with one
>gotcha. Here is the ppd file I hacked up to do it:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <SOFTPKG NAME="Net_SSLeay.pm" VERSION="1,30,0,0">
> <TITLE>Net_SSLeay.pm</TITLE>
> <ABSTRACT>Perl extension for using OpenSSL</ABSTRACT>
> <AUTHOR>Sampo Kellomaki</AUTHOR>
> <IMPLEMENTATION>
> <OS NAME="MSWin32"/>
> <ARCHITECTURE NAME="MSWin32-x86-multi-thread-5.8"/>
> <CODEBASE HREF="Net_SSLeay.pm.tar.gz"/>
> <PROVIDE NAME="Net::SSLeay" VERSION="1.30"/>
> </IMPLEMENTATION>
> </SOFTPKG>
>
>(indended for usenet readability, but don't have any leading spaces on
>your first line)
>
>The gotcha was from the original XML file
> http://theoryx5.uwinnipeg.ca/ppms/Net_SSLeay.pm.ppd
>The <AUTHOR> tagset in that file looks like this:
> <AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
>(domain obfuscated as a courtesy to the author)
>
>ppm wouldn't build (and the error message was not very instructive).
>I think the '@' was the problem. Anyway, after much head-scratching
>(and acting on a pure hunch) I removed the e-mail address from my .ppd
>and it built just fine.
>
>The tarball is here: http://theoryx5.uwinnipeg.ca/ppms/x86/Net_SSLeay.pm.tar.gz
>
>If you have already copied the two .dll files per Chris' instructions
>then you need only download the tarball and hack up the .ppm file to
>be able to install Net::SSLeay with ppm.
>
>Thanks again, Chris!
>
------------------------------
Date: Fri, 17 Aug 2007 16:17:31 -0400
From: monkeys paw <user@example.net>
Subject: grep unexpected output
Message-Id: <keidnUkutrXKn1vbnZ2dnUVZ_gadnZ2d@insightbb.com>
The following code...
@a1 = ('Test', 'steve');
@a2 = ('All_UPF', 'Cat', 'Happy', 'LegsOnly', 'Master', 'NILS', 'Test',
'steve');
for (@a2) {
if (grep($_, @a1)) {
print "YES: $_\n";
} else {
print "NO: $_\n";
}
}
gives this output...
YES: All_UPF
YES: Cat
YES: Happy
YES: LegsOnly
YES: Master
YES: NILS
YES: Test
YES: steve
I was expecting this output...
NO: All_UPF
NO: Cat
NO: Happy
NO: LegsOnly
NO: Master
NO: NILS
YES: Test
YES: steve
What am i doing wrong? Thank you.
------------------------------
Date: Fri, 17 Aug 2007 22:28:50 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: grep unexpected output
Message-Id: <fa50pl$gr8$1@mlucom4.urz.uni-halle.de>
monkeys paw wrote:
> @a1 = ('Test', 'steve');
> @a2 = ('All_UPF', 'Cat', 'Happy', 'LegsOnly', 'Master', 'NILS', 'Test',
> 'steve');
>
> for (@a2) {
> if (grep($_, @a1)) {
> print "YES: $_\n";
> } else {
> print "NO: $_\n";
> }
> }
> What am i doing wrong? Thank you.
$_, which is set in the for loop, is also
produced within grep, so you habe to use
an explicit varable, like:
for my $elem (@a2) {
if( grep(/\Q$elem\E/, @a1) ) {
print "YES: $elem\n";
}
else {
print "NO: $elem\n";
}
}
Furthermore, you have tell grep to do
a textual /$match/ on the loop variable -
which (not in your case) may contain
characters that may have special meaning
within your regular expression /$match/
context. You keep them by "quoting" them
into a digestible form by \Q...\E meta-
characters.
Regards
M.
------------------------------
Date: Fri, 17 Aug 2007 20:01:12 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: grep unexpected output
Message-Id: <1187406072.765756.95820@r34g2000hsd.googlegroups.com>
On Aug 17, 4:17 pm, monkeys paw <u...@example.net> wrote:
> The following code...
>
> @a1 = ('Test', 'steve');
> @a2 = ('All_UPF', 'Cat', 'Happy', 'LegsOnly', 'Master', 'NILS', 'Test',
> 'steve');
>
> for (@a2) {
> if (grep($_, @a1)) {
> print "YES: $_\n";
> } else {
> print "NO: $_\n";
> }
>
> }
>
> gives this output...
>
> YES: All_UPF
> YES: Cat
> YES: Happy
> YES: LegsOnly
> YES: Master
> YES: NILS
> YES: Test
> YES: steve
>
> I was expecting this output...
>
> NO: All_UPF
> NO: Cat
> NO: Happy
> NO: LegsOnly
> NO: Master
> NO: NILS
> YES: Test
> YES: steve
>
> What am i doing wrong? Thank you.
The syntax of grep is:
grep EXPR, LIST
For each element of LIST, it assigns $_ to that element, and then
evaluates EXPR. If EXPR is true for any of those evaluations, the
grep returns true. So what you were doing is looping through @a1 and
testing whether the elements of @a1 are true. Obviously they all
are. And so the grep returned true, and you executed the if block.
Then in that if block, that $_ referred to the elements of @a2 that
you were looping through via the for loop.
So you were doing two things wrong:
1) Using $_ for two different purposes, and not realizing it.
2) only testing the truth of $_, rather than whether or not $_ was
actually equal to some value.
You will need to give an explicit variable name to the foreach loop
iterator, so that you can compare it to the $_ that's created by grep:
for my $a2_elem (@a2) {
if (grep { $a2_elem eq $_ } @a1)) {
print "YES: $a2_elem\n";
} else {
print "NO: $a2_elem\n";
}
}
Paul Lalli
------------------------------
Date: Fri, 17 Aug 2007 20:20:23 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: OT: well-formed XML (was Re: Gaa! UNIX hack tries PPM and fails!)
Message-Id: <slrnfccian.7g4.tadmc@tadmc30.sbcglobal.net>
usenet@DavidFilmer.com <usenet@DavidFilmer.com> wrote:
> The gotcha was from the original XML file
It actually is NOT an XML file. It is not well-formed.
> http://theoryx5.uwinnipeg.ca/ppms/Net_SSLeay.pm.ppd
> The <AUTHOR> tagset in that file looks like this:
> <AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
^ ^
^ ^
^
That breaks well-formedness. It should instead be:
<AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
> I think the '@' was the problem.
XML cannot contain angle brackets that are not part of markup.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 17 Aug 2007 13:38:34 -0700
From: mihirtr@gmail.com
Subject: Re: Perl Search Help
Message-Id: <1187383114.525266.321580@m37g2000prh.googlegroups.com>
On Aug 17, 12:09 pm, j...@toerring.de (Jens Thoms Toerring) wrote:
> mihi...@gmail.com wrote:
> > I am trying to do following with Perl. Can someone check and help me
> > out if it is possible.
> > I am have multiple .c files, I need to find out second parameter in
> > function call My_Function_Test from these files and output to a file.
> > For example:
> > Example .c file
> > Sample_Func1()
> > {
> > MY_STRUCT_1 abc;
> > My_Function_Test (MY_1ST_PARAMETER,
> > sizeof(MY_STRUCT_1),
> > MY_3RD_PARAMETER);
> > }
> > Sample_Func1()
> > {
> > MY_STRUCT_2 abc;
> > My_Function_Test (MY_1ST_PARAMETER,
> > sizeof(MY_STRUCT_2),
> > MY_3RD_PARAMETER);
> > }
> > After running perl script, the output should be following
> > sizeof(MY_STRUCT_1)
> > sizeof(MY_STRUCT_2)
>
> If you don't mind a few false positives (from the functions
> definition and possible prototype declarations or places where
> calls of the function are commented out) and and the way you
> call the function isn't too complicated (e.g. with arguments
> that are enclosed in parenthesis and then contain commas or
> the functions, the function call isn't part of a macro etc.)
> it can be rather simple: Read in the whole file into a single
> string and do repeated regexp searches for
>
> \WMy_Function_Test\s*\([^,]*,\s*([^,]*)
>
> The second argument should then be in $1. Print it out after
> removing trailing white space. But for a 100% reliable solu-
> tion I guess you probably will need a full-blown preprocessor
> and parser for C.
> Regards, Jens
> --
> \ Jens Thoms Toerring ___ j...@toerring.de
> \__________________________ http://toerring.de- Hide quoted text -
>
> - Show quoted text -
Thanks, I will try it out.
------------------------------
Date: 17 Aug 2007 21:36:17 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Rename Perl Process
Message-Id: <5imimhF3nh00bU1@mid.uni-berlin.de>
Wolfgang Hennerbichler <wogri.wogri@gmail.com> wrote:
> On Aug 17, 4:34 pm, j...@toerring.de (Jens Thoms Toerring) wrote:
> > And those error messages also will never appear anywhere since
> > neither STDOUT nor STDERR are open anymore.
> Well, I didn't really show you how my real program looks like. There's
> also this section:
> 141 if (defined ($options{l}) and not defined $options{d}) {
> 142 open (STDERR, ">>$options{l}");
> 143 STDERR->autoflush(1);
> 144 }
> that recreates the STDERR filehandle and sends it to the destination
> of the logfile. So don't worry, my error messages are in a safe
> place :)
I won't;-)
> > BTW, it looks a bit as if you want to create a daemon, and
> > the usual way to create one is forking twice (always letting
> > the parent process exit).
> Why? You might be right, but I don't know the reason for the double-
> fork, it works perfectly with the single-fork here.
It seems to be the case under Linux, but there seem to be some
other (probably mostly legacy) systems where a single fork()
isn't enough to get rid of the controlling terminal (and where
the daemonthus could be killed when the terminal is closed).
To avoid such problems a double fork() traditionally has done.
But when you're only running this on Linux where the process
group ID differs from the process ID anyway you can forget
about it and just fork() once.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Sat, 18 Aug 2007 04:58:54 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Sending a "status"
Message-Id: <fa5nil$1m5s$2@ns.felk.cvut.cz>
Bill H wrote:
> Using $|++ I have learned that I can "flush" the print buffer to a
> browser while perl is doing things, instead of sending all the html
> when it is done. Is there any drawbacks to using this in the real
> world that any of you may have encountered?
>
> Basically what I would be doing is sending a status to a client while
> the perl scripts are working such as (after sending the html headers
> and other stuff):
>
> Saving your data...
> Processing your data...
> Generating completed pdf...
> Complete.
>
> etc...
>
> and then sending the ending html data.
>
It is solvable but not for 100% ;-)
At first you must keep in mind that some html tags are displayed after end
tag only. For example you must not put messages into <table>.
At second you must send many (useless) spaces to fill browser buffer.
$|=1;
print "<p>Saving your data...</p>, ' 'x1024;
# do something
print "<p>Processing your data......</p>, ' 'x1024;
# do something
This work well (tested) for MSIE5.x and latter and Firefox 2.x and latter.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Fri, 17 Aug 2007 21:14:10 -0500
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Using Subroutines with CGI::Session::MySQL?
Message-Id: <13ccngu7tudoq3e@corp.supernews.com>
On 08/17/2007 02:22 PM, L. D. James wrote:
> On Aug 17, 11:29 am, xhos...@gmail.com wrote:
>> "L. D. James" <lja...@apollo3.com> wrote:
>>> On Aug 16, 9:18 pm, xhos...@gmail.com wrote:
>
>> The uninitialized message is different from the "will not stayed shared"
>> message. One happens at run time, one at compile time.
>>
>>> A fresh load of the code from a different machine that didn't have the
>>> any of the cookie information would initially give the warnings. I
>>> fixed the warnings by initializing them with a default null value as:
>>> $name = $session->param('f_name') || "";
>>> $count = $session->param("count") || "0";;
>> It is the occurence of $name and $count (and $session) inside the sub
>> that gives rise to the will not stay shared errors. The references
>> outside the sub are not relevant to that matter.
>
> After studying the results environment hash, I'm sure this explains
> why you and I see some things differently. You mentioned that
> mod_perl behave different from straight perl. I don't run mod_perl.
>
>>> I had mentioned in my description that there was no problem accessing
>>> the session information. The problem was in writing, or updating the
>>> session information.
>> Are you sure? On my system, running your code, the information was being
>> updated just fine. It didn't *look* like it was being updated, because
>> the information retrieved and printed did not reflect the update. That
>> isn't because it wasn't being updated, but rather because it was being
>> retrieved from the wrong session.
>>
>> If I report $count both inside the sub and in the main code, I noticed
>> that the one printed from the main code always appeared to be updated,
>> while the one printed from the sub appeared not to be.
>
> On mine, it would be updated, subsequently upon calling the data, it
> would read the data, and display what had been placed in the cookie
> session. The display of the data would function equally whether being
> called from the sub routine or from the main program. When it appears
> in the variable would depend on when it was placed in the session and
> read from the session.
>
> Again, session reads are never a problem on my system, only updating
> the session.
>
>>> Likewise, I have not intentionally used mod_perl and don't think I
>>> am. Can you tell me how to insure that I am avoiding mod_perl, as you
>>> do?
>> Sorry, I'm just barely competent (if that) to configure my own apache
>> installation, and am in no position to help other people with theirs.
>
> Without trying, you inadvertently showed me by way of the environment
> hash code you mentioned in the previous message.
>
>> After all, I'm a Perl person, not an apache person. You might want
>> to seek help in an apache-specific resource.
>
> I didn't know that mod_perl was in the picture. I had intentionally
> tried to leave it out. It seems as if I actually succeeded. I'm very
> concerned about the consistent behavior of my programs, that's why I
> put so much into knowing as much about the environment as I can.
> That's why I endeavored to use straight perl, of which I hoped had
> some consistency with the reference manuals I was studying.
>
> -- L. James
>
You've helped to demonstrate that this is not a mod_perl-related
problem. When I create a Perl/CGI program that doesn't unclude the
"undef $session;" at the bottom, the bug returns.
BTW, I was wrong about putting the program in curly braces and using the
PerlRun Apache Perl handler. Neither solves the problem.
This might be a bug in CGI::Session::MySQL (3.2.4.2). When a code block
is exited, lexical variables within that block are supposed to become
undefined; however, in CGI::Session::MySQL, this does not result in the
session data being flushed back to the database.
PS.
As alternatives to "undef $session" for fixing the problem, one can use
"$session->flush()" or "$session->close()" (at the end of the program).
------------------------------
Date: Sat, 18 Aug 2007 04:45:15 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: well-formed XML (was Re: Gaa! UNIX hack tries PPM and fails!)
Message-Id: <fa5nik$1m5s$1@ns.felk.cvut.cz>
Tad McClellan wrote:
> usenet@DavidFilmer.com <usenet@DavidFilmer.com> wrote:
>
>> The gotcha was from the original XML file
>
>
> It actually is NOT an XML file. It is not well-formed.
>
>
>> http://theoryx5.uwinnipeg.ca/ppms/Net_SSLeay.pm.ppd
>> The <AUTHOR> tagset in that file looks like this:
>> <AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
> ^ ^
> ^ ^
> ^
> That breaks well-formedness. It should instead be:
>
> <AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
>
>
>> I think the '@' was the problem.
>
>
Maybe he can use
<AUTHOR>Sampo Kellomaki <sampo@example.com></AUTHOR>
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
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 V11 Issue 767
**************************************