[25361] in Perl-Users-Digest
Perl-Users Digest, Issue: 7606 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 5 09:05:50 2005
Date: Wed, 5 Jan 2005 06:05:34 -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 Wed, 5 Jan 2005 Volume: 10 Number: 7606
Today's topics:
clp.moderated (was Re: ssl login to ebay) <tadmc@augustmail.com>
Re: cross-platform shell scripts <phaylon@dunkelheit.at>
Re: cross-platform shell scripts <nun@example.com>
Re: cross-platform shell scripts <claudio_greco@yahoo.com>
Re: cross-platform shell scripts <tadmc@augustmail.com>
Re: Curses and getch problem -- stdin, initscr and newt <bik.mido@tiscalinet.it>
Re: Curses and getch problem -- stdin, initscr and newt <bik.mido@tiscalinet.it>
Re: Dummy regex question <1usa@llenroc.ude.invalid>
Re: Dummy regex question <jurgenex@hotmail.com>
Re: Dummy regex question <sbryce@scottbryce.com>
Re: Dummy regex question <tadmc@augustmail.com>
Execute another perl script from my perl script <mikael.petterson@ericsson.se>
Re: Execute another perl script from my perl script <shawn.corey@sympatico.ca>
Re: Execute another perl script from my perl script <shawn.corey@sympatico.ca>
Re: Execute another perl script from my perl script <mritty@gmail.com>
Re: FAQ 1.4: What are perl4 and perl5? <tintin@invalid.invalid>
Re: FAQ 1.4: What are perl4 and perl5? <matternc@comcast.net>
Re: FAQ 1.4: What are perl4 and perl5? <tadmc@augustmail.com>
Re: FAQ 4.30: How do I capitalize all the words on one kerb@kerb.eu.org
Re: FAQ 4.30: How do I capitalize all the words on one <josef.moellers@fujitsu-siemens.com>
Re: FAQ 4.30: How do I capitalize all the words on one <mritty@gmail.com>
Re: file rename help (Anno Siegel)
Re: file rename help <tadmc@augustmail.com>
Re: Looking at a character <zen13097@zen.co.uk>
Re: Newbie question: "Get substring of line" <jl_post@hotmail.com>
Re: NEWBIE: Perl CGI script that redirects to another w <tintin@invalid.invalid>
Re: NEWBIE: Perl CGI script that redirects to another w <tadmc@augustmail.com>
Re: Searching perl script which calls web page and forw <no@mail.com>
Similair command like 'ls' in perl <mikael.petterson@ericsson.se>
Re: Similair command like 'ls' in perl <phaylon@dunkelheit.at>
Re: Similair command like 'ls' in perl <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Similair command like 'ls' in perl <josef.moellers@fujitsu-siemens.com>
Re: Similair command like 'ls' in perl <mritty@gmail.com>
Re: Similair command like 'ls' in perl <xx087@freenet.carleton.ca>
Re: Similair command like 'ls' in perl <mikael.petterson@ericsson.se>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 4 Jan 2005 22:16:31 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: clp.moderated (was Re: ssl login to ebay)
Message-Id: <slrnctmqgv.4ck.tadmc@magna.augustmail.com>
Peter Dietrich <peter.c.dietrich@freenet.de> wrote:
> Note: I have also posted this on comp.lang.perl.moderated, but the message
> has not appeared there for two days now.
Did you receive the registration email? You should have
gotten one that looks like this:
http://www.plover.com/clpm/how-to-register
Did you follow the instructions for registering?
Did you get an email rejecting your post?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 05 Jan 2005 12:47:54 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: cross-platform shell scripts
Message-Id: <pan.2005.01.05.11.47.54.489883@dunkelheit.at>
Jürgen Exner wrote:
> How does explorer.exe interface between the inner workings of the OS and
> the outside world?
Through security holes?
scnr,
Robert
--
http://www.dunkelheit.at/
thou shallst fear...
------------------------------
Date: Wed, 05 Jan 2005 13:00:25 +0100
From: Mitja <nun@example.com>
Subject: Re: cross-platform shell scripts
Message-Id: <opsj4oyzyedob4us@localhost>
On Wed, 05 Jan 2005 00:18:13 GMT, Jürgen Exner:
> Mitja wrote:
>> On Tue, 04 Jan 2005 16:07:46 GMT, Jürgen Exner:
>>> Claudio wrote:
>>>> I would like to use it for creating cross-platform shell scripts
>>>> (Windows and Unix ).
>>> Well, do you know for certain that your Windows users installed a
>>> shell (e.g. tsch, bash, or whatever) on their boxes?
>> Windows user _do_ have a shell installed. It's called explorer.exe.
> You may want to check your references.
> Explorer.exe is a web browser (with some added functionality). I
> certainly wouldn't consider it a "shell".
I beleive that would be iexplore.exe, not explorer.exe. In Win 2k/NT, you
can check the task manager.
> Actually, which script language to you use to for a shell script, that
> runs on explorer.exe?
> Maybe you meant cmd.exe or command.com?
Hmmm.... I must admit I'm a bit at a loss here. cmd and command - yes, I'd
say they are shells alright. I still think, however, that explorer.exe
(_not_ MSIE) is a shell as well, and the more frequently used one at that.
Consider - the so called "shell extensions" in windows usually provide
extra functionality/option in the start menu / right-click menus / etc.
This further supports the idea of explorer.exe as a shell.
You did get me a bit confused with that question :)
I just did a search on google for "explorer.exe" windows shell, and the
results sum up my arguments pretty well.
>> From dictionary.com:
>> The command interpreter used to pass
>> commands to an operating system; so called because it is the
>> part of the operating system that interfaces with the outside
>> world.
> How does explorer.exe interface between the inner workings of the OS and
> the outside world?
With its GUI. But we were not talking about the same explorer here (see
above).
--
Mitja
------------------------------
Date: 5 Jan 2005 05:10:31 -0800
From: "Claudio" <claudio_greco@yahoo.com>
Subject: Re: cross-platform shell scripts
Message-Id: <1104930631.360326.107130@z14g2000cwz.googlegroups.com>
Bob Walton wrote:
> Claudio wrote:
>
> Maybe you want Perl Power Tools: http://ppt.perl.org
>
That's definitely what I wanted.
Thanks!
------------------------------
Date: Tue, 4 Jan 2005 20:30:30 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: cross-platform shell scripts
Message-Id: <slrnctmka6.4ck.tadmc@magna.augustmail.com>
Jürgen Exner <jurgenex@hotmail.com> wrote:
> How does explorer.exe interface between the inner workings of the OS and the
> outside world?
It is FM. (the "M" is for magic)
And that's all you need to know, so don't ask again. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 05 Jan 2005 13:33:33 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Curses and getch problem -- stdin, initscr and newterm issues?
Message-Id: <v45mt05sldn7vg2kknuj576t6jlbn3eeru@4ax.com>
On Tue, 04 Jan 2005 22:51:18 +0100, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
>>1 while <>
^
^
Aren't you missing something here?!?
>If you do not supply args on the cmdline, this will wait for STDIN
>forever unless you close it (^D - or ^Z), and Curses or not, the code
>that follows will never be reached.
Incidentally the code you shown doesn't even compile. Mind you: it's
always recommended to paste rather than retype.
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: Wed, 05 Jan 2005 13:33:35 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Curses and getch problem -- stdin, initscr and newterm issues?
Message-Id: <t75mt0t3cuo713i2o9d6crfau3bt985ud0@4ax.com>
On 4 Jan 2005 13:03:58 -0800, spambox@volja.net wrote:
>> open(TTYI, "/dev/tty") or die $!;
>> $scr = newterm(undef, STDOUT, TTYI) or die $!;
^^^^^^^^^
^^^^^^^^^
>> set_term($scr);
>
>Okay, at last, here's the solution:
>
>
>close(STDIN);
>^^^^^^^^^^^^^
I've not tested my guess, but it seems quite reasonable that "here's
the solution" is a side effect of closing STDIN for when <> tries to
access it, it will silently fail, period.
Thinking of it better, it's not too hard to test it:
$ perl -e 'close STDIN; 1 while <>; die "Done"'
Done at -e line 1.
I wouldn't call this "a solution". I'd call it a clumsy workaround.
>open(TTYI, "</dev/tty");
Do a favour to yourself and die here too! (No pun intended...)
Do a favour to yourself and use lexical fhs.
Do a favour to yourself and use the three args form of open().
>I only have to figure out what to pass as the first argument to newterm
>or whatever it is that garbles up the screen after usage.
I can't help you on this. But I can _help_ you recommending you not to
spread clumsy code.
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: 5 Jan 2005 05:05:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Dummy regex question
Message-Id: <Xns95D5E0D4C1Easu1cornelledu@132.236.56.8>
"JayEs" <not@home.net> wrote in
news:V6KCd.7186$F67.783@newssvr12.news.prodigy.com:
>> The function you want is called split.
>
> I tried:
>
> @array = split(/ /,$test);
>
> But when I test with:
>
> print $array[0];
>
> ...it contains the entire $test and $array[1] is undef. I checked the
> part of html that I am parsing
Well, you never mentioned that you were parsing HTML.
> and it looks like "$ 12.25" in the
> HTML fragment, but when I do:
>
> print $test;
>
> ...it shows me: "$ 12.25"
Where?
D:\Home>perl -e "print q{$ 12.25}"
$ 12.25
> Is there something special I need to do to handle the ?
Yes. You need to convert it to a space.
> HELP!!
You can help others help you by correctly and fully describing the
parameters of your questions. It looks like you would also benefit from
getting an introductory Perl book and actually studying it.
Here is one way to do it. You might also find the HTML::Entities module
useful if there is chance other HTML entitites may appear in the input.
D:\Home>cat t.pl
use strict;
use warnings;
while(my $line = <DATA>) {
chomp $line;
next unless $line;
$line =~ s/ / /g;
my ($currency, $amount) = split /\s+/, $line;
print "Currency: $currency\tAmount: $amount\n";
}
__DATA__
$ 12.00
USD 187.54
CAD 1.20
??? 12.65
D:\Home>perl t.pl
Currency: $ Amount: 12.00
Currency: USD Amount: 187.54
Currency: CAD Amount: 1.20
Currency: ??? Amount: 12.65
Sinan.
------------------------------
Date: Wed, 05 Jan 2005 05:17:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Dummy regex question
Message-Id: <kLKCd.16636$Y57.5179@trnddc08>
JayEs wrote:
>> The function you want is called split.
>
> I tried:
>
> @array = split(/ /,$test);
>
> But when I test with:
>
> print $array[0];
>
> ...it contains the entire $test and $array[1] is undef. I checked the
> part of html that I am parsing and it looks like "$ 12.25" in
Well, if you want to split at the text ' ' then you should tell split()
to split at the text ' ' and not at a non-existing space character.
> the HTML fragment, but when I do:
>
> print $test;
>
> ...it shows me: "$ 12.25"
I can not reproduce this behaviour:
C:\tmp>type t.pl
use strict; use warnings;
my $foo ='$ 12.25';
print $foo;
C:\tmp>t.pl
$ 12.25
As you can see, my mini test program prints '$ 12.25'.
Could you please show us a minimal sample script that exhibits the behaviour
you described above?
> Is there something special I need to do to handle the ?
No, you just have to tell split the actually text at which you want to
split.
jue
------------------------------
Date: Wed, 05 Jan 2005 00:04:50 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Dummy regex question
Message-Id: <dLOdnXF48JcWDEbcRVn-2A@comcast.com>
JayEs wrote:
>>The function you want is called split.
>
>
> I tried:
>
> @array = split(/ /,$test);
>
> But when I test with:
>
> print $array[0];
>
> ...it contains the entire $test and $array[1] is undef. I checked the part
> of html that I am parsing and it looks like "$ 12.25" in the HTML
> fragment, but when I do:
What is in the HTML fragment is irrelevant. What is important is what is
in $test. Your original problem definition said that you wanted to split
on a space.
> print $test;
>
> ...it shows me: "$ 12.25"
It looks like a space to me.
> Is there something special I need to do to handle the ?
No, because $test does not contain the
The posting guidelines for this group suggest that you post a short but
complete program that demonstrates your problem. If you were to do that,
it would help us help you.
use strict;
use warnings;
my $test = '$ 12.25';
my @array = split / /, $test;
print "$array[0]\n$array[1]\n";
OUTPUT:
$
12.25
------------------------------
Date: Tue, 4 Jan 2005 19:42:27 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Dummy regex question
Message-Id: <slrnctmhg3.4ck.tadmc@magna.augustmail.com>
JayEs <not@home.net> wrote:
> How do I split these strings into 2, separating the currency code and the
> value?
You have a SAQ.
Q: how do I split a string
A: split()
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 05 Jan 2005 13:18:09 +0100
From: Petterson Mikael <mikael.petterson@ericsson.se>
Subject: Execute another perl script from my perl script
Message-Id: <crglm8$1al$1@newstree.wise.edt.ericsson.se>
Hi,
I have a perl script where I want to call another perl script.
The perl script I want to call is ( including files):
${arc_bin}/addproj -p $project -r $release -i $isit -V $view
I have tried eval() that I used in my shell script but it did not work.
Any hints?
//Mikael
------------------------------
Date: Wed, 05 Jan 2005 08:00:29 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Execute another perl script from my perl script
Message-Id: <iwRCd.38162$P%3.1445182@news20.bellglobal.com>
Petterson Mikael wrote:
> Hi,
>
> I have a perl script where I want to call another perl script.
> The perl script I want to call is ( including files):
>
> ${arc_bin}/addproj -p $project -r $release -i $isit -V $view
>
> I have tried eval() that I used in my shell script but it did not work.
>
> Any hints?
>
> //Mikael
perldoc -f system
perldoc -f exec
perldoc perlop (See `)
--- Shawn
------------------------------
Date: Wed, 05 Jan 2005 08:04:08 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Execute another perl script from my perl script
Message-Id: <JzRCd.38165$P%3.1445418@news20.bellglobal.com>
Shawn Corey wrote:
>
>
> Petterson Mikael wrote:
>
>> Hi,
>>
>> I have a perl script where I want to call another perl script.
>> The perl script I want to call is ( including files):
>>
>> ${arc_bin}/addproj -p $project -r $release -i $isit -V $view
>>
>> I have tried eval() that I used in my shell script but it did not work.
>>
>> Any hints?
>>
>> //Mikael
>
>
> perldoc -f system
> perldoc -f exec
> perldoc perlop (See `)
>
> --- Shawn
I forgot:
perldoc -f open (See |)
--- Shawn
------------------------------
Date: Wed, 05 Jan 2005 13:31:52 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Execute another perl script from my perl script
Message-Id: <c%RCd.10250$PY6.4942@trndny02>
"Petterson Mikael" <mikael.petterson@ericsson.se> wrote in message
news:crglm8$1al$1@newstree.wise.edt.ericsson.se...
> I have a perl script where I want to call another perl script.
> The perl script I want to call is ( including files):
>
> ${arc_bin}/addproj -p $project -r $release -i $isit -V $view
>
> I have tried eval() that I used in my shell script but it did not
work.
"did not work" is a poor error description. Please read the posting
guidelines that are posted to this group regularly.
> Any hints?
There are a number of ways of executing external commands. Among them
are:
system (read: perldoc -f system)
exec (read: perldoc -f exec)
backticks (read: perldoc perlop, search for 'qx')
pipes (read: perldoc -f open)
Which one you want to use depends on what kind of information you want
to retrieve from the command, and how you want to interact with the
command.
Paul Lalli
------------------------------
Date: Wed, 5 Jan 2005 19:26:52 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: FAQ 1.4: What are perl4 and perl5?
Message-Id: <341fi3F45b6rfU1@individual.net>
"brian d foy" <comdog@panix.com> wrote in message
news:040120051720352492%comdog@panix.com...
> In article <040120050606407285%comdog@panix.com>, brian d foy
> Actually, maybe we should morph into "What are perl4, perl5, and
> perl6?" :)
The are certainly enough questions as to what perl6 is (and when it is
available) to qualify as a FAQ.
------------------------------
Date: Wed, 05 Jan 2005 06:14:15 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: FAQ 1.4: What are perl4 and perl5?
Message-Id: <mrGdnWHllKSVUUbcRVn-1w@comcast.com>
Uri Guttman wrote:
>>>>>> "CM" == Chris Mattern <matternc@comcast.net> writes:
>
> CM> Uri Guttman wrote:
> >>>>>>> "AJF" == Alan J Flavell <flavell@ph.gla.ac.uk> writes:
> >>
> AJF> As I recall, both Digital Unix (or whatever it's called today) and
> AJF> Solaris make use of Perl 4 scripts in their maintenance procedures,
> AJF> and come with a version of Perl 4 installed for that reason. In
> >> fact, AJF> a Solaris user brought this up on the group recently, as I
> >> dimly AJF> recall.
> >>
> >> solaris 9 at least comes with 5.6.1. i don't think solaris ever came
> >> with perl4. it does have some perl scripts but not perl4 ones. very
> >> few modern unix flavors (i wouldn't call dec unix modern :) come with
> >> perl4.
> >>
> >> uri
> >>
> CM> Solaris is weird. 9 ships with 5.6.1...and 5.00503. However, it
> doesn't CM> seem to come with any flavor of Perl 4.
>
> yeah, i found them in /usr/perl5. but only 5.6.1 is linked from /usr/bin
> and in /usr/perl5. i wonder if there are scripts which have
> usr/perl5/5.00503/bin/perl5.00503 for a #! line?
>
> maybe they kept it in case some older scripts use it. in any case, i
> keep perl in /usr/local/bin myself so i never see solaris's perl.
>
Actually, you can link your perl to /usr/bin if you want. Solaris's
perl scripts all go the /usr/perl5 directory, so you won't break
them.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Tue, 4 Jan 2005 20:27:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: FAQ 1.4: What are perl4 and perl5?
Message-Id: <slrnctmk5c.4ck.tadmc@magna.augustmail.com>
Matt Garrish <matthew.garrish@sympatico.ca> wrote:
>
> "brian d foy" <comdog@panix.com> wrote in message
> news:040120050606407285%comdog@panix.com...
>> In article <Xns95D47575A0A9ebohlmanomsdevcom@130.133.1.4>, Eric Bohlman
>> <ebohlman@omsdev.com> wrote:
>>
>>> PerlFAQ Server <comdog@panix.com> wrote in
>>> news:crbts5$2bt$1@reader1.panix.com:
>>>
>>> > 1.4: What are perl4 and perl5?
>>
>>> Does this still belong in the FAQ as of 2005? The only reason I can
>>> think
>>> of is poorly-written books with "Perl 5" in the title (are any of them
>>> still in print?).
>>
>> it probably doesn't belong. I'll see about removing it.
>>
>
> Or how about replacing it with:
>
> How to spot Perl4 code
>
> a) You found it at www.scriptarchive.com/
>
> b) It has lots of funky &function(); calls
c) it uses chop() instead of chomp() to remove newlines
d) it uses local() (or nothing) instead of my()
e) it uses "require 'something.pl';" instead of "use something;"
f) it uses symbolic references rather than real references
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Jan 2005 04:53:38 -0800
From: kerb@kerb.eu.org
Subject: Re: FAQ 4.30: How do I capitalize all the words on one line?
Message-Id: <1104929618.196848.203770@c13g2000cwb.googlegroups.com>
$text =~ tr/a-a/A-Z/;
------------------------------
Date: Wed, 05 Jan 2005 14:23:40 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: FAQ 4.30: How do I capitalize all the words on one line?
Message-Id: <crgphh$9bk$1@nntp.fujitsu-siemens.com>
kerb@kerb.eu.org wrote:
> $text =3D~ tr/a-a/A-Z/;
>=20
Nope, this changes _all_ letters to their upper case version.
"To capitalize" means to change just the first of a series of=20
consecutive letters:
this sentence looks like this when capitalized
This Sentence Looks Like This When Capitalized
this sentence looks like this when uppercased
THIS SENTENCE LOOKS LIKE THIS WHEN UPPERCASED
See the difference, it's subtle, but if you look closely enough B-{)
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Wed, 05 Jan 2005 13:24:44 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: FAQ 4.30: How do I capitalize all the words on one line?
Message-Id: <wURCd.23357$152.3680@trndny01>
<kerb@kerb.eu.org> wrote in message
news:1104929618.196848.203770@c13g2000cwb.googlegroups.com...
> $text =~ tr/a-a/A-Z/;
This is wrong in a number of ways:
1) you meant a-z, not a-a
2) this capitalizes every letter, not every word
3) this does not handle 'international' characters.
The FAQ entry contains the correct answer.
Paul Lalli
------------------------------
Date: 5 Jan 2005 11:07:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: file rename help
Message-Id: <crghpm$ml0$1@mamenchi.zrz.TU-Berlin.DE>
Shawn <spedwards@x.qwest.net> wrote in comp.lang.perl.misc:
> > So in this case...
> >
> >> while ($cfile = <FILE_LIST>) {
> >
> > ...I'd use
> >
> > for (grep !/txt/, <f*>) {
> >
>
> I will give this a try. Just trying to find all files that start with a f
> and don't have a txt extention.
A ".txt" extension? Then it should be
for ( grep !/\.txt$/, <f*> ) {
Anno
------------------------------
Date: Tue, 4 Jan 2005 20:40:23 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: file rename help
Message-Id: <slrnctmksn.4ck.tadmc@magna.augustmail.com>
Shawn <spedwards@x.qwest.net> wrote:
>
>>
>> Oh yes - I can see where the "insufficient arguments" is coming from, and
>> it is indeed coming from mv. The string you are passing to system is
>> effectively
>>
>> /bin/mv f01234\n f01234\n.zero.txt"
>>
>> so that's three lines of shell script:
>>
>> /bin/mv f01234
>> f01234
>> .zero.txt
>>
>> Clearly wrong. If you had used chomp to clean up the filename then the
>> system( ) call would have worked without errors.
>>
>
> The output from the system call just wasn't something I had put into
> consideration.
That is fine, because the output from the system() call has not
been discussed anywhere in this thread that I remember.
It is certainly not related to the Nameless quote above
(please provide an attribution when you quote someone).
mv is likely to make _no_ output at all anyway...
> I obviously needed a better understanding of the system call for its usage.
I think you need a better understanding of what Nameless was trying
to point out above.
There was nothing wrong with your system() call. It is
the *argument* to system() that is messed up.
Backtrack to where you construct that messed up argument
and figure out what it takes to un-mess it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Jan 2005 07:39:30 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Looking at a character
Message-Id: <41db99b2$0$21319$db0fefd9@news.zen.co.uk>
On Tue, 04 Jan 2005 13:15:38 -0500, Sherm Pendley <spamtrap@dot-app.org> wrote:
>
> If you want an array with all of the characters as elements, split() the
> string with an empty delimiter:
>
> my $chars = split(//, $s);
^
ITYM:
my @chars = split(//, $s);
------------------------------
Date: 5 Jan 2005 05:54:27 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Newbie question: "Get substring of line"
Message-Id: <1104933267.285083.279430@z14g2000cwz.googlegroups.com>
> jl post@hotmail com <jl_post@hotmail.com> writes:
>> Some people don't like using the $' variable because
>> it comes at a performance cost. If this performance
>> cost boethers you, you can change that last line to:
Uri Guttman replied:
>
> and it is not commonly used as well. so why did you
> even bother to mention it?
Since you asked, I'll tell you:
Have you ever tried teaching Perl to someone who just didn't have a
good grasp of regular expressions? To someone who sort of understood
them, but couldn't get his mind around the fact that the regular
expression "[fee|fie|foe]" is identical to "[feio|]"? Or that, no
matter how manly times you tell him (and get him to agree) that "*"
means "match zero or more occurrances of", he still thinks it's wrong
that ".*" can successfully match an empty string?
I've dealt with people like this. And I've found that, in many
cases, instead of spending five or ten minutes explaining to them why
the use of $`, $&, and $' is a bad idea and get them to write through
hoops avoiding their use (hoops for them, not for me), it's just best
to teach them the simpler solution first and let them learn that. The
milliseconds of run time they waste from running their script with the
"poorer" solution more than makes up for the time lost writing their
code in a way that is not understood very well, finding/correcting bugs
that may result, and the additional time explaining how to "do it
right."
I personally think that the line:
$string = $' if "abc=xyz" =~ m/=/;
is easier to read and understand than the line:
$string = $1 if "abc=xyz" =~ m/=(.*)$/;
I have a feeling that you might disagree. Whatever the case, I've
found that, even when a beginnier Perl programmer understands each of
the symbols in the pattern-match "m/=(.*)$/", he can still have a
difficult time putting them all together to deduce the purpose of the
entire match. In those cases, I've found that it's good to start out
simple (like "m/=/") and then expand to a more complex explanation if
necessary.
As for the performance penalty of using $`, $&, and $', I believe
that it's not as bad as most people think. The performance penalty
does not have a behavior of N-SQUARED (measured in Big-O notation). I
tend to think (but I could be wrong) that it's more on the order of N,
which isn't really all that bad in the big scheme of things. You may
save millisends running your script if you remove all instances of $`,
$&, and $', but it's not going to remove any bottleneck that's taking
too much processor time. In fact, I'd be surprised if you saved over
ten seconds by running a script (with $`, $&, and $' removed)
repeatedly for one whole day straight. In fact, I'm not aware of
anyone who has ever removed $`, $&, and $' from his scripts to find
that the scripts ran noticeably faster. (And if there's evidence of
this to the contrary, I'd be interested in knowing about it.)
And I've wondered: just how much IS the performance penalty,
anyway? I decided to perform a Benchmark test:
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;
my $count = 1e7;
my $bad = q!$string = $' if "abc=xyz" =~ m/=/!;
my $good = q!$string = $1 if "abc=xyz" =~ m/=(.*)$/!;
timethese($count, {bad => $bad, good => $good})
__END__
The results surprised me. I got the following output:
> Benchmark: timing 10000000 iterations of bad, good...
> bad: 18 wallclock secs (16.42 usr + -0.03 sys = 16.39 CPU)
> @ 610090.90/s
> good: 22 wallclock secs (20.73 usr + 0.00 sys = 20.73 CPU)
> @ 482299.60/s
Apparently, the "bad" code (with $') ran faster than the "good" code!
This seems strange considering that use of $' is supposed to incur a
performance penalty, not an optimization. Thinking about this, I would
come to the conclusion that the penalty mainly happens on the regular
expressions that don't use $`, $&, or $' in that they use extra
processor time figuring out these variables when they don't need them.
In other words, if every single regular expression used $', there would
be no real performance penalty at all.
If I'm right with that reasoning, then that would actually make the
regular expression that uses $' the preferred choice for one-line Perl
scripts.
So it looks like there is a reason to learn $' after all. And even
if your script runs slightly slower as a result of using it, I doubt
you'll ever notice the difference.
> nor did you tell the OP where to learn about regexes or whatever.
It's often difficult to tell the tone of a response in a plain-text
message, but it seems like you're irritated at me for some reason, Uri.
I don't know whether you are irritated at me personally or at just my
post, but if I said something that offended you, then I apologize.
It's just that when I read a message like yours where first I'm
criticized for putting in too much information and then criticized for
not putting enough in, I get the impression that it's not my post you
are upset at, but at me personally.
When I post messages to UseNet, I usually post messages that I think
will be helpful to a user, depending on what level of experience I
think he's at. Obviously, if I think he's a beginner, the information
I post will probably not be helpful to an advanced programmer. Of
course, I could be wrong about what is helpful and what is not, but
that's the beauty of UseNet -- everyone is free to post what they want.
Again, Uri, I'm sorry if I offended you in this post or in an
earlier post.
-- Jean-Luc
------------------------------
Date: Wed, 5 Jan 2005 19:54:56 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: NEWBIE: Perl CGI script that redirects to another webpage
Message-Id: <341h6oF45qvglU1@individual.net>
"Tester" <SPAM FREE WORLD> wrote in message
news:41db2985$1@news1.homechoice.co.uk...
> Hi There,
>
> I think this is very simple. I need to write a PERL script that a form is
> submitted to it, one of the forms input parameters is a URL.
>
> Once the script has done some other processing, it redirects the users
> browser to the URL.
>
> E.g.
> Webpage is Form submission.
> User presses submit and it sends over form details including one (hidden)
> field called URL
> PERL script processes the form and then redirects browser to the URL field
>
> I hope that makes sense and I am sure that is easy to do but I am not sure
> how.
>
> Kind regards and thanks in advance.
#!/usr/bin/perl
use strict;
use CGI;
my $q = new CGI;
my $url=$q->param('url');
print $q->redirect($url);
------------------------------
Date: Tue, 4 Jan 2005 22:22:51 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: NEWBIE: Perl CGI script that redirects to another webpage
Message-Id: <slrnctmqsr.4ck.tadmc@magna.augustmail.com>
Tester <> wrote:
> Subject: NEWBIE: Perl CGI script that redirects to another webpage
Have you seen the Posting Guidelines that are posted here frequently?
> I think this is very simple.
Then you should look for it in the Perl FAQ *before* posting
to the Perl newsgroup!
> Once the script has done some other processing, it redirects the users
^^^^^^^^
> browser to the URL.
perldoc -q redirect
How do I redirect to another page?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 05 Jan 2005 07:22:05 GMT
From: BG <no@mail.com>
Subject: Re: Searching perl script which calls web page and forwards to me / displays with adjusted URLs
Message-Id: <pan.2005.01.05.07.15.06.120767@mail.com>
> I am searching now I perl script which I can install on the third party
> server and which acts as an intermediate broker between me and ebay.
I don't use perl. How about php? This was just posted else where and
is simple. http://eof.servehttp.com/alt255/inc/fetch.php
<form action="<?php print($_SERVER['PHP_SELF']);?> ">
<input type="text" size="50" name="page" value="">
<button value="submit">Submit</button>
</form>
<? if(isset($_GET['page']))
{@include ("http://" . $_GET['page']);} ?>
------------------------------
Date: Wed, 05 Jan 2005 13:54:44 +0100
From: Petterson Mikael <mikael.petterson@ericsson.se>
Subject: Similair command like 'ls' in perl
Message-Id: <crgnqr$2o0$1@newstree.wise.edt.ericsson.se>
Hi,
When I do 'ls' in a shell I get a whole bunch of information including a
timestamp. Is it possible to get the same information in perl. Why I
need this? I need to find out which directory ( in a directory) that was
created last.
BR
//Mikael
------------------------------
Date: Wed, 05 Jan 2005 14:07:44 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <pan.2005.01.05.13.07.44.76813@dunkelheit.at>
Petterson Mikael wrote:
> Is it possible to get the same information in perl.
Yes?
g,
Robert
--
http://www.dunkelheit.at/
...and in darkness bind them.
------------------------------
Date: Wed, 5 Jan 2005 14:13:35 +0100
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <Xns95D590B83ABEelhber1lidotechnet@62.89.127.66>
Petterson Mikael <mikael.petterson@ericsson.se> wrote:
> Hi,
>
> When I do 'ls' in a shell I get a whole bunch of information
> including a timestamp. Is it possible to get the same information
> in perl. Why I need this?
You don't, if all you need...
I need to find out which directory ( in
> a directory) that was created last.
...is that.
perldoc -f -X
--
Cheers,
Bernard
------------------------------
Date: Wed, 05 Jan 2005 14:25:02 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <crgpk2$9bk$2@nntp.fujitsu-siemens.com>
Petterson Mikael wrote:
> Hi,
>=20
> When I do 'ls' in a shell I get a whole bunch of information including =
a=20
> timestamp. Is it possible to get the same information in perl. Why I=20
> need this? I need to find out which directory ( in a directory) that wa=
s=20
> created last.
perldoc -f stat
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Wed, 05 Jan 2005 13:36:05 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <93SCd.10251$PY6.784@trndny02>
"Petterson Mikael" <mikael.petterson@ericsson.se> wrote in message
news:crgnqr$2o0$1@newstree.wise.edt.ericsson.se...
> Hi,
>
> When I do 'ls' in a shell I get a whole bunch of information including
a
> timestamp. Is it possible to get the same information in perl. Why I
> need this? I need to find out which directory ( in a directory) that
was
> created last.
This is what we call an "XY Problem". Fortunately, it's one that you
corrected in the same message. Basically, you want to know X, the
creation time of a certain directory. But you've already decided that
the best way to do this is Y - to obtain a directory listing ala `ls`.
So instead of asking us how to do X, you've asked us how to do Y.
To solve you're actual problem, X, checkout
perldoc -f -X
(in this case, the -X above is coincidental to the XY problem)
Paul Lalli
------------------------------
Date: 5 Jan 2005 13:35:36 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <slrnctnr99.es7.xx087@smeagol.ncf.ca>
At 2005-01-05 07:54AM, Petterson Mikael <mikael.petterson@ericsson.se> wrote:
> Hi,
>
> When I do 'ls' in a shell I get a whole bunch of information including a
> timestamp. Is it possible to get the same information in perl. Why I
> need this? I need to find out which directory ( in a directory) that was
> created last.
opendir my $d, $directory;
my @dirs = map {$_->[0]}
sort {$a->[1] <=> $b->[1]}
map {[$_, -M]}
grep {-d}
readdir $d;
closedir $d
# I assume by "created last" you mean newest
my $last = "$directory/$dirs[0]";
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Wed, 05 Jan 2005 14:47:09 +0100
From: Petterson Mikael <mikael.petterson@ericsson.se>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <crgqt2$4ae$1@newstree.wise.edt.ericsson.se>
Robert Sedlacek wrote:
> Petterson Mikael wrote:
>
>
>>Is it possible to get the same information in perl.
>
>
> Yes?
>
> g,
> Robert
>
Any hints?
//Mikael
------------------------------
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 7606
***************************************