[24963] in Perl-Users-Digest
Perl-Users Digest, Issue: 7213 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 6 00:07:13 2004
Date: Tue, 5 Oct 2004 21: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, 5 Oct 2004 Volume: 10 Number: 7213
Today's topics:
[completely off-topic] Re: Using a string as a variable <1usa@llenroc.ude.invalid>
Can't get pod2usage verbose to work <nospam@ireallymeanit.com>
Re: Can't get pod2usage verbose to work <1usa@llenroc.ude.invalid>
How big a part does hardware play in script execution s <none@none.com>
Re: How big a part does hardware play in script executi <andres@monroy.com>
Re: How Google/Amazon/eBay use? <chernyshevsky@hotmail.com>
Re: Is PHP still slower than Perl? <blackhole@electrictoolbox.com>
Re: Is PHP still slower than Perl? <Andrew@DeFaria.com>
Re: Is PHP still slower than Perl? <yeah@right.com>
Re: Need robust commercial password manager service (wana)
Re: reading a list of files <tadmc@augustmail.com>
Re: regex error <see@sig.invalid>
Re: Regular Expression help please <1usa@llenroc.ude.invalid>
Re: Symbolic algebra <ftoewe@austin.rr.com>
Re: What is @ <jurgenex@hotmail.com>
Re: What is @ <tadmc@augustmail.com>
Re: Win2k CMD shell variables and backtick execution <lv@aol.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Oct 2004 22:40:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: [completely off-topic] Re: Using a string as a variable name.
Message-Id: <Xns9579BE0DDECA7asu1cornelledu@132.236.56.8>
"David K. Wall" <dwall@fastmail.fm> wrote in
news:Xns9579B01A9304Ddkwwashere@216.168.3.30:
> I used to do the same sort of thing when writing SAS macros. (For
> those unfamiliar with it, SAS is a statistical package, or at least
> started as one.) SAS macro language has string variables only, so
> even arrays have to be simulated using symbolic references.
...
> But when I use SAS, I have no choice: it's symbolic references or
> nothing.
I will not touch SAS macros with a ten-foot pole. It is impossible to
decipher what exactly is going on in each step and it is even more
impossible to figure out what other people are doing.
Some time ago, I used to use gslgen (http://www.imatix.com/html/gslgen/)
which would let me come up with a meta-specification in XML for what I
wanted to do and then translate into SAS or Stata code. That is how much I
hate SAS macro programming.
To bring this post somewhat near topicality, Perl makes it even easier for
me to do this. (And, no, no one has to decipher my XML stuff. I just end up
with clean SAS files that might appear a little repetitive but are
straightforward to understand even by novices).
Sorry, couldn't resist.
Sinan.
------------------------------
Date: Tue, 05 Oct 2004 22:22:15 GMT
From: Martin Gill <nospam@ireallymeanit.com>
Subject: Can't get pod2usage verbose to work
Message-Id: <r8F8d.164233$U04.37184@fe1.news.blueyonder.co.uk>
Hi
I'm trying to learn perl, so i've been playing with some of the examples
in the documentation.
I tried creating a simple script with Getopt::Long and Pod::Usage.
When I use pod2usage(-verbose => x) where x is less than two, i don't
get to see my SYNOPSIS block, in fact, i get to see nothing at all.
I thought it was my script, so I copy/pasted the example script into a
new file and ran that. Same result.
A quick search in google revealed some old messages in this group that
talked about line endings being a problem. I use SciTE as my editor, so
it was nice and easy to change the line endings of my file. I tried
CR/LF, LF on its own, and CR on it's own as line endings, but still no luck.
Anyone have any ideas what I am doing wrong?
I've attached the sample code I'm working from to the email.
I'm running:
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
Binary build 810 provided by ActiveState Corp.
Built Jun 1 2004 11:52:21
On Windows XP Pro SP2.
Thanks for any help,
Martin
---------------Code-----------------------
use Getopt::Long;
use Pod::Usage;
my $man = 0;
my $help = 0;
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;
## If no arguments were given, then allow STDIN to be used only
## if it's not connected to a terminal (otherwise print usage)
pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN));
__END__
=head1 NAME
sample - Using GetOpt::Long and Pod::Usage
=head1 SYNOPSIS
sample [options] [file ...]
Options:
-help brief help message
-man full documentation
=head1 OPTIONS
=over 8
=item B<-help>
Print a brief help message and exits.
=item B<-man>
Prints the manual page and exits.
=back
=head1 DESCRIPTION
B<This program> will read the given input file(s) and do something
useful with the contents thereof.
=cut
------------------------------
Date: 5 Oct 2004 22:33:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Can't get pod2usage verbose to work
Message-Id: <Xns9579BCD01EC78asu1cornelledu@132.236.56.8>
Martin Gill <nospam@ireallymeanit.com> wrote in
news:r8F8d.164233$U04.37184@fe1.news.blueyonder.co.uk:
> Hi
>
> I'm trying to learn perl, so i've been playing with some of the
> examples in the documentation.
>
> I tried creating a simple script with Getopt::Long and Pod::Usage.
>
> When I use pod2usage(-verbose => x) where x is less than two, i don't
> get to see my SYNOPSIS block, in fact, i get to see nothing at all.
>
> I thought it was my script, so I copy/pasted the example script into a
> new file and ran that. Same result.
It is your script. See below.
> ---------------Code-----------------------
> use Getopt::Long;
> use Pod::Usage;
>
> my $man = 0;
> my $help = 0;
> ## Parse options and print usage if there is a syntax error,
> ## or if usage was explicitly requested.
> GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
> pod2usage(1) if $help;
> pod2usage(-verbose => 2) if $man;
>
> ## If no arguments were given, then allow STDIN to be used only
> ## if it's not connected to a terminal (otherwise print usage)
> pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t
> STDIN));
> __END__
Why is this __END__ this many spaces over?
>
> =head1 NAME
Reading perldoc perlpod:
A verbatim paragraph is distinguished by having
its first character be a space or a tab.
and:
All command paragraphs (which are typically only
one line long) start with "=", followed by an
identifier,
indicate that the pod directives should be flush against the left margin
Here is what happens when I run your script after I make those changes:
C:\My Documents> perl -v
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
C:\My Documents> cat s.pl
use Getopt::Long;
use Pod::Usage;
my $man = 0;
my $help = 0;
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
GetOptions('help|?' => \$help, man => \$man) or pod2usage;
...
...
C:\My Documents> perl s.pl
s.pl: No files given.
Usage:
sample [options] [file ...]
Options: -help brief help message -man full documentation
C:\My Documents> perl s.pl -man
NAME
sample - Using GetOpt::Long and Pod::Usage
SYNOPSIS
sample [options] [file ...]
Options: -help brief help message -man full documentation
OPTIONS
-help Print a brief help message and exits.
-man Prints the manual page and exits.
DESCRIPTION
This program will read the given input file(s) and do something
useful
with the contents thereof.
Sinan
------------------------------
Date: Wed, 06 Oct 2004 02:23:43 +0100
From: gunzip <none@none.com>
Subject: How big a part does hardware play in script execution speed?
Message-Id: <4163491e$0$44837$ed2619ec@ptn-nntp-reader02.plus.net>
Consider 2 servers:
1. Running Perl CGI
Dual Xeon 2.4Ghz
2Mb RAM
Mobo X
SCSI RAID
2. Running mod_php
Dual P4 2.4Ghz
Mobo X
SCSI RAID
Would the Perl CGI scripts run faster than the mod_php equivalents under
similar heavy loads? Before you ask, I don't have a clue about benchmarking
and these are hypothetical scenarios.
My point is whether the hardware is a bigger factor than the
language/implementation features which generate so many flame wars. In other
words, is Perl CGI on today's hardware faster than mod_php on last year's?
gunzip
------------------------------
Date: Tue, 05 Oct 2004 23:58:50 -0400
From: Andres Monroy-Hernandez <andres@monroy.com>
Subject: Re: How big a part does hardware play in script execution speed?
Message-Id: <6PWdnaru9_rm8P7cRVn-vg@comcast.com>
Hi,
When you say "Perl CGI" do you mean regular mod_cgi or mod_perl. Most
likely mod_php would be faster than regular cgi's. On the other hand
mod_perl is extremely fast.
I think mod_perl, mod_php and other similar technologies are very
comparable in terms of performance.
Hardware plays an important role, but the design and coding of your
application is maybe the *most* important factor to consider. A well
written php web app will outperform a badly written one in perl or in
any other language. Buying more memory or a faster hard drive it's
"easier" than re-implementing your application due to a bad original
design.
The bottom line is that perl and php can be as fast as you want.
Now, to decide on which hardware to buy, the most important thing is to
know whether your app is CPU-bound or IO-bound. Most web apps, I think,
are IO-bound, so a faster HD and more memory would make things faster.
Regards,
-Andrés
gunzip wrote:
> Consider 2 servers:
>
> 1. Running Perl CGI
> Dual Xeon 2.4Ghz
> 2Mb RAM
> Mobo X
> SCSI RAID
>
> 2. Running mod_php
> Dual P4 2.4Ghz
> Mobo X
> SCSI RAID
>
> Would the Perl CGI scripts run faster than the mod_php equivalents under
> similar heavy loads? Before you ask, I don't have a clue about benchmarking
> and these are hypothetical scenarios.
>
> My point is whether the hardware is a bigger factor than the
> language/implementation features which generate so many flame wars. In other
> words, is Perl CGI on today's hardware faster than mod_php on last year's?
>
> gunzip
------------------------------
Date: Tue, 5 Oct 2004 20:24:15 -0400
From: "Chung Leong" <chernyshevsky@hotmail.com>
Subject: Re: How Google/Amazon/eBay use?
Message-Id: <IsSdned-z5JApv7cRVn-rQ@comcast.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:Bf48d.4079$eq1.2873@trnddc08...
> http://www-free.info wrote:
> > I am pretty sure that Google does not use database. Not sure about
> > Amazon or eBay
>
> Excuse me?
> Where do you think they store their millions of articles/queries/items?
>
> jue
Keanu Reeves's brain?
------------------------------
Date: Wed, 06 Oct 2004 11:10:01 +1300
From: Chris Hope <blackhole@electrictoolbox.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <WZE8d.10173$JQ4.683541@news.xtra.co.nz>
John Bokma wrote:
> I mean something like:
>
> $query = "INSERT INTO table VALUES(?, ?, ?)";
> mysql_bla( $query, $a, $b, $c );
>
> Hence without the quote_she_bang_garbage
You can do that with the PEAR database libraries, although some PHP
developers on this newsgroup argue that PEAR is too slow, but I personally
have never had any problems with it. For databases that actually support
prepared queries it does it in the database; for those that don't (eg MySQL
4.0.x and earlier) it simulates it in code.
http://pear.php.net/manual/en/package.database.db.php
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
------------------------------
Date: Tue, 05 Oct 2004 17:52:37 -0700
From: Andrew DeFaria <Andrew@DeFaria.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <b4df6$41634147$c09cfcf$19738@msgid.meganewsservers.com>
"Michael Vilain <vilain@spamcop.net>" wrote:
> One thing I like about php is that each script is stored in the usual
> place in the user's document directory. The files are executed and the
> output is displayed without having to put everything in the ScriptAlias
> directory (usually cgi-bin).
Or you could enable the CGI type.
--
I wasn't born a bitch. Men like you made me this way.
------------------------------
Date: Tue, 5 Oct 2004 23:49:27 -0400
From: "Doug B" <yeah@right.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <YWJ8d.3710$J8.1339@fe02.usenetserver.com>
While this topic appear to have been intended to create an argumentative
long thread of discussion, I will add in my own ideas.
The idea of comparing one language to another requires some assumptions and
restrictions on what is being compared. I primarily do web based stuff, so
I will address the various languages in terms of their use on the internet.
PHP is intended for and excels at processing text, a range of math
functions, and interaction with databases, with a limited amount of fuss on
the part of the coder. It also is a natural for building web pages
requiring the coder to do nothing special to get their output to the
browser. If speed includes deployment time, php wins this in my book.
PERL offers additional capabilities over PHP many of which are of no use to
the web server uses. If those additional capabilities are of use to you
then PERL must take the front seat. Again, PERL has managed to stay fairly
simple for the programmer allowing them to concentrate more on the task at
hand than the architecture of the processor they might be running on, or how
memory is laid out. PERL for web work requires a few additional steps
however when coding, so for me, PHP wins here. But I also use perl quite a
bit for other tasks, like when PHP has been crippled by the hoster such as
doing http uploads.
C and C++, and other more complex systems require you to do a bit more
planning for your program, both in the coding, and the deployment of that
program, requiring a compile step in the testing process which is not
necessary in the PHP or PERL pipeline of development. So if speed includes
deployment time, perl and php both win over C. I also don't know C or C++
so I cannot address specific strengths or weaknesses, but the learning curve
alone pushes C off to the side for many people.
ASP in my opinion is an overly complex language which brings with it all the
drawbacks of C and VB in terms of a lack of simple text handling (which is
virtually all web work is). ASP unfortunately is the only way (or VB) to
access some of the microsoft proprietary features when doing certain things
though I believe, so if those features are required in your application,
then you are stuck with ASP or VB.
JAVA is fantastic in concept, but typically poor in execution. It is
essentially centrally managed code, which auto deploys to the end user,
hopefully OS independant. This OS independance though comes at a price in
terms of system performance more often than not, and people tend to use java
in places where something with significantly less overhead would have
sufficed.
One you left out, ColdFusion. CF is a very nice system also, with similar
capabilities to PHP. This comes at a cost though in dollars. PHP is free,
and CF is certainly not free. PHP also has far more features which can be
compiled in (for free) extending it to include graphics
manipulation/creation and database interaction with most any database server
available. ColdFusion is good, but cost becomes a factor pretty quick.
------------------------------
Date: 5 Oct 2004 17:47:52 -0700
From: ioneabu@yahoo.com (wana)
Subject: Re: Need robust commercial password manager service
Message-Id: <bf0b47ca.0410051647.44fbdfe4@posting.google.com>
> I'm looking for a commercial password management service that will
> work seamlessly with my site, manage up to 1,000-2,000 usernames and
> passwords and not have to be maintained in my own cgi directory of my
I wanted one too and couldn't find one. I finally wrote it myself and
finished basic working version today. it handles creation of new
users, password validation, and session management. I used Perl,
CGI.pm, DBI.pm and MySQL. I learned what I need to know from 'Perl
and MySQL for the Web' by Paul DuBois plus a big stack of O'Reilly
Perl books, a couple of Lincoln Stein books, and some invaluable help
from the kind people of comp.lang.perl.misc.
wana
------------------------------
Date: Tue, 5 Oct 2004 20:05:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: reading a list of files
Message-Id: <slrncm6h6c.4mq.tadmc@magna.augustmail.com>
Pinocchio <krakle@visto.com> wrote:
> my @filenames = </some/path/to/dir/*>;
>
> Then loop through the array and perform whatever functions you want
> to...
>
> foreach my $file (@filenames) {
> # some yadda perl
> }
@filenames is serving no useful purpose.
foreach my $file ( </some/path/to/dir/*> ) { # Look Ma! No temp vars!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Oct 2004 20:04:41 -0400
From: Bob Walton <see@sig.invalid>
Subject: Re: regex error
Message-Id: <416334a4$1_2@127.0.0.1>
Brendon Caligari wrote:
> Bob Walton wrote:
>
>> Brendon Caligari wrote:
>>
>>> Abigail wrote:
>>>
>>>> Brendon Caligari (bcaligari@nospam.fireforged.com) wrote on MMMMLII
>>>> September MCMXCIII in
>
...
> This code was not meant to be 'proper' ..but to expose the panic
> situation. The original script was longer but i reduced it to the
> shortest i could where it would still 'panic'.
Well, I didn't get any "panics", but I did manage to typo the data and
have the length: line not match, which then generated a warning on the
next match. A check for matching would have made the problem
immediately apparent, instead of having to chase it down with the
debugger. It is *always* good practice, *particularly* in test scripts,
to provide proper tests. The extra bit of typing is more than
compensated for by debugging time, even on simple things.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 5 Oct 2004 22:48:46 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Regular Expression help please
Message-Id: <Xns9579BF602D4DCasu1cornelledu@132.236.56.8>
deja_NOSPAM_@zaft.com (Shane) wrote in
news:d0cc80fa.0410050859.a580bc8@posting.google.com:
> Thanks for understanding. Not to mean that I will make a habit of off
> topic posts :-)
>
> Really, sorry for the off topic post all. Again, I just didn't know
> where else to go that I may actually get an answer.
So, apparently, you did not really need an answer. I did point out that you
should try comp.editors but I don't see a post from you.
I have a feeling your posts might not be seen by a lot of people from this
point on.
Sinan.
------------------------------
Date: Tue, 05 Oct 2004 23:41:34 GMT
From: "Fred Toewe" <ftoewe@austin.rr.com>
Subject: Re: Symbolic algebra
Message-Id: <OiG8d.18699$YT3.10483@fe2.texas.rr.com>
"Brian Troutwine" <goofy_headed_punk@msn.com> wrote in message
news:pan.2004.09.30.19.59.34.333004@msn.com...
> I'm trying to write a program to output a Lagrange interpolating
> polynomial.
> http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
>
> So far what I'm getting is output that looks somewhat along the lines of:
>
> ((x-2)(x-3)(x-4)(x-5)(1)/(24))+
> ((x-1)(x-3)(x-4)(x-5)(2)/(-6))+
> ((x-1)(x-2)(x-4)(x-5)(6)/(4))+
> ((x-1)(x-2)(x-3)(x-5)(24)/(-6))+
> ((x-1)(x-2)(x-3)(x-4)(120)/(24))
>
> What I want is to be able to take that and output it in the form of
>
> Ax^n + Bx^(n-1) ... + C
>
> Does anybody have the experience to tell me how to calculate symbolically?
> (Specifically how to implement a symbolic algebra module.)
>
Never did see a good answer to this one so I played around with it until
the following evolved. Uses the Math::Polynomial module to simplify the
math - Gee! what a concept. Fred
use strict;
use warnings;
use diagnostics;
use Math::Polynomial;
Math::Polynomial->verbose(1);
#((x-2)(x-3)(x-4)(x-5)(1)/(24))+
#((x-1)(x-3)(x-4)(x-5)(2)/(-6))+
#((x-1)(x-2)(x-4)(x-5)(6)/(4))+
#((x-1)(x-2)(x-3)(x-5)(24)/(-6))+
#((x-1)(x-2)(x-3)(x-4)(120)/(24))
#What I want is to be able to take that and output it in the form of
#Ax^n + Bx^(n-1) ... + C
my @Polys;
my $Total = Math::Polynomial->new();
my @zeros = (-1,-2,-3,-4,-5);
my @weights = (1/24,-2/6,6/4,-24/6,120/24);
for my $p (0..4) {
my $Poly = Math::Polynomial->new(0,1);
for my $i (0..4) {
next if ($i == $p);
my $Term = Math::Polynomial->new(1, $zeros[$i]);
$Poly = $Poly * $Term;
}
push @Polys, $Poly;
$Total += $Poly * $weights[$p];
}
$"="\n";
print "\nPolynomials are:\n@Polys\n\n$Total\n";
------------------------------
Date: Wed, 06 Oct 2004 00:03:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: What is @
Message-Id: <JDG8d.8591$1g5.6581@trnddc07>
asdf wrote:
> I have a perl script for filtering spam. Did not write it, don't
> know perl. The white list and black list files it looks to are just
> lists of email addresses. I have been told since perl 5 came out I
> should escape all @ with a \.
That is BS.
> What if I don't? Is is just another
> form of wildcard?
It has nothing to do with wildcards whatsoever.
The @ is the syntactic indicator for an array, just like the $ indicates a
scalar and the % a hash.
> The chances of something other than the intended
> email address having the same start and ending seems remote.
>
> vic@some.com
> vic\@some.com
If you don't want to refer to the array @some but to the literal text
'@some' _AND_THIS_TEXT_IS_IN_A_DOUBLE_QUOTED_STRING_ then you need to escape
the and at sign, otherwise not. If you escape it randomly, then chances are
that the code doesn't work any longer because perl will not be able to
recognize an array any more.
jue
------------------------------
Date: Tue, 5 Oct 2004 19:59:05 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: What is @
Message-Id: <slrncm6gqp.4mq.tadmc@magna.augustmail.com>
asdf <asdf@see.below.com.net.org.invalid> wrote:
> I will escape it.
Why?
All of the advice to this point has been to leave the data alone!
> I looked at the script and cannot figure it out.
Here is a test to try:
Is it working without backslashing at-signs?
If so, then leave the data alone.
If not, then try backslashing at-signs.
ie. do not "fix it" if it is not "broken".
> Should only take, I don't know how long
About 10 seconds...
> to edit the file.
... if you use Perl to do it for you (untested):
perl -p -i.noslash -e 's/\@/\\@/g' data_file
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Oct 2004 21:21:35 -0500
From: l v <lv@aol.com>
Subject: Re: Win2k CMD shell variables and backtick execution
Message-Id: <416356b2_1@corp.newsfeeds.com>
buildmorelines wrote:
> I want to do backtick execution (to capture STDOUT to a variable for
> matching/error handling) with a shell variable in it. If I type it
> into a C prompt
>
> C:\>"%PROGRAMFILES%\Windows Media Player\mplayer2.exe" #works fine
>
> When I do
>
> C:\>%PROGRAMFILES%\Windows Media Player\mplayer2.exe
>
> I get
>
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file.
>
> Now if I do it in Perl as (heres a list of everything I tried)
>
> system('%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe');
> system("%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
> system("\%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
> system'"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"';
> `"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"`;
> `\"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe\"`;
> qx/"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"/;
> qx!"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"!;
> qx#"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"#;
> qx("%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
>
> $run = '"%PROGRAMFILES%\Windows Media Player\mplayer2.exe"';
> `$run`;
>
> $run = '%PROGRAMFILES%\Windows Media Player\mplayer2.exe';
> `$run`;
>
> I get
>
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file
>
> I've spent 3 hours trying to do this.
> The only code I found that does it (written by myself), is this
> totally crazy, and there has to be a better, more efficent way. It is
> below.
>
> #!/usr/bin/perl
> $data = `echo %PROGRAMFILES%\\Windows Media Player\\mplayer2.exe`;
> chop $data;
> $data = '"' . $data . '"';
> print "\n data is \n\n $data \n\n";
> `$data`;
>
> Idealy I would like this to work.
>
> $run_result = `%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe`;
>
> Also I know that I need to manually close Windows Media Player for all
> of these to work but thats not the point and I have a solution for
> that (cmd /c or start).
The "crazy" method works as the dos echo is converting %PROGRAMFILES% to
c:\Program Files. Instead use Perl's built in method to access
environment variables -- %ENV, where $ENV{PROGRAMFILES} is equilivent to
%PROGRAMFILES%. Also on Win2k and up (I can't speak to NT4), use
forward slashes vs backslashes. Therefore, per your example, you can
simply do:
$run_result = `$ENV{Programfiles}/Windows Media Player/mplayer2.exe`;
Len
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
------------------------------
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 7213
***************************************