[18332] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 500 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 16 03:05:40 2001

Date: Fri, 16 Mar 2001 00:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984729913-v10-i500@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 16 Mar 2001     Volume: 10 Number: 500

Today's topics:
    Re: binary files (Alan Barclay)
    Re: Copy/Paste using Perl? <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: FAQ 7.12:   What's a closure? (Abigail)
    Re: FAQ 7.12:   What's a closure? <rick.delaney@home.com>
    Re: Help in understood Perl some slides (Taming of Came <cave@pertus.com.pl>
    Re: Help to Install Perl (Ben Okopnik)
    Re: Help to Install Perl <webmaster@webdragon.munge.net>
        How to do this? (Jim Kroger)
    Re: How to do this? <uri@sysarch.com>
    Re: How to do this? <joe+usenet@sunstarsys.com>
    Re: How to do this? <c_clarkson@hotmail.com>
    Re: HTTP Client Question <spohn@bigfoot.com>
    Re: Is there a shorter way for this? <johnlin@chttl.com.tw>
        module for national holidays <gordon@balafon.net>
    Re: module for national holidays (Abigail)
        Most efficient way to extract unique array elements? (Billy Peterson)
    Re: Most efficient way to extract unique array elements <postmaster@castleamber.co.nz>
    Re: Most efficient way to extract unique array elements (Damian James)
        on cgi.pm <lzcom.info@verizon.net>
    Re: perl hacker wanted <webmaster@webdragon.munge.net>
    Re: perl hacker wanted <webmaster@webdragon.munge.net>
    Re: Print own "die" message (Abigail)
        problems with systems calls <duncan@viator.com>
        Server run on a cd <jtjohnston@courrier.usherb.ca>
        Straight array output (George Kluver)
    Re: Straight array output <joe+usenet@sunstarsys.com>
        Test Shows 99.99% of High School Seniors Can't Read Per <krahnj@acm.org>
    Re: Test Shows 99.99% of High School Seniors Can't Read (James Dale)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 16 Mar 2001 03:36:19 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: binary files
Message-Id: <984713708.260355@elaine.furryape.com>

In article <x78zm68qp8.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
>IIRC the russians did some base 3 systems. i think they did some
>research and found that was more space effcient than binary. they were
>true 3 state logic systems, using 3 voltage levels per tri-digit
>(trit?). i doubt perl has ever run on any of those.

Obviously, this should be tit, same as binary digits are bits.

Computers which are good at processing trinary systems, and
are therefore good at dealing with tits, would be good
for processing pr0n.


------------------------------

Date: 16 Mar 2001 02:44:57 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Copy/Paste using Perl?
Message-Id: <864rwu77py.fsf@jon_ericson.jpl.nasa.gov>

lkenny@fisheries.org (LK) writes:

> I am trying to write a program that will take the information from
> selected WordPerfect files and move them into notepad, so I can then
> run another program on the info in notepad.  I am working on a windows
> machine with ActivePerl installed.

[snip code, which should use strict, check the status of opens, and
read files a line at a time.]

> But the newfile that is created is pretty garbled and is unables to be
> processed properly.

Umm... a WordPerfect file is likely to be pretty garbled.  You're
going to have to filter out all of the formatting codes.  I imagine
that you are reinventing the wheel here.

Jon


------------------------------

Date: 16 Mar 2001 02:27:04 GMT
From: abigail@foad.org (Abigail)
Subject: Re: FAQ 7.12:   What's a closure?
Message-Id: <slrn9b2ufo.p0e.abigail@tsathoggua.rlyeh.net>

Uri Guttman (uri@sysarch.com) wrote on MMDCCLIV September MCMXCIII in
<URL:news:x7elvy8ra9.fsf@home.sysarch.com>:
 .. >>>>> "A" == Abigail  <abigail@foad.org> writes:
 .. 
 ..   A> Uri Guttman (uri@sysarch.com) wrote on MMDCCLIII September MCMXCIII in
 ..   A> <URL:news:x7hf0u8wo0.fsf@home.sysarch.com>:
 .. 
 ..   A> ^^ also see Class::Classless on CPAN for a different approach.  i believe
 ..   A> ^^ it also uses closures and perl refs but none of perl's builtin OO stuff.
 .. 
 .. 
 ..   A> I believe Class::Classless was inspired by OO::Closures.
 .. 
 .. dunno. i first heard about it at damian advanced OO lecture at yapc last
 .. year. this is the first time i have heard about OO::Closures.
 .. 
 .. other than the very different api and some feature differences (SUPER,
 .. etc.) what other diffs are there? speed?


I haven't tested it, but I expect OO::Closures to be way slower than
Perl OO. After all, it's done in 100% pure Perl, there's no "lovely
hand optimized C" behind it.

It was made mostly as a proof of concept. It shows you what's possible,
and that you can do OO without using language supported OO constructs.

The biggest advantage this has for me is that instance variables have
all the advantage as normal Perl lexicals. You don't need all that
extra punctuation, and you get all the benefits of 'use strict'.
(But the latter can be achieved with "inside-out" objects as well).



Abigail
-- 
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
           ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'


------------------------------

Date: Fri, 16 Mar 2001 03:04:41 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: FAQ 7.12:   What's a closure?
Message-Id: <3AB18609.BE2AD52D@home.com>

Abigail wrote:
> 
> # $Date: 2001/03/15 22:32:22 $
> #
> # $Id: Closures.pm,v 1.3 2001/03/15 22:32:22 abigail Exp abigail $
> #
> # $Log: Closures.pm,v $
> # Revision 1.3  2001/03/15 22:32:22  abigail
> # Fixed copyright/license/email address.
> #
> # Revision 1.2  1999/08/02 06:06:04  abigail
> # Bug fixes and more efficient use of code (Rick Delaney).

Looks like you need to downgrade me to just "Bug fixes".

[snip]

>         # Go looking for the method in an inherited object.
>         foreach my $super (@supers) {
>             return eval {$super -> ($method => @args)} unless $@;
                     ^^^^                                ^^^^^^^^^
>             croak $@ unless $@ =~ /^No such method/;
>         }

I sent you mail a while ago about this but I guess you never got it.
This is the "more efficient" code I suggested but it is quite wrong.

What you want it to do is return only if the code in eval doesn't die. 
Of course, $@ is tested *before* eval is run (so before eval could set
it) so it is testing $@ from some previously run eval.  The code above
is equivalent to

    $@ or return eval {$super -> ($method => @args)};

I think your original code was more like

    if (wantarray) {
        my @ret = eval {$super -> ($method => @args)};
        return @ret unless $@;
    }
    elsif (etc.

which would have worked correctly.

My suggestion to let the calling context propagate through to eval makes
no sense if you need to check $@ (which one usually does).

-- 
Rick Delaney
rick.delaney@home.com


------------------------------

Date: Fri, 16 Mar 2001 07:34:17 +0100
From: Mirek Rewak <cave@pertus.com.pl>
Subject: Re: Help in understood Perl some slides (Taming of Camel)
Message-Id: <mec3btkk4t1l5jpvmlg49is0lib1scd3cp@4ax.com>

Wow!
Thank a lot for help to all that take part in topic. It was great by
you (Perl community is the best thing of Perl) that I get fine
explanation.

PS Sound file to slides (that was mentioned by nobull) would be also
great.

Pozdrowienia
Mirek Rewak
cave@pertus.com.pl



------------------------------

Date: 16 Mar 2001 06:48:23 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Help to Install Perl
Message-Id: <slrn9b3dqj.cr0.ben-fuzzybear@Odin.Thor>

The ancient archives of Wed, 14 Mar 2001 14:12:20 GMT showed
Bob Dilworth of comp.lang.perl.misc speaking thus:
>On 13 Mar 2001 19:00:50 GMT, "Scott R. Godin"
><webmaster@webdragon.munge.net> wrote:
>
>>Personally I think neither of you has a clue as to the actual tone and 
>>spirit and intent of the reply I made. Oh well. Smoke another one, it 
>>might help... :)
>
>I assume you mean the tone and spirit of ridicule over something as
>innane and innocuous as violating the clpm Taliban's Jeopardy Posting
>rule?  When in Afghanistan .... etc., etc.


Thank you _so_ kindly for popping up! I'm always looking for a way to
filter out extraneous noise in this group.

Let's see now, that scorefile was right around here somewhere... Ah.


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
for(reverse (0..99)){($a,$b,$c)=(' bottles of beer',' on the wall',
'Take one down, pass it around');$a=~s/s// if/1/;print"$_$a$b\n\n"
unless/99/;print"$_$a$b\n$_$a\n$c\n"unless/0/;}print"*hic*\n"


------------------------------

Date: 16 Mar 2001 07:43:19 GMT
From: "Scott R. Godin" <webmaster@webdragon.munge.net>
Subject: Re: Help to Install Perl
Message-Id: <98sg6n$4ap$4@216.155.32.174>

In article <slrn9b3dqj.cr0.ben-fuzzybear@Odin.Thor>, 
ben-fuzzybear@geocities.com wrote:
  
 | Thank you _so_ kindly for popping up! I'm always looking for a way to
 | filter out extraneous noise in this group.
 | 
 | Let's see now, that scorefile was right around here somewhere... Ah.
 | 
 | 
 | Ben Okopnik
 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 | for(reverse (0..99)){($a,$b,$c)=(' bottles of beer',' on the wall',
 | 'Take one down, pass it around');$a=~s/s// if/1/;print"$_$a$b\n\n"
 | unless/99/;print"$_$a$b\n$_$a\n$c\n"unless/0/;}print"*hic*\n"

ROFL, and the sig was SO apropos too :D

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


------------------------------

Date: Fri, 16 Mar 2001 05:26:28 GMT
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: How to do this?
Message-Id: <minorseventhSPAMBLOCK-1603010026270001@sdn-ar-002njprinp319.dialsprint.net>

Hi, I'm using "Learning Perl" and have been looking through to try and
find some use of Perl commands in an algorithm to do this but everything
I've figured out seems kludgy and very awkward, much more so than it would
be in C.

I have input files that consist of a variable number of columns. I'd just
like to put each column in an array. The best I've figured out is put the
file contents into an array, one line per array item, then loop through
the array, and for each item (line) split it into another array, then loop
through this array, and put each item in successive column arrays. This
seems kludgy to say the least. In C you can just get strings from the file
until eol, putting them in successive arrays directly, then increment the
pointer, and do the next line, until eof.

Thanks for any help.
Jim


------------------------------

Date: Fri, 16 Mar 2001 05:54:35 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to do this?
Message-Id: <x7zoem6yxv.fsf@home.sysarch.com>

>>>>> "JK" == Jim Kroger <minorseventhSPAMBLOCK@earthlink.net> writes:

  JK> Hi, I'm using "Learning Perl" and have been looking through to try
  JK> and find some use of Perl commands in an algorithm to do this but
  JK> everything I've figured out seems kludgy and very awkward, much
  JK> more so than it would be in C.

stop thinking like c, this is perl.

  JK> I have input files that consist of a variable number of
  JK> columns. I'd just like to put each column in an array. The best
  JK> I've figured out is put the file contents into an array, one line
  JK> per array item, then loop through the array, and for each item
  JK> (line) split it into another array, then loop through this array,
  JK> and put each item in successive column arrays. This seems kludgy
  JK> to say the least. In C you can just get strings from the file
  JK> until eol, putting them in successive arrays directly, then
  JK> increment the pointer, and do the next line, until eof.

you could do a similar thing. but what is successive arrays? a 2-d
array?

here is one approach:

while( my $line = <> ) {

	my $col_num = 0 ;
	foreach $col ( split ' ', $line ) {

		push @{$matrix[$col_num]}, $col ;
	}
}

is that too complex for you?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: 16 Mar 2001 01:08:10 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: How to do this?
Message-Id: <m3d7biutyt.fsf@mumonkan.sunstarsys.com>

minorseventhSPAMBLOCK@earthlink.net (Jim Kroger) writes:

> I have input files that consist of a variable number of columns. I'd just
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
for example?

> like to put each column in an array. The best I've figured out is put the
> file contents into an array, one line per array item, then loop through
> the array, and for each item (line) split it into another array, then loop
> through this array, and put each item in successive column arrays. This
> seems kludgy to say the least. 

Why don't you post some sample data and the code you've written to parse 
the file? (If the code doesn't quite work right, that's OK - but a good
description of your file format is vital.) There's a whole bunch of ways 
to improve on what you've described, but without anything concrete from 
you, there's little chance a solution you get here will be of much use.

> In C you can just get strings from the file until eol, putting them in
> successive arrays directly, then increment the pointer, and do the
> next line, until eof.

If you are referring to C's scanf and friends, perl's regexp engine is
light-years more powerful.

Joe Schaefer
-- 
#include <stdio.h> /* requires gcc and *nix
use strict; system("cc -x c $0") and die $?; open C, "|a.out" or die $! . q*/
main(){char s[32]; remove("a.out"); printf("%s/C hacker\n",fgets(s,32,stdin));
return 0;}/*; print C "Just another Perl"; close C or die $?; #*/


------------------------------

Date: Fri, 16 Mar 2001 01:54:20 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: How to do this?
Message-Id: <08ADAA73B08D5E86.CF2E69E708A6F257.CE5D2256BFBA1117@lp.airnews.net>


"Uri Guttman" <uri@sysarch.com> wrote
[SNIP]
:
: you could do a similar thing. but what is successive arrays? a 2-d
: array?
:
: here is one approach:
:
: while( my $line = <> ) {
:
: my $col_num = 0 ;
: foreach $col ( split ' ', $line ) {
:
: push @{$matrix[$col_num]}, $col ;
: }
: }
:
: is that too complex for you?
:

    Wouldn't you want to increment $col_num somewhere in there?

Charles K. Clarkson





------------------------------

Date: Thu, 15 Mar 2001 22:36:56 -0600
From: "Al Spohn" <spohn@bigfoot.com>
Subject: Re: HTTP Client Question
Message-Id: <tb363ge1fot6ca@corp.supernews.com>


Bart Lateur <bart.lateur@skynet.be> wrote in message
news:iql2bt0uuc1ocjo4c7eg59k4pgka32or65@4ax.com...
> Al Spohn wrote:
>
> >So my question may
> >not have been Perl specific, but the answer could/might well have been.
>
> And it gets worse. The whole thread (30 messages I can count)
> degenerates, again, into one that isn't even technology related.

True enough - I've certainly vented more than I ever thought myself capable
of.  Though maybe not the ideal turn of events in a technology oriented
newsgroup, I guess it's a good sign people care enough to voice their
opinion.  I suspect you're not the only one ready to get back to the
technology.




------------------------------

Date: Fri, 16 Mar 2001 11:00:55 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Is there a shorter way for this?
Message-Id: <98rvib$375@netnews.hinet.net>

"Bart Lateur" wrote
> John Lin wrote:
> >Doesn't matter.  It's "local"ized within map.
> It DOES matter. You can't use $_ both for the main string and for the
> indexes, at the same time.
Ug...  sorry...  I was careless...
John Lin





------------------------------

Date: Fri, 16 Mar 2001 02:10:06 GMT
From: Gordon Tisher <gordon@balafon.net>
Subject: module for national holidays
Message-Id: <87wv9qo44n.fsf@havnor.balafon.net>


Hi,

Is there a perl module that knows about national holidays (I'm
particularly interested in Canadian holidays)?  I can't seem to find
any mention of such on CPAN.

Thanks,

Gordon

-- 
Gordon Tisher <gordon@balafon.net>



------------------------------

Date: 16 Mar 2001 02:34:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: module for national holidays
Message-Id: <slrn9b2utq.p0e.abigail@tsathoggua.rlyeh.net>

Gordon Tisher (gordon@balafon.net) wrote on MMDCCLIV September MCMXCIII
in <URL:news:87wv9qo44n.fsf@havnor.balafon.net>:
:: 
:: Hi,
:: 
:: Is there a perl module that knows about national holidays (I'm
:: particularly interested in Canadian holidays)?  I can't seem to find
:: any mention of such on CPAN.


Date::Manip can read a configuration file in which you can put your
holidays.



Abigail


------------------------------

Date: Fri, 16 Mar 2001 05:50:06 GMT
From: billyNOSPAMPLEASE@answerfolks.com (Billy Peterson)
Subject: Most efficient way to extract unique array elements?
Message-Id: <billyNOSPAMPLEASE-1603010050050001@sdn-ar-002njprinp319.dialsprint.net>

Dear Perl programmers,

Please excuse the amateurish question, I'm trying to break from the world
of shell programming into Perl. I have to get a list of the unique
elements in array 1 and put them into array 2. For example, 

car
bike
car
truck
bike

would yield

car
bike
truck

I have been doing this by outputting array 1 into a file, running the file
through the Ustat command uniq and directing that into another file,
opening that file and putting the contents into an array. Then unlinking
the created files. I'm hoping there is a Perl command for this, or at
least a more efficient method. 

                                                         Regards,
                                                         Billy P.


------------------------------

Date: Fri, 16 Mar 2001 20:05:10 +1300
From: "John Bokma" <postmaster@castleamber.co.nz>
Subject: Re: Most efficient way to extract unique array elements?
Message-Id: <98se1s$5ro$1@lust.ihug.co.nz>

Billy Peterson wrote in message ...
>Dear Perl programmers,
>
>Please excuse the amateurish question, I'm trying to break from the world
>of shell programming into Perl. I have to get a list of the unique
>elements in array 1 and put them into array 2. For example,
>
>car
>bike
>car
>truck
>bike
>
>would yield
>
>car
>bike
>truck
>
>I have been doing this by outputting array 1 into a file, running the file
>through the Ustat command uniq and directing that into another file,
>opening that file and putting the contents into an array. Then unlinking
>the created files. I'm hoping there is a Perl command for this, or at
>least a more efficient method.

Use a hash. A long example:

my %hash;
foreach my $item (@array1)
{
    $hash{$item} = 1;
}

keys %hash now contain the unique elements

shorter way:

my %hash;
@hash{@array1} = (1) x @array1;

HTH,
John


--
Castle Amber - Software Development
Perl / Java / C / C++ developer *available*
email john@castleamber.co.nz for more info
or visit http://castleamber.co.nz/




------------------------------

Date: 16 Mar 2001 07:09:54 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Most efficient way to extract unique array elements?
Message-Id: <slrn9b3f1o.k7d.damian@puma.qimr.edu.au>

Billy Peterson chose Fri, 16 Mar 2001 05:50:06 GMT to say this:
>Dear Perl programmers,
>
>Please excuse the amateurish question, I'm trying to break from the world
>of shell programming into Perl. I have to get a list of the unique
>elements in array 1 and put them into array 2. For example, 
>

Use a hash -- the keys are garanteed to ne unique:

#!/usr/local/bin/perl -w
use strict;

my @list = qw( car bike car truck bike );

my %seen = ();
my @unique = grep { !$seen{$_}++ } @list;

$" = "\n";
print "@unique\n";
__END__

This preserves the original order of the array.

HTH
Cheers,
Damian
-- 
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker


------------------------------

Date: Fri, 16 Mar 2001 05:16:36 GMT
From: "lindaz" <lzcom.info@verizon.net>
Subject: on cgi.pm
Message-Id: <Ukhs6.598$l6.290989@paloalto-snr1.gtei.net>

Thank you very much, Wyzelli.

I tried your cgi.pm. It looks much simpler but I am not familar with the
module. On the output, the values 'name' and 'comment' still didn't pop up.
My html page actually was a complete form page (I cut it off) and I didn't
change the form when I tried your script. May I ask why it didn't work. Any
tips or suggestions would be greatly appreciated.

Linda




------------------------------

Date: 16 Mar 2001 07:37:05 GMT
From: "Scott R. Godin" <webmaster@webdragon.munge.net>
Subject: Re: perl hacker wanted
Message-Id: <98sfr1$4ap$2@216.155.32.174>

In article <tb2rgcnc54k800@corp.supernews.com>, Chris Stith 
<mischief@velma.motion.net> wrote:

 | One of the nicer ones is
 | http://users.lmi.net/ennui/usenet001.htm
 | which has a section on advertising. It
 | describes only product ads, but it says
 | not to advertise anything on Usenet at all.
 | I must say, I really like this site. It
 | even has a button that says,' q{Plonk!!}.


Wow, I didn't know the Klingons had made it so far into Usenet society 
:-) 

