[13463] in Perl-Users-Digest
Perl-Users Digest, Issue: 873 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 22 02:07:26 1999
Date: Tue, 21 Sep 1999 23:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937980310-v9-i873@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 21 Sep 1999 Volume: 9 Number: 873
Today's topics:
Re: Ad hominem (was Re: perl related question now!) <uri@sysarch.com>
Re: Ad hominem (was Re: perl related question now!) <elaine@chaos.wustl.edu>
Re: Ad hominem (was Re: perl related question now!) <uri@sysarch.com>
Re: adduser/rmuser/passwd over socket? (Martien Verbruggen)
Re: Array length <kmonte@columbus.rr.com>
Re: Interesting behavior of IO::Handle - bug? <uri@sysarch.com>
Re: newbie question...well kindof <WiseGuy_73NOeqSPAM@go.com>
Re: newbie question...well kindof (Martien Verbruggen)
Re: newbie question...well kindof <uri@sysarch.com>
Newbie question <uriel443nospam@mindspring.com>
Re: Newbie question <kmonte@columbus.rr.com>
Re: Newbie question (Martien Verbruggen)
Re: Newbie question <uri@sysarch.com>
problem with the UNIX sum checksum command and unpack (Fergus McMenemie)
Regex and my whos_john_galt@my-deja.com
Re: Regex and my (Martien Verbruggen)
Re: sort depth <dana@oz.net>
Re: sort depth <dana@oz.net>
Re: sort depth <WiseGuy_73NOcdSPAM@go.com>
Re: sort depth <elaine@chaos.wustl.edu>
Re: sort depth <uri@sysarch.com>
Re: stripping newlines out of a string (Larry Rosler)
Re: Which are the best books for learning Perl for use <uri@sysarch.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Sep 1999 00:43:46 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Ad hominem (was Re: perl related question now!)
Message-Id: <x7so475zel.fsf@home.sysarch.com>
>>>>> "E-A" == Elaine -HFB- Ashton <elaine@chaos.wustl.edu> writes:
E-A> FE
E-A> / \
E-A> OC CO
E-A> | | = ?
E-A> OC CO
E-A> \ /
E-A> FE
ferrous wheel?
i remember it like this:
FE
|
C
/ \
FE-C C-FE
| |
FE-C C-FE
\ /
C
|
FE
i have seen one like that and another with the answer 'paradox'. it was
a benzene ring with 2 MD groups in the para locations.
this is the only bit of chemistry humor i remember from too many years
ago.
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 22 Sep 1999 00:55:07 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Ad hominem (was Re: perl related question now!)
Message-Id: <37E860AD.846521C3@chaos.wustl.edu>
Uri Guttman wrote:
> E-A> FE
> E-A> / \
> E-A> OC CO
> E-A> | | = ?
> E-A> OC CO
> E-A> \ /
> E-A> FE
> ferrous wheel?
Nope. COfFEe Ring. Ba dum. :)
>
> i have seen one like that and another with the answer 'paradox'. it was
> a benzene ring with 2 MD groups in the para locations.
Hmm. Don't think I remember that one.
> this is the only bit of chemistry humor i remember from too many years
> ago.
It's age and all those days of acetone, benzene and aromatics in the lab.
We should come up with something corny for Perl....I may have to look up
the structure for nacre or mother of pearl or maybe something completely
caustic :)
e.
------------------------------
Date: 22 Sep 1999 01:44:28 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Ad hominem (was Re: perl related question now!)
Message-Id: <x7aeqf5wlf.fsf@home.sysarch.com>
>>>>> "E-A" == Elaine -HFB- Ashton <elaine@chaos.wustl.edu> writes:
E-A> Uri Guttman wrote:
E-A> FE
E-A> / \
E-A> OC CO
E-A> | | = ?
E-A> OC CO
E-A> \ /
E-A> FE
>> ferrous wheel?
E-A> Nope. COfFEe Ring. Ba dum. :)
>>
>> i have seen one like that and another with the answer 'paradox'. it was
>> a benzene ring with 2 MD groups in the para locations.
E-A> Hmm. Don't think I remember that one.
and i just recalled the variant, orthodox. i don't remember the
positions on the ring the MD's had to be to get those names.
>> this is the only bit of chemistry humor i remember from too many years
>> ago.
E-A> It's age and all those days of acetone, benzene and aromatics in
E-A> the lab.
i thought you were still breathing them! :-)
E-A> We should come up with something corny for Perl....I may have to
E-A> look up the structure for nacre or mother of pearl or maybe
E-A> something completely caustic :)
not too many chem types here (except you).
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 22 Sep 1999 05:54:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: adduser/rmuser/passwd over socket?
Message-Id: <ha_F3.21$is3.895@nsw.nnrp.telstra.net>
In article <rugjip9klg725@corp.supernews.com>,
"Song Kim" <song@isot.com> writes:
> I have a FreeBSD boxes, one running WWW and the other running SENDMAIL. I
> want to be able to adduser/rmuser/passwd from a NT box. Is the perl socket
> the right choice? Are there a port already available?
This is hardly a perl question.
I would not even consider doing this. Never. However, if you're
trapped by Billware, I would probably use some ssh implementation to
do this. Anything that does not use encryption should _not_ be used.
But, again, this is offtopic. Once you have worked out what sort of
protocols and techniques and protection you want to use, and you have
looked at the modules that are available for perl, and you have tried
writing something, feel welcome to come back to ask more.
Martien
PS. There is no such thing as a perl socket. There is no such thing as
a port for adduser/rmuser/whateveruser commands. The latter are
command on your Unix box. sockets are used for TCP/IP connections
between two machines on a network. You really need to do a little more
general investigation in this area before you even start thinking
about implementing something like this, which needs a full awareness
of all the issues involved. Unless you don't mind compromising your
machine?
PPS. I am not trying to be mean. This is serious advice. Programming
is a skill. Not just anyone can just pick up an editor and be a
programmer. Just like not just anyone can pick up a shovel and be a
farmer.
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Wed, 22 Sep 1999 00:36:21 -0400
From: "kmonte" <kmonte@columbus.rr.com>
Subject: Re: Array length
Message-Id: <hZYF3.15976$mo.523341@viper>
Balasundar Raju <raju@bernie.mit.edu> wrote in message
news:37E84AB7.115E3143@bernie.mit.edu...
> Hi,
>
> Could someone let me know how to find the length of an array - i.e. the
> number
> of elements in an array? Thanks,
>
>
$Elements = @Array;
from perldata portion of the online manuals.
Note that the value of an actual array in a scalar context is the length
of the array; the following assigns the value 3 to $foo:
@foo = ('cc', '-E', $bar);
$foo = @foo; # $foo gets 3
kenn
Post news - read news. answering questions in Newsgroups is a public
service which I do for free - answering questions by email is consulting for
which I charge
money.
------------------------------
Date: 22 Sep 1999 01:30:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Interesting behavior of IO::Handle - bug?
Message-Id: <x7ln9z5x8t.fsf@home.sysarch.com>
>>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
KS> In article <7s984c$86e$1@nnrp1.deja.com>,
KS> Brundle <brundlefly76@hotmail.com> wrote:
>> But if I simply assign the value of the array index to another scalar,
>> it works as expected:
>>
>> $currentpipe=$PIPES[$CURRENTPIPE];
>> print $currentpipe $stuff;
KS> I saw something about it the other day -- either in Tom's FMTYEWTK
KS> about filehandles or in the FAQ. You should be able to say print
KS> {$PIPES[$CURRENTPIPE]} $stuff. I didn't understand why. Filehandles
KS> are brain-damaged.
if you are going to be the top poster here, at least learn to research
basic things yourself. the filehandle object after print and printf must
be a real filehandle or a single scalar variable with a file handle
value. as you pointed out blocks work too. anything else is interperted
as an expression to be printed which will probably cause a syntax error
since there is no , after it.
so i wonder who is brain damaging her now?
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Tue, 21 Sep 1999 22:39:23 +1700
From: Wise Guy <WiseGuy_73NOeqSPAM@go.com>
Subject: Re: newbie question...well kindof
Message-Id: <02e322c1.b4bb8214@usw-ex0106-042.remarq.com>
Juergen Pabel <juergenp@cc.gatech.edu> wrote:
> hi y'all,
> sorry if this is stupid but i have searched the web
> and looked at faq's
No question is a silly question ... we are all learning :-)
> i wanna check if a certain key exists in a hash...i
> have an array
> here's what i got:
> foreach $tmp (@requiredData)
> {
> #todo: this somehow won't work
> if(not exists $data->{$tmp})
Try :- if(not exists $data{$tmp}) ...
> {
> push(@missingFields, $tmp);
> }
> }
> i have found one weird side effect: if i print the
> hash like
> #inside a foreach loop
> print "$data{$tmp}...\n"
> then the output is weird, like the hash itself is
> corrupted but if i print it out using
> print "$data{'USER'}...\n"
> print "$data{'PASS'}...\n"
> then it shows me the expected values
Works for me ____ check out the value of $tmp before this
line.
> one more thing: i am using the NET::POP3 package and
> found that if i
> construct an object like
> $pop = NET::POP3->new('pop.somedomain');
> it connects, but if i do this
> $pop = NET::POP3->new("$tmp");
> or this
> $pop = NET::POP3->new($tmp);
> where $tmp = 'pop.somedomain' it won't work at
> all...
Did u try
$pop = NET::POP3->new('$tmp');
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Wed, 22 Sep 1999 05:47:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: newbie question...well kindof
Message-Id: <M3_F3.17$is3.895@nsw.nnrp.telstra.net>
In article <37E85357.1B91F983@cc.gatech.edu>,
Juergen Pabel <juergenp@cc.gatech.edu> writes:
> i wanna check if a certain key exists in a hash...i have an array
# perldoc -f exists
> (@requiredFields) which is filled with the contents of a txt file. i
> then test if all names (in @requiredData) exist in the hash (%data). all
According to your code, data is not a hash, but a reference to a hash.
> if(not exists $data->{$tmp})
See?
But then you go on to treat it like a hash anyway:
> print "$data{$tmp}...\n"
> print "$data{'USER'}...\n"
> print "$data{'PASS'}...\n"
> then it shows me the expected values
If that is true, then you should be looking at $data{$tmp} up there,
and not $data->{$tmp}.
You're not using strict, and the -w flag, are you?
> one more thing: i am using the NET::POP3 package and found that if i
New unrelated questions should really go in a new post.
> construct an object like
> $pop = NET::POP3->new('pop.somedomain');
> it connects, but if i do this
> $pop = NET::POP3->new("$tmp");
unnecessary quotes.
> or this
> $pop = NET::POP3->new($tmp);
> where $tmp = 'pop.somedomain' it won't work at all...this makes me
Are you 100% certain about this? Your string does not contain newlines
or spaces or anything else like that? Because it just works fine for
me.
> suspect that there is a difference between the type of a hardcoded (the
> '') version and the "" version...is this so?
Nope.
> i am using perl 5.005_03 on a redhat 6.0 linux box, the net::pop3 is
> version 2.16
Welllll... I have heard that certain things on RedHat's shipping
version of perl 5.005_03 are not entirely correct. I tried to compile
up a version myself at home, but it seems a lot of the dbm stuff on
this RedHat release is buggered as well.
It is possible you are seeing some of these problems, but I would
first and foremost investigate very precisely that those variables
contain what you think they contain.
> please reply to this group and my email since i am not always having
> access to a newsgroup server
Sorry. Just to the newsgroup.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: 22 Sep 1999 01:48:59 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: newbie question...well kindof
Message-Id: <x767135wdw.fsf@home.sysarch.com>
>>>>> "WG" == Wise Guy <WiseGuy_73NOeqSPAM@go.com> writes:
>> $pop = NET::POP3->new('pop.somedomain');
>> it connects, but if i do this
>> $pop = NET::POP3->new("$tmp");
>> or this
>> $pop = NET::POP3->new($tmp);
>> where $tmp = 'pop.somedomain' it won't work at
>> all...
WG> Did u try
WG> $pop = NET::POP3->new('$tmp');
where did you get that one from? is the mail server named $tmp? i don't
think that is a legal top level domain. please refrain from posting
guesses.
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 22 Sep 1999 00:11:25 -0400
From: Uriel <uriel443nospam@mindspring.com>
Subject: Newbie question
Message-Id: <AVboN2sybgKxKfMdPL1klD=6A8t+@4ax.com>
I have read over the FAQ, and couldn't find the answer to this,
although, it is possible I may have missed it... if so, I apologize
and ask somone to point me in the right direction.
Everything I've read about Perl tells me that it is a free format
language, but when I try to run a particular script, it is coming back
with several (10 to be exact) syntax errors. I have not been able to
find anything to help me with this, but I do have the output from the
error logs and the original script. I just do not have enough
knowledge to find what the actual problem is.
Any suggestions on where to find an answer would be greatly
appreciated.
Chris Rabig
------------------------------
Date: Wed, 22 Sep 1999 00:31:06 -0400
From: "kmonte" <kmonte@columbus.rr.com>
Subject: Re: Newbie question
Message-Id: <mUYF3.15973$mo.523086@viper>
Uriel <uriel443nospam@mindspring.com> wrote in message
news:AVboN2sybgKxKfMdPL1klD=6A8t+@4ax.com...
> I have read over the FAQ, and couldn't find the answer to this,
> although, it is possible I may have missed it... if so, I apologize
> and ask somone to point me in the right direction.
>
> Everything I've read about Perl tells me that it is a free format
> language, but when I try to run a particular script, it is coming back
> with several (10 to be exact) syntax errors. I have not been able to
> find anything to help me with this, but I do have the output from the
> error logs and the original script. I just do not have enough
> knowledge to find what the actual problem is.
>
>
> Any suggestions on where to find an answer would be greatly
> appreciated.
>
I would suggest posting you script and the error messages. (and even if it
is missing in your script, put -w at the end before posting)
Be advised, you will get a lot of flames and holier-than-thou responses from
the gurus who forget what it is like to be a newbie, but there are others
who will provide you with honest, useful content.
kenn
>
> Chris Rabig
------------------------------
Date: Wed, 22 Sep 1999 05:40:37 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question
Message-Id: <pZZF3.14$is3.895@nsw.nnrp.telstra.net>
In article <AVboN2sybgKxKfMdPL1klD=6A8t+@4ax.com>,
Uriel <uriel443nospam@mindspring.com> writes:
> I have read over the FAQ, and couldn't find the answer to this,
> although, it is possible I may have missed it... if so, I apologize
> and ask somone to point me in the right direction.
>
> Everything I've read about Perl tells me that it is a free format
> language, but when I try to run a particular script, it is coming back
It is free format, but it still has a rigid syntax. English is fairly
free format, i.e. you can change the order of many things, but nor
unlimitedly so. At some point it becomes nonsensical. Likewise with
perl. It's flexible, but within limits.
> with several (10 to be exact) syntax errors. I have not been able to
And those errors are? If you don't tell us, we can't point out what
they mean. And if you don't show us code, we can't tell you what's
wrong with it.
> find anything to help me with this, but I do have the output from the
> error logs and the original script. I just do not have enough
> knowledge to find what the actual problem is.
Good things to help you identify problems like these are: Always run
perl with the -w option. Always use strict. And if you have error
messages, you most likely want to have a look at the perldiag
documenation, which describes perl's error messages, and possible
causes.
The documentation that comes with perl should be on your hard disk.
Probably perldoc provides you access to it:
# perldoc perl
# perldoc perldiag
# perldoc perldoc
# perldoc -f open
# perldoc -q question_keyword
If you have the ActiveState distribution, you will most likely have
the HTML version of the documentation installed locally as well,
together with a link somewhere in your start menu to it.
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 22 Sep 1999 01:41:38 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Newbie question
Message-Id: <x7d7vb5wq5.fsf@home.sysarch.com>
>>>>> "k" == kmonte <kmonte@columbus.rr.com> writes:
>> Any suggestions on where to find an answer would be greatly
>> appreciated.
k> I would suggest posting you script and the error messages. (and
k> even if it is missing in your script, put -w at the end before
k> posting) Be advised, you will get a lot of flames and
k> holier-than-thou responses from the gurus who forget what it is
k> like to be a newbie, but there are others who will provide you with
k> honest, useful content.
note to all c.l.p.misc folks:
kmonte has taken on the mantle of answering all the newbie questions. we
have finally found someone to do this job for us. now we can go on
flaming each other and bragging about our perl golf scores.
so all newbies, just send email with your problems to
kmontecolumbus.rr.com and stop posting here.
thanx for your selfless volunterism!!
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 22 Sep 1999 07:03:02 +0100
From: fergus@twig.demon.co.uk (Fergus McMenemie)
Subject: problem with the UNIX sum checksum command and unpack
Message-Id: <1dyisxt.x9e4crytcy1yN@twig.demon.co.uk>
Hello all,
I use the UNIX sum command as the basis of an ad-hoc
scheme that keeps and eye on all SUID files. I liked
the fact that perl contains an equivalent in built
checksum command of its own (unpack). I could use both
methods to check a file, and the value would be the
same.
However I have now seen several cases where a file was
changed yet the System V sum value didn't change. In
most cases the files byte contents were the same it
was just the order of the lines that had changed.
All the other UNIX checksum commands do correctly
detect the change. However I would really would
like to be able to cross check any given value with
perl.
Has anybody got a perl algorithm equivalent to any of
the other UNIX checksum commands
Thanks in advance... fergus...
------------------------------
Date: Wed, 22 Sep 1999 05:05:30 GMT
From: whos_john_galt@my-deja.com
Subject: Regex and my
Message-Id: <7s9o2k$itg$1@nnrp1.deja.com>
Thanks in advance.
I am going to research this more intensely, but why does:
my $value="9876543210";
my ($pubw)=$value=~/(\d{6})/;
print $pubw;
produce: 987654
BUT...
$value="9876543210";
$pubw=$value=~/(\d{6})/;
print $pubw;
produce: 1
I use these statements in a foreach loop, does the my force immediate
evaluation and the 1 is generated by the loop?...but when I take the
value of $value away, pubw appears undefined as if the 1 represents
true..
Any assistance would be greatly appreciated.
Joey
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 05:34:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Regex and my
Message-Id: <4UZF3.13$is3.895@nsw.nnrp.telstra.net>
In article <7s9o2k$itg$1@nnrp1.deja.com>,
whos_john_galt@my-deja.com writes:
> Thanks in advance.
>
> I am going to research this more intensely, but why does:
>
> my $value="9876543210";
> my ($pubw)=$value=~/(\d{6})/;
> print $pubw;
>
> produce: 987654
>
> BUT...
>
> $value="9876543210";
> $pubw=$value=~/(\d{6})/;
> print $pubw;
>
> produce: 1
Because in the first case the match is executed in a list context, and
in the second case it is executed in a scalar context. In a list
context a match will return the subexpreassions matched. In scalar
context it will return true or false.
All the my's are just confusing the issue. You're looking at the
difference between
# perl -wl
$_ = 'foobar';
$match = m/(foo)/;
print $match;
($match) = m/(foo)/;
print $match;
__END__
1
foo
# perldoc perlop
/m\/PATTERN
Martien
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: 22 Sep 1999 04:05:20 GMT
From: Dana Booth <dana@oz.net>
Subject: Re: sort depth
Message-Id: <7s9ki0$qql$0@216.39.141.21>
Dana Booth <dana@oz.net> wrote:
DB: Can anyone tell me how deep the sort function goes?
I should have been more specific... This is Perl 5 on an OpenBSD box. I have
a textfile containing lines which I would like Perl to sort numerically.
Each line is a 23 digit number. And my question would be, to how many digits
is the sort function going to work?
--
------------------------
Dana Booth <dana@oz.net>
Tacoma, Wa., USA
---
pgp key is on keyserver pgpkeys.mit.edu:11371
------------------------------
Date: 22 Sep 1999 05:07:57 GMT
From: Dana Booth <dana@oz.net>
Subject: Re: sort depth
Message-Id: <7s9o7d$5ef$0@216.39.141.21>
Larry Rosler <lr@hpl.hp.com> wrote:
>> Can anyone tell me how deep the sort function goes?
LR: Please explain what you mean by this question. If you mean "how many
LR: fields can be compared?", the limit is your patience in writing the code
LR: to extract and compare the subkeys.
Yes, I receive a tab delimited textfile each morning containing seven
fields, and the first field is a 23 digit number. I only wanted to sort by
the first field. I've never been taught Perl, and have only used "sort"
previously while extracting data from dbm databases. I'd read each line as
one element into an array to be sorted, but I now realize that Perl sorted
beyond the numerical first field, through a couple of strings, and continued
on with other numerical fields further in.
--
------------------------
Dana Booth <dana@oz.net>
Tacoma, Wa., USA
---
pgp key is on keyserver pgpkeys.mit.edu:11371
------------------------------
Date: Tue, 21 Sep 1999 22:11:23 +1700
From: Wise Guy <WiseGuy_73NOcdSPAM@go.com>
Subject: Re: sort depth
Message-Id: <0a0bc822.ad6eab68@usw-ex0106-042.remarq.com>
Dana Booth <dana@oz.net> wrote:
> I should have been more specific... This is Perl 5 on
> an OpenBSD box. I have
> a textfile containing lines which I would like Perl to
> sort numerically.
> Each line is a 23 digit number. And my question would
> be, to how many digits
> is the sort function going to work?
> --
I tried this out ___ it gives me 13 digits after the
decimal point in the format x.xxxxxxxxxxxxxe+n ... where
e+n is 10 to the corresponding power. This is if u tell
Perl to treat the lines as numbers. If however, u enclose
these in quotes, u will get the desired output :-)
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Wed, 22 Sep 1999 01:20:26 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: sort depth
Message-Id: <37E8669A.7A63A2CD@chaos.wustl.edu>
Dana Booth wrote:
> Can anyone tell me how deep the sort function goes?
Sort sorts a list and
returns the list but sorted
"perldoc -f sort"
http://www.perl.com/
http://www.perl.com/reference/query.cgi?section=sort&x=10&y=9
http://www.perl.com/pub/v/documentation
http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html
......and many others
e.
------------------------------
Date: 22 Sep 1999 01:34:54 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: sort depth
Message-Id: <x7hfkn5x1d.fsf@home.sysarch.com>
>>>>> "DB" == Dana Booth <dana@oz.net> writes:
DB> Dana Booth <dana@oz.net> wrote:
DB> DB: Can anyone tell me how deep the sort function goes?
DB> I should have been more specific... This is Perl 5 on an OpenBSD
DB> box. I have a textfile containing lines which I would like Perl to
DB> sort numerically. Each line is a 23 digit number. And my question
DB> would be, to how many digits is the sort function going to work?
have you read the docs on sort? it doesn't do anything directly with
numbers. by default it sorts strings by using the internal equivilent of
cmp. so read the docs and faqs on sort to learn how to sort
numerically. but if those numbers are fixed length then you could sort
them as strings and it will work just fine.
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Tue, 21 Sep 1999 21:06:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: stripping newlines out of a string
Message-Id: <MPG.1251f58374d8fe56989fbb@nntp.hpl.hp.com>
In article <37E84332.87D6A2E9@thetoolhouse.com> on Tue, 21 Sep 1999
21:47:14 -0500, Quinn Coldiron <qcoldiro@thetoolhouse.com> says...
> I'm on RedHat 6.0 and am trying to write a Perl script that will strip
> the newline character out of a string. Any help?
'The' newline character???
To strip the first newline character from a string:
s/\n//
To strip all newline characters from a string:
tr/\n//d
To strip the terminating newline from a line:
chomp
(assuming you haven't changed the $/ variable, which you don't know
about yet)
Another way to do that:
s/\n$//
You choose!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Sep 1999 01:22:57 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Which are the best books for learning Perl for use in a Web environment?
Message-Id: <x7ogev5xla.fsf@home.sysarch.com>
>>>>> "t" == topalli <topalli@my-deja.com> writes:
t> Two books that have been very helpful for me have been
t> PERL and CGI for the world wide web a visual quickstart guide by peachpit
t> press. Very easy to read with many interesting examples. A very clear
t> book. www.cookwood.com/perl
i seem to have the job of reviewing perl books i see online. this one is
different. i haven't found any galring errors which is rare but it does
have some problems.
the chapter on line is about arrays and the examples do some cgi
stuff. they use
require "subparseform.lib";
&Parse_Form;
which is not even the cgi-lib standard. so who knows what that is.
but my main problem is how simplistic the writing is. the author show
specific examples of how to manipulate arrays and their data without
much in the way of sytax and semantic explanation. and the text always
tell the reader what to type as if they can't follow a simple piece of
code example:
To store the length of an array in a scalar variable:
1.Type $scalar, where scalar is the name of
the variable that will contain the length of
the array.
2.Type = (the equals sign).
3.Type @array, where array is the name of
the array whose length
you want.
that is very typical style and very condescending IMO. almost like it
was trying to teach logo to 2nd graders. enough with the 'type' this
stuff. and i wonder if its readers will be able to jump out of the small
box the examples create.
To add one or more items to the beginning of an array:
1.Type unshift(@array,, where @array is
the array to which you want to add items.
2.Type newelement,, where newelement is a
scalar constant, a scalar variable, or an
array whose elements you wish to add to
the beginning of the array mentioned in
step 1.
3.If desired, type nextnewelement,, where
nextnewelement is an additional scalar or
array that you wish to add to the array in
step 1.
4.Type ).
5.Type ; to finish the line. The array now
contains the new elements followed by its
original contents.
doesn't that look annoying! also what about unshifting an expression?
stating you can unshift constants, scalar variables and arrays is
misleading when they are all just list expressions.
here is another odd thing. the page previous to this teaches push. and
this page is on combining arrays. so why is the example code doing what
should be a push with an full assignment. but the 'type part' shows 3
separate arrays being used.
1.Type @combined, where combined is the
name of the array that will contain the
items from both arrays.
2.Type = (the equals sign).
3.Type (@first, @second) where first is
the name of the array whose elements
should be at the beginning of the array and
second is the name of the array whose
items should follow.
4.Type ; to finish the line. The @combined
array now contains the items from @first
followed by the items from @second.
the code example has this highlighted in pink:
@classes = (@classes, @newclasses);
so it doesn't even build on the previous page or show a real example for
this concept. not good.
but i will add it to my perl books page when i premier that.
(you can see the beta at: http://elm.he.net/cgi-bin/suid/~uri/books.pl
note that url is temporary)
t> Perl5 for web professionals (www.phptr.com/essential) by brown, bellow,
t> livingston prentice hall. Also a cleat guide. It has the benefit of
t> explaining _Every_ line of code in every example.
who care about explanations if the code sux. i downloaded this from:
http://www.phptr.com/essential/perl/chapter4/search1.zip
my comments are inserted.
#!/usr/bin/perl
require "get_form_data.pl";
&get_form_data();
another roll your own cgi parser.
$search_term = $FORM{'search'};
print "Content-type: text/html\n\n";
opendir(DIR, ".");
no check for failure. and why are we searching the cgi-bin dir (assuming
that is where this script is located)?
while($file = readdir(DIR))
{
next if($file !~ /.html/);
boy, that is a winner. what if i had a file name xhtmlfoo?
open(FILE, $file);
no check for failure again
$found_match = 0;
$title = "";
while(<FILE>)
{
if(/$search_term/i)
{
$found_match = 1;
}
if(/<TITLE>/)
what if the tag is in lower case? he does a case insensitive search above.
{
chop;
$title = $_;
$title =~ s/<TITLE>//g;
$title =~ s/<\/TITLE>//g;
why the /g? could there be multiple title tags? also what if the title
is on multiple lines? also the case issue rears its ugly head again.
}
}
if($title eq "")
{
$title = $file;
}
if($found_match)
{
print "<A HREF=\"$file\">$title</A>\n";
print "<BR>\n";
lovely backwhacks of quotes. multiple prints. two of my favorite
hallmarks of bad perl programs.
}
the indent above is as i found it.
close(FILE);
}
closedir(DIR);
exit;
t> Sent via Deja.com http://www.deja.com/
t> Share what you know. Learn what you don't.
another negative proof of that motto.
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
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 873
*************************************