[26305] in Perl-Users-Digest
Perl-Users Digest, Issue: 8484 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 4 14:05:17 2005
Date: Tue, 4 Oct 2005 11:05:06 -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 Tue, 4 Oct 2005 Volume: 10 Number: 8484
Today's topics:
ksh after perl script <atk@sbcglobal.net>
Re: overload proxy object <eric@afaik.us>
Perl's umask equivalent command <atk@sbcglobal.net>
Re: Perl's umask equivalent command (Anno Siegel)
Re: Perl's umask equivalent command <tadmc@augustmail.com>
Re: Regex: Matching Characters NOT in a Certain Range <hal@thresholddigital.com>
Re: threads, XSUB allocated memory, destructors, destru xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 04 Oct 2005 16:41:29 GMT
From: "E Arredondo" <atk@sbcglobal.net>
Subject: ksh after perl script
Message-Id: <Zgy0f.14$Zs3.9@newssvr25.news.prodigy.net>
Hello, Please help me, I want to run a ksh script after a perl script on the
same cgi file, basically the perl is taking care of the uploading zip files
with photos from a website and then the korn shell uncompresses the received
files and moves them to their specific location and creates thumbnails, is
that possible ? Or maybe moving the ksh part of the script to a new file and
then making Perl execute it once it finishes with the first part . (i.e.
Perl execute "/script/processupload")
Here's how it gets run from a website : <FORM ACTION="/cgi-bin/upload.cgi"
METHOD="post" ENCTYPE="multipart/form-data">
Here's the actual script : upload.cgi
-------------------------------- start here -------------------
#!/usr/bin/perl -w
use CGI;
$upload_dir = "/www/docs/upload";
$query = new CGI;
$filename = $query->param("photo");
$claim = $query->param("claim");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open (UPLOADFILE, ">$upload_dir/$filename")
or die "Can't write to directory '$upload_dir/$filename': $~\n";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your photo!</P>
</BODY>
</HTML>
END_HTML
#!/bin/ksh <<<<<<<<<<<<<----------------------here's what's next
umask 0
photos=/www/docs/domain.com/jpg/claims/
cd /www/docs/upload
setcase -lr /www/docs/upload > /dev/null 2>&1
ls *zip | while read line
do
typeset -i CLAIM1=`echo $line | cut -f1 -d.`
typeset -i folder=`expr $CLAIM1 / 500`
typeset -i claim=`expr $CLAIM1`
if [ $claim -gt "100000" ]
then
if [ ! -d $photos$folder/$claim ]
then
mkdir -p $photos$folder/$claim
fi
if [ -d $photos$folder/$claim ]
then
cd $photos$folder/$claim
unzip -oq /www/docs/upload/$line
setcase -lr $photos$folder/$claim > /dev/null 2>&1
for lone in !(*tnail*)
do
if [ ! -f "tnail$lone" ]
then
echo $lone
/usr/local/bin/djpeg $lone | /usr/local/bin/pnmscale 0.2 |
/usr/local/bin/cjpeg > tnail$lone
fi
done
rm -rf /www/docs/upload/$line
fi
fi
done
------------------ cut here -------------------------------------
Thanks.
------------------------------
Date: Tue, 04 Oct 2005 13:26:40 -0400
From: Eric Anderson <eric@afaik.us>
Subject: Re: overload proxy object
Message-Id: <1128446816.0d2c2f644c2a98d2e0a7bf504f9d9918@teranews>
Anno Siegel wrote:
> It occurred to me that your original AUTOLOAD solution should
> work just fine if you specify autoloading like this:
>
> '""' => sub { $_[ 0]->stringify },
>
> instead of
>
> '""' => 'stringify',
Hmm... This is an interesting approach. I want to try avoid any changes
to the object being proxied so I would prefer it to work as normal:
'""' => 'to_string'
but I'll keep that approach in mind. It might be "good enough".
>>In
>>particular, the class Data::User is hard-coded into Class::Delayed,
>>which could mess up further inheritance. See what you can do with it.
I am also trying to avoid this approach. I agree it is disappointing
that can() doesn't work as it should but I am willing to live with that
to allow this Proxy class work with any object.
I wonder if I could overload the can() to return the correct behavior?
Something like:
sub can {
my ( $self, @args ) = @_;
$self->{obj}->can(@args);
}
Obviously I would need to check if obj is initialized and if not
initialize it but the basic idea might work.
> I have cleaned up things a little. In the code below the problem
> class (Heavy) is written more or less like any hash-based class.
I appreciate your effort but I don't think the "inherit" will work for
me. I need the class to be able to delay initialization for many object
types. Not just one.
Eric
------------------------------
Date: Tue, 04 Oct 2005 15:21:17 GMT
From: "E Arredondo" <atk@sbcglobal.net>
Subject: Perl's umask equivalent command
Message-Id: <N5x0f.1$Zs3.0@newssvr25.news.prodigy.net>
Hi,
I need all files created to be -rw-rw-rw , on unix I would put at the top of
the script:
#!/bin/ksh
umask 0
Can I use umask on perl ?
#!/usr/bin/perl -w
umask 0
Thanks
------------------------------
Date: 4 Oct 2005 15:34:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl's umask equivalent command
Message-Id: <dhu7e3$6vo$1@mamenchi.zrz.TU-Berlin.DE>
E Arredondo <henry@vegena.net> wrote in comp.lang.perl.misc:
> Hi,
>
> I need all files created to be -rw-rw-rw , on unix I would put at the top of
> the script:
>
> #!/bin/ksh
> umask 0
>
>
> Can I use umask on perl ?
>
> #!/usr/bin/perl -w
> umask 0
What happened when you ran this? See "perldoc -f umask".
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Tue, 4 Oct 2005 11:14:57 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl's umask equivalent command
Message-Id: <slrndk5ak1.njo.tadmc@magna.augustmail.com>
E Arredondo <atk@sbcglobal.net> wrote a SAQ:
> Can I use umask on perl ?
Yes, perl has a function for using a umask.
I'll leave it as an exercise for the reader to guess
what such a function might be named...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 04 Oct 2005 13:01:16 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Regex: Matching Characters NOT in a Certain Range
Message-Id: <ZsydnVodxrfHKN_eRVn-rQ@comcast.com>
A. Sinan Unur wrote:
> Hal Vaughan <hal@thresholddigital.com> wrote in
> news:NqmdnbZHArRErd_enZ2dnUVZ_tOdnZ2d@comcast.com:
>
>> Anno Siegel wrote:
>
> ...
>
>>> Have you looked at perlre?
>
> ...
>
>> I can never remember all the terms to search for.
>
> perldoc perltoc
Thanks. I never knew that! (Seriously -- I was used to searching for
terms, but never new there was a toc!)
Hal
------------------------------
Date: 04 Oct 2005 16:24:43 GMT
From: xhoster@gmail.com
Subject: Re: threads, XSUB allocated memory, destructors, destruction
Message-Id: <20051004122443.459$sY@newsreader.com>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote:
> <xhoster@gmail.com> wrote in message
>
> >
> > On linux, I just get a segfault.
> >
>
> On Win32 I get a segfault, too - produced, I presume, by freeing "to
> wrong pool".
>
> ...
>
> >
> > For reasons I don't understand, it is trying to call DESTROY twice for
> each
> > object. It goes through calling DESTROY once for each object, then
> > starts running through again, seg faulting at some random point on the
> > second pass.
> >
>
> On Win32, it looks like it's only being called once for each object - and
> it seems to be the freeing of the very last object that needs to be freed
> that produces the error (now that I look more closely).
Could it be that Win32 is also trying to destroy everything twice, and it
is the destroying of the very first object, but on the second pass, which
produces the error? (doing so before the message on that one can be
printed)
> On further investigation, I found that if the pointer objects are not
> blessed into a package, then there seems to be no problem at all - see
> the (modified) script below my sig. Does it also work ok on linux ?
Yes, it seems to work on Linux.
> If so
> then perhaps the op can get around his problem by using unblessed objects
> - which means that it's then his responsibility to call _destroy()
> explicitly at the appropriate time(s).
I tried moving the DESTROY from XSUB to Perl, and have the Perl DESTROY
call _destroy. But now DESTROY is getting called twice again, and we are
back to seg-faulting.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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 8484
***************************************