(-: yeah it's obscure)

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


------------------------------

Date: 16 Mar 2001 07:40:38 GMT
From: "Scott R. Godin" <webmaster@webdragon.munge.net>
Subject: Re: perl hacker wanted
Message-Id: <98sg1m$4ap$3@216.155.32.174>

In article <slrn9b2o4t.p0e.abigail@tsathoggua.rlyeh.net>, 
abigail@foad.org wrote:

 | Usenet is an organized anarchy, and you are looking for rules cast in 
 | stone?
 | 
 | Mind boggling.

heh. I'm simply boggled at the number of punnish directions I could take 
using this as the point of departure. :D

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


------------------------------

Date: 16 Mar 2001 02:32:17 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Print own "die" message
Message-Id: <slrn9b2uph.p0e.abigail@tsathoggua.rlyeh.net>

Chris Stith (mischief@velma.motion.net) wrote on MMDCCLIV September
MCMXCIII in <URL:news:tb2oft11ue6p71@corp.supernews.com>:
|| Bart Lateur <bart.lateur@skynet.be> wrote:
|| > Chris Stith wrote:
|| 
|| >>Or even execute a block in which your print() your message then
|| >>exit() -- or you can do that inside a die handler... 
|| 
|| > The good thing about the __DIE__ handler is taht it also works on fatal
|| > errors that you didn't expect. Assign it in a BEGIN block upfront your
|| > script, and it will even catch syntax errors.
|| 
|| True. I hadn't thought about using DIE to catch syntax errors, though.

Actually, it turns out syntax errors are mere warnings, triggering
$SIG{__WARN__}.

Here's a JAPH using the trick (with help from Clinton Pierce and
Schuyler):

    #!/opt/perl/bin/perl   --   # Remove trailing newline!
    BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;
    truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ

