[6903] in Perl-Users-Digest
Perl-Users Digest, Issue: 528 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 27 17:17:21 1997
Date: Tue, 27 May 97 14:02:46 -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 Tue, 27 May 1997 Volume: 8 Number: 528
Today's topics:
Re: Reading binary files: OK under DEC UNIX, error unde <rootbeer@teleport.com>
regexp solver (Kyzer)
Re: searching for two or more strings that match in a s (Chipmunk)
Status of Perl Compiler (Mark A. Lehmann)
Re: telnet job <jay@rgrs.com>
Re: telnet job (Kyzer)
Re: The perl way? What is it really? <vladimir@cs.ualberta.ca>
Re: types (Kyzer)
Re: types (Tung-chiang Yang)
Re: types <rootbeer@teleport.com>
undef, split: bug? <fred@lovelace.infobiogen.fr>
use of seek (David M. Mehringer)
Re: Using perl and rlogin (Kyzer)
Re: What is an "EMT Trap"? (Kyzer)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 May 1997 12:41:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Marelius <john@xray.bmc.uu.se>
Subject: Re: Reading binary files: OK under DEC UNIX, error under Win32
Message-Id: <Pine.GSO.3.96.970527124119.8179R-100000@kelly.teleport.com>
On Tue, 27 May 1997, John Marelius wrote:
> Two of my PERL program that read data from binary files (FORTRAN
> unformatted files) work fine with PERL 5.002 under DEC UNIX (2.0 and up)
> but fails under PERL 5.003_07 for Win32 (NT 4.0/Alpha).
> The calls to the read function work normally the first 100-200 bytes but
> after that read fails to read any more.
You probably need binmode, documented in perlfunc. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 27 May 1997 17:20:39 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: regexp solver
Message-Id: <5mf557$51v@info.abdn.ac.uk>
I'm wondering, is there a program to solve perl regexps?
(That is, print out all possible matches, using * to represent 'this could
match anything, and I'm not going to print that all out)
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
SAM: 'Hey, Hey, Buddy, come here! We want to talk to you a minute!'
BLAM, BLAM
Pok, Pok
MAX: 'Yeah, no kidding! We won't hurt you!'
BLAM
------------------------------
Date: 27 May 1997 18:47:08 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: searching for two or more strings that match in a single array
Message-Id: <5mfa7c$14t$2@dartvax.dartmouth.edu>
In article <5md5t0$8u8$1@news8.gte.net>
ddougal@concentric.net (David Dougal) writes:
> I have the following array:
>
> @array = ("w0123456789","l0123456787","w0134265879", "t0123456789",
> "w0123456789", "w0123456789");
>
> I want to compare each element and find the ones that match and count the
> number of matches and print out the results. I need to find the most matches.
>
> I would need to compare element 0 with all the elements in the array and count
> the number of matches for element 0 and print results and so on....
How do you want to do the comparisons? How do you decide whether two
elements match?
What results do you want to print?
In this code, two elements match if they have the same string value.
For each element, the number of matching elements is printed,
regardless of order in the array.
(Note that if element 0 matches two other elements, those two other
elements also each match two elements.)
for ($i=0; $i<=$#array; ++$i) {
$match[$i] = 0 if !defined $match[$i];
for ($j = $i+1; $j<=$#array; ++$j) {
if ($array[$i] eq $array[$j]) {
$match[$i]++;
$match[$j]++;
}
}
print "Element $i matched $match[$i] other elements.\n";
}
Chipmunk
------------------------------
Date: 27 May 1997 13:57:24 -0500
From: mlehmann@prismnet.com (Mark A. Lehmann)
Subject: Status of Perl Compiler
Message-Id: <5bhgfog2uj.fsf@smokey.prismnet.com>
I've been using the Perl Compiler for about a week, but I've found that this
awesome tool croaks on most of my code. I see that the Perl Compiler at CPAN
is near to a year old. I have also seen information indicating that
Malcom Beatie is the project lead for Perl 5.005 so that the perl Compiler
will be a working part of the Perl language. Probably like most of the perl
giants he is doing this with outrageous spare time that exists in the minds
of the perl non-contributing user community.
So, I'm curious, what is the scoop on the Compiler?
Thanks to Malcom, and the rest of the compiler contributors, for the Compiler.
--
Mark Lehmann.
------------------------------
Date: 27 May 1997 11:51:04 -0400
From: Jay Rogers <jay@rgrs.com>
To: h50@nikhefh.nikhef.nl (Marc de Kamps)
Subject: Re: telnet job
Message-Id: <82d8qcewwn.fsf@shell2.shore.net>
h50@nikhef.nl (Marc de Kamps) writes:
> I am having trouble with the folowing construction:
>
> open( FTPJOB , "telnet $ftpsite 80 << EOP
> GET bla.html
> EOP | ")
> while( <FTPJOB> ){
> # Do something with the contents of bla.html
> }
> close( FTPJOB );
>
> On IRIX6.0 this works fine, on SunOs5.5.1 it doesn't.
I believe that the telnet program on a Soloris machine always reads
from tty and never from stdin.
You should get the info by connecting directly to the port instead of
using a telnet program. The module LWP.pm can help you communicate
with an http server.
You can also use the Net::Telnet module:
use Net::Telnet ();
$t = new Net::Telnet (-Host => $ftpsite,
-Port => 80,
-Timeout => 10,
-Telnetmode => 0);
$t->print("GET bla.html");
while ($line = $t->getline) {
# Do something with the contents of bla.html
}
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: 27 May 1997 17:15:55 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: telnet job
Message-Id: <5mf4sb$51v@info.abdn.ac.uk>
Marc de Kamps, while smelling of fish, wrote:
: open( FTPJOB , "telnet $ftpsite 80 << EOP
[snip]
: close( FTPJOB );
: Some pointers towards what I am doing wrong ?
IIRC, port 80 is the Webserver port, not the FTP port.
Oh, and I suggest you use the Net::FTP module on CPAN (www.perl.com/CPAN/)
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
AtheistCode(v1.0) ACv1.0 DUR5 STR4 BIT4 ACT1 DEF4 DEB5 CON1 SLM5 XTN4 PUB2
------------------------------
Date: 25 May 1997 21:37:23 -0600
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: The perl way? What is it really?
Message-Id: <omk9km3nv0.fsf@tees.cs.ualberta.ca>
In article <EALu75.18I@nonexistent.com> abigail@fnx.com (Abigail) writes:
> A break/continue/next/last is nothing more than a goto
So is while: an if plus a goto out of the loop, and there's a little goto at
the end of the loop.
> and we'll all know what Dijkstra said: Goto considered harmful.
And then this became the catchphrase of language theorists: assignment
considered harmful, inheritance considered harmful, ... Nobody gives a rat's
ass about all this though. Except poor PhD candidates such as myself :-)
> It's a pain in the ass to proof the correctness of your program if
> it contains goto's. [*]
It's a pain in the ass to program anything for the real world. I'd much rather
be with half-dressed chicks on a beach. But, not everyone has a rich daddy.
> [*] Anyone out there teaching program correctness and using Perl
> programs as examples?
Anyone out there teaching program correctness and using *any* real-world
programs as examples? I didn't think so.
------------------------------
Date: 27 May 1997 16:55:54 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: types
Message-Id: <5mf3mq$51v@info.abdn.ac.uk>
Tung-chiang Yang, while smelling of fish, wrote:
[snipped]
: This does not work ......
: $a = '';
: print "Trial 2: It is an integer\n" if ($a eq int($a));
I believe it's because $a='', an empty string. When evaluated as an integer,
it becomes a number (0). When reevaluated as a string again, it becomes the
string '0'. '' ne '0'.
: Tom Phoenix wrote:
: : Mostly, this will do it.
: : print "it's an integer" if $foo == int($foo);
I think $foo='' is stretching the values of 'mostly' :)
print "integer!" if ($foo ne '') and ($foo == int($foo));
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
"The Romans grew the grape as far north as Brighton, but then, the Romans
never built sugar silos on this scale." - Open University
------------------------------
Date: Tue, 27 May 1997 18:08:24 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: types
Message-Id: <tcyangEAuqE0.4vz@netcom.com>
Kyzer (junkmail@sysa.abdn.ac.uk) wrote:
: : $a = '';
: : print "Trial 2: It is an integer\n" if ($a eq int($a));
: I believe it's because $a='', an empty string. When evaluated as an integer,
: it becomes a number (0). When reevaluated as a string again, it becomes the
: string '0'. '' ne '0'.
Well, as long as the program somehow might result in $a equalling '',
this kind of test might be necessary.
: print "integer!" if ($foo ne '') and ($foo == int($foo));
This does not work always as someone else along this thread pointed out.
In "==", both $foo and int($foo) will be interpreted as numbers, and
therefore they become "0" if $foo is, say, 'a';
(Code:)
#!/usr/local/bin/perl
$a = 'a';
print "It is an integer\n" if ($a ne '') && ($a == int($a));
(Output:)
{netcom10:32} ~/tmp/a
It is an integer
Replacing $a above with '0.0', which is an integer by human beings,
and I can get "It is an integer", though.
How about the pattern /[+-]?\d+\.?0*/ to test for integers? I could
be wrong here for the pattern since I did not keep the Perl book with me
.... and I cannot remember exactly what each character mean in the
pattern.....
P.S. Mathematical people will say 0.9999999999999999999999 ..... == 1 :)
though I understand this number does not exist for finite
precision computer hardwares.
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Tue, 27 May 1997 12:02:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tung-chiang Yang <tcyang@netcom.com>
Subject: Re: types
Message-Id: <Pine.GSO.3.96.970527120053.8179E-100000@kelly.teleport.com>
On Tue, 27 May 1997, Tung-chiang Yang wrote:
> Tom Phoenix (rootbeer@teleport.com) wrote:
>
> : > How to know if what's returned from a from is an integer
> : > or not ?
>
> : Mostly, this will do it.
>
> : print "it's an integer" if $foo == int($foo);
> This does not work ......
> $a = '';
> print "Trial 1: It is an integer\n" if ($a == int($a));
That's why I said "Mostly"! :-) I wasn't trying to tell numbers from
non-numbers. Given a number, that tells the difference between an integer
and a non-integer.
I figured that if the original poster had wanted to know how to tell a
number from a non-number, the answer in the FAQ would have sufficed. :-)
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 27 May 1997 17:51:17 +0200
From: Frederic Achard <fred@lovelace.infobiogen.fr>
Subject: undef, split: bug?
Message-Id: <wvlo50ncay.fsf@lovelace.infobiogen.fr>
Dear all,
The following perl code
" $ perl5.004 -e ' ( undef, undef, $a) = split / /, "1 2 3"; print " $a\n"'
"
prints only the new line
The previous perl version returned what I'd expect:
" $ perl5.003 -e ' ( undef, undef, $a) = split / /, "1 2 3"; print " $a\n"'
" 3
This looks pretty much like a bug to me. Unless I have been miss-using
split and undef for months :-(
Frederic Achard
PS:
" perl.004 -V
Summary of my perl5 (5.0 patchlevel 4 subversion 0) configuration:
Platform:
osname=solaris, osvers=2.5.1, archname=sun4-solaris
uname='sunos lovelace 5.5.1 generic_103640-08 sun4u sparc sunw,ultra-enterprise '
hint=previous, useposix=true, d_sigaction=define
bincompat3=y useperlio= d_sfio=
Compiler:
cc='cc', optimize='-O', gccversion=
cppflags='-I/usr/local/include'
ccflags ='-I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=true
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=n, randbits=15
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
cccdlflags='-Kpic', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Locally applied patches:
REFCASE1 - fix for case-insensitivity in regex backreferences
Built under solaris
Compiled at May 21 1997 12:26:10
@INC:
/usr/local/lib/perl5/sun4-solaris/5.004
/usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/sun4-solaris
/usr/local/lib/perl5/site_perl
.
------------------------------
Date: 27 May 1997 16:54:31 GMT
From: dmehring@cco.caltech.edu (David M. Mehringer)
Subject: use of seek
Message-Id: <5mf3k7$oi@gap.cco.caltech.edu>
I have the written the following bit of code that uses the unix zcat
utility to uncompress a gzipped file into memory.
$zcat="/opt/bin/zcat";
# $line_files[$i] is a gzipped file
open (LINEFILE,"$zcat $line_files[$i] |");
The resulting uncompressed file is formatted, so I would like to use
"seek" to move the pointer around within it. However, seek does not seem
to work on "files" in memory. For example, the following bit of code
does not produce the expected result
seek(LINEFILE,810,0);
read(LINEFILE,$line,81);
print "$line\n";
The camel book says that the seek function will return a value of 1 if
successful and 0 if unsuccessful, but the print statement in the chunk of
code below shows that $junk is the null string:
$junk=seek(LINEFILE,810,0);
print "$junk\n";
So, my question is, is there something special I need to do to get seek
to work on a "file" that is in memory, or is seek not able to work on such
things? Sorry if my jargon is wrong.
Please email and thanks in advance.
--
Dave Mehringer California Institute of Technology
dmehring@socrates.caltech.edu Department of Physics
CSO post-doc/AIPS manager Pasadena, CA USA
http://socrates.caltech.edu/~dmehring/dmehring.html
------------------------------
Date: 27 May 1997 16:13:53 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: Using perl and rlogin
Message-Id: <5mf181$51v@info.abdn.ac.uk>
Paul Vermette [NiD/BiM], while smelling of fish, wrote:
: I am not using the password anymore because I found out about the .rhosts
: file.. which makes things somewhat more secure.. the big problem now is
: still waiting to see when the forked process can start taking commands..
Ahh... so what you want, in reality, is rsh (remote shell)
#!/usr/local/bin/perl -w
my @hosts=('dixie','vortex','murphy');
foreach (@hosts) {
print "On $_\n", `/usr/bin/rsh $_ who`, "\n";
}
__END__
or alternatively,
print `finger \@$_`, "\n";
: PS I am not a hacker.. I don't believe in wasting my time on that SH!T
That's OK, I was just making sure - anyone mentioning passwords is immediatly
considered a suspect :)
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
AtheistCode(v1.0) ACv1.0 DUR5 STR4 BIT4 ACT1 DEF4 DEB5 CON1 SLM5 XTN4 PUB2
------------------------------
Date: 27 May 1997 16:50:55 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: What is an "EMT Trap"?
Message-Id: <5mf3df$51v@info.abdn.ac.uk>
Mark Little, while smelling of fish, wrote:
: I'm trying to run Perl5.003 on an Amiga 3000 but I keep getting "EMT Trap"
It's in the Amiga ixemul documentation - see <signal.h> and signal(3)
SIGEMT - emulate instruction executed - process termination with core dump
#define SIGEMT 7 /* EMT instruction */
This may not help, but nethertheless check:
- using the correct ixemul.library binary for your processor?
- fully installed perl? (/usr/lib/perl5/m68k-amigaos/* is in place?)
- using the latest snapshot of ixemul and perl from ADE master site?
-kyz (happily running perl5.003 on his A1200/020)
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
sh: cookie not found
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 528
*************************************