[10216] in Perl-Users-Digest
Perl-Users Digest, Issue: 3809 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 24 03:07:35 1998
Date: Thu, 24 Sep 98 00:00:40 -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 Thu, 24 Sep 1998 Volume: 8 Number: 3809
Today's topics:
Re: any way to encrypt my script? <zenin@bawdycaste.org>
Re: any way to encrypt my script? <zenin@bawdycaste.org>
Re: Array of hashes: a better way? <uri@sysarch.com>
Re: Array of hashes: a better way? (Ronald J Kimball)
file opened with "+>>" query <steph@hotkey.net.au>
Re: File Reading (Ronald J Kimball)
Re: How to count match pattern? (Ronald J Kimball)
Re: How to post via HTTPS (Mads Toftum)
Re: IO::Select Problems <jimbo@soundimages.co.uk>
leading space <sameers@ece.rutgers.edu>
Re: leading space (Tad McClellan)
Re: leading space (Craig Berry)
Re: Manipulating Single lines in file... (Tad McClellan)
NT 4 + PWS 4 vs PERL 5 + CGI <new_email@see.web.page>
Re: Perl & Java - differences and uses <bjohnsto_usa_net@my-dejanews.com>
Re: Perl with use/require doesn't work under cron <uri@sysarch.com>
Re: Poll: How Did You Learn Perl? <jimbo@soundimages.co.uk>
Re: Poll: How Did You Learn Perl? (Ronald J Kimball)
Re: Q: Picking an element from a hash (not knowing whic (Ronald J Kimball)
Re: Question about Sendmail, Perl, and CGI <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Regular Expression Beautifier (Ronald J Kimball)
Re: Sorting Array Of Directories via ABC, not date... (Tad McClellan)
Re: Sorting Array Of Directories via ABC, not date... (Andre L.)
Re: substitute to a new string, leaving first unchaned (Tad McClellan)
Re: substitute to a new string, leaving first unchaned (Craig Berry)
Re: substitute to a new string, leaving first unchaned (Ronald J Kimball)
Re: substitute to a new string, leaving first unchaned <ff@creative.net>
Re: system call treats vars as literals... (perl 5.005) <uri@sysarch.com>
Re: system call treats vars as literals... (perl 5.005) (Tad McClellan)
weird telnet problem <samblack@earthlink.net>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Sep 1998 06:34:02 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: any way to encrypt my script?
Message-Id: <906618831.135006@thrush.omix.com>
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>snip<
: He said 'nobody who has *never* written or maintained, etc.' An
: unfortunate double negative. To rephrase, 'Only people who have ever
: written or maintained a compiler, interpreter, or other computer
: language translator should really be commenting in this thread.'
See, there's a problem here. Such a definition spans from GCC
down to super simple configuration file readers, and everything
in between. This is because there is code at every level between
these extremes, so to try and draw a line in the sand someplace
isn't going to get you very far.
Computers are binary, knowledge isn't. Knowledge isn't even
a gray scale, it's a rainbow. Please do not close your mind
to the ideas of the "lesser people", because by definition they
can bring a perspective you may not be able to see (for better
or worse).
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 24 Sep 1998 06:37:37 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: any way to encrypt my script?
Message-Id: <906619046.12687@thrush.omix.com>
Rich Grise <richgrise@entheosengineering.com> wrote:
: Tom Christiansen wrote:
: >
: [great wisdom excerpted]
: >
: > --tom
: > --
: > Someone who truly understands UNIX not only understands why "rm *"
: > screws you, but understands why IT HAS TO BE THAT WAY.
:
: Wouldn't that be
: $ rm -R *
: ?
: (or ``rm -r *'' - I can never remember which ones use the upper/lower
: case ``r'' for recursion)
-r, but that's not the point.
Typing
rm * ~
When you really meant
rm *~
Will silently remove *all* your files in the current directory and
then complain that it can not find the file '~'. Probably not
what was intended. :-)
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 24 Sep 1998 00:03:46 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Array of hashes: a better way?
Message-Id: <x73e9iw40t.fsf@sysarch.com>
>>>>> "AL" == Andre L <alecler@cam.org> writes:
AL> In article <saryaraecjg.fsf@camel.fastserv.com>, Uri Guttman
AL> <uri@camel.fastserv.com> wrote:
>> [snip]
>> i can't tell the difference between S and s!
AL> That's what happens to people who never use capitals. <smurk>
english is case insensitive! perl isn't :-)
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 24 Sep 1998 02:40:09 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Array of hashes: a better way?
Message-Id: <1dfu7cr.1s03pldb1swneN@bay2-418.quincy.ziplink.net>
John Porter <jdporter@min.net> wrote:
> If there weren't 2 pieces, $items[1] will be undef,
> and any time you use it like a string it'll look like ''.
Although he'd get a warning for using an unitialized value, since he's
got -w on the shebang line.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 24 Sep 1998 16:29:29 +1000
From: Stephan Carydakis <steph@hotkey.net.au>
Subject: file opened with "+>>" query
Message-Id: <3609E6C8.2285@hotkey.net.au>
Hello All,
I run a Win95 machine at home for developing running Perl 5.004_02. I
have written a CGI script that manages a simple database(flat text) and
am using the following code to write a new record to file:
####################################################
########## Write NEW REQUEST to DATABASE ##########
####################################################
sub new_req
{
my ($data);
print "<body>\n";
print "<font face=verdana size=3><b><u>Processing New Job
Request......Please Wait</u></b></font><br>\n";
print "<font face=verdana size=2><b>Getting File Lock....\n";
&lock("$jrf_db_lock");
open(FILE, "+>>$jrf_db_file") || &error("can't access database
File","$!");
print "getting new index....\n";
$index=0;
while (defined ($line = <FILE>) ) { $index++; }
print "$index</b></font><br>\n";
$data =
"$index:$FORM{sm}:$FORM{phe}:$FORM{djr}:$FORM{csnumb}:$FORM{csname}:$FORM{nwr}:$time:
: :\n";
print FILE "$data";
close(FILE);
&unlock("$jrf_db_lock");
## NOTE last 3 blank fields are for admin purposes and will show:
## 1.Processed(tag/un-tag) 2.Person Processing 3. date Processed
print "<font face=verdana size=2><b>writting new Job Request to
Database..</b></font><br>\n";
print "<font face=verdana size=2 color=#ff0000><b>New Job Request
successfully Entered into Database on the <font
color=#000000>$time</font></font></b><br>\n";
print <<"EOF";
<form action=user_jrf.cgi method=post>
<input type=hidden name=username value=$FORM{username}>
<input type=hidden name=password value=$FORM{password}>
<input type=hidden name=action value=get>
<input type=submit value="Make Another Job Request">
</form>
EOF
}
################################################
## Get a file lock. work-around for win95 ##
################################################
sub lock
{
local($lock_file) = @_;
local($timeout);
$timeout=20; # in seconds
print "<b>WAITING FOR LOCK</b>\n<br>";
while (-e $lock_file && (stat ($lock_file))[9] + $timeout > time) {
sleep(1);
}
open(LOCK_FILE, ">$lock_file") or &error('cant get file lock',"$!");
print LOCK_FILE "temp file";
print "<b>Got File Lock....</b>\n";
}
################################################
## Unlock the file. work-around for win95 ##
################################################
sub unlock
{
local($lock_file) = @_;
close(LOCK_FILE);
unlink($lock_file);
1;
}
On 5.004_02 Perl at home, this works fine. But on the clients ISP's
machine (NT4 IIS4) runing ActiveWare version 5.003_07, the file doesnt
get anything written to it. It does get created, but nothing is written.
Is it something to do with the way I'm opening the file("+>>")? I
realise I can first open it for reading, get the new index, then open it
for appending and write to it, but I would like to do it the way I am
now.
My question is why does it work at home and not on ISP. Is it the
different versions of Perl. Does ActiveWare 5.003_07 support opening a
file for read/write ?? Or is this not a Perl issue at all?? If it isn't,
I appologise for wasting your time.
Thankyou in advance.
______________________________________________________
Stephan Carydakis steph@hotkey.net.au
______________________________________________________
------------------------------
Date: Thu, 24 Sep 1998 02:40:10 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: File Reading
Message-Id: <1dfu7qv.1jy8qo1c2zpcN@bay2-418.quincy.ziplink.net>
Reiner <slug@labyrinth.net.au> wrote:
> The problem is if the $question does not exist. I tried things like the
> line below but had no luck.
> while ((<FILE> != $question)) && (!$!) { }
I don't know that $! gets set if you try to read past the end of a file.
while (defined($line = <FILE>) && $line != $question) { }
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 24 Sep 1998 02:40:11 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to count match pattern?
Message-Id: <1dfu7xu.pi3d6l1g0kafmN@bay2-418.quincy.ziplink.net>
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
> Hmm... In other words, if you do s/pattern/replace/g;, you want to know
> how many times the replacement occured?
>
> That's a good question. I don't know of a straightforward way to do it.
You just can't cancel a stupid post fast enough. Sigh...
:-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 24 Sep 1998 06:57:40 GMT
From: mt@dev.null (Mads Toftum)
Subject: Re: How to post via HTTPS
Message-Id: <360aec36.899980@news.inet.tele.dk>
On Thu, 24 Sep 1998 06:55:57 GMT, harry@dublin.net (Harry) wrote:
> I was just wondering how I post via https. I have downloaded
> SSLeay & have the Perl modules to connect to a secure-host.
>
> Although, I'm really confused as to how I post.
[snip]
> Anyone have any tips?
Basically just RTFM - if you're using the Net::SSLeay module, then it
has an example as part of it's documentation. If you're using
Crypt-SSLeay, then you should read the LWP documentation and use HTTPS
as the protocol instead of HTTP.
vh.
Mads Toftum, (QDPH/JAPH)
---
A computer lets you make more mistakes faster than any other
invention, with the possible exceptions of handguns and Tequilla.
-- Mitch Ratcliffe
------------------------------
Date: 24 Sep 1998 06:41:58 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: IO::Select Problems
Message-Id: <uiuienk2h.fsf@jimbosntserver.soundimages.co.uk>
"Edwin S. Ramirez" <edwin.ramirez@erols.com> writes:
> line from the socket and then return to the select statement. However, if
> there are multiple lines waiting in the socket, once I read a single line
> from the socket, select does not return any sockets from the can_read
> statement. It does not realize that there is data already in the socket and
> it does not return when new data arrives.
Yeah, use sysread to get the data from the socket. This will return a
string that you can then break into lines if you want.
>From the perlfunc man page:
WARNING: Do not attempt to mix buffered I/O (like read() or <FH>) with
select(). You have to use sysread() instead.
>From the perlfunc man page:
sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
sysread FILEHANDLE,SCALAR,LENGTH
Attempts to read LENGTH bytes of data into variable SCALAR from the
specified FILEHANDLE, using the system call read(2). It bypasses
stdio, so mixing this with other kinds of reads, print(), write(),
seek(), or tell() can cause confusion because stdio usually buffers
data. Returns the number of bytes actually read, or undef if there was
an error. SCALAR will be grown or shrunk so that the last byte
actually read is the last byte of the scalar after the read. An
OFFSET may be specified to place the read data at some place in the
string other than the beginning. A negative OFFSET specifies placement
at that many bytes counting backwards from the end of the string. A
positive OFFSET greater than the length of SCALAR results in the
string being padded to the required size with ``\0'' bytes before the
result of the read is appended.
I suspect this may be part of the problem you are having. Buffered IO
means you have to change the way you work. While <> is real handy for
reading it does not mix well with select. It does not also mix well
with binary data where new lines may be few and far between. If you
are passing large amounts of binary data around then sysread will
provide you the means to get the data in chunks that you can work with
without putting you in a blocked state, like buffered IO.
Once you are finished reading the socket, remove it from the list of
readable sockets. If you want to read that socket again, say after you
have written data to the client, add the socket back to select for
read state monitoring. To repeat: When using select, YOU have to be
the IO buffer, not the system. You have to keep track of the data you
are reading, like how much you've read so far and when there is no
more data left to read. You may even be done with the socket while
data is still available to be read.
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: Thu, 24 Sep 1998 00:14:30 -0400
From: Sameer Sharma <sameers@ece.rutgers.edu>
Subject: leading space
Message-Id: <3609C726.5345@ece.rutgers.edu>
Hi,
If I read in the contents of a file into an array and then print it, I
get leading space in each of the elements but the first one.
e.g.
@bench = <FILE_BENCH>;
close (FILE_BENCH);
open (FILE_BENCH, ">$file_bench");
print FILE_BENCH ("@bench");
close (FILE_BENCH);
Since I am new at Perl, I could not find any direction from the
docs/FAQs.
Hopefully someone can tell me precisely what is wrong here.
Sameer
------------------------------
Date: Wed, 23 Sep 1998 23:53:40 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: leading space
Message-Id: <k8jcu6.207.ln@flash.net>
Sameer Sharma (sameers@ece.rutgers.edu) wrote:
: If I read in the contents of a file into an array and then print it, I
: get leading space in each of the elements but the first one.
Because you asked for a space to be inserted between array elements.
: e.g.
: @bench = <FILE_BENCH>;
: close (FILE_BENCH);
: open (FILE_BENCH, ">$file_bench");
Even "sample code" should check the return value from open() calls.
Really.
open (FILE_BENCH, ">$file_bench") ||
die "could not open '$file_bench' $!";
Let's not get a bunch of bad sample code around for people to copy...
: print FILE_BENCH ("@bench");
^ ^
^ ^ delete those two characters. Don't ask for
stuff if you don't want stuff ;-)
: close (FILE_BENCH);
: Since I am new at Perl, I could not find any direction from the
: docs/FAQs.
from the 'perlvar' man page:
------------------------
=item $LIST_SEPARATOR
=item $"
This is like "C<$,>" except that it applies to array values interpolated
into a double-quoted string (or similar interpreted string). Default
is a space. (Mnemonic: obvious, I think.)
------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Sep 1998 05:09:23 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: leading space
Message-Id: <6uck63$1tf$3@marina.cinenet.net>
Sameer Sharma (sameers@ece.rutgers.edu) wrote:
: If I read in the contents of a file into an array and then print it, I
: get leading space in each of the elements but the first one.
I'm assuming there's an assumed open up here, and that you're checking its
result. :)
: @bench = <FILE_BENCH>;
: close (FILE_BENCH);
: open (FILE_BENCH, ">$file_bench");
You might want to use '+<' open mode and seek to avoid all this open/close
dancing. You definitely want to check the result of that open.
: print FILE_BENCH ("@bench");
Doublequotes are doing bad voodoo on you. See perldoc perlvar, the entry
on $". Might I ask why you thought either the parens *or* the quotes in
that last line were necessary or desirable?
: close (FILE_BENCH);
:
: Since I am new at Perl, I could not find any direction from the
: docs/FAQs.
Could you explain that, please? I should think that the opposite would be
true, that a newcomer to Perl would get maximum value from these
resources. Of course, as I do with all Perl neophytes, I very highly
recommend you get the Llama book as well.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Wed, 23 Sep 1998 22:38:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Manipulating Single lines in file...
Message-Id: <6recu6.di6.ln@flash.net>
The Astrochicken (agn@cryogen.com) wrote:
: pretty much what i want to
: know is how to delete individual lines from a 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?"
: If you can provide
: information that would help me, it would be greatly appreciated. Thank
: you.
You had already been provided that information before you posted!
It came with the perl distribution.
I dunno why you are asking it here, yet again...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Sep 1998 22:22:35 PDT
From: "Phlip" <new_email@see.web.page>
Subject: NT 4 + PWS 4 vs PERL 5 + CGI
Message-Id: <6uckur$fh5@chronicle.concentric.net>
Groupies.
To decode the above acronyms, I have Windows NuT 4 and Personal Web
Server. I'm trying to install PERL 5 so I can gate to it with
http://localhost/cgi-bin/hello.pl
Ever since running the batch file "perlw32-install.bat" that came with
PERL 5 for NT, when I point IE4 at that URL I get a very slow crawl,
then the browser times out waiting for a page.
It's as if PERL started but PWS never figured out it ended and never
sent the page it output. If there were an installation problem or
security problem PWS would have bounced an error page back instantly.
The following responses will not help:
Read the FAQ.
Use www.dejanews.com and scan for "PERL and PWS and hang".
Switch to another language/platform/web server.
Scan MS's knowledge base.
Set PERL.EXE to Read/Execute permissions for the Guest role in the
NTFS file settings.
Set CGI-BIN to Script, Read and Execute permissions in PWS's virtual
directory tree.
Add the .pl extension to the ScriptMap node of the Registry
settings.
Change the CreateProcessWithNewConsole setting in the Registry.
Use PERLis.DLL.
Thanks in advance!
-- Phlip (no replies - address munged)
======= http://users.deltanet.com/~tegan/home.html =======
-- All sensors report Patti having a very good time --
------------------------------
Date: 24 Sep 1998 05:41:44 GMT
From: "bjohnsto_usa_net" <bjohnsto_usa_net@my-dejanews.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <01bde77e$0bd13f00$b516b3d1@lhodgkiss>
> > Zenin <zenin@bawdycaste.org> wrote:
> [...] My understanding is that Java byte code can't do lambda
> >> style functions for instance, thus making things like a Java
> >> byte code backend for Perl [...]
>
David Formosa <dformosa@zeta.org.au> wrote in article
> A lambda style function is a function that has no name. For example in
> perl I can go,
>
> $var = sub {
> $x =shift;
> $y =shift;
> return $x+$y;
> }
>
> and in lisp I can go
>
> (setf var (lambda (x y) (+ x y)))
>
> The function is now only advalable via the verable that it has been
assigned
> to it.
Is a lambda style function functionally different to inner classes?
I find that inner classes do what I could use smalltalk code blocks [ ... ]
for.
Here is how an inner class looks.
public class lambda
{
interface ifunc
{
public double f(double d);
}
public static void main(String args[])
{
ifunc o1 = new ifunc() { public double f(double d) { return d * 2; }
};
ifunc o2 = new ifunc() { public double f(double d) { return d * 3; }
};
System.out.println("ifunc 4.0 - " + o1.f(4.0)+ "\n");
System.out.println("ifunc 4.0 - " + o2.f(4.0)+ "\n");
}
}
Although the SIGNATURE of the function has a name (ifunc.f) the actual
functions do not.
Java typed solution is definitely more verbose than the other languages.
If there is some design which needs lambda style functions instead of inner
classes I would be interested.
Brendan Johnston
------------------------------
Date: 24 Sep 1998 00:26:44 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl with use/require doesn't work under cron
Message-Id: <x7zpbquoe3.fsf@sysarch.com>
>>>>> "b" == bobmorgan <bobmorgan@my-dejanews.com> writes:
b> Hi, I have a perl script that that uses "use myPackage;". The
b> script works fine from the command line (AIX 4.1.4). When I try and
b> run the script as a cron job, the script never runs. I tested this
b> by using some print statements to a file and they never show up
b> when under cron but work fine when run from the command line.
b> The packages that I am using are some of my own located in the
b> same directory as the script.
cron doesn't cd to any special directory so your script can find the
packages. when you run them locally they are found. there are several
ways to fix this:
set PERL5LIB to contain the path to the modules before the script is run
in cron. this can be doen with the env command in the crontab file
put this in the script
use lib 'path_to_modules' ;
hth,
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 24 Sep 1998 07:07:02 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <uhfxyniwp.fsf@jimbosntserver.soundimages.co.uk>
Randal Schwartz <merlyn@stonehenge.com> writes:
>
> Let's say the word "free" means "with peanut butter"
>
> (ducking)
So let's get this straight. With every jar of Skippy, creamy or
chunky, I get a Perl latest.tar.gz? Now, is this in the jar (like in a
ceral box) or is it attched (by some means currently ill-defined) to
the outside of the jar? Will it add much to the cost of Skippy? Or,
will the fear of such a potent Skippy cause a downturn in Skippy
uptake and therefore a radical re-pricing making Skippy much less
expensive and by extension my latest.tar.gz even free-er?
Personally, I hate peanut butter. Can we say "free" means "large
double pepperoni with extra cheese"? Now where do they attach the
latest.tar.gz?
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: Thu, 24 Sep 1998 02:40:12 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <1dfu8tm.1m4h1021dan281N@bay2-418.quincy.ziplink.net>
John Porter <jdporter@min.net> wrote:
> From what resource(s) did you learn Perl?
I learned Perl mainly from the first Camel book, mixed with some
studying of existing code.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 24 Sep 1998 02:40:16 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <1dfu9ec.1bvhm3g1umrwbyN@bay2-418.quincy.ziplink.net>
John Porter <jdporter@min.net> wrote:
> Andrea Spinelli wrote:
> >
> > if ( $#a < 0 ) {
> > my ($k,$v) = each %h;
> > @a = ($k);
> > }
>
> This is an excellent way of doing it -- as long as you
> truly don't care how the element is chosen.
> If you actually need randomness, then you could do
> something with keys() and rand().
And as long as you don't care if @a is assigned the list (undef) if the
each iterator for %h happens to be at the end of the hash...
DB<1> %h = (a => 1, b => 2, c => 3)
DB<2> for (1..3) { each %h }
DB<3> if ($#a < 0) { @a = scalar each %h }
DB<4> X a
@a = (
0 undef
)
DB<5>
Perhaps it's not such an excellent way of doing it after all.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 24 Sep 1998 08:49:34 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Question about Sendmail, Perl, and CGI
Message-Id: <83ww6udmyp.fsf@vcpc.univie.ac.at>
Re: Question about Sendmail, Perl, and CGI, Patrick
<phunter@hass.usu.edu> said:
Patrick> writing samples online as well, using the file
Patrick> upload feature of Netscape. I would then want the
Patrick> submitted files to be included as attachments when
Patrick> sendmail sends the data to the recipient.
perldoc CGI
perldoc Mail::Send
perldoc MIME::Base64
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Thu, 24 Sep 1998 02:40:17 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Regular Expression Beautifier
Message-Id: <1dfu9n6.1ac1kgt1y2x2rjN@bay2-418.quincy.ziplink.net>
Daniel Grisinger <dgris@rand.dimensional.com> wrote:
> regdecl is a regular expression beautifier that
> accepts a regular expression as input and generates
> a formatted, commented, regular expression as output.
> ( # Start capturing group
> walla-walla # The literal string `walla-walla'
> ) # End group
For capturing groups, the group's number should be output. In other
words, does this group correspond to \1, \2, \3, ...?
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 23 Sep 1998 22:48:00 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Sorting Array Of Directories via ABC, not date...
Message-Id: <gdfcu6.di6.ln@flash.net>
Vikram Pant (nospam@wam.umd.edu) wrote:
: I was wondering if a Perl function existed that sorts arrays by ABC?
Perl FAQ, part 4,
"How do I sort an array by (anything)?"
The reason the FAQ was created was so that there wouldn't be
yet more repetitions of these things.
You have spit in the face of the folks that went to the trouble of
compiling the FAQ by ignoring it and asking yet again in
the newsgroup.
They deserve better than that...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 24 Sep 1998 00:39:31 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Sorting Array Of Directories via ABC, not date...
Message-Id: <alecler-2409980039310001@dialup-513.hip.cam.org>
In article <MPG.10733393e42bcb059897b7@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:
> In article <MPG.10734b2291b9063098969c@news.wam.umd.edu> on Wed, 23 Sep
> 1998 19:15:32 -0400, Vikram Pant <nospam@wam.umd.edu> says...
> ...
> > I was wondering if a Perl function existed that sorts arrays by ABC?
>
> Yes, there is. Its name is 'sort' (how's that for a surprise?).
>
> Do `perldoc -f sort` and look at the examples.
Also worth looking into is perlfaq4, "How do I sort an array by (anything)?".
Andre
------------------------------
Date: Wed, 23 Sep 1998 21:47:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: substitute to a new string, leaving first unchaned
Message-Id: <osbcu6.sd6.ln@flash.net>
due@discovernet.net wrote:
: Can someone provide some help for the following.
: I want to take an array, use s/// to find something and change it but leave
^^^^^^^^^
: the original unchanged and write the change to a new var. Is there a one
^^^^^^^^^
You cannot both change it and leave it unchanged.
That is a contradiction...
: liner to do this?
: I am using:
: $foo = 'one two three';
: $bar = $foo;
: $bar =~ s/one/une/;
: but I would like to do it all at once like:
: $bar = $foo =~ s/one/une/;
: but $bar here is 1 as the substitution is successful. I have tried () in
: various places without success. Any suggestions?
Try () in the correct place ;-)
($bar = $foo) =~ s/one/une/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Sep 1998 05:02:37 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: substitute to a new string, leaving first unchaned
Message-Id: <6ucjpd$1tf$2@marina.cinenet.net>
due@discovernet.net wrote:
: I want to take an array, use s/// to find something and change it but leave
: the original unchanged and write the change to a new var. Is there a one
: liner to do this?
:
: I am using:
: $foo = 'one two three';
: $bar = $foo;
: $bar =~ s/one/une/;
: but I would like to do it all at once like:
:
: $bar = $foo =~ s/one/une/;
:
: but $bar here is 1 as the substitution is successful. I have tried () in
: various places without success. Any suggestions?
You *almost* had it (and it's one of my favorite idioms, the old
copy-through-a-filter):
($bar = $foo) =~ s/one/une/;
Never forget that in Perl, assignment yields an lvalue. That and the
logical operators returning the values encountered rather than simple
booleans are my two favorite things about Perl expressions.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Thu, 24 Sep 1998 02:40:18 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: substitute to a new string, leaving first unchaned
Message-Id: <1dfu9zg.98blditfasmmN@bay2-418.quincy.ziplink.net>
<due@discovernet.net> wrote:
> but I would like to do it all at once like:
>
> $bar = $foo =~ s/one/une/;
>
> but $bar here is 1 as the substitution is successful. I have tried () in
> various places without success. Any suggestions?
Try them like this:
($bar = $foo) =~ s/one/une/;
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 23 Sep 1998 23:49:28 -0700
From: Farhad Farzaneh <ff@creative.net>
To: due@discovernet.net
Subject: Re: substitute to a new string, leaving first unchaned
Message-Id: <3609EB78.89EDEA92@creative.net>
Just put parens around your assignment:
($bar = $foo) =~ s/one/une/;
will first assign $bar, then run the replacement on it.
due@discovernet.net wrote:
>
> Can someone provide some help for the following.
>
> I want to take an array, use s/// to find something and change it but leave
> the original unchanged and write the change to a new var. Is there a one
> liner to do this?
>
> I am using:
> $foo = 'one two three';
> $bar = $foo;
> $bar =~ s/one/une/;
> but I would like to do it all at once like:
>
> $bar = $foo =~ s/one/une/;
>
> but $bar here is 1 as the substitution is successful. I have tried () in
> various places without success. Any suggestions?
>
> Bob
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 24 Sep 1998 00:14:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: system call treats vars as literals... (perl 5.005)
Message-Id: <x71zp2w3j1.fsf@sysarch.com>
>>>>> "PP" == Paul Pazandak <pazandak@OBJS.com> writes:
PP> system ( 'cat i:\foo.txt $_ > $mytmpfile');
PP> print "Processing file: $_" ;
what is different about the above 2 string literals? can you tell the
difference? (i feel like singing from sesame street, "which one these is
different from the others")
PP> so, why is the variable handled like a literal in the system call??????
PP> Were's this darn oddity documented in "Programming Perl"?
all over the plce but starting on p. 39 you might read about string
literals.
and it ain't no oddity. it is a normality (sic).
PP> [please respond directly to me.]
i would have if you didn't ask :-)
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 23 Sep 1998 23:27:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: system call treats vars as literals... (perl 5.005)
Message-Id: <mmhcu6.mq6.ln@flash.net>
Paul Pazandak (pazandak@OBJS.com) wrote:
: I am trying to simply call cat (win95) with three vars, but they are treated as literals...
: Why?
Because you _asked_ for them to be treated as literals.
(you put them in single quotes)
: system ( 'cat i:\foo.txt $_ > $mytmpfile');
: Doing a print works:
: print $_ ;
: or
: print "Processing file: $_" ;
See? They get expanded when you use double quotes...
: so, why is the variable handled like a literal in the system call??????
It is not the system() call (not "system call").
It is the quotes that you chose.
Choose the other kind of quotes ;-)
: Were's this darn oddity documented in "Programming Perl"?
On page 39 (second edition).
But you don't need Programming Perl to find the documentation
for this so-called "oddity".
It comes with the perl distribution.
It is already on your hard disk.
It is sometimes called the 'perldata' man page:
"String literals are usually delimited by either single or double
quotes. They work much like shell quotes: double-quoted string
literals are subject to backslash and variable substitution;
single-quoted strings are not"
: [please respond directly to me.]
Nope.
If we do that, then nobody else gets access to the answer.
That is an altogether too selfish approach to find much support
amongst the open and free (with peanut butter ;-) Perl community.
You should hire a consultant if you want individual attention.
Ask it here, get the answer here.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 24 Sep 1998 01:07:48 -0700
From: MadMonkey <samblack@earthlink.net>
Subject: weird telnet problem
Message-Id: <3609FDD4.86FED07C@earthlink.net>
I finally figured out how to use IPC::open2 to talk to telnet. But when
I connect to a remote host telnet spits this out:
trying 111.111.11.1....
connected to mymother.com ------- and then stops. It never gives me the
login: prompt.
Why does it just sit there? When I run it outside the script it works
fine.
Thanks
J
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3809
**************************************