(Put it in a file, remove the trailing newline, and execute the file).


Or a variant, using a neat trick from Clint to combine seek and open:

    #!/opt/perl/bin/perl   --    # No trailing newline after the last line!
    BEGIN{$|=$SIG{__WARN__}=sub{$_=$_[0];y-_- -;print/(.)"$/;seek _,-open(_
    ,"+<$0"),2;truncate _,tell _;close _;exec$0}}//rekcaH_lreP_rehtona_tsuJ



Abigail
-- 


------------------------------

Date: Fri, 16 Mar 2001 18:20:08 +1100
From: Duncan Hall <duncan@viator.com>
Subject: problems with systems calls
Message-Id: <3AB1BEA8.91904259@viator.com>

Can anyone tell me why when run from a browser this script does not
finish displaying the page until the download of the jre.zip file is
complete?

I'm running apache-suexec to make the system call.

Thanks

Dunc

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "just downloading jre.zip first - its 15 meg in size\n";

`wget http://192.168.100.5/jre.zip -O /var/www/html/downloads/jre.zip`;

--
-------------------------------------------------
This email is freely distributable under the GPL
LLAP





------------------------------

Date: Fri, 16 Mar 2001 00:45:00 -0500
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Server run on a cd
Message-Id: <3AB1A85C.690F41AE@courrier.usherb.ca>

