[24972] in Perl-Users-Digest
Perl-Users Digest, Issue: 7222 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 8 03:06:55 2004
Date: Fri, 8 Oct 2004 00:05: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, 8 Oct 2004 Volume: 10 Number: 7222
Today's topics:
How does the complement work with transliteration ? (anita)
Re: How does the complement work with transliteration ? <sholden@flexal.cs.usyd.edu.au>
Re: Is PHP still slower than Perl? (Brad Shinoda)
Re: Is PHP still slower than Perl? <postmaster@castleamber.com>
Re: Is PHP still slower than Perl? <blackhole@electrictoolbox.com>
linked list for string class larry_wallet@yahoo.com
Re: linked list for string class <jurgenex@hotmail.com>
Re: linked list for string class <notvalid@email.com>
Re: linked list for string class <uri@stemsystems.com>
Re: Loop through scalar? <sdn.girths00869@zoemail.net>
need some visual clarity/implimentation LWP help (buildmorelines)
Re: perl regexp for iptables (Kaushal Bhandu)
Re: query to join two tables in 2 different Oracle sche (Gerhard M)
Re: Running vi from Perl (Gerhard M)
To Tad: Great perl class, and question <af4bh@iglou.com>
Re: Top 10 list algorithm <abigail@abigail.nl>
Re: Win2k CMD shell variables and backtick execution (buildmorelines)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Oct 2004 21:27:41 -0700
From: anita1766@yahoo.com (anita)
Subject: How does the complement work with transliteration ?
Message-Id: <1a1fc02.0410072027.4e6b1aa8@posting.google.com>
Hello
I was wondering how tr/abcd/1234/cs is supposed to work... I intend it
to mean- if its anything other than abcd replace with ... I am not
sure what the right way is.
Without the /c, tr/abcd/1234/s does the expected, replaces each of a
b c and d found, with their corresponding replacement characters. But
in the /c case I notices that any character that was not one of abcd
was replaed with 4, the last character in the REPLACEMENTSTRING 1234.
I tried to look at documentation - they have just one example of
replacing all that dont fit the search with a space. If any of you
have examples of how you use this thing with /c, i'd love to see them.
Thanks
anita
------------------------------
Date: 8 Oct 2004 05:17:48 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: How does the complement work with transliteration ?
Message-Id: <slrncmc8ns.7j8.sholden@flexal.cs.usyd.edu.au>
On 7 Oct 2004 21:27:41 -0700, anita <anita1766@yahoo.com> wrote:
> Hello
> I was wondering how tr/abcd/1234/cs is supposed to work... I intend it
> to mean- if its anything other than abcd replace with ... I am not
> sure what the right way is.
>
> Without the /c, tr/abcd/1234/s does the expected, replaces each of a
> b c and d found, with their corresponding replacement characters. But
> in the /c case I notices that any character that was not one of abcd
> was replaed with 4, the last character in the REPLACEMENTSTRING 1234.
>
> I tried to look at documentation - they have just one example of
> replacing all that dont fit the search with a space. If any of you
> have examples of how you use this thing with /c, i'd love to see them.
perldoc perlop:
tr/SEARCHLIST/REPLACEMENTLIST/cds
y/SEARCHLIST/REPLACEMENTLIST/cds
...
If the "/d" modifier is used, the REPLACEMENTLIST is always
interpreted exactly as specified. Otherwise, if the
REPLACEMENTLIST is shorter than the SEARCHLIST, the final
character is replicated till it is long enough. If the
REPLACEMENTLIST is empty, the SEARCHLIST is replicated. This
latter is useful for counting characters in a class or for
squashing character sequences in a class.
Using a replacement list of more than one character with /c will
give results that depend on what order the complement characters
are listed in the resulting complemented SEARCHLIST.
I don't think that's defined anywhere, but I would assume is would
be in ord() order though how that interacts with unicode strings
I have no idea and the assumption is vaguely supported by:
---
; perl -de1
...
main::(-e:1): 1
DB<1> $s="\0\1\2abc"
DB<2> x $s
0 "\c@\cA\cBabc"
DB<3> $s=~tr/abc/123/c
DB<4> x $s
0 '123abc'
---
I think "don't do that" applies here.
--
Sam Holden
------------------------------
Date: 7 Oct 2004 15:44:08 -0700
From: oracle.shinoda@gmail.com (Brad Shinoda)
Subject: Re: Is PHP still slower than Perl?
Message-Id: <ad3a63b3.0410071444.5d9c1623@posting.google.com>
John Bokma <postmaster@castleamber.com> wrote in message news:<Xns957AC495EAC76castleamber@130.133.1.4>...
> oracle.shinoda@gmail.com (Brad Shinoda) wrote in
> news:ad3a63b3.0410061342.780a787c@posting.google.com:
>
> > John Bokma <postmaster@castleamber.com> wrote in message
> > news:<Xns9579AAC4C59F6castleamber@130.133.1.4>...
> >> That's mySQL, not PHP.
> >>
> >> I mean something like:
> >>
> >> $query = "INSERT INTO table VALUES(?, ?, ?)";
> >> mysql_bla( $query, $a, $b, $c );
> >>
> >> Hence without the quote_she_bang_garbage
> >
> > I can't believe you can't actually write such a function yourself???
>
> Sure. I can even write my own improved PHP clone. What's the point?
You're the one who wants the functionality. That's what the "point"
is.
>
> > People should always be writing wrapper functions or classes to handle
> > db connections, to remove such stuff as addslashes()ing. Use
> > func_num_args() to find out the number of arguments passed to a php
> > function and func_get_arg([number]) to get the [number]th argument
> > passed. I've written such a function for myself.
>
> Yes, and everybody has to write wrapper functions. You get the point
> now, or do you want it spelled out?
I see what you mean, you're saying that you'd rather it be
incorporated into the language rather than something you have to do
yourself. Misunderstanding on my part.
>
> > Well in fact I use
> > three classes for handling databases - one abstract "Database" class
> > for any database,
>
> Yes, in Perl that is called DBI. You don't have to write it yourself.
>
>
> > one Database specific class (eg mysql_db for mysql
> > databases) and a Query class for handling queries in the manner you
> > suggest. Now I do this:
> >
> > $sql = "SELECT foo, bar
> > FROM table
> > WHERE a = ?
> > AND b = ?";
> > $db->query(new Query($sql, $a, $b), __LINE__, __FILE__);
> >
> > And all query preprocessing is handled by the Query class, and
> > database connection/query processing/error handling is handled by the
> > database-specific class.
> >
> > I use such classes in all my developments. They're written once then
> > forgotten about, and simply reused where needed.
>
> Wonderful. With Perl it's put on CPAN and used (and tested) by many
> people.
I dunno what CPAN is but I'll assume it's some kind of equivilant to
PEAR?
>
> > All I'm saying is that it's really pretty easy to implement many
> > things yourself, without moaning that the language hasn't done them
> > for you.
>
> Programming shouldn't be about reinventing wheels, and worse reinventing
> bugs.
I suppose, but at the same time doing it yourself gives you more
control, and more scope for customisability.
------------------------------
Date: 7 Oct 2004 23:11:47 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <Xns957BB919761EFcastleamber@130.133.1.4>
oracle.shinoda@gmail.com (Brad Shinoda) wrote in
news:ad3a63b3.0410071444.5d9c1623@posting.google.com:
> John Bokma <postmaster@castleamber.com> wrote in message
> news:<Xns957AC495EAC76castleamber@130.133.1.4>...
>> oracle.shinoda@gmail.com (Brad Shinoda) wrote in
>> news:ad3a63b3.0410061342.780a787c@posting.google.com:
>>
>> > John Bokma <postmaster@castleamber.com> wrote in message
>> > news:<Xns9579AAC4C59F6castleamber@130.133.1.4>...
>> >> That's mySQL, not PHP.
>> >>
>> >> I mean something like:
>> >>
>> >> $query = "INSERT INTO table VALUES(?, ?, ?)";
>> >> mysql_bla( $query, $a, $b, $c );
>> >>
>> >> Hence without the quote_she_bang_garbage
>> >
>> > I can't believe you can't actually write such a function
>> > yourself???
>>
>> Sure. I can even write my own improved PHP clone. What's the point?
>
> You're the one who wants the functionality. That's what the "point"
> is.
No, I want less garbage, and less error prone code, *that's* the point.
>> Yes, and everybody has to write wrapper functions. You get the point
>> now, or do you want it spelled out?
>
> I see what you mean, you're saying that you'd rather it be
> incorporated into the language rather
Nooooo... please don't incorporate more functions in the language. By
know PHP must be the language with the biggest function clutter *in* the
language, combined with the worst naming scheme (or lack of) ever.
> than something you have to do
> yourself. Misunderstanding on my part.
Have a look at DBI, or JDBC. It's not that difficult to understand what
I mean. Once you understand the basics, you get my point ;-)
>> Wonderful. With Perl it's put on CPAN and used (and tested) by many
>> people.
>
> I dunno what CPAN is but I'll assume it's some kind of equivilant to
> PEAR?
It's most likely the other way around. And I am afraid PEAR doesn't come
close to CPAN.
>> Programming shouldn't be about reinventing wheels, and worse
>> reinventing bugs.
>
> I suppose, but at the same time doing it yourself gives you more
> control, and more scope for customisability.
What do you want to customise about prepared statements? It's like
saying, let's not include geometrical functions, but let's write them
ourselves, so we can customise them...
Everytime I look at PHP I am afraid to discover one day that + has been
replaced with
add_two_positive_integers( $a, $b )
negative_integer_add_positive_integer( $a, $b )
addnegativeintegers( $a, $b )
get_sumof_positiveandnegative_integer( $a, $b )
integer_add( $a, $a_is_positive, $b, $b_is_positive )
:
:
:-)
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Fri, 08 Oct 2004 12:31:43 +1300
From: Chris Hope <blackhole@electrictoolbox.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <blk9d.10956$JQ4.718758@news.xtra.co.nz>
Brad Shinoda wrote:
> I dunno what CPAN is but I'll assume it's some kind of equivilant to
> PEAR?
CPAN is a huge repository of prebuilt and reusable packages. I think I saw
someone mention that there's currently about 7000 packages available. So it
is sort of the equivilent of PEAR, but PEAR's still in its infancy compared
to CPAN and many PHP developers don't seem to know about it.
One difference between this aspect of Perl vs PHP (and I'm speaking here as
someone who used to develop Perl about 6 years ago and then switched to
PHP) is that all the Perl developers seem to know about CPAN and it sounds
like it's easy to contribute to, whereas the reverse seems to be true for
PHP.
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
------------------------------
Date: 7 Oct 2004 21:57:04 -0700
From: larry_wallet@yahoo.com
Subject: linked list for string class
Message-Id: <2ef9cd87.0410072057.50dafd0e@posting.google.com>
How would I go about creating a linked list in Perl? I would like to
dynamically generate structures or objects and link one to the next so
that I may traverse the list back and forth.
I would then like to have each object in the list contain as a member
a single text character. By stringing together an arbitrary number of
these objects, this larger structure, which could be a class
containing the linked list, could be used as a "string" class,
literally a string of characters, not bound by the limitations of
simple common strings.
I appreciate any thoughts on how I might implement this structure in
Perl, which seems uniquely well suited to the task.
****
*lw*
****
Director of Generic Programming and Abstractions,
Integrated Distributed Systems, Inc.
------------------------------
Date: Fri, 08 Oct 2004 05:11:16 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: linked list for string class
Message-Id: <Ujp9d.17532$1g5.5749@trnddc07>
larry_wallet@yahoo.com wrote:
> How would I go about creating a linked list in Perl?
perldoc perlref
perldoc perlreftut
jue
------------------------------
Date: Fri, 08 Oct 2004 05:17:58 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: linked list for string class
Message-Id: <9qp9d.839$6q2.689@newssvr14.news.prodigy.com>
larry_wallet@yahoo.com wrote:
> I would then like to have each object in the list contain as a member
> a single text character. By stringing together an arbitrary number of
> these objects, this larger structure, which could be a class
> containing the linked list, could be used as a "string" class,
> literally a string of characters, not bound by the limitations of
> simple common strings.
I'm curious to know what the limitations of common strings are and how
your string class overcomes them.
--Ala
------------------------------
Date: Fri, 08 Oct 2004 05:21:25 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: linked list for string class
Message-Id: <x7655leqgq.fsf@mail.sysarch.com>
>>>>> "AQ" == Ala Qumsieh <notvalid@email.com> writes:
AQ> larry_wallet@yahoo.com wrote:
>> I would then like to have each object in the list contain as a member
>> a single text character. By stringing together an arbitrary number of
>> these objects, this larger structure, which could be a class
>> containing the linked list, could be used as a "string" class,
>> literally a string of characters, not bound by the limitations of
>> simple common strings.
AQ> I'm curious to know what the limitations of common strings are and
AQ> how your string class overcomes them.
they are just classier!
<and i ask the same question>
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 07 Oct 2004 21:19:11 -0500
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: Loop through scalar?
Message-Id: <Xns957BE31C83106sdn.comcast@216.196.97.136>
Abigail <abigail@abigail.nl> wrote in
news:slrncljpj4.hv.abigail@alexandra.abigail.nl:
> Unlike others in this thread, I wouldn't use split, but m//g:
>
> while ($var =~ /(.*\n)/g) {
Out of curiosity, why?
--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
------------------------------
Date: 7 Oct 2004 17:47:19 -0700
From: bulk88@hotmail.com (buildmorelines)
Subject: need some visual clarity/implimentation LWP help
Message-Id: <ee659c69.0410071647.6d2f10b7@posting.google.com>
I would like to know how to merge the cookies line into creation of
request variable/object?. The code works fine, but for visual clarity
it would be nice to merge the cookies line into some other line if
possible.(I love Perl because it still has a good old thing called
procedural programing, OO stuff is chinese to me).
my $ua = new LWP::UserAgent;
my $request = HTTP::Request->new('GET', $my_url);
$request->header('Cookie' => 'foo_likes_it=hi');
my $response = $ua->request($request);
print $response->content;
Also, less importantly (remember TMTOWTDI), did I do the right thing
by adding a static cookies header to the HTTP request? or should the
professional way be through the cookie_jar of LWP::UserAgent, and then
to HTTP::Cookies, or play with HTTP::Headers?
The cookie is always static, and never needs to be changed. There is
no need to "save" or "capture" any cookies from the server.
------------------------------
Date: 7 Oct 2004 21:44:29 -0700
From: kaushalgoa@yahoo.co.in (Kaushal Bhandu)
Subject: Re: perl regexp for iptables
Message-Id: <b25b43f3.0410072044.1ce38f72@posting.google.com>
Actually I want a script that can modify and generate the
iptables.save script that has default rules for iptables in it . I
want a script that can generate new rules , add to the iptables.save
file and restart the services if necessary . So I have to write system
API and userAPI that can handle this .
I am very much used to the regular expressions . But when u have a
look at the iptables.save file anyone can guess the irregularity in
variables and rules pattern . So I need to have a lot of elseifs in my
script . What I am not getting is whether you can put all the
variables like -m , -A , --dport etc. in an array and use them as
$array[4] ( like this ) in an regular expression .
Or is there any other way we can do this ??
Kaushal
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<ck3cho$4gn$1@mamenchi.zrz.TU-Berlin.DE>...
> Kaushal Bhandu <kaushalgoa@yahoo.co.in> wrote in comp.lang.perl.misc:
> > I want to use the perl regular Expression for iptables script and
> > arrange the data in tables .
>
> Which iptables script? Iptables itself appears to be a binary. Their
> web site lists dozens of scripts that go with it.
>
> > I have no idea how to insert the
> > variables like -m , -A etc . which stand for Appending a new rule to
> > the script .
>
> "-m" and "-A" aren't variables, they are text strings. Where do you
> want to insert them?
>
> > Then I want to write a custom application ( GUI interface
> > ) that can modify or add rules easily .
> >
> > eg of a line in the script
> > -A OUTPUT -p tcp --dport 21 -j ACCEPT FTP
> >
> > I compared my approach with the webmin mechanism , there seems to be
> > large difference the way it handles files ..
> >
> > Can anybody help me with this ??
>
> Not before you describe in some more detail what you want to accomplish.
>
> Is the "script" something your program will generate and modify? Or
> will your program generate output that is going to be used to run a
> given script?
>
> Note that people here will have first-hand knowledge of iptables
> only by coincidence. We can help with Perl programs, but not with
> how to build an iptables script for a certain purpose.
>
> Anno
------------------------------
Date: 7 Oct 2004 23:26:00 -0700
From: notruf_1102003@yahoo.de (Gerhard M)
Subject: Re: query to join two tables in 2 different Oracle schema
Message-Id: <942c5b0d.0410072226.7b7a80a2@posting.google.com>
harryooopotter@hotmail.co_ (Harry) wrote in message news:<1ng9d.38959$N%.26178@edtnps84>...
> schema B: a table "report" with study_id, etc.
>
> select s.study_id, r.report_type
> from study s connected to schema A using userid xxx password yyy,
> report r connected to schema B using userid ppp password qqq
> where s.study_id = r.study_id
>
as study_id is within table report try
SQL> select study_id, report_type from report;
gerhard
... but that's not a post for comp.lang.perl.misc, so please check
groups before posting ...
------------------------------
Date: 7 Oct 2004 22:59:55 -0700
From: notruf_1102003@yahoo.de (Gerhard M)
Subject: Re: Running vi from Perl
Message-Id: <942c5b0d.0410072159.6404b4f2@posting.google.com>
rickKasten@gmail.com (DrStrangepork) wrote in message news:<a4cf4e10.0410071249.68034a9@posting.google.com>...
> rickKasten@gmail.com (DrStrangepork) wrote in message news:<a4cf4e10.0410061323.789d8f39@posting.google.com>...
> > I wrote a script from which I sometimes launch a system command. In
> > Win32, this system call launches Notepad, but in Linux it must launch
> > vi. It does, but I get a warning "Vim: Warning: Output is not to a
> > terminal". vi is there, because the commands work (like :q exits and
> > I am returned to my perl script), but like the warning says, no
> > output. How can I resolve this problem?
>
> I figured it out. The proper code is
>
> system "p4 protect";
>
> Thanks!
i don't now "p4" and "which p4" will return "no p4 in ....".
I've tried
perl <<!
system ("vi test.txt");
print "DONE\n";
!
on various systems without any problems:
uname -srv
1) HP-UX B.11.23 U
2) OSF1 V5.1 1885
3) Linux 2.4.20-4GB #1 Mon Apr 26 16:44:14 UTC 2004
what is your p4, which platform is used, and provide some more code
(code of "p4" and code of your script)
if your p4 is a script, using "vi $@ &", the message is OK cause vi
(vim) needs to be connected to STDIN.
gerhard
------------------------------
Date: Fri, 8 Oct 2004 00:45:38 -0400
From: "asdfasd" <af4bh@iglou.com>
Subject: To Tad: Great perl class, and question
Message-Id: <41661b40$1_1@news.iglou.com>
Thanks Tad. I enjoy your training class a lot during your visit here in
Lexington, Kentucky.
Just a quick question: We have some old perl scripts that don't really
conform to the new coding standard, mainly with the problem of variable
scoping. You mentioned in the class that the "my" keyword should be used in
the new perl; otherwise, the variables will be default to global.
Is there a tool, or some scripts, that will be able to parse the source
files and "suggest" the existance of local/global variable conflicts? We
are trying to upgrade our perl runtime (Windows) to 5.8x, but facing the
possibility of having an extensive code review. Any help will be greatly
appreciated.
Thanks in advance.
David
hodavid@lexmark.com
------------------------------
Date: 07 Oct 2004 22:11:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Top 10 list algorithm
Message-Id: <slrncmbfno.34g.abigail@alexandra.abigail.nl>
Fatted (fatted@gmail.com) wrote on MMMMLV September MCMXCIII in
<URL:news:2skn1fF1msrubU1@uni-berlin.de>:
!! Is there a better (faster) way of implementing my top_sort function?
!! (Creating a top 10 list of the highest numbers from a large set).
!! Or did I get lucky? :)
#!/usr/bin/perl
use strict;
use warnings;
no warnings qw /syntax/;
my @heap = map {int rand 1_000_000} 1 .. 100_000;
sub heapify;
sub heapify {
my $index = shift;
my ($c1, $c2) = (2 * $index + 1, 2 * $index + 2);
my $max = $index;
$max = $c1 if $c1 < @heap && $heap [$c1] > $heap [$max];
$max = $c2 if $c2 < @heap && $heap [$c2] > $heap [$max];
return if $max == $index;
@heap [$index, $max] = @heap [$max, $index];
heapify $max;
}
for (my $i = int (@heap / 2); $i >= 0; $i --) {heapify $i}
if (@heap) {
for (1 .. 10) {
print $heap [0], "\n";
my $tmp = pop @heap;
last unless @heap;
$heap [0] = $tmp;
heapify 0;
}
}
__END__
999999
999996
999981
999974
999960
999942
999923
999923
999922
999904
--
$_ = "\x3C\x3C\x45\x4F\x54\n" and s/<<EOT/<<EOT/ee and print;
"Just another Perl Hacker"
EOT
------------------------------
Date: 7 Oct 2004 17:28:24 -0700
From: bulk88@hotmail.com (buildmorelines)
Subject: Re: Win2k CMD shell variables and backtick execution
Message-Id: <ee659c69.0410071628.7af27c91@posting.google.com>
Thanks, I never knew perl had a special variable to get into shell variables.
l v <lv@aol.com> wrote in message news:<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 7222
***************************************