[7441] in Perl-Users-Digest
Perl-Users Digest, Issue: 1066 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 23 20:07:22 1997
Date: Tue, 23 Sep 97 17:00:23 -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, 23 Sep 1997 Volume: 8 Number: 1066
Today's topics:
Re: '0': string or number? you make the call! <andi@team-konzept.de>
Re: ^Z and file input problem <youngej@magpage.com>
Re: Calling a Perl Script... <nospam-djohnson@uu.net-nospam>
Re: cgi data <tou@tou.com>
Re: Deleting Files <senthil@tdiinc.com>
Designing Flags for Script (David Zeng)
Re: Designing Flags for Script (brian d foy)
Getting backreferences from global pattern match? (Sean McAfee)
Re: help for user authentication <rra@stanford.edu>
HELP How do I use perl <mochans@homemail.com>
Re: HELP How do I use perl <fishrman@shell.wco.com>
Installing Perl modules w/o root? peter@widgetworks.com
Re: Memory leak? <bholzman@mail.earthlink.net>
Re: Need bulk Unix <-> PC file conversion ("Waqar Hafiz")
Re: pack question (Andrew M. Langmead)
Re: pack question (Jason Gloudon)
Re: Perl <=> C Server (Andrew M. Langmead)
Re: PERL courses in Atlanta?? <alan.tidwell@conted.gatech.edu.removethis>
perl mail on solaris (John Armsby)
Question: Finding rgexp list in a second list (Drew Dowling)
Re: Question: How to generate same "random" numbers... <ajohnson@gpu.srv.ualberta.ca>
sorting on 1 column in a record of columns <jim.blackwell@gsfc.nasa.gov>
Text::English (Gene Hsu)
What does the . operator do? <nate@wvecomputers.net>
Re: What does the . operator do? (brian d foy)
Re: what's wrong in this function? <nospam-djohnson@uu.net-nospam>
Where can I find lister.pl? (Joel R. McClure)
Re: Where is PerlShop to be found? <bholzman@mail.earthlink.net>
Re: Where is PerlShop to be found? <rh@net55.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Sep 1997 00:13:20 +0200
From: Andreas Schmidt <andi@team-konzept.de>
To: Dan Boorstein <danboo@ixl.com>
Subject: Re: '0': string or number? you make the call!
Message-Id: <34283EEC.CD1@team-konzept.de>
Dan Boorstein wrote:
>
> hello all,
>
> first off here is the code and results which confuse me:
>
> danboo> cat test.pl
> #!/usr/bin/perl -w
>
> $test0 = '0';
> $test00 = '00';
>
> $test0 && print "test0\n";
> $test00 && print "test00\n";
> danboo> ./test.pl
> test00
>
> now, here is what i thought would happen:
>
> $test0 would be assigned a string with the value '0'
> $test00 would be assigned a string with the value '00'
>
> $test0 would be defined as a non-empty string and print "test0\n"
> $test00 would be defined as a non-empty string and print "test00\n"
>
> as you can see, only "test00\n" was printed. so, is the string '0'
> a "failure/false" condition, or is it being evaluated as a numeric?
> i tried using the debugger to follow along but had little success.
In perl there are no datatypes like integer or string, they all are just
scalars. So there is no difference between assigning 0 or '0'. A scalar
is evaluated in the context of an operation. And how it is evaluated is
defined in the perl language: If you use the scalar '0' (or just 0) in
an arithmetic operation it is evaluated as the number 0, in a string
function it is the string containing one character and in a logical
function it is evaluated to false.
In an logical context the scalar '00' will be handled like the other
non-empty strings too, and so evaluated to true.
Hope that helps.
Andi
------------------------------
Date: 23 Sep 1997 23:51:01 GMT
From: Ed Young <youngej@magpage.com>
Subject: Re: ^Z and file input problem
Message-Id: <609kl5$6fg$0@204.179.92.76>
I suspect that you are using Win95 or WinNT. ^Z (ASCII 26) is an end
of file marker in these operating systems. To get around this "feature"
use:
binmode FILEHANDLE
(see perlfunc or the functions part of the camel book for further
explanation)
Icepick@pclink.com wrote:
>
> I'm writting a tiny crypto script as entertainment. But it barfs
> when ever a byte is encrypted as ASCII 26 aka ^Z. Everything
> beyond that byte is ignored.
>
> My script will encrypt and write just fine, but it chokes when
> reading in the data, at the ^Z point. My read file sub is below.
>
> How can I do this so that I can read in beyond a ^Z?
>
> open (INP, "text") || die "can't open \"text\""; # open the file
>
> for ($i=0;$i<=$len;$i++) { read(INP,$plain[$i],1);
> $plain[$i]=ord($plain[$i]); # convert to asci
>
> }
>
> close (INP) || die "can't close \"text\""; # and close it (nicely)
>
> --
> no more no less no fear no need no height no depth too great godspeed
> Want $1000?? Help break RC5! http://rc5.distributed.net/
>
------------------------------
Date: Tue, 23 Sep 1997 16:28:58 -0500
From: Dale Johnson <nospam-djohnson@uu.net-nospam>
To: Guy Doucet <gdoucet@ait.acl.ca>
Subject: Re: Calling a Perl Script...
Message-Id: <3428349A.41C67EA6@uu.net-nospam>
Guy Doucet wrote:
>
Guy,
> (1) I want to know how to call a Perl script from an HTML/JavaScript
> document, other than the <form method="post"... or "get"... What I'm
> getting at is I'd like to know if a JavaScript can call the Perl script
> directly.
>
The only way to do this without doing it through an http server is to
modify
the perl script to be a fully functioning daemon (on a unix box) or a
service (on an NT box) that is listening at a given Port. That is, a
program
that binds to a port and can accept commands from an external source.
At least, that's the only way I can think of right now. And even then,
it
could not be called directly from an html page. I'm not sure about the
javascript. If Javascript can telnet to a non-standard port, then it
can.
> (2) I am running on a Novell Web Server and I was wondering how to call
> a Perl script that doesn't return anything to the web page. When I try,
> I get Document contains no data.
>
You will always get a "Document Contains No Data" if you call a script
directly from a browser (i.e. http://my.domain.name/cgi-bin/scriptname).
A browser is expecting some sort of response from the http server to the
browser's GET/POST/HEAD query.
To avoid this, call the script as part of another page as a Server Side
Include (SSI). Either that, or have the script print the following
lines:
print "Content-type: text/html\r\n\r\n";
print "Script Function Completed\r\n";
Good luck.
Dale
--
Dale R. Johnson, Jr. -- djohnson[at]uu.net -- http://www.drsj.com/
PGP Key: 1024/7F16D9FF Fingerprint: D52DF796E5693AA3 F500A8FCEF354154
perl -e 'foreach(`finger johnson\@doit.net`){$a=1if/^-/;print if$a}'
------------------------------
Date: Tue, 23 Sep 1997 13:45:03 -0700
From: Joel Shellman <tou@tou.com>
To: asmr@antispam.edu
Subject: Re: cgi data
Message-Id: <34282A4F.BB698D58@tou.com>
asmr wrote:
>
> Under normal circumstances I would take the time to learn how to do this
> myself, but unfortunately time constraints have forced me to get a
> project done as quickly as possible.
>
> I'm creating a perl script that will allow users to access information,
> as long as the identification number entered is valid. I have a list of
> the valid id numbers in a file, and the data is structured as follows:
>
> 123456789
> 234567891
> 098765432
>
> and so on for a list of aprox. 200 numbers. I need to check the user
> input of their ID and see if it appears in the data file. If anyone
> could crank out the few lines of code I need it would save me a
> considerable amount of time. (to make things easier to explain, i've
> called the user entered id number "input{'id'}" and the data text file
> "data.txt")
>
> Thanks in advance! :)
> Allison Conover
> conov@hotmail.com
$ID is the user inputted id.
open( fileData, "data.txt" );
while ( <fileData> ) {
$CheckId = chomp($_);
if ( $CheckId eq $ID ) {
goto Found;
}
}
close( fileData );
NotFound:
do whatever
Found:
do whatever
Good luck,
Joel Shellman
--
TaoTree Research and Development
Web Development/Design, Virtual Servers, hosting, Perl/CGI programming
http://www.tou.com/rd/
Revolutionary new clicks-based Banner Exchange Guarantees you traffic
http://www.tou.com/ite/
------------------------------
Date: Tue, 23 Sep 1997 14:25:47 -0700
From: Senthilvel Rangaswamy <senthil@tdiinc.com>
To: Melinda <capulet16@hotmail.com>
Subject: Re: Deleting Files
Message-Id: <Pine.SOL.3.96.970923142458.12236A-100000@springle>
How about using unlink..
> page is being designed. My present solution is to make the file size
> equal to 0 bytes but it's an untidy way of doing things. Also if anyone
> uploads new picture files I want to delete others of their choice as I
> have set limits on total space for the image directory.
> I know it must be a simple solution but as yet the answer to doing it
> has eluded me.
> Hope to hear from someone out there,
> Warren
>
>
------------------------------
Date: 23 Sep 1997 20:03:45 GMT
From: dizzy@soda.CSUA.Berkeley.EDU (David Zeng)
Subject: Designing Flags for Script
Message-Id: <6097b1$93g@agate.berkeley.edu>
Hi, All,
I have another newbie question.
In my script, I have many print lines for debugging purposes. It is
annoying to have them show up and flood the actual error outputs.
I am wondering if we can design a -bug flag upon calling the script to
output all these lines, and not output these lines if -bug is not called?
For example, I have a script named: "blah," and I would like to call this
script from the shell by "./blah -bug <arg1> <arg2> <arg3>" to be able to
see the debug messages. If I type "./blah <arg1> <arg2> <arg3>," then
I wouldn't get all those printouts.
Any help would be appreciated.
David Zeng
p.s. Thanks to everyone who answered my question on input to a script.
------------------------------
Date: Tue, 23 Sep 1997 17:12:33 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Designing Flags for Script
Message-Id: <comdog-ya02408000R2309971712330001@news.panix.com>
In article <6097b1$93g@agate.berkeley.edu>, dizzy@soda.CSUA.Berkeley.EDU (David Zeng) wrote:
>In my script, I have many print lines for debugging purposes. It is
>annoying to have them show up and flood the actual error outputs.
>I am wondering if we can design a -bug flag upon calling the script to
>output all these lines, and not output these lines if -bug is not called?
sure. have some command line option (see Getopt::*), then debugging code
like:
use vars qw($debug);
$debug = 0; #set initial value
$debug = 1 if (....) #use whatever your condition will be, based
#on using some command line strategy
# some code
print "Whatever i need to know at this point" if $debug;
you can also mess with the value of the warnings switch (-w) by
setting $^W. for instance, you can turn on warnings:
$^W = 1 if $debug;
or turn off warnings in a block
{
local $^W = 0;
#stuff goes here
}
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 23 Sep 1997 22:01:31 GMT
From: mcafee@battlezone.rs.itd.umich.edu (Sean McAfee)
Subject: Getting backreferences from global pattern match?
Message-Id: <609e7r$fcs$1@newbabylon.rs.itd.umich.edu>
I have a file containing lines of the form:
A:abc B:xyz A:123 B:456 A:foo B:bar ...
...where the A, B pair can repeat an arbitrary number of times. I want to
extract the strings after the colon in each pair and store them in arrays
@A and @B. This doesn't work:
while (/A:(\S+) B:(\S+)/g) {
push(@A, $1);
push(@b, $2);
}
$1 and $2 are apparently never set, as I get only null strings in @A and
@B (although I do get the correct *number* of null strings). I can't find
any reason in the docs why this should be so. Can anyone shed some light
on the situation for me? Thanks in advance.
--
Sean McAfee | GS d->-- s+++: a25 C++ US+++$ P+++ L E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ | mcafee@
| R+ tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 23 Sep 1997 12:59:44 -0700
From: Russ Allbery <rra@stanford.edu>
To: Mike Wang <wangyj@sro.cig.mcel.mot.com>
Subject: Re: help for user authentication
Message-Id: <m3bu1jdcnj.fsf@windlord.Stanford.EDU>
[ Copy e-mailed to the original person asking. ]
brian d foy <comdog@computerdog.com> writes:
> Russ Allbery <rra@stanford.edu> wrote:
>> You have to use .htaccess. Sorry. (And a CGI programming newsgroup is
>> where you really want to ask these sorts of questions.)
> no you don't. it's just a matter of sending the proper HTTP response.
> Perl can do lots if you just give it a chance :)
Sigh. You are, of course, correct. (Although the point about a CGI
programming group still stands, and would have resulted in the original
poster getting a more accurate answer originally.)
> #!/usr/bin/perl
> print <<'HTTP';
> Status: 401 Authentication Required
> Host: computerdog.com
> Content-type: text/plain
> Authentication is required to access this resource
> HTTP
> __END__
> of course, you'll need to handle the response yourself, but that's
> the point, isn't it ;)
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Tue, 23 Sep 1997 15:51:12 -0400
From: shresthm <mochans@homemail.com>
Subject: HELP How do I use perl
Message-Id: <34281DB0.48F9@homemail.com>
I have absoluely no idea how to get started on perl. I made a pl file,
made it executible by the chmod parameter, and then what the hell am I
supposed to do. I have the 1st. edition of the Ilama book, and I
couldn't find the answer to it. I thought I could write some CGI stuff
with perl, but I have no idea how it works. I tried to open the file
with Netscape and it treated the .pl file that I had written as a text
file and showed the source. What the hell am I supposed to do now?
------------------------------
Date: 23 Sep 1997 20:36:56 GMT
From: "Michael A. Watson" <fishrman@shell.wco.com>
Subject: Re: HELP How do I use perl
Message-Id: <609998$j66$1@news.wco.com>
shresthm <mochans@homemail.com> wrote:
> I have absoluely no idea how to get started on perl. I made a pl file,
> made it executible by the chmod parameter, and then what the hell am I
> supposed to do. I have the 1st. edition of the Ilama book, and I
> couldn't find the answer to it. I thought I could write some CGI stuff
> with perl, but I have no idea how it works. I tried to open the file
> with Netscape and it treated the .pl file that I had written as a text
Unless you have you have the perl version specific to your operating system
loaded on your machine you will need to execute it on a machine that has
perl loaded. I run mine on my ISP's machine. Note not all ISP's allow users
to run user created programms.
to run type 'perl <filename>' or perl -w <filename> for verbose error messages.
------------------------------
Date: 23 Sep 1997 16:17:06 -0400
From: peter@widgetworks.com
Subject: Installing Perl modules w/o root?
Message-Id: <609842INNooi@retriever.cs.umbc.edu>
I've installed many perl libraries into the standard library directory
as root for years... Now I need to install some libraries on a system
that has Perl 5.003 installed, but to which I do not have root
access. To wit, I need to install these modules into my home
directoty. Anyone know how to do this?
Compiling perl and maintaining my own complete library is *not* an
option.
Peter Johansson
peter@widgetworks.com
------------------------------
Date: Tue, 23 Sep 1997 18:37:35 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
Subject: Re: Memory leak?
Message-Id: <342844AF.ED0C434C@mail.earthlink.net>
> I am curious are we acknowledging the presence of a memory leak here or
> can someone explain if the code we were shown explains the memory usage.
> As it is I can't explain the memory usage.
>
Besides the obvious efficiency problems of holding the newassign stuff
in an array, I can't see anything egregiously wrong with the code,
either. If the original poster could give more info about his system,
like what OS he's on, that might help. I'm guessing that it must be a
_major_ problem with the system-supplied getpw* functions, although that
seems ridiculous. If it was loading a complete copy of /etc/passwd into
memory for every getpwent() call, the image would get near 29 Megs after
80 getpwent calls if /etc/passwd was on the order of 320,000 Bytes. And
if that were the case, it'd probably hold around 4,000 entries, in which
case the image would reach 250 Megs after processing only 800 getpwent
calls. Steve, if these size estimates are in the ballpark for your
/etc/passwd file, perhaps that is indeed what's going on, although it's
pretty hard to believe that any OS could get those functions _so_
wrong.
Hmmm.
Benjamin Holzman
------------------------------
Date: Tue, 23 Sep 1997 20:46:15 +0100
From: waqar.hafiz@virgin.net ("Waqar Hafiz")
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <19970923195025.AAA16567@p41-canary-gui.tch.virgin.net>
>Ron Savage (rpsavage@ozemail.com.au) wrote:
>[How do I convert DOS CR-LF to UNIX LF?]
Most of the Unix OSs provide utilities like dos2unix and
unix2dos. See man pages for these.
------------------------------
Date: Tue, 23 Sep 1997 20:53:06 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: pack question
Message-Id: <EGzBCI.Gtq@world.std.com>
alex@kawo2.rwth-aachen.de (Trudno zhit' v derevne bez nagana.) writes:
>sub byte_seq
>{
> $length = length($_[0]); # length of 1st argument
> pack ('C' . ('xC' x $length)), (2 * $length), (split //, $_[0]);
^ ^
^ misplaced paren.
^ or remove both of them.
this evaluates a list consisting of:
( pack('CxCxCxC'), # pack with nothing to pack will return undef
(2 * $length), # will return 6
(split //, $_[0]) # will return a list consisting of each element in $_[0]
)
Unfortunately, I don't get the same output as you do. Also, you don't
want to 'C' pack your characters themselves. If you do, you get the
ASCII reprentation of the character with the numerical encodings "A",
"B", and "C".
How about:
I think what you want is:
sub byte_seq {
$length = length($_[0]); # length of 1st argument
pack ('C' . ('xA' x $length), (2 * $length), (split //, $_[0]));
}
or you can also do:
sub byte_seq {
my $string = shift;
return join pack('C', 2 * length $string), map "\0$_", split //, $string;
}
Both should create a packed string consisting of the seven bytes
0x06 0x00 0x65 0x00 0x66 0x00 0x67
>BTW can i use: print CLIENT byte_seq('ABC');
>or should i: print CLIENT &byte_seq('ABC');
You can use either. Since the "&" is optional in many cases
now. (Execpt that it calls the user defined function instead of the
builtin one, without requiring the user defined one is not imported
into the current package. Also, it doesn't disable prototypes like the
"&" version.)
--
Andrew Langmead
------------------------------
Date: 23 Sep 1997 21:34:02 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: pack question
Message-Id: <609cka$7p8$1@daily.bbnplanet.com>
Trudno zhit' v derevne bez nagana. (alex@kawo2.rwth-aachen.de) wrote:
: Hi,
: i am writing a Perl program which should send a Unicode string
: over socket to a Java program, but have a problem understanding
: pack. What i'd like to do is to send following byte sequence:
: 6, 0, 'A', 0, 'B', 0, 'C'
: (6 is the length of following byte sequence, the 0s are because of
: Unicode). It works fine, when i use: pack 'CxCxCxC', 6, 65, 66, 67;
: But when i try a subroutine:
: sub byte_seq
: {
: $length = length($_[0]); # length of 1st argument
: pack ('C' . ('xC' x $length)), (2 * $length), (split //, $_[0]);
: } ^^^^^^^^^^^^^^^^^^^^^^^^
First Problem : Look at your parentheses. They Don't include all of your
arguments. You can leave the first pair of () out.
Another problem you are having here (or would with the above correction),
is that 'C' wants numeric arguments. When you split the string 'ABC' you
get single character scalars 'A' 'B' 'C' which are all converted to the
numeric value zero.
What 'C' wants as in your manual example is numbers, in your case the ASCII
values, of the characters in those scalars which the ord function will
provide.
Perl isn't like C in this respect.
This works for me in Perl5.004, I renamed $length as it isn't nice to
use variables with the names of functions.
sub byte_seq {
my($arglen) = length($_[0]); # length of 1st argument
$template = 'C' . 'xC' x $arglen; # Doing it in the next line is
# is somewhat troublesome
pack $template,(2 * $arglen), map { ord $_ } split (//, $_[0])
}
: BTW can i use: print CLIENT byte_seq('ABC');
Yeah you can.
But you should do this.
: or should i: print CLIENT &byte_seq('ABC');
: Thanks a lot for your help!
: /Alex
: --
: russkaya literatura v ------ http://www.simplex.ru/lit.html
: internete http://www.friends-partners.org/~afarber/lit.html
: java preferans ------------ http://www.simplex.ru/pref.html
: besplatnye kommercheskie ob'yavleniya http://www.simplex.ru
Jason Gloudon
------------------------------
Date: Tue, 23 Sep 1997 20:19:19 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl <=> C Server
Message-Id: <EGz9s7.7GM@world.std.com>
Doug Seay <seay@absyss.fr> writes:
>Andrew M. Langmead wrote:
>> Otherwise take a look at the "pack" and "unpack" functions.
>True in this case, but what about
> struct bar
> {
> char one;
> int two;
> };
>This will be a bit harder to pack because of alignment questions.
Which is why I mentioned it in the paragraph preceding the one you
quoted. (and also why writing structs out directly is not such a good
idea.)
> If you don't
>understand what is going on with this,
>try testing
> sizeof(bar) > sizeof(bar.one) + sizeof(bar.two)
>If this is TRUE, your C compiler inserted unused bytes to keep fields
>well aligned and you will need to find out how your compiler places
>fields in a struct.
Also take a look at the C macro offsetof() in <stddef.h>
--
Andrew Langmead
------------------------------
Date: Tue, 23 Sep 1997 16:35:17 -0700
From: Alan Tidwell <alan.tidwell@conted.gatech.edu.removethis>
Subject: Re: PERL courses in Atlanta??
Message-Id: <34285235.7964@conted.gatech.edu.removethis>
Andreas Dieberger wrote:
>
> Hi.
>
> Does anybody have an idea where it is possible to attend Perl classes in
> Atlanta? Can be a continuing education type class, or whatever.
>
Georgia Tech offers "Basic Perl Programming" and "Advanced Perl
Programming" through our Continuing Education Program.
Basic Perl Programming will be offered on October 1, 1997 and again on
November 19, 1997
Advanced Perl Programming will be offered on October 2-3, 1997 and again
on November 20-21, 1997
Please visit our web site at www.conted.gatech.edu for more details.
>From the home page click on the "Continuing Education Short Courses and
Conferences" button, then choose "computing" from the left-hand window.
or contact our Marketing Department at (404)894-2547.
Alan Tidwell
Program Support Manager
Distance Learning, Continuing Education and Outreach
(404)894-2407
------------------------------
Date: Tue, 23 Sep 1997 23:23:54 GMT
From: jaws@atl.mindspring.com (John Armsby)
Subject: perl mail on solaris
Message-Id: <609jac$5d2@camel2.mindspring.com>
the following script send Email but I do not get the subject. A
recipient gets the body of the message only. Can anyone help? I am
using perl 5.003 on a sun sparc 20 running /usr/bin/mail on solaris.
#usr/local/bin/perl
my $Mailto="jaws@mindspring.com";
my $MailSubject="test email";
open (DOMAIL, "| mail -s $MailSubject $Mailto");
print DOMAIL <<"EndOfMessage";
this is a test
EndOfMessage
The operating system things $MailSubject is another recipient...
John
jaws@mindspring.com
------------------------------
Date: Tue, 23 Sep 1997 22:08:55 GMT
From: dowling@netcom.com (Drew Dowling)
Subject: Question: Finding rgexp list in a second list
Message-Id: <dowlingEGzEuv.IDx@netcom.com>
Keywords: Question rgexp list
As a shell head and an awker I knew sooner or later I'd get into perl. Last
month with a copy of the blue camel later becames sooner... and I'm liking it.
I've found the perl FAQ to be of great help as well, pointing out logic
constrcuts I would not of thought of. Most recentally I've been working on
comparing two lists of names. One list is is 2K and the other about 18K.
I understand the concept of building a hash of keys from one list and and
setting a value so I can test for each key in my second list aginst the
hash to see if it has a value set. This works really well and quickly.
Looping to foreach loops once inside the other list (36K iterations of a
test) was taking a bit long :)
What I was wondering about is if there is a quick easy way to test for
each member of one list as if it were a rgexp rather than as a whole? Both
lists are merly names, so lest say:
cat file1
-
Byko, Susan
Carmen, Joel
Carr, Tom
Clarissa, Stephanie
-
cat file2
-
Byko, Susana
Bzeeny, Chris
Carmen, John
Carmen, Jason
Carr, Thomas
Clarissa, Stephanie
Donnald, Eric
-
I want to do two additional things besides finding exact matches from file1
in file 2. I'd like to be able to determine that "Byko, Susana" does
actualy include "Byko, Susan" and "Carr, Thomas" contains "Carr, Tom". As
well as showing me that "Carmen, Joel" matches most of both "Carmen, John"
and "Carmen, Jason" from a last name to first initial standpoint.
Now looping two foreach strctures together is nice when you have this
example data, but when you have the kind of numbers I mentioned it's: run
program, eat lunch, play 18 holes, come back and it's done. Not that I
wouldn't mind playing 18 holes of golf everytime I run this thing, but is
there a nicer, quicker way to do this with checking each entry in file2
aginst each entry in file 1?
--
Drew Dowling Drewhead /\
dowling@netcom.com 69 WWW / \Alpha Phi Omega
Atlanta, Georgia Nimat Apatschin/ \ Gamma Lambda
CLEMSON UNIVERSITY ALUMNI TBS, INC /______\
TIGER BAND! http://www.geocities.com/SouthBeach/Marina/8169
This account protected by spamguard(TM). Use keyword "Tiger" in subject line.
------------------------------
Date: Tue, 23 Sep 1997 13:51:00 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Question: How to generate same "random" numbers...
Message-Id: <34280F94.5FF7FCF3@gpu.srv.ualberta.ca>
Nevin Kapur wrote:
>
> Is it possible to generate repeatable sets of random numbers using perl.
> What I need is some function which will accept a seed and repeatedly
> generate the same random numbers.
Yes...it is possible.
did you find the documentation on the rand() function
in the perlfunc manpage? try: perldoc -f rand
you should also notice a 'see also, srand()' in there.
Seeding srand() will cause subsequent calls to rand() to
produce psuedo-random numbers from some point X in its cycle,
re-seeding srand() with the same seed will cause rand() to
begin producing from that same point X in the cycle again,
giving you the same sequence again (presumably for testing
purposes).
hope it helps
regards
andrew
------------------------------
Date: Tue, 23 Sep 1997 19:32:50 -0400
From: Jim Blackwell <jim.blackwell@gsfc.nasa.gov>
Subject: sorting on 1 column in a record of columns
Message-Id: <342851A0.3522C174@gsfc.nasa.gov>
Hi,
I have a bunch of records that are separated by vertical bars. parsing
isn't the problem. What I am trying to do is sort on one column such
that the entire row is carried with it.
Ex:
col1 col2 col3
aaaa bbb ccc
true false whatever
Say I want to reverse sort on the 3rd column. What I'd like to end up
with is
col1 col2 col3
true false whatever
aaaa bbb ccc
How do I setup a sort so I get this sort of result ? I've done it in
IDL easily since what you get back from its sort routine is an index so
you can take and sort on one component and get the rest to follow by
saying something like array1=array1(index)
where index was an array of indicies of the sorted array.
I figure there's an easy solution. Some day I hope to contribute to
this newsgroup rather than tapping it for info all the time ;)
Jim Blackwell
------------------------------
Date: Tue, 23 Sep 1997 16:23:32 -0700
From: gene@moreinfo.com (Gene Hsu)
Subject: Text::English
Message-Id: <gene-ya02408000R2309971623320001@corp.supernews.com>
Does anyone know where to find this module? I haven't been able to find
it in CPAN, though it's mentioned (barely) in one of the author lists.
I'd like to get it so I can try out some of the Information Retrieval stuff
from the perl journal.
-- Gene
------------------------------
Date: Tue, 23 Sep 1997 17:54:38 -0500
From: Nate <nate@wvecomputers.net>
Subject: What does the . operator do?
Message-Id: <342848AD.12C7543F@wvecomputers.net>
what exactly does the . operator do.. for instance:
$data{'new_item'} .="; " if $data{'new_item'};
Thanks for any help anyone can offer.
Nathan Stitt
nate@wavecomputers.net
------------------------------
Date: Tue, 23 Sep 1997 19:18:39 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: What does the . operator do?
Message-Id: <comdog-ya02408000R2309971918390001@news.panix.com>
In article <342848AD.12C7543F@wvecomputers.net>, Nate <nate@wvecomputers.net> wrote:
>what exactly does the . operator do.. for instance:
it concatenates its operands.
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 23 Sep 1997 16:33:39 -0500
From: Dale Johnson <nospam-djohnson@uu.net-nospam>
To: "Tam, Kai Fai" <tam1@uwindsor.ca>
Subject: Re: what's wrong in this function?
Message-Id: <342835B3.167EB0E7@uu.net-nospam>
> Do you have any idea about what's wrong in the function below,
> no matter syntax or style?
>
> sub award
> {
> local ($tmpflags);
>
> $tmpflags=$flags; $flags="g"; &matchaction; $flags=$tmpflags;
> }
>
> Thanks!
>
> Ken
Ken,
If you are trying to get $tmpflags to have a value of "g", then yes, I
have
an idea. You need to assign "g" to $flags BEFORE you assign $flags to
$tmpflags. I would do the code this way:
sub award
{
local ($tmpflags);
$flags = "g"; $tmpflags = $flags; &matchaction; $flags = $tmpflags;
}
NOTE: It is difficult to be sure since you haven't told us what the
function is supposed to return, nor do you show what
"&matchaction"
does.
Good luck.
Dale
--
Dale R. Johnson, Jr. -- djohnson[at]uu.net -- http://www.drsj.com/
PGP Key: 1024/7F16D9FF Fingerprint: D52DF796E5693AA3 F500A8FCEF354154
perl -e 'foreach(`finger johnson\@doit.net`){$a=1if/^-/;print if$a}'
------------------------------
Date: Tue, 23 Sep 1997 18:07:19 GMT
From: lnusebs.hzg90n@eds.com (Joel R. McClure)
Subject: Where can I find lister.pl?
Message-Id: <34280512.15943903@news.ses.cio.eds.com>
I was wondering where I can find lister.pl or lister-pl?
TIA,
Joel McClure
------------------------------
Date: Tue, 23 Sep 1997 18:08:04 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: rh@net55.com
Subject: Re: Where is PerlShop to be found?
Message-Id: <34283DC4.FFDDB8E8@mail.earthlink.net>
[posted & mailed]
rh@net55.com wrote:
>
> I'd like to obtain PerlShop
>
> but I need a current complete URL?
>
> Can anyone help?
>
> Thanks in advance
>
> Hank
>
Look, if you've got access to a web browser, which you obviously do, you
should _use a search engine_! That's what they're there for! Anyway, I
just did a search at altavista.digital.com for "PerlShop" and came up
with 163 matches, most of which seem to be relevant. Here's what I
guess you wanted:
http://www.arpanet.com/PerlShop/perlshop.html
------------------------------
Date: Tue, 23 Sep 1997 17:17:18 -0600
From: rh <rh@net55.com>
Subject: Re: Where is PerlShop to be found?
Message-Id: <34284DFE.8AFC4D2@net55.com>
Benjamin Holzman wrote:
>
> [posted & mailed]
>
> rh@net55.com wrote:
> >
> > I'd like to obtain PerlShop
> >
> > but I need a current complete URL?
> >
> > Can anyone help?
> >
> > Thanks in advance
> >
> > Hank
> >
> Look, if you've got access to a web browser, which you obviously do, you
> should _use a search engine_! That's what they're there for! Anyway, I
> just did a search at altavista.digital.com for "PerlShop" and came up
> with 163 matches, most of which seem to be relevant. Here's what I
> guess you wanted:
> http://www.arpanet.com/PerlShop/perlshop.html
Thanks...but the link is 'dead'...
I had tried it prior to posting my message.
I hope someone has a current link for PerlShop
Hank
------------------------------
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 1066
**************************************