[9353] in Perl-Users-Digest
Perl-Users Digest, Issue: 2948 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 23 13:07:57 1998
Date: Tue, 23 Jun 98 10:00:25 -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 Jun 1998 Volume: 8 Number: 2948
Today's topics:
a bit confused about seek <quednauf@nortel.co.uk>
Re: a bit confused about seek <jdporter@min.net>
Re: after 5 hrs, the beginner beats the s/// <*@qz.to>
Re: CGI Help Please <altenbur@ncsa.uiuc.edu>
RE: Compiling 5.004_04 for IRIX 6.4 <gzajdel@interv.com>
Error creating file <altenbur@ncsa.uiuc.edu>
Re: Error creating file <tchrist@mox.perl.com>
Re: Error creating file <altenbur@ncsa.uiuc.edu>
Re: first language (Kaz Kylheku)
Re: Flames.... <merlyn@stonehenge.com>
Re: How can I get the IP-Number & the Remote_Host Name <mhofer@lady.ny.jpmorgan.com>
Re: How can I get the IP-Number & the Remote_Host Name (Larry Rosler)
Re: How to test perl on my windows95 home computer...? <danboo@negia.net>
Re: Learning Perl; (i.e. newbie question) <rootbeer@teleport.com>
Re: MD5 and Perl4 <rootbeer@teleport.com>
Problem with I/O <jeff@uen.org>
Re: Problem with I/O <rootbeer@teleport.com>
Re: QUESTION: Why does only one of these work? <rootbeer@teleport.com>
Re: Sending mail in Perl <xuming@email.unc.edu>
stylistic remote array passing (Thomas Frederick O'Connell)
Re: Weekdays <-> Dates <mhofer@lady.ny.jpmorgan.com>
Re: Writing Perl extensions in languages other than C/C (Ken Fox)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Jun 1998 16:57:19 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: a bit confused about seek
Message-Id: <358FD05F.99592243@nortel.co.uk>
Hi there,
I did a little experiment on seek (I can't decide if I should jump around in the
file or slurp in completely into memory) - anyways, that's the program:
open FILE, "< /u/quednauf/temp/testfile.txt" or die "didn't happen: $!";
for ($i =0; $i <=8; $i++) {
seek FILE, $i, 0 or die "Jumped off the cliff: $!";
print <FILE>;
}
It works on the following file:
0
1
2
3
4
5
6
7
8
9
10
(There is a \n behind the '10')
As output I get:
0
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
2
3
4
And so on: I can't quite see why...
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 23 Jun 1998 16:14:29 GMT
From: John Porter <jdporter@min.net>
Subject: Re: a bit confused about seek
Message-Id: <358FD608.2270@min.net>
F.Quednau wrote:
>
> I did a little experiment on seek (I can't decide if I should jump around in the
> file or slurp in completely into memory) - anyways, that's the program:
>
> open FILE, "< /u/quednauf/temp/testfile.txt" or die "didn't happen: $!";
> for ($i =0; $i <=8; $i++) {
> seek FILE, $i, 0 or die "Jumped off the cliff: $!";
> print <FILE>;
> }
Dude, print takes a list of arguments, so <FILE> is in a list
context: it returns every (remaining) line in the file!
--
John Porter
------------------------------
Date: 23 Jun 1998 16:03:58 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <eli$9806231201@qz.little-neck.ny.us>
In comp.lang.perl.misc, Tom Christiansen <tchrist@mox.perl.com> wrote:
> In comp.lang.perl.misc,
> gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
> :I personally find it funny that it took SEVEN (at this count) people
> :to show this guy up.
>
> None of whom (modulo me) actually provided the proper answer.
Then a quote in the sig:
> If I had any humility I would be perfect.
Gee, I wonder why some people find Tom arrogant?
Elijah
------
thinks telling someone where to find the answer is not "providing" it
------------------------------
Date: Tue, 23 Jun 1998 11:11:07 -0500
From: david lee altenburg <altenbur@ncsa.uiuc.edu>
Subject: Re: CGI Help Please
Message-Id: <358FD39A.C5D29BFD@ncsa.uiuc.edu>
Hi,
Is there any whitespace between "ending_print_tag" (the one at the end) and
the beginning of the line? If there is a tab, a space, anything before the
"ending_print_tag", it will not be found. I'm not sure if that's what it is,
but when I get an error such as your, 90% of the time. it's because I had tabs
between the beginng of the line and the "end_of_print"...or whatever i used.
HTH,
David Altenburg
altenbur@ncsa.uiuc.edu
Dr.V wrote:
> I'v been working on this for weeks now and i can't find the problem.
> Can anyone tell me what is wrong with this program?
> when i test it using my computer, using perl5 for windows 95/nt it does'nt
> give me an error code. so i then put it on the server and try it.
> I log in useing telnet and check it there. and i get this error.
>
> Can't find string terminator "ending_print_tag" anywhere befor EOF at
> first.cgi line 4.
>
> #!/usr/bin/perl5
> print "content-type: text/html\n\n";
>
> print = <<'ending_print_tag';
> <html>
> <head>
> <title> My first CGI </title>
> <background="#000000" text="#FF0000" >
> </head>
> <body>
> <h1> My First CGI </h1>
> <em> HELLO, INTERNET! </em>
> <hr noshade>
> Watch out cyber space, i'm on the loose
> </body>
> </html>
> ending_print_tag
>
> So you know this is out a CGI Programing book .
> I have had no luck running any cgi scripts at all.
> I tryed FormMail and other Form scripts and all i get is the 500 internal
> server error.
> The script above was tried cus it's a very simple script, just to see if it
> would work.
> I also have this script being ran from the test web page.
> the address is www.capequip.com/first.htm
>
> I would be very appreciate any help or clues in cureing my frustration.
>
> DrV.
------------------------------
Date: Tue, 23 Jun 1998 09:24:34 -0700
From: Greg Zajdel <gzajdel@interv.com>
Subject: RE: Compiling 5.004_04 for IRIX 6.4
Message-Id: <358FD6C2.F2EF899E@interv.com>
Has anyone been successful at this. I have a C compiler loaded and it
works if I give it the path name. However as I do an sh Configure and
except all the defaults under [ irix_6 ] it complains that it can't find
my C compiler.
Anyone have any luck compiling this successfully?
Greatly appreciate any help
Regars
Greg Zajdel
------------------------------
Date: Tue, 23 Jun 1998 11:00:27 -0500
From: david lee altenburg <altenbur@ncsa.uiuc.edu>
Subject: Error creating file
Message-Id: <358FD11B.F862BFEF@ncsa.uiuc.edu>
Hi,
When I run the code found below, I keep getting a "bad file number"
error. If any of you knowlegeable folks would be willing to let me in
on what's causing the error, I would greatly appreciate it.
Here's the code:
...lots o other code, where $CourseTitle and $output are defined......
$dirname = "/FOO/coursefiles/" . $CourseTitle;
$filename = "description.html";
$dirname =~ tr/ /_/;
&addToCatalog(@data);
mkdir($dirname, 0777);
open( COURSEFILE, ">$dirname/$filename" );
flock(COURSEFILE, LOCK_EX);
print COURSEFILE $output;
close(COURSEFILE);
.... a bit more code that does other things....
at the line where i try to open the file, i get a "bad file number"
error, and the file is not opened.
Any help would be greatly appreciated!
TIA,
David Altenburg
altenbur@ncsa.uiuc.edu
"Life is like a box of chocolates. A cheap, thoughtless, perfunctory
gift
that nobody ever asks for. Unreturnable, because all you get back is
another
box of chocolates. So, you're stuck with this undefinable whipped mint
crap
that you mindlessly wolf down when there's nothing else left to eat.
Sure,
once in a while, there's a peanut butter cup, or an english toffee, but
they're gone too fast, and the taste is ... fleeting. So you end up
with
nothing but broken bits filled with hardened jelly and teeth-shattering
nuts.
And if you're desperate enough to eat those, all you've got left is an
empty
box filled with useless brown paper wrappers."
-Cigarette Smoking Man
------------------------------
Date: 23 Jun 1998 16:19:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Error creating file
Message-Id: <6mokin$ls4$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
altenbur@ncsa.uiuc.edu writes:
: open( COURSEFILE, ">$dirname/$filename" );
: flock(COURSEFILE, LOCK_EX);
You lose. You clobber, then lock. Bad.
--tom
--
/* Force them to make up their mind on "@foo". */
--Larry Wall, from toke.c in the v5.0 perl distribution
------------------------------
Date: Tue, 23 Jun 1998 11:27:27 -0500
From: david lee altenburg <altenbur@ncsa.uiuc.edu>
Subject: Re: Error creating file
Message-Id: <358FD76F.B9AEC58B@ncsa.uiuc.edu>
--------------E4819E9C07BCEE9FFA3C2645
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Tom Christiansen wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> altenbur@ncsa.uiuc.edu writes:
> : open( COURSEFILE, ">$dirname/$filename" );
> : flock(COURSEFILE, LOCK_EX);
>
> You lose. You clobber, then lock. Bad.
Do you mean that I shouldn't lock the file after opening it up for
writing? That makes sense (I didn't really think about it), but
removing the flock doesn't change anything, as far as the error I'm
getting. Oh, well. Thanks anyway. Have any other ideas?
Thanks,
David Altenburg
altenbur@ncsa.uiuc.edu
--
"Life ... is like a box of chocolates. A cheap, thoughtless, perfunctory gift
that nobody ever asks for. Unreturnable, because all you get back is another
box of chocolates. So, you're stuck with this undefinable whipped mint crap
that you mindlessly wolf down when there's nothing else left to eat. Sure,
once in a while, there's a peanut butter cup, or an english toffee, but
they're gone too fast, and the taste is ... fleeting. So you end up with
nothing but broken bits filled with hardened jelly and teeth-shattering nuts.
And if you're desperate enough to eat those, all you've got left is an empty
box filled with useless brown paper wrappers."
-Cigarette Smoking Man
--------------E4819E9C07BCEE9FFA3C2645
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
Tom Christiansen wrote:
<BLOCKQUOTE TYPE=CITE> [courtesy cc of this posting sent to cited
author via email]
<P>In comp.lang.perl.misc,
<BR> altenbur@ncsa.uiuc.edu writes:
<BR>: open( COURSEFILE, ">$dirname/$filename" );
<BR>: flock(COURSEFILE, LOCK_EX);
<P>You lose. You clobber, then lock. Bad.</BLOCKQUOTE>
Do you mean that I shouldn't lock the file after opening it up for writing?
That makes sense (I didn't really think about it), but removing the flock
doesn't change anything, as far as the error I'm getting. Oh, well. Thanks
anyway. Have any other ideas?
<P>Thanks,
<P>David Altenburg
<BR>altenbur@ncsa.uiuc.edu
<PRE>--
"Life ... is like a box of chocolates. A cheap, thoughtless, perfunctory gift
that nobody ever asks for. Unreturnable, because all you get back is another
box of chocolates. So, you're stuck with this undefinable whipped mint crap
that you mindlessly wolf down when there's nothing else left to eat. Sure,
once in a while, there's a peanut butter cup, or an english toffee, but
they're gone too fast, and the taste is ... fleeting. So you end up with
nothing but broken bits filled with hardened jelly and teeth-shattering nuts.
And if you're desperate enough to eat those, all you've got left is an empty
box filled with useless brown paper wrappers."
-Cigarette Smoking Man</PRE>
</HTML>
--------------E4819E9C07BCEE9FFA3C2645--
------------------------------
Date: Tue, 23 Jun 1998 16:25:06 GMT
From: kaz@cafe.net (Kaz Kylheku)
Subject: Re: first language
Message-Id: <6mokht$utq@espresso.cafe.net>
In article <6mmma7$bgc$1@user1.teleport.com>,
Paul Buder <paulb@user1.teleport.com> wrote:
>In <6mlctf$vam$1@nnrp1.dejanews.com> raw@cs.wisc.edu writes:
>
>>"The case like this" was concerned with an early stage of learning: in C,
>>you must either supply non-standard input routines (which must at
>>some point be unlearned) or use scanf (with an explanation of pointers
>>in order to understand &, or with no explanation at all). The best option
>
>All this talk of scanf. I hope you people don't actually use that
>horrid function in your C code. Can you say buffer overflow? fgets
>and fread take a little more work sometimes but at least you can
>control the size of things getting put into your variables.
Maybe you should read a little about the definition of scanf. There are indeed
ways to control how many characters are converted, using the appropriate
conversion specififers.
When used properly, scanf can be a precise tool that does the job, can be
safe. Of course, it is unfortunate that it can also be used unsafely, but
there are certain situations in which you know that the input won't overflow
(because, for example, it comes from a file that was generated by the same
software) so you can make a case for using the simple conversion specifiers
like %s .
The scanf function has been critizied for being bad for interactive user
input, because it is not easy to synchronize the act of obtaining data from
the user with actions taken by scanf and the surrounding parser, and error
recovery is tricky. When the scanf() function returns, you have no idea how
much unconsumed input remains even if the user just typed one line. Thus you
can't make a meaningful decision about error recovery. Furthermore, if the
user types an insufficient number of tokens and then ends the line, scanf will
not terminate---yet the user has no way to make a correction because the data
from the previous line has already passed into the stdin buffer.
------------------------------
Date: Tue, 23 Jun 1998 16:55:15 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Flames....
Message-Id: <8c67hs6ot4.fsf@gadget.cscaper.com>
>>>>> "birgitt" == birgitt <birgitt@my-dejanews.com> writes:
birgitt> Abigail said once here a couple of weeks ago, that the downfall
birgitt> of usenet started with the invention of the "post" button on your
birgitt> news reader (round about).
I think that's a misquote *and* a misattribution. It was me who has
said repeatedly:
One of the most significant events in the "dumbing down" of Usenet
was the day that Netscape added a "POST" button to their *web browser*
making it pretend to be a newsreader (which it STILL isn't).
And that's why people still routinely killfile any postings from web
browsers. Ugh. (I don't, but I think about it very often.)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 69 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 23 Jun 1998 12:21:21 -0400
From: "Michael D. Hofer" <mhofer@lady.ny.jpmorgan.com>
Subject: Re: How can I get the IP-Number & the Remote_Host Name
Message-Id: <358FD601.5EA5@lady.ny.jpmorgan.com>
Um, sometimes there are other variables. Try:
#!/opt/perl5.004/bin/perl
print "Content-type: text/html\n\n";
print "<html><head><title>Environment</title></head><body>\n";
print "<h1>Environment Variables:</h1>\n";
foreach $key (sort keys %ENV){
print "\t$key:\t$ENV{$key}<br>\n";
}
print "</body></html>\n";
as a cgi script to get the complete set for the particular situation.
Especially proxy settings can alter the list you get.
michael
F.Quednau wrote:
>
> Alex T wrote:
> >
> > Hello...
> > How can I get the IP-Number & the Remote_Host Name from a user who is
> > running my
> > CGI-Application?
>
> A script lying around in my cgi-bin, I use it as a reference...
>
> #!/opt/corp/local/perl-5.004/bin/perl5.00404 -w
> #
> # CGI script to print out the relevant environment variables.
> # It's just one big print statement, but note the use of the
> # associative %ENV array to access the environment variables.
> #
>
> print "Content-type: text/html
>
> <head>
> <title> CGI Tutorial: Environment variables script</title>
> </head>
> <body>
>
> <hr>
> <h1> Environment variables script</h1>
> <hr>
>
> <p>
>
> Here are the environment variables that this CGI script has been
> called with.
>
> <p>
> <hr>
>
> <pre>
> SERVER_SOFTWARE = $ENV{'SERVER_SOFTWARE'}
> SERVER_NAME = $ENV{'SERVER_NAME'}
> GATEWAY_INTERFACE = $ENV{'GATEWAY_INTERFACE'}
> SERVER_PROTOCOL = $ENV{'SERVER_PROTOCOL'}
> SERVER_PORT = $ENV{'SERVER_PORT'}
> REQUEST_METHOD = $ENV{'REQUEST_METHOD'}
> HTTP_ACCEPT = '$ENV{'HTTP_ACCEPT'}'
> PATH_INFO = $ENV{'PATH_INFO'}
> PATH_TRANSLATED = $ENV{'PATH_TRANSLATED'}
> SCRIPT_NAME = $ENV{'SCRIPT_NAME'}
> QUERY_STRING = $ENV{'QUERY_STRING'}
> REMOTE_HOST = $ENV{'REMOTE_HOST'}
> REMOTE_ADDR = $ENV{'REMOTE_ADDR'}
> REMOTE_USER = $ENV{'REMOTE_USER'}
> CONTENT_TYPE = $ENV{'CONTENT_TYPE'}
> CONTENT_LENGTH = $ENV{'CONTENT_LENGTH'}
> </pre>
>
> <hr>
> </body>"; # Print statement (and program) ends here
>
> --
> ____________________________________________________________
> Frank Quednau
> http://www.surrey.ac.uk/~me51fq
> ________________________________________________
--
Michael D. Hofer
Internet Services
212 235 4415
------------------------------
Date: Tue, 23 Jun 1998 09:46:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How can I get the IP-Number & the Remote_Host Name
Message-Id: <MPG.ff97bbfb2b40aa49896b4@nntp.hpl.hp.com>
In article <358FCDAA.699@min.net>, John Porter <jdporter@min.net> says...
> Larry Rosler wrote:
> >
> > This is a sounder (and shorter) approach:
> > foreach (sort keys %ENV) { print "$_ = '$ENV{$_}'\n" }
> > Of course, it no longer is "just one big print statement, but" you can't
> > win 'em all :-).
>
> local $, = "\n";
> print map { "$_ = '$ENV{$_}'" } sort keys %ENV;
>
> --
> John Porter
>
I meant that he couldn't print his HTML-headers, ENV variables, and HTML-
trailers all in one big print statement, but you're right. He can.
Why bother with $, though?
print <<HEAD, map("$_ = '$ENV{$_}'\n", sort keys %ENV), <<TRAIL;
Content-type: text/html
<html>
...
<pre>
HEAD
</pre>
...
</body>
</html>
TRAIL
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Jun 1998 12:15:14 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: How to test perl on my windows95 home computer...?
Message-Id: <358FD492.7B507C9C@negia.net>
F.Quednau wrote:
>
> Marcel Ouwendijk wrote:
> >
> > I want to test my perl programs on my homecomputer with windows95 befor i
> > upload theme to my provider.
> >
>
[snip]
> installed. Don't worry if you don't have a network card, just install a Network
> Card anyway :) Don't forget to include that particular Protocol. Then you get a
[snip]
hmm, do you have stock in 3com or some other network card vendor? :-)
all you need is the TCP/IP drivers which are installed with dial-up
networking. i've been running a webserver at home in win32 and linux for
about 3+ years now with no network card in sight.
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Tue, 23 Jun 1998 16:51:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Learning Perl; (i.e. newbie question)
Message-Id: <Pine.GSO.3.96.980623094708.24075a-100000@user2.teleport.com>
On Tue, 23 Jun 1998, Jay Buffington wrote:
> Subject: Learning Perl; (i.e. newbie question)
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> $guess = @a[rand(@b)];
This is the syntax to access a list slice, but you're not doing that. You
probably wanted a dollar sign before the 'a'.
If you turn on -w warnings and step through your script in the debugger,
I'm sure you'll see what's going on. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 23 Jun 1998 16:23:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: MD5 and Perl4
Message-Id: <Pine.GSO.3.96.980623085735.24075X-100000@user2.teleport.com>
On 23 Jun 1998, P=E5l L=F8berg wrote:
> So what I'm really looking for is MD5 implemented in pure Perl code.
This could be done. I doubt that it has, though, because that would be on
the order of 100,000% slower than the implementation in the module. That's
just a rough estimate; you're welcome to try to prove me wrong. But if you
can calculate the MD5 checksum of your MD5 code with ordinary Perl4 in
less than, oh, about a second, I'll have to ask how you can justify using
a Cray when you've obviously got way too much spare time. :-)=20
--=20
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 17 Jun 1998 15:18:33 -0600
From: Jeff Payne <jeff@uen.org>
Subject: Problem with I/O
Message-Id: <358832A9.D8D15263@uen.org>
Hello,
I've looked through the FAQ, on www.perl.com, and through several
CPAN
lists, yet I'm still stuck on what may be a simple question (Oh Is
started with the manual).
I have a script that displays the contents of a file, these contents
change periodically so the
script is an endless loop the has a sleep built in before a new update.
My problem is this:
I'd like to be able to handle user options, while not interupting the
loop if there is no input from
the user. Let me try to rephrase that: I want to have the loop continue
as it does now until the user
presses a key on the keyboard, I'd then like to deal with what key was
pressed, and return to normal
loop operation.
I've tried to use every form of STDIN that I can imagine os see in the
Programming book. Talked to
several others in hopes they'd have a clear suggestion, etc. One
suggested threading may be in order,
but I'm stuck on where to learn about this, or what to look for in the
CPAN.
--
Looking forward to helpfull suggestions,
Jeff@uen.org
UtahLINK Network Operations
------------------------------
Date: Tue, 23 Jun 1998 16:55:36 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Problem with I/O
Message-Id: <Pine.GSO.3.96.980623095356.24075b-100000@user2.teleport.com>
On Wed, 17 Jun 1998, Jeff Payne wrote:
> I'd like to be able to handle user options, while not interupting the
> loop if there is no input from the user.
Sounds as if you want the information under "How can I tell if there's a
character waiting on a filehandle?" in section five of the FAQ. Hope this
helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 23 Jun 1998 16:37:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: QUESTION: Why does only one of these work?
Message-Id: <Pine.GSO.3.96.980623092547.24075Y-100000@user2.teleport.com>
On 23 Jun 1998, Mario D'Alessio wrote:
> A coworker wrote a perl 4 script,
It should go without saying that your system should have a version of Perl
that's no older than, say, the Spice Girls. :-)
> foreach (<STDIN>)
> {
> next if 1 .. /pattern/;
> I just could not get this to work. It never skipped
> any lines. When I replaced "foreach" with "while",
> it worked fine.
The literal 1 is checking against $. (the number of the last read line).
But foreach needs to build its entire list before it can start iterating,
so that number will normally be larger than one.
Of course, using while in that loop is better in virtually every way. It's
generally a waste to load the whole file into memory when you can work
with it just as well a line at a time.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 23 Jun 1998 11:04:20 -0400
From: Xuming Wang <xuming@email.unc.edu>
Subject: Re: Sending mail in Perl
Message-Id: <358FC3F4.86350576@email.unc.edu>
F.Quednau wrote:
>
> > $^=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
>
> Odd, very odd. That program outputs:
>
> #!/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
the only part I don't understand is how tr[C-~][:-u] works.
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@AB:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu
can some one explain to me?
thanks!
--
Xuming Wang
------------------------------
Date: Tue, 23 Jun 1998 11:38:10 -0500
From: tfo@telalink.net (Thomas Frederick O'Connell)
Subject: stylistic remote array passing
Message-Id: <tfo-2306981138100001@jesus.telalink.net>
i have not seen a reference to my problem in the FAQ, the camel book, the
llama book, CPAN docs, or this newsgroup, but if you have (after reading
the problem), and i have overlooked it, please just point me in the right
direction. i am definitely an advocate of RTFM and only post when i can't
find what i'm looking for. is this disclaimer necessary? arguably, but
usenet flaming can get kind of nasty (even amongst perl developers...).
is there a graceful way to pass arrays between different hosts (or even
different scripts, i guess)? i have a script that needs to distribute
several arrays to other scripts on multiple hosts. in the past, i have
just used system calls and ssh to deliver command-line scalar arguments (a
technique that works just fine), but i can't pass remote array references,
and i need the data to remain as distinct arrays on the remote side. i
suppose i could pass each array as a quoted string and then shove all that
into an array on the other side, but it seems to me that there is either a
more intuitive (universally, even if not to me) or more graceful solution.
requesting the data rather than distributing it is not really an option in
this case. i would also prefer to avoid using RPC (or anything of its
ilk), although this may end up being the only reasonable alternative to
arrays as strings.
thanks be unto all donors of aid and/or information.
-freddie
------------------------------
Date: Tue, 23 Jun 1998 12:25:48 -0400
From: "Michael D. Hofer" <mhofer@lady.ny.jpmorgan.com>
Subject: Re: Weekdays <-> Dates
Message-Id: <358FD70C.564D@lady.ny.jpmorgan.com>
Eric Bohlman wrote:
>
> Hauk Langlo <hauk@forumnett.no> wrote:
> : Hi there. I'm about to make a program which needs to know which day of
> : the week it is. I have a good idea about how to do it, but it feels like
> : an unescesary amount of work. If anyone know somewhere I can find a
> : model on how to do this, or maybe have a subroutine they have made
> : themselfes, I would really apprecuate to have a look at it. Thanks.
>
> Take a look at perlfaq4; it's got code to do this.
what code? it's
$dow=(localtime)[6];
--
Michael D. Hofer
Internet Services
212 235 4415
------------------------------
Date: 23 Jun 1998 15:53:16 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Writing Perl extensions in languages other than C/C++
Message-Id: <6moj1c$2kr4@eccws1.dearborn.ford.com>
James Hague <jhague@dadgum.com> writes:
> I'd like to create some Perl extensions that aren't written in C. ...
> So here's my question: has anyone written-up an explanation of linkage
> between Perl and external routines on a lower level than xstut?
The language must have C compatible linkage to integrate with perl.
I've used <gasp> Fortran. ;) The trouble with many languages is that
they are able to call functions with C linkage, but not be (easily)
called by C. You'll probably resort to writing custom XS wrappers
for most languages.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
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 2948
**************************************