[11889] in Perl-Users-Digest
Perl-Users Digest, Issue: 5489 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 26 18:17:00 1999
Date: Mon, 26 Apr 99 15:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 26 Apr 1999 Volume: 8 Number: 5489
Today's topics:
Re: "learning perl" does not seem to be written well (Tad McClellan)
Re: "learning perl" does not seem to be written well <upsetter@ziplink.net>
Re: "learning perl" does not seem to be written well (Tad McClellan)
Re: ActiveState PERL for Win32 -- How to. <jean_barry@my-dejanews.com>
autoincrement magic a..z <squid@panix.com>
Re: autoincrement magic a..z (Larry Rosler)
Re: autoincrement magic a..z <uri@sysarch.com>
Re: autoincrement magic a..z (Larry Rosler)
Count the number of files in a dir. <stevenabell@hotmail.com>
Counting files in a dir. <stevenabell@hotmail.com>
Re: Country of a visitor <selectthree@gsig-net.qc.ca>
Re: Delete line (Tad McClellan)
Eliminate elements from array with second array? lou@visca.com
Re: Eliminate elements from array with second array? (Larry Rosler)
Re: Eliminate elements from array with second array? (Andrew Allen)
Re: Extracting emails from array <upsetter@ziplink.net>
Re: Extracting emails from array (Randal L. Schwartz)
Re: How do i print something using perl? <upsetter@ziplink.net>
Re: How to access entire command line? (Tad McClellan)
Re: How to ftp in perl? (Alastair)
Re: Limit 10 matches to display on screen (Jere Julian - Personal Account)
Re: New to Perl (David Dadzie)
Re: New to Perl (Bob Trieger)
Re: newbie with a "howto" question <aqumsieh@matrox.com>
Perl Editors On Win32 <ian.taite@nospam.zen.co.uk>
Re: Perl Editors On Win32 (Alastair)
Q: regarding "[warn] {client} handler 'cgiwrapper' not <mr001@4acura.com>
Re: QUESTION:Perl Regular Expression Subtring Matches? <c_graham@hinge.mistral.co.uk>
Re: Simple Question (John Moreno)
Re: Statistics for comp.lang.perl.misc <jbc@shell2.la.best.com>
Re: The docs as talking books (was Re: newbie with a "h <droby@copyright.com>
Re: Very long strings (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 Apr 1999 10:09:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <53s1g7.bc3.ln@magna.metronet.com>
John Callender (jbc@shell2.la.best.com) wrote:
: Randal L. Schwartz <merlyn@stonehenge.com> wrote:
: > Page 13 is still in chapter 1. You are reading through the brief
: > runthrough of everything that appears in later chapters. It will be
: > explained much more thoroughly later.
: For what it's worth, I had exactly the same reaction to the Llama's
: quick run-through when I first picked up the (then magenta) book
: several years ago. I was in pretty much the same boat as this thread's
: original author, with no formal programming/Unix background to speak
: of, and I started to get panicky about halfway through the first
: chapter.
I found that to be the case when I tried to start off a couple
of Perl classes with my own "trimmed down" stroll.
The students didn't like it, so I (nearly) stopped doing it.
I now use this stroll, just to get them the shebang line and
chmod and other details of actually getting some Perl program
to run:
--------------
#!/usr/bin/perl -w
use strict;
print 'type something: ';
my $line = <STDIN>;
chomp $line;
print "you entered '$line'\n";
--------------
and
--------------
#!/usr/bin/perl -w
use strict;
while (<>) { # read a line while there are lines left in the file
print;
}
--------------
That's it!
Those two programs let me present many Perl features that
I discuss only perfunctorily at this point.
I give the "ten minute" treatment to:
-w
use strict and my()
single vs. double quotes
variable interpolation
backslash escapes
input
output
"funny characters" and scalar variables
second one is 'cat' written in Perl (for motivation)
: Or maybe the two of us were just incredible dweebs, and no one else has
: ever had that problem. *shrug*
I have first hand knowledge of about 20 others with a similar
take on it.
The "stroll" is great for Programmers who are "learning just
another language". (which, I think, is the target audience for
the Llama)
My students tend to not be at that level yet. Some learned C
"last month", others have never programmed at all.
For them, I speed through the stroll and try to quickly get
to Chapter 2.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Apr 1999 20:53:56 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <En4V2.495$7j4.221299@news.shore.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
: As others have pointed out, _Learning_Perl_ (the LLama) is really only
: tuned for those programmers (not non-programmers aka Prisoners of Bill)
: already conversant with the small-script culture that gave birth to
: Perl; that is, the Unix sysadmin cum toolsmith culture.
How odd, then, that I was able to learn Perl from this book with virtually
no knowledge of the "Unix sysadmin cum toolsmith culture." I didn't start
to appreciate the usefulness of Unix in general (pipes, redirection, shell
scripts, that sort of thing) until I'd been programming Perl for a couple
of years. Surely I'm not the only one.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Mon, 26 Apr 1999 12:20:39 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <no32g7.jr3.ln@magna.metronet.com>
ralawrence@my-dejanews.com wrote:
: In article <0lk1g7.t73.ln@magna.metronet.com>,
: tadmc@metronet.com (Tad McClellan) wrote:
: > ralawrence@my-dejanews.com wrote:
: >
: > : Here is how I see it (and I *am* a newbie so bear with me).
: >
: > But you don't have it quite right.
: Thanks to all of you that pointed out how hopelessly wrong I was.
: I've now made a total tit out of myself infront of 16 million odd people.
It may be painful, but public humiliation pretty much ensures
that you don't forget the "lesson".
I've humiliated myself dozens of times here, and have thus
internalized dozens of newly learned things :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Apr 1999 20:53:39 GMT
From: jeanb <jean_barry@my-dejanews.com>
Subject: Re: ActiveState PERL for Win32 -- How to.
Message-Id: <7g2joh$41i$1@nnrp1.dejanews.com>
Thanks.
You're just so right.
The "open a -dos- box and call *perl + script* from within it" is just what
misses in the docs; anyways, I never saw it.
It works just fine...like you say : just as expected.
Thanks.
--
Jean Barry
Jean_barry@my-dejanews.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 26 Apr 1999 16:40:43 -0400
From: Yeoh Yiu <squid@panix.com>
Subject: autoincrement magic a..z
Message-Id: <oxgg15n2jzp.fsf@panix.com>
the block : for ($i="a"; $i lt "z"; $i++) {print "$i";}
prints out
abcdefghijklmnopqrstuvwxy
as expected.
But changing the lt to le does not print out
abcdefghijklmnopqrstuvwxyz
I need an extra test to stop the z from cycling up to aa ab ac ... .
So I have done what I wanted, but I am puzzled as to why
for ($i="a"; $i le "z"; $i++) {print "$i";}
doesn't print ouit a to z.
squid.
full code below:
#!/usr/local/bin/perl5 -w
for ($i="a"; $i lt "z"; $i++) {print "$i";}
print "\n";
for ($j="a"; $j le "z"; $j++) {
if( $j eq "aa") {print "\n";exit;} else{
print "$j";}}
output:
abcdefghijklmnopqrstuvwxy
abcdefghijklmnopqrstuvwxyz
------------------------------
Date: Mon, 26 Apr 1999 14:08:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: autoincrement magic a..z
Message-Id: <MPG.118e759779ad0e0d989945@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <oxgg15n2jzp.fsf@panix.com> on 26 Apr 1999 16:40:43 -0400,
Yeoh Yiu <squid@panix.com> says...
> the block : for ($i="a"; $i lt "z"; $i++) {print "$i";}
> prints out
>
> abcdefghijklmnopqrstuvwxy
>
> as expected.
>
> But changing the lt to le does not print out
>
> abcdefghijklmnopqrstuvwxyz
>
> I need an extra test to stop the z from cycling up to aa ab ac ... .
>
> So I have done what I wanted, but I am puzzled as to why
>
> for ($i="a"; $i le "z"; $i++) {print "$i";}
>
> doesn't print ouit a to z.
'aa' is less-than-or-equal-to 'z'.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 26 Apr 1999 17:16:04 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: autoincrement magic a..z
Message-Id: <x7so9n9j6z.fsf@home.sysarch.com>
>>>>> "YY" == Yeoh Yiu <squid@panix.com> writes:
YY> the block : for ($i="a"; $i lt "z"; $i++) {print "$i";}
YY> abcdefghijklmnopqrstuvwxy
correct.
YY> But changing the lt to le does not print out
YY> abcdefghijklmnopqrstuvwxyz
YY> for ($i="a"; $i le "z"; $i++) {print "$i";}
YY> doesn't print ouit a to z.
because when $i eq z, it passes the test, prints and then increments to
'aa'. and that fails the le test since 'aa' IS le 'z'. perl does a
lexigraphical compare and length doesn't come into the picture.
as you have seen it works fine with $i ne 'aa'.
you could also check the length with
length( $i ) == 1 && $i le 'z'
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Mon, 26 Apr 1999 14:52:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: autoincrement magic a..z
Message-Id: <MPG.118e7fe68607613b989946@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x7so9n9j6z.fsf@home.sysarch.com> on 26 Apr 1999 17:16:04 -
0400, Uri Guttman <uri@sysarch.com> says...
...
> you could also check the length with
>
> length( $i ) == 1 && $i le 'z'
And you can just as well skip the second part of the test, which is
redundantly superfluous.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 26 Apr 1999 21:00:36 GMT
From: "stevenabell" <stevenabell@hotmail.com>
Subject: Count the number of files in a dir.
Message-Id: <Ut4V2.30$vY2.775@c01read01.service.talkway.com>
Dear All,
If the answers to some of my questions are in the FAQs then I'm
afraid that you'll have to forgive me. I did look through them a
week or so ago, but since then I don't seem to have been able to get
back in, and a few rather urgent problems have come up since.
So, any help on any of the following would be *terrific* :)
1. Is it possible in Perl to count the number of files in a directory
and assign that to a variable? Because the files are situated in a
UNIX directory, I did think of doing something like:
`ls testdir/*.* > list`
and then count the number of lines in "list", but surely there's
another way? (I don't even know the correct syntax for the above to
work)
2. I have a number of files which I must perform a UNIX function on.
Well, in fact it's a Shell application, called "stoplist". What I need
to do is apply "stoplist" to each document and then place the treated
documents in another directory. The original number of files to be
treated will always vary, but will always be grouped together in the
same directory. So for example, if we have the following files:
/mydir/file1
/mydir/file2
/mydir/file3
I want to apply "stoplist" to them so that I have:
/stopped/file1.stop
/stopped/file2.stop
/stopped/file3.stop
3. Because each file is going to have a different directory structure,
ie - we could have the following:
/stopped/chair/table/file1.stop
/stopped/chair/file2.stop
/stopped/chair/table/file3.stop
what I need to do is rename each file according to the length of its
path, so that they are renamed as follows:
file2.stop -> doc1
file1.stop -> doc2
file3.stop -> doc3
where "doc1", "doc2" etc are written to another unique directory.
4. I have a Perl script set up to reply to a form (written in HTML),
but when the script generates the results of the form back to the
user, it continues to search for something else, thereby forcing the
user to click on "Stop" in the browser (followed by "Transfer
Interrupted"). Simplified, the script looks something like:
if {$var eq "red"}
&return;
exit;
else {$var eq "blue"}
exit;
sub return
{
print "<HTML>......"
}
Even though I have the "exit"s in the script, when it generates the
results it still doesn't bomb out.
Like I said, if the answers to any of these are in the FAQs, then
please accept my apologies. Any replies / solutions would make it a
lot easier to sleep at night!
Regards,
Steve Bell
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).
------------------------------
Date: Mon, 26 Apr 1999 20:53:39 GMT
From: "stevenabell" <stevenabell@hotmail.com>
Subject: Counting files in a dir.
Message-Id: <nn4V2.19$LK2.49@c01read02-admin>
Dear All,
If the answers to some of my questions are in the FAQs then I'm
afraid that you'll have to forgive me. I did look through them a
week or so ago, but since then I don't seem to have been able to get
back in, and a few rather urgent problems have come up since.
So, any help on any of the following would be *terrific* :)
1. Is it possible in Perl to count the number of files in a directory
and assign that to a variable? Because the files are situated in a
UNIX directory, I did think of doing something like:
`ls testdir/*.* > list`
and then count the number of lines in "list", but surely there's
another way? (I don't even know the correct syntax for the above to
work)
2. I have a number of files which I must perform a UNIX function on.
Well, in fact it's a Shell application, called "stoplist". What I need
to do is apply "stoplist" to each document and then place the treated
documents in another directory. The original number of files to be
treated will always vary, but will always be grouped together in the
same directory. So for example, if we have the following files:
/mydir/file1
/mydir/file2
/mydir/file3
I want to apply "stoplist" to them so that I have:
/stopped/file1.stop
/stopped/file2.stop
/stopped/file3.stop
3. Because each file is going to have a different directory structure,
ie - we could have the following:
/stopped/chair/table/file1.stop
/stopped/chair/file2.stop
/stopped/chair/table/file3.stop
what I need to do is rename each file according to the length of its
path, so that they are renamed as follows:
file2.stop -> doc1
file1.stop -> doc2
file3.stop -> doc3
where "doc1", "doc2" etc are written to another unique directory.
4. I have a Perl script set up to reply to a form (written in HTML),
but when the script generates the results of the form back to the
user, it continues to search for something else, thereby forcing the
user to click on "Stop" in the browser (followed by "Transfer
Interrupted"). Simplified, the script looks something like:
if {$var eq "red"}
&return;
exit;
else {$var eq "blue"}
exit;
sub return
{
print "<HTML>......"
}
Even though I have the "exit"s in the script, when it generates the
results it still doesn't bomb out.
Like I said, if the answers to any of these are in the FAQs, then
please accept my apologies. Any replies / solutions would make it a
lot easier to sleep at night!
Regards,
Steve Bell
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).
------------------------------
Date: Mon, 26 Apr 1999 17:01:28 -0400
From: Pierre-Luc <selectthree@gsig-net.qc.ca>
Subject: Re: Country of a visitor
Message-Id: <3724D426.5B80B47C@gsig-net.qc.ca>
OK. I wasn't enough clear, I guest.
I want to program a counter for my site and for the others that will
want it and I want to be able to track the country of origin of a
visitor (like Nedstat counter (http://usa.nedstat.net), for example,
does).
Does somebody know the code to
first, detect the server's adress (like when I post on MSNBC, it is
written that I come from modem37.gsig-net.qc.ca, as example)
and then, to isolate the extension (note that I'm able to do it, so I
mostly want help for #1.)
Thank you very much,
Pierre-Luc Soucy
Note : for those who think it's useless to have the country of a
visitor, I think that it is usefull to see if your site interests people
away from your own country, and in wich proportion.
Tony Curtis wrote:
> Re: Country of a visitor, selectthree
> <selectthree@gsig-net.qc.ca> said:
>
> selectthree> Does anyone know the code to determine
> selectthree> the origin country of a visitor (or
> selectthree> only it's code, like .com, .ca, .uk,
> selectthree> .fr...)?
>
> selectthree> Please help me.
>
> Try asking for their passport.
>
> Your question is far too vague and doesn't have
> anything to do with perl does it?
>
> tony
------------------------------
Date: Mon, 26 Apr 1999 11:29:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Delete line
Message-Id: <tn02g7.vm3.ln@magna.metronet.com>
cryptoman@my-dejanews.com wrote:
: which function should I use to delete a line in a
: text's file.
Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Apr 1999 21:13:49 GMT
From: lou@visca.com
Subject: Eliminate elements from array with second array?
Message-Id: <7g2ku8$57l$1@nnrp1.dejanews.com>
My question concerns finding the best way to eliminate elements from an array
if they contain any of a list of strings from another array. Here's the
relevant part of what I have:
----------
my $dir = '/www/maindir';
my @skips = qw(cgi-bin messages oldstuff ppd test archives);
my @found = ();
finddepth sub {push @found, $File::Find::name if /(html?|cgi)$/ && !-d}, $dir;
my %found = ();
for (@found) {
$found{$_} = '1'
}
for my $key (keys %found) {
for (@skips) {
delete $found{$key} if $key =~ m!/$_/!
}
}
@found = (keys %found);
---------
Is there a better way to do this?
Thank you very much.
--
Lou Hevly
http://www.visca.com
lou@visca.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 26 Apr 1999 14:58:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Eliminate elements from array with second array?
Message-Id: <MPG.118e81513320d912989947@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7g2ku8$57l$1@nnrp1.dejanews.com> on Mon, 26 Apr 1999
21:13:49 GMT, lou@visca.com <lou@visca.com> says...
> My question concerns finding the best way to eliminate elements from an array
> if they contain any of a list of strings from another array. Here's the
> relevant part of what I have:
<SNIP> of quadratic algorithm.
> Is there a better way to do this?
perlfaq4: "How do I compute the difference of two arrays? ..."
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 26 Apr 1999 21:50:27 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Eliminate elements from array with second array?
Message-Id: <7g2n33$b6k$1@fcnews.fc.hp.com>
lou@visca.com wrote:
: My question concerns finding the best way to eliminate elements from an array
: if they contain any of a list of strings from another array. Here's the
: relevant part of what I have:
: ----------
: my $dir = '/www/maindir';
: my @skips = qw(cgi-bin messages oldstuff ppd test archives);
: my @found = ();
: finddepth sub {push @found, $File::Find::name if /(html?|cgi)$/ && !-d}, $dir;
then you can do:
my $re=join("|",@skips);
@found=grep(!m{/($re)/}o,@found);
(note: you'll want to quotemeta the elements of @skips if there may be
regexp characters in it)
or even more simply:
@found=grep(!/(cgi-bin|messages|oldstuff|ppd|test|archives)/,@found);
and get rid of @skips (if it's truly a "constant").
Andrew
------------------------------
Date: Mon, 26 Apr 1999 20:43:35 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Extracting emails from array
Message-Id: <Xd4V2.492$7j4.221299@news.shore.net>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
: fred&barney@stonehenge.com
: which is a perfectly legal address (try it... it's an autoresponder).
: Or my friend Eli, with an address of something like <*@qz.to>, also
: legal.
Although in real life, of course, excluding email addresses like the two
above is unlikely to exclude that many users.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 26 Apr 1999 13:58:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Extracting emails from array
Message-Id: <m1so9np08p.fsf@halfdome.holdit.com>
>>>>> "Scratchie" == Scratchie <upsetter@ziplink.net> writes:
Scratchie> Although in real life, of course, excluding email addresses like the two
Scratchie> above is unlikely to exclude that many users.
Do you dare exclude the CTO of a company that hasn't got a "nice clean
c-symbol@foo.bar.com" email address wanting to buy a bunch of your
stuff, but his email address is "pager:fred"@bob.big.com? Why do
people always go back to the "but it wouldn't exclude THAT MANY
people" argument?
<sigh>
Just do it right. Remember that to the left of the "@" can be
ANYTHING and you won't go wrong. Stop being so narrow minded.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 26 Apr 1999 20:47:33 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: How do i print something using perl?
Message-Id: <Fh4V2.494$7j4.221299@news.shore.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
: Ilya, please go soak your head. Why do we have to listen to
: your ranting about why OS/2 is a Gift from God? I am tired
: of it. You still don't get it, and never will, and won't shut up.
I hope I'm not the only one who sees the irony in this message.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Mon, 26 Apr 1999 12:23:54 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to access entire command line?
Message-Id: <qu32g7.jr3.ln@magna.metronet.com>
georgee1631@my-dejanews.com wrote:
: Inside a perl script is there a system variable or something that I can use to
: access the entire command line that invoked the script.
^^^^^^
^^^^^^
Nope.
Redirections are handled by the shell before perl is even
invoked, so perl (of course) cannot show the redirection
part of the command line.
"command line arguments" _are_ accessable from within your
perl program though.
An appropriate word search in the standard Perl docs that
came with your perl will reveal all...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Apr 1999 21:56:07 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: How to ftp in perl?
Message-Id: <slrn7i9rpj.5d.alastair@calliope.demon.co.uk>
mr_potato_head@my-dejanews.com <mr_potato_head@my-dejanews.com> wrote:
>Hi, I need to ftp a file on a daily basis from one unix server to a
>novell server and I would like to do this ftp in perl. Does anyone have a
>short hack to show me how to do this??? Thanks in advance...
Look on CPAN (http://www.cpan.org). The 'Net::FTP' module might be of interest.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: 26 Apr 1999 21:17:33 GMT
From: julianje@mercury.interpath.com (Jere Julian - Personal Account)
Subject: Re: Limit 10 matches to display on screen
Message-Id: <7g2l5d$mf4$1@gaddy.interpath.net>
gtan (00224166@bigred.unl.edu) wrote:
: I am using win32:odbc and i am having trouble to display the next 10
: results that matches the query. I use the following code so that only 10
: results will display on screen each time
By no means pretty but here's a snippet of what I have done a long time back.
I am sorry that this is bad coding example mixing straight printing and useing
CGI.pm in the same code but it shows getting used to cgi.pm.
If you need more help please email me at mailto:jjulian@laddnet.com
-Jere Julian
use CGI qw(:standard);
sub list_DB_stuff {
$beginno = param('scroll') ? param('scroll') : 0;
$reccount = 0;
$start = $beginno+1;
$hicount = $start+9;
while (($db->FetchRow()) && ($printcount < 10)) {
$reccount++;
next if $reccount < $beginno;
%line = $db->DataHash; # Set Row of data into a Hash Array.
###############
# Print Stuff Here.
###############
}
&next_prev_buttons;
}
sub next_prev_buttons {
print "\n\n";
print "<table width=100%>\n<tr>";
if ($beginno > 0) {
$scrbk = $beginno - 10;
print
start_form(-action=>"$LUISDIR/InitialDisplay.pl"),
"<input type=hidden name=orderby value=$orderby>",
"<input type=hidden name=scroll value=$scrbk>",
"<td>",
"<input type=submit value=\"Previous 10\">",
"</td>",
end_form;
}
if (($beginno + 10) < $totalreccount ) {
$scrfw = $beginno + 10;
print
start_form(-action=>"$LUISDIR/InitialDisplay.pl"),
"<input type=hidden name=orderby value=$orderby>",
"<input type=hidden name=scroll value=$scrfw>",
"<td align=right>",
"<input type=submit value=\"Next 10\">",
"</td>",
end_form;
}
print "</tr>\n</table>";
}
------------------------------
Date: Mon, 26 Apr 1999 20:30:29 GMT
From: ded@globalnet.co.uk (David Dadzie)
Subject: Re: New to Perl
Message-Id: <3724c4bf.297131077@news.globalnet.co.uk>
Hello,
Could somebody please help me or point me in the right direction. I
have a comma delimited file with 12 lines & 18 fields per line.
"UK", 1.23, 2.75, 2.50, ......, 6.56
(The spaces are just for clarity)
I read the file into an array:
@transform = <MYFILE>;
I can access each line with:
$Temp = @transform[0];
but I can't get to the individual fields eg: "UK" or 1.23, etc.
I'm sure this is a 'no-brainer', however, I'm stumped.
Thanks in advance,
David Dadzie.
------------------------------
Date: Mon, 26 Apr 1999 21:39:15 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: New to Perl
Message-Id: <7g2lto$8sr$1@holly.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
ded@globalnet.co.uk (David Dadzie) wrote:
>Hello,
>
>Could somebody please help me or point me in the right direction. I
>have a comma delimited file with 12 lines & 18 fields per line.
>
>"UK", 1.23, 2.75, 2.50, ......, 6.56
>(The spaces are just for clarity)
>
>I read the file into an array:
>
> @transform = <MYFILE>;
>
>I can access each line with:
>
> $Temp = @transform[0];
>
>but I can't get to the individual fields eg: "UK" or 1.23, etc.
>
>I'm sure this is a 'no-brainer', however, I'm stumped.
You want to use the split function in a foreach or while loop.
while (<MYFILE>) {
@transform = split ",";
do something with the elements of @transform
}
Check out the docs on while, foreach and split.
------------------------------
Date: Mon, 26 Apr 1999 16:30:09 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: newbie with a "howto" question
Message-Id: <x3yeml7cege.fsf@tigre.matrox.com>
chrisb@hgu.mrc.ac.uk (Chris Boyd) writes:
> To get a uniq(1) effect in a one-liner you can do (warily modifying
> perlfaq4):
>
> tcsh% /bin/echo '1\n1\n2\n1' |\
> perl -e '@in=<>;print grep($_ ne $prev && ($prev=$_), @in);'
> 1
> 2
> 1
>
> No doubt there is a more optimal solution (NDTIAMOS).
How about:
% /bin/echo '1\n1\n2\n1' |\
perl -ne 'print unless $_ eq $prev; $prev = $_'
Ala
------------------------------
Date: Mon, 26 Apr 1999 21:41:12 +0100
From: "Ian Taite" <ian.taite@nospam.zen.co.uk>
Subject: Perl Editors On Win32
Message-Id: <Qc4V2.20256$Hh5.2084@news-reader.bt.net>
Anyone know of a free full screen editor running under Windows NT
that's Perl aware? i.e. colour codes the program source
Ian.
------------------------------
Date: Mon, 26 Apr 1999 21:48:28 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Perl Editors On Win32
Message-Id: <slrn7i9rb8.5d.alastair@calliope.demon.co.uk>
Ian Taite <ian.taite@nospam.zen.co.uk> wrote:
>Anyone know of a free full screen editor running under Windows NT
>that's Perl aware? i.e. colour codes the program source
Dejanews keeps track on a myriad of editors.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Mon, 26 Apr 1999 13:23:45 -0700
From: "Louis B." <mr001@4acura.com>
Subject: Q: regarding "[warn] {client} handler 'cgiwrapper' not found for {script}"
Message-Id: <7g2hvl$hq1@sjx-ixn6.ix.netcom.com>
I have several different scripts running on a hosted server. Been running
them without problems until one day (April 19) I started getting the message
"[warn] {client} handler 'cgiwrapper' not found for {script}" in my error
log. Called my host hoping to resolve this but they pretty much just
brushed it off saying that it's only a warning and not to worry about it.
When/if we fix it, we fix it.
Well that's not good enough for me. I frequently look to the file size of
my error log to tell me whether or not there's a problem then download the
log and examine it. Now with all these warnings I don't know if there's an
actual problem or just this damn warning, so anytime I want to check I have
to download and scan the log.
The only thing I could get out of my host is that they upgraded to Perl
5.04.3 sometime last week. They won't concede to when, but I bet it was on
the night of the 18th/19th. They also said that it may be a bandwidth
problem that may be starting to read saturation. The bandwidth issue
doesn't seem to be it since prior to the 19th, on days that I got as much or
more traffic than after the 19th, I didn't get the warning whereas on days
after I did. As a matter of fact, on *every* day after the 19th I got the
warning, whereas prior to I never got it! I also got out of them [webhost]
that I'm only using 2% of the servers bandwidth, so that's ruled out.
The only thing I can think of is that it has to do with the upgrade. Anyone
have any ideas, solutions or can confirm that it has to do with the new
version?
TIA and sorry for the running on about it.
-louis
------------------------------
Date: Mon, 26 Apr 1999 22:24:50 +0000
From: Craig Graham <c_graham@hinge.mistral.co.uk>
Subject: Re: QUESTION:Perl Regular Expression Subtring Matches? Strange Behaviour...
Message-Id: <3724E7B2.C5567F41@hinge.mistral.co.uk>
David Cassell wrote:
> Yes. And it does. And the parens only capture three characters at
> a time. But parens around the whole pattern would capture the whole
> schmeer.
Yup. Putting ((a.b)+) gives:
$_=aibajbccc
/((a.b)+)/
result:
$&=aibajb, $1=aibajb, $2=ajb
which still leaves the fact that the first substring match
where (a.b) matches aib passes through to the last match $&,
but fails to appear anywhere as a substring.
> > It should if you're contracted by a company which produces standalone
> > Web Browser set-top boxes that wants JavaScript support adding
> > to their in-house written browser ;)
>
> Ohhhhh. Well, you have my deepest sympathies, if that's any
> consolation.
> :-)
It's ok, pays the bills. Not as much fun as when I used to write
Playstation games, and not as cool as when I used to design Spacecraft
electronics, but much better payed than either of them.
> > *** Added Note: Netscape/JavaScript's regexp handler is taken directly
> > from Perl anyway.....
>
> Hmm. I didn't know that. How does that work?
Dunno. I haven't looked at Netscapes source (so we can claim clean
room on the JavaScript interpreter), I'm just going from the JavaScript
specs (1.4) which say (quote):
"Perl is the programming language from which JavaScript modeled its
regular expressions."
And all expressions I've tried as tests came back with the same results
in Netscape and Perl (which started me on this thread about substring
matches in the first place).
> David
Craig.
------------------------------
Date: Mon, 26 Apr 1999 17:12:01 -0400
From: planb@newsreaders.com (John Moreno)
Subject: Re: Simple Question
Message-Id: <1dqvosn.w3tg6v1gi9wzqN@roxboro0-0051.dyn.interpath.net>
Jason Simms <ffchopin@worldnet.att.net> wrote:
> Shashank Tripathi <mkshanx@ust.hk> wrote in message
> news:7g0ngo$620@ustsu10.ust.hk...
> > Is there a way to scour through every file in a specified directory on my
> > computer thru perl?
>
> Sure... Use the File::Find module that comes standard with Perl. Read the
> docs - it's really quite simple. You basically pass it the name of a
> directory(ies), and the name of a subroutine to execute for each file it
> comes across. Simple and powerful.
How about doing the same thing on a remote computer?
--
John Moreno
------------------------------
Date: 26 Apr 1999 21:06:56 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <3724d570$0$229@nntp1.ba.best.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> : 25 Top 10 newbie errors?
> I'm so very happy that I kill on the muffyword "newbie"
> in the subject line. Perhaps it's time to repost my
> killfile to help others avoid the crap as well.
Helping someone as important to Perl as yourself to avoid crap is
certainly a good thing, and I'm happy to have contributed to that cause
by choosing that subject line. I think it was reasonably descriptive
(unlike most subjects containing that word), and that based on your
history you might have contributed to the thread had you seen it, but
the loss of your input must be balanced against the substantial benefit
that you (and we) receive by virtue of your killing such stuff unseen.
At the same time, I'm forced to wonder a couple of things.
The first thing I'm forced to wonder is, assuming I chose a different
subject line, would you have given an opinion on the question that came
up of whether people new to both Perl and programming should be advised
to always "use strict". At least one person argued that this was
inflicting needless complexity on people already struggling with plenty
of the necessary sort. I would have loved to hear your take on it.
The second thing I have to wonder is, is it a good thing or a bad thing
for the larger Perl culture that someone of your stature posts
responses like this, in which articles by (or, in this case, merely
about) newbies are equated with crap. They may well *be* crap, most of
them, and I'm certainly not questioning your right to flag them as
such, or to muse out loud about the timeliness of helping others to do
likewise.
I suppose I'm not sure what I'm questioning, except that I identify
with these newbies, and have a hard time processing it when I see you,
in particular, whom I admire greatly for the part you've played in
opening so many newbie eyes to the joys of Perl, reflexively putting us
down.
It's not really *you*, so much, that I'm worried about; your net
contribution to the newbie cause is always going to be a positive one,
no matter how much of this stuff you engage in. It's more the people
who try to imitate you, without necessarily having the balancing effect
of whatever kinder impulse it is that leads you to devote so much of
your time and talent to documenting things for others' benefit.
In thinking about this I was reminded of the Austen passage in which
Emma tells Miss Bates she may have difficulty in limiting herself to
saying only three very dull things, and Knightley gets upset at her. I
wouldn't presume to lecture you the way he lectured her, but that's
basically how it made me feel.
"Were she a woman of fortune, I would leave every harmless absurdity to
take its chance, I would not quarrel with you for any liberties of
manner. Were she your equal in situation-- but, Emma, consider how far
this is from being the case. She is poor; she has sunk from the
comforts she was born to; and, if she live to old age, must probably
sink more. Her situation should secure your compassion. It was badly
done, indeed! You, whom she had known from an infant, whom she had seen
grow up from a period when her notice was an honour, to have you now,
in thoughtless spirits, and the pride of the moment, laugh at her,
humble her--and before her niece, too--and before others, many of whom
(certainly some,) would be entirely guided by your treatment of her.
--This is not pleasant to you, Emma--and it is very far from pleasant
to me; but I must, I will,--I will tell you truths while I can;
satisfied with proving myself your friend by very faithful counsel, and
trusting that you will some time or other do me greater justice than
you can do now."
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Mon, 26 Apr 1999 20:04:29 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: The docs as talking books (was Re: newbie with a "howto" question)
Message-Id: <7g2gs9$1e8$1@nnrp1.dejanews.com>
In article <7fs3qa$1ig$1@gellyfish.btinternet.com>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> To this end I have started work on the module Pod::Speech which will render
> the otherwise excellent but until now and in this respect severely limited
> Perl documenatation as the spoken word. Initially the interface will be
> limited in comparison to say perldoc but Doris is going to do some work
> on integrating the functionality of PSI::ESP and it is hoped that the
> version to be included in the Perl 7 distribution will allow even the most
> profoundly idle to find the answers they need - in concert with development
> in the area of code generation we could find ourselves with a language
> where no-one will be required to know how to program or type a line of code.
>
Which generation language are we reaching for here? I've lost count. ;-)
> One area where some feedback would be useful is as to who's voice should be
> used - Mrs Gellyfish is dead set on that of Sir Anthony Hopkins but I think
> that might be national bias on her part. Suggestions ?
>
Since we're already dependent upone PSI::ESP, why not use it to determine the
interface at run-time? Surely Doris could code something that would detect
the user's gender, sexual orientation, education level, income category,
etc., and just generate an approximately appropriate voice.
And then in version 8, it's on to the MTV docs.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 26 Apr 1999 10:52:15 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Very long strings
Message-Id: <viu1g7.bc3.ln@magna.metronet.com>
Max Vilin (max.vilen@home.se) wrote:
: How would I go about to extract large text strings from a database and
: presenting them without having to trucate them?
print routine_that_gives_lots_of_text();
In other words, the same way that you present small text strings.
Maybe you wanted to ask some other question?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5489
**************************************