I have a question. Have you ever, or is it possible to run a very basic
copy of a server from a CD rom? I tried and failed with sambar.com. It
requires to write server logs etc. and its author has never answered me
for
custom help.

I would like to put:

http://www.CollegeSherbrooke.qc.ca/~languesmodernes/jtj/unit2/

on a CD-rom when it's finished.

I need to run a server from a CD for 2 things ONLY:

CGI:
(1) First, I have html <form> contents that I want to email, so I want
to take advantage of the Perl kernel that Sambar has to do a little CGI
emailing of forms, providing the user enters a valid smtp somewhere.

If the server ran its *.ini using the windows directory, I could cobble
something myself so my students could configure the cd to mail using
their
isp's smtp.

RealMedia:
(2) Second, I also have some RealMedia (RealAudio & RealVideo) META
files (*.ram and *.rpm) where I need to type the FULL PATH to the
RealMedia file *.rm. Therefore, in each *.ram and *.rpm, I NEED to type
soemthing like: http://localhost/real/realsample.rm

On start up, in the autostart.inf file I would start the server and then

shell: http://localhost/index.html

Can you help me find a wauy to do this?
It's a project I will distribute for free to students to work on school
material from home. Not for $, so please be gentle.

Thanks,

John




------------------------------

Date: Fri, 16 Mar 2001 06:03:07 GMT
From: GKluver@deja.com (George Kluver)
Subject: Straight array output
Message-Id: <GKluver-1603010103060001@sdn-ar-002njprinp319.dialsprint.net>


