[22442] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4663 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 4 18:10:38 2003

Date: Tue, 4 Mar 2003 15:10:12 -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           Tue, 4 Mar 2003     Volume: 10 Number: 4663

Today's topics:
        Shell commands (Andy)
    Re: Shell commands <mhunter@celeste.net.berkeley.edu>
    Re: Stolen! <goldbb2@earthlink.net>
    Re: Stolen! <newsfeed2@boog.co.uk>
    Re: Stolen! <flavell@mail.cern.ch>
    Re: Text list to html files <usenet@dwall.fastmail.fm>
    Re: Text list to html files (Tad McClellan)
    Re: Works offline but not online <goldbb2@earthlink.net>
    Re: Works offline but not online <s_grazzini@hotmail.com>
        XS code to call DLL <brian_helterline@hp.com>
    Re: XS code to call DLL <goldbb2@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 4 Mar 2003 12:43:54 -0800
From: andyram27@hotmail.com (Andy)
Subject: Shell commands
Message-Id: <124d30f8.0303041243.71035144@posting.google.com>

Hi,

This should be relatively straightforward but I'm having a tough time.
 I'm trying to use the copy command within a perl script, but I need
to pass an option to the command as well.  I basically need to execute
the following (i'm on win32 but it works the same on unix):

xcopy /S D:\scripts\somedir R:\somedir

So my code looks like this:

xcopy($src,$dest);

But I can't seem to figure out how to pass the /S option.

THX,ANDY


------------------------------

Date: Tue, 4 Mar 2003 21:44:50 +0000 (UTC)
From: Mike Hunter <mhunter@celeste.net.berkeley.edu>
Subject: Re: Shell commands
Message-Id: <slrnb6a7ps.165.mhunter@celeste.net.berkeley.edu>

On 4 Mar 2003 12:43:54 -0800, Andy wrote:
>  Hi,
> 
>  This should be relatively straightforward but I'm having a tough time.
>   I'm trying to use the copy command within a perl script, but I need
>  to pass an option to the command as well.  I basically need to execute
>  the following (i'm on win32 but it works the same on unix):
> 
>  xcopy /S D:\scripts\somedir R:\somedir
> 
>  So my code looks like this:
> 
>  xcopy($src,$dest);
> 
>  But I can't seem to figure out how to pass the /S option.

You need to look into back-ticks, i.e. `command args` or the "system"
command.

Mike


------------------------------

Date: Tue, 04 Mar 2003 15:44:13 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Stolen!
Message-Id: <3E65101D.18805224@earthlink.net>

Peter Cooper wrote:
> 
> Eric Roode wrote:
> > I can't really answer this, having never used PHP, but it's my
> > understanding that PHP makes some quick and dirty tasks quicker and
> > less dirty.  In particular, it's supposed to make database access
> > sweet.
> 
> The most compelling argument I've seen is one of speed. With all of
> the statistics I've seen (even those done by Perl people), PHP with
> the Zend optimiser outperforms Perl by a long way on Web applications,
> and outperforms mod_perl /slightly/.

Umm... mod_perl *is* Perl, thus I have to ask, how can mod_perl be
faster than Perl?

> I am of the belief, however, that I can write something in Perl in a
> more optimised way than I could in PHP.. no matter what the core speed
> of the languages are.

-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


------------------------------

Date: Tue, 4 Mar 2003 21:44:11 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Stolen!
Message-Id: <g699a.12587$EN3.102177@newsfep4-glfd.server.ntli.net>

> >The most compelling argument I've seen is one of speed. With all of the
> >statistics I've seen (even those done by Perl people), PHP with the Zend
> >optimiser outperforms Perl by a long way on Web applications, and outperforms
> >mod_perl /slightly/.
>
> Are you comparing here Perl run as CGI with PHP run as CGI - or Perl run
> as CGI with PHP run as a web server module? If the latter, that is then
> where your speed difference is - CGI versus module execution; not language
> difference (and actually your mention about PHP outperforming mod_perl only
> slightly seems to indicate that execution mode difference is the reason
> for the speed difference - not the language).

Sorry, yeah, replace 'Perl' with CGI in my statement. Ditto to Benjamin. PHP
still beat Perl, even with mod_perl, however.

I'm the least pro-PHP guy you could find, but I gotta say the benchmarks still
show it's faster. The main benchmark I recall was in PerlMonth.. which seems to
have fallen off of the Web, but a cached version is at:

http://tinyurl.com/6uyq

PHP was about 20% faster across the board (mod_php 4-alpha versus mod_perl),
although these are old stats.

Anyone got any really up to date benchmarks?

Pete




------------------------------

Date: Tue, 4 Mar 2003 23:30:04 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Stolen!
Message-Id: <Pine.LNX.4.53.0303042323200.3335@lxplus079.cern.ch>

On Tue, Mar 4, Benjamin Goldberg inscribed on the eternal scroll:

> Peter Cooper wrote:
> > The most compelling argument I've seen is one of speed. With all of
> > the statistics I've seen (even those done by Perl people), PHP with
> > the Zend optimiser outperforms Perl by a long way on Web applications,
> > and outperforms mod_perl /slightly/.
>
> Umm... mod_perl *is* Perl, thus I have to ask, how can mod_perl be
> faster than Perl?

I think you're trying to call attention to the overhead of invoking a
Perl script via CGI?  I'm not sure though whether you'd rate the
language-independent overhead of the CGI invocation, or the
Perl-specific overhead of running the script (compared with say
pre-compiled C or whatever[1]), as more significant. But either way,
if the comparison is with PHP running as a handler (rather than via
the CGI) then the hon Usenaut is not really comparing like with like.

cheers

[1] "physicists write FORTRAN in any language" - as someone commented
years ago


------------------------------

Date: Tue, 04 Mar 2003 20:33:13 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Text list to html files
Message-Id: <Xns93349E3854FAdkwwashere@216.168.3.30>

Greg Raven <greg@racquettech.com> wrote on 04 Mar 2003:

> Finally, I wasn't able to spot anything about the DATA filehandle
> in the Posting Guidelines, nor using perldoc -q and looking for
> <DATA> or filehandle, but I'll keep looking. 

Look in perldata under "Scalar value constructors".

perldoc perldata

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


------------------------------

Date: Tue, 4 Mar 2003 16:24:50 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Text list to html files
Message-Id: <slrnb6a9ti.1us.tadmc@magna.augustmail.com>

Greg Raven <greg@racquettech.com> wrote:
> Tad McClellan wrote:

>> The DATA filehandle is special (the Posting Guidelines mention that too).
>> 
>> If you want to open a Real File then you should choose a filehandle
>> name *other* than DATA.
> 
> Then I screwed it up, 


No you didn't. You don't _have to_ use a different name, my suggestion
was for the benefit of the maintenance programmer, not for the
interpreter.

DATA is special, so using it in a non-special way may confuse folks.


> Finally, I wasn't able to spot anything about the DATA filehandle in the 
>   Posting Guidelines, 


It actually only talks about the __DATA__ token, which is where the
DATA filehandle gets its data from:

    Describe *precisely* the input to your program. Also provide example
    input data for your program. If you need to show file input, use the
    __DATA__ token (perldata.pod) to provide the file contents inside of
    your Perl program.


> nor using perldoc -q and looking for <DATA> or 
> filehandle, but I'll keep looking.


Look here in the "Scalar value constructors" section:

   perldoc perldata


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 04 Mar 2003 15:36:48 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Works offline but not online
Message-Id: <3E650E60.F1B71F5E@earthlink.net>

Johan Ljunggren wrote:
> 
> On 2003-03-04 11:47, news@roaima.freeserve.co.uk wrote:
> > Johan Ljunggren <Johan.Ljunggren@uab.ericsson.se> wrote:
> >
> >>I have a perl CGI script that uses xalan (XSLT) to convert a XML
> >>file to a HTML file. When running it offline it works fine, but when
> >>running it online it doesn't...!?
> >
> >
> > What *exactly* happens, or doesn't happen? Saying "it doesn't
> > [work]" is not particularly helpful.
> 
> $rc = 256 and no HTML output.

This indicates that the system() function succeeded, and $java was
successfully started, but that it did an exit(0).

What could cause org.apache.xalan.xslt.Process to do a System.exit(0)? 
I don't know, but I do know that it's not a perl question.

(I would *guess* that it either didn't have permission to read some
file, or didn't have permission to write to some file... but that's just
a guess.)


-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


------------------------------

Date: Tue, 04 Mar 2003 22:17:32 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Works offline but not online
Message-Id: <0C99a.66529$ma2.18127272@twister.nyc.rr.com>

Benjamin Goldberg <goldbb2@earthlink.net> writes:
> Johan Ljunggren wrote:
>> 
>> $rc = 256 and no HTML output.
> 
> This indicates that the system() function succeeded, 
> and $java was successfully started, but that it did 
> an exit(0).
> 

You mean exit(1). :)

-- 
Steve


------------------------------

Date: Tue, 4 Mar 2003 12:21:09 -0800
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: XS code to call DLL
Message-Id: <b431s8$3tr$1@hpcvsgen.cv.hp.com>

Hello,

This is my first attempt to try and access a DLL (Windows) from perl.
I have the C header file for the function definitions but don't know
if/how to link them with perl.  I looked into the XS module, but it
quickly confused me.  Any general guidence would be greatly appreciated
such as:
I'm assuming I need to make a module to access the .DLL
Do I need to write 'C' code to glue this together?
Can I do the module all in perl?

Thanks for any pointers/help

-brian




------------------------------

Date: Tue, 04 Mar 2003 16:33:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: XS code to call DLL
Message-Id: <3E651BAF.44A7F7A0@earthlink.net>

Brian Helterline wrote:
> 
> Hello,
> 
> This is my first attempt to try and access a DLL (Windows) from perl.
> I have the C header file for the function definitions but don't know
> if/how to link them with perl.

   use Win32::API;

> I looked into the XS module, but it quickly confused me.

XS is a language, not a module.

It's essentially C, but with some other stuff thrown in to make hooking
it up to perl a little bit easier.

> Any general guidence would be greatly appreciated such as:
> I'm assuming I need to make a module to access the .DLL
> Do I need to write 'C' code to glue this together?
> Can I do the module all in perl?

You probably can do it all in perl -- it depends on the data structures
involved.  If you need to pass to one of the dll's functions a function
pointer as a callback, then you'll need C or XS.  For the most common
types (ints, longs, pointers) Win32::API will work fine directly.

I *think*, but am not entirely certain, that you can use the following
tricks to pass 'float' or 'double' parameters to a .dll function:
   If a function takes a 'float' argument, tell Win32::API that you're
passing in a long, and then give it unpack("L", pack("f", $float)).
   If a takes a 'double' argument, tell Win32::API that you're passing
in two longs, and then give it unpack("LL", pack("d", $double)).
   If a .dll function returns a float, say that it returns a long, and
unpack("f",pack("L",$ret_val)) to get a float.

If these tricks don't work, or if the function returns a double, then
you may need to use XS.  

-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


------------------------------

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.  

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 4663
***************************************


home help back first fref pref prev next nref lref last post