How might one print to screen twenty arrays in straight, vertical columns?
Each column is the contents of one of them.

Thank you!
George


------------------------------

Date: 16 Mar 2001 01:56:18 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Straight array output
Message-Id: <m33dceurql.fsf@mumonkan.sunstarsys.com>

GKluver@deja.com (George Kluver) writes:

> How might one print to screen twenty arrays in straight, vertical columns?
> Each column is the contents of one of them.

If I understood you, here's one way using format/write:

#!/usr/bin/perl -w

format COLS =
@>>>>>   @<<<<<   @<<<<<   @>>>>>   @|||||   @<<<<<
$_[0],   $_[1],   $_[2],   $_[3],   $_[4],   $_[5]
 .

$~="COLS";

my @cols = ([1..10], ['a'..'t'], ['A'..'F'],
            [999..1024], ['Q'..'Z'], ['w'..'G']);

{
  local $^W=0; # drop uninitialized variable warnings
  my $n = 0;
  ++$n, write while grep {defined} @_ = map { $_->[$n] } @cols;
}

__END__

See

  % man perlform

for details.

-- 
Joe Schaefer                   "A witty saying proves nothing."
                                               -- Voltaire


------------------------------

Date: Fri, 16 Mar 2001 03:12:57 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Test Shows 99.99% of High School Seniors Can't Read Perl
Message-Id: <3AB18644.ECAB827A@acm.org>

http://www.bbspot.com/News/2001/03/perl_test.html


John
-- 
use Perl;
program
fulfillment


------------------------------

Date: 16 Mar 2001 16:12:56 +1100
From: jdale@cs.rmit.edu.au (James Dale)
Subject: Re: Test Shows 99.99% of High School Seniors Can't Read Perl
Message-Id: <3ab1a0d8$1@mercury.its.rmit.edu.au>

ROFL This is funny.

"John W. Krahn" <krahnj@acm.org> writes:

>http://www.bbspot.com/News/2001/03/perl_test.html


>John
>-- 
>use Perl;
>program
>fulfillment


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 500
**************************************


home help back first fref pref prev next nref lref last post