[19388] in Perl-Users-Digest
Perl-Users Digest, Issue: 1583 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 22 00:05:30 2001
Date: Tue, 21 Aug 2001 21:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998453106-v10-i1583@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 21 Aug 2001 Volume: 10 Number: 1583
Today's topics:
Re: For loop iterator variable not working correctly?? (Martien Verbruggen)
Re: grep 5th word in a text-file <l_pantin@hotmail.com>
Re: grep 5th word in a text-file <godzilla@stomp.stomp.tokyo>
Re: Hash Question <l_pantin@hotmail.com>
Re: Hash Question <mark.riehl@agilecommunications.com>
Re: Hash Question <l_pantin@hotmail.com>
Re: Is element in array <godzilla@stomp.stomp.tokyo>
Re: Last index of array referenced in a scalar?? <l_pantin@hotmail.com>
Re: need to reformat file from variable to fixed length <krahnj@acm.org>
Re: Passing code pieces to program <cberry@cinenet.net>
perl builder <bevis@ucdavis.edu>
Re: perl builder <bevis@ucdavis.edu>
Re: perl builder (John J. Trammell)
Re: PERL compiler for windows <cyberian_bear@hotmail.com>
Re: PERL compiler for windows (Sam Holden)
Re: Perl OO needs the opposite of SUPER:: (John Lin)
Re: Perl OO needs the opposite of SUPER:: (John Lin)
PerlFS? <spam@klamath.dyndns.org>
Re: regex to edit config variable <l_pantin@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Aug 2001 03:24:11 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: For loop iterator variable not working correctly??
Message-Id: <slrn9o69er.5d7.mgjv@verbruggen.comdyn.com.au>
On Tue, 21 Aug 2001 20:48:12 GMT,
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
> Eric Bohlman at ebohlman@omsdev.com said...
[And Carlos C. Gonzales wrote earlier:]
>> > @new = qw/harry\@tiger.net undef undef Russia undef undef/;
>>
>> I hope you realize that the second, third, fifth, and sixth elements of
>> @new are going to be set to the literal string "undef," not Perl's
>> undefined value.
>
> Thanks Eric. I didn't realize that. Very glad you pointed that out to
> me. I will have to study up on using Perl's undefined value which is
> what I meant to use.
It's not really related to what undef does, but to what qw() does. It
separates its arguments in "words" and treats each as a quoted string.
perlop has more to say on this.
>
>> > sub update_record
>> > {
>> > my ($old_key, $new) = @_;
>> > my (@old, $i);
>> > print "\@\$new[0] = @$new[0]\n";
>>
>> You want $$new here, not @$new. I'd actually write it as $new->[0], but
>> that's a matter of personal preference.
>
> @$new seems to work fine Eric. I read somewhere that whenever you have a
It may work, but that's not the point. You're accessing a scalar
value, so you should use $. It's the same as accessing an element from
an array, which you also shouldn't do by using array slice notation.
For references, I prefer
$new->[0]
mainly to avoid the doubling up of @, $ and %, which I find ugly and
hard to read.
> reference to something, to dereference it (or pull it's value out) you
> just put the symbol for the type of variable that is being referenced in
> front of the "$".
That is indeed what you do if you want to access the whole thing.
$new = [1, 2, 3];
@$new is the whole array.
$$new[0] is its first element.
@$new[0,1] is a slice containing the first two elements.
@$new[0] is a slice containing only the first element.
The first character, in Perl, identifies what you're getting back from
the identifier, not what the identifier is.
Yes, it is confusing.
> So far this seems to work for me and makes my perlisms
> a bit more consistent.
consistent, maybe, but not correct :)
> I think I will switch my code to using the arrow
> though. That definitely seems to be the clearest way to do it.
And that, IMO, is the best thing to do.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Wed, 22 Aug 2001 01:59:56 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: grep 5th word in a text-file
Message-Id: <wmEg7.28542$1p1.2061755@bgtnsc04-news.ops.worldnet.att.net>
Sorry, but if $1 = "radius log report for: foo" your tidbit works for me.
Download the Perl/Tk debugger (ptkdb) to make sure you're splitting the
right string.
Kevin
In article <7iBg7.86707$B37.2004948@news1.rdc1.bc.home.com>, "Timo Trinks"
<trinks@prolink.de> wrote:
> hi.
>
> i'm trying to code a script that reads the 5th word of a line and writes
> it to stdout:
>
> radius log report for: foo
>
> so foo is the word to be extracted from a logfile and to be written to
> stdout or to another file.
>
> i tried sth like my $word = (split ' ', $1)[4]; but unsuccessfully... so
> any ideas ?
>
> tia,
>
> Timo
------------------------------
Date: Tue, 21 Aug 2001 20:01:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: grep 5th word in a text-file
Message-Id: <3B832075.849C8521@stomp.stomp.tokyo>
Timo Trinks wrote:
(snipped)
> i'm trying to code a script that reads the 5th word of a line and writes
> it to stdout:
> radius log report for: foo
> so foo is the word to be extracted from a logfile and to be written to
> stdout or to another file.
Yours are exceptionally incoherent parameters. You have
failed to indicate if there are further data after your
fifth word.
Work at writing clear, concise and coherent articles.
Consider not posting articles until you can do so.
Posting this type of incoherent article is very rude.
> so any ideas ?
Yes, some good ideas which avoid slow and inefficient grep.
$fifth_word = substr ($your_input, rindex ($your_input, " ") + 1);
Easy, yes? Why did you not think of this?
I have elected to include additional example code to
compensate for your ignorance in not writing an article
which is clear, concise and coherent.
My having to compensate for this ignorance of others,
is most annoying. However, this is the norm here.
Godzilla! Queen Of Coherentia.
--
#!perl
print "Content-type: text/plain\n\n";
$input = "Godzilla Rocks And Rolls. Oh Yes! She Rocks My Socks Off!";
$find_what_word = 1;
&Find_Word;
$find_what_word = 8;
&Find_Word;
$find_what_word = 6;
&Find_Word;
sub Find_Word
{
if ($find_what_word == 1)
{ $found_word = substr ($input, 0, index ($input, " ")); }
else
{
$position = 0;
for ($iterate = 1; $iterate < $find_what_word; $iterate++)
{
$position = index ($input, " ", $position);
$position++;
}
}
$found_word = substr ($input, $position, index ($input, " ", $position + 1) - $position);
print "Number $find_what_word Word: $found_word\n";
}
$last_word = substr ($input, rindex ($input, " ") + 1);
print "\n\n$last_word";
exit;
PRINTED RESULTS:
________________
Number 1 Word: Godzilla
Number 8 Word: Rocks
Number 6 Word: Yes!
Off!
------------------------------
Date: Wed, 22 Aug 2001 01:51:42 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: Hash Question
Message-Id: <OeEg7.28526$1p1.2061365@bgtnsc04-news.ops.worldnet.att.net>
That's because the elements of array $HashName{$key}{all_transmitters}
can't be accessed by index because they're hashes, not arrays. I can
access such an element perfectly fine with something like
$RxTxData{$key}{all_transmitters}[0]{last_tx_time}. And yes, you can
delete elements from hashes in the manner you described, although in this
case perhaps a better choice might be to undef such elements so that the
last_tx_time key sticks around as a placeholder.
Kevin
In article <OgDg7.530$nV4.190080@typhoon1.gnilink.net>, "Mark Riehl"
<mark.riehl@agilecommunications.com> wrote:
> All - I'm trying to use the complex hash. The script below runs, and I
> can loop through each of the sub elements w/o a problem.
>
> Question is, how do I access individual elements to update the values?
> For example, I want to change the last_tx_time property in the
> all_transmitters array of hashes for the first element (urn=4) to a new
> value.
>
> I thought that I use something similar to the following, but haven't had
> any luck:
>
> $HashName{$key}{all_transmitters}[0][0]
>
> Also, same question for a delete. I'm assuming that once I figure out
> the syntax to access the element, then deleting an element would use the
> same syntax. Is this correct?
>
> Any suggestions?
>
> Thanks,
> Mark
>
>
> ****************************************************************************
> *********
> #!perl -w
>
> use strict;
>
> my ($who, $key, %RxTxData);
>
> %RxTxData = (
> 1000=> {
> current_transmitters => [
> { urn=>"1", time=>"8456823", lat=>"35.311",
> long=>"-116.4101", },
> { urn=>"2", time=>"8456824", lat=>"35.312",
> long=>"-116.4201", },
> { urn=>"3", time=>"8456825", lat=>"35.313",
> long=>"-116.4301", },
> ],
> all_transmitters => [
> { urn=>"4", last_tx_time=>"8451234",}, { urn=>"5",
> last_tx_time=>"8451234",}, { urn=>"6", last_tx_time=>"8451234",},
> ],
> statistics => [
> { time=>"8456823", visibility=>"123", accuracy=>"456", }, {
> time=>"8456823", visibility=>"123", accuracy=>"456", }, {
> time=>"8456823", visibility=>"123", accuracy=>"456", },
> ],
> last_sa_time=>"1000",
> last_lat=>"35.1000",
> last_long=>"-116.5",
> },
> );
>
> for $key (keys %RxTxData) {
> print "Table key = $key\n";
>
> for $who ( @{ $RxTxData{$key}{current_transmitters} } ) {
> print "$who->{urn},$who->{time},$who->{lat},$who->{long}\n";
> }
>
> for $who ( @{ $RxTxData{$key}{all_transmitters} } ) {
> print "$who->{urn}\t$who->{last_tx_time}\n";
> }
> for $who ( @{ $RxTxData{$key}{statistics} } ) {
> print "$who->{time},$who->{visibility},$who->{accuracy}\n";
> }
>
> print "$RxTxData{$key}{last_sa_time}\n"; print
> "$RxTxData{$key}{last_lat}\n";
> print "$RxTxData{$key}{last_long}\n";
> }
>
>
>
------------------------------
Date: Wed, 22 Aug 2001 01:55:35 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Re: Hash Question
Message-Id: <riEg7.585$nV4.266298@typhoon1.gnilink.net>
All - I stumbled upon the answer. To access an individual element, I used
the following:
print " @{$RxTxData{$key}{all_transmitters}[0]}{urn}\n";
So, to change the value, I was able to use the following:
@{$RxTxData{$key}{all_transmitters}[0]}{last_tx_time} = $new_val;
One more question though - would it be possible to add another layer of
complexity and replace my arrays of hashes with hashes? I'd like to be able
to use a key to find a value rather than loop through an array.
Thanks,
Mark
"Mark Riehl" <mark.riehl@agilecommunications.com> wrote in message
news:OgDg7.530$nV4.190080@typhoon1.gnilink.net...
> All - I'm trying to use the complex hash. The script below runs, and I
can
> loop through each of the sub elements w/o a problem.
>
> Question is, how do I access individual elements to update the values?
For
> example, I want to change the last_tx_time property in the
all_transmitters
> array of hashes for the first element (urn=4) to a new value.
>
> I thought that I use something similar to the following, but haven't had
any
> luck:
>
> $HashName{$key}{all_transmitters}[0][0]
>
> Also, same question for a delete. I'm assuming that once I figure out the
> syntax to access the element, then deleting an element would use the same
> syntax. Is this correct?
>
> Any suggestions?
>
> Thanks,
> Mark
>
>
>
****************************************************************************
> *********
> #!perl -w
>
> use strict;
>
> my ($who, $key, %RxTxData);
>
> %RxTxData = (
> 1000=> {
> current_transmitters => [
> { urn=>"1", time=>"8456823", lat=>"35.311",
> long=>"-116.4101", },
> { urn=>"2", time=>"8456824", lat=>"35.312",
> long=>"-116.4201", },
> { urn=>"3", time=>"8456825", lat=>"35.313",
> long=>"-116.4301", },
> ],
> all_transmitters => [
> { urn=>"4", last_tx_time=>"8451234",},
> { urn=>"5", last_tx_time=>"8451234",},
> { urn=>"6", last_tx_time=>"8451234",},
> ],
> statistics => [
> { time=>"8456823", visibility=>"123", accuracy=>"456", },
> { time=>"8456823", visibility=>"123", accuracy=>"456", },
> { time=>"8456823", visibility=>"123", accuracy=>"456", },
> ],
> last_sa_time=>"1000",
> last_lat=>"35.1000",
> last_long=>"-116.5",
> },
> );
>
> for $key (keys %RxTxData) {
> print "Table key = $key\n";
>
> for $who ( @{ $RxTxData{$key}{current_transmitters} } ) {
> print "$who->{urn},$who->{time},$who->{lat},$who->{long}\n";
> }
>
> for $who ( @{ $RxTxData{$key}{all_transmitters} } ) {
> print "$who->{urn}\t$who->{last_tx_time}\n";
> }
> for $who ( @{ $RxTxData{$key}{statistics} } ) {
> print "$who->{time},$who->{visibility},$who->{accuracy}\n";
> }
>
> print "$RxTxData{$key}{last_sa_time}\n";
> print "$RxTxData{$key}{last_lat}\n";
> print "$RxTxData{$key}{last_long}\n";
> }
>
>
>
------------------------------
Date: Wed, 22 Aug 2001 02:08:38 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: Hash Question
Message-Id: <GuEg7.28556$1p1.2062280@bgtnsc04-news.ops.worldnet.att.net>
Why wouldn't it be? The declaration remains entirely straightforward.
%RxTxData = (
1000=> {
current_transmitters => {
a => { urn=>"1", time=>"8456823", lat=>"35.311",
long=>"-116.4101", },
b => { urn=>"2", time=>"8456824", lat=>"35.312",
long=>"-116.4201", },
c => { urn=>"3", time=>"8456825", lat=>"35.313",
long=>"-116.4301", }
}
... and so on.
Kevin
In article <riEg7.585$nV4.266298@typhoon1.gnilink.net>, "Mark Riehl"
<mark.riehl@agilecommunications.com> wrote:
> All - I stumbled upon the answer. To access an individual element, I
> used the following:
>
> print " @{$RxTxData{$key}{all_transmitters}[0]}{urn}\n";
>
> So, to change the value, I was able to use the following:
> @{$RxTxData{$key}{all_transmitters}[0]}{last_tx_time} = $new_val;
>
> One more question though - would it be possible to add another layer of
> complexity and replace my arrays of hashes with hashes? I'd like to be
> able to use a key to find a value rather than loop through an array.
>
> Thanks,
> Mark
>
>
>
> "Mark Riehl" <mark.riehl@agilecommunications.com> wrote in message
> news:OgDg7.530$nV4.190080@typhoon1.gnilink.net...
>> All - I'm trying to use the complex hash. The script below runs, and I
> can
>> loop through each of the sub elements w/o a problem.
>>
>> Question is, how do I access individual elements to update the values?
> For
>> example, I want to change the last_tx_time property in the
> all_transmitters
>> array of hashes for the first element (urn=4) to a new value.
>>
>> I thought that I use something similar to the following, but haven't
>> had
> any
>> luck:
>>
>> $HashName{$key}{all_transmitters}[0][0]
>>
>> Also, same question for a delete. I'm assuming that once I figure out
>> the syntax to access the element, then deleting an element would use
>> the same syntax. Is this correct?
>>
>> Any suggestions?
>>
>> Thanks,
>> Mark
>>
>>
>>
> ****************************************************************************
>> *********
>> #!perl -w
>>
>> use strict;
>>
>> my ($who, $key, %RxTxData);
>>
>> %RxTxData = (
>> 1000=> {
>> current_transmitters => [
>> { urn=>"1", time=>"8456823", lat=>"35.311",
>> long=>"-116.4101", },
>> { urn=>"2", time=>"8456824", lat=>"35.312",
>> long=>"-116.4201", },
>> { urn=>"3", time=>"8456825", lat=>"35.313",
>> long=>"-116.4301", },
>> ],
>> all_transmitters => [
>> { urn=>"4", last_tx_time=>"8451234",}, { urn=>"5",
>> last_tx_time=>"8451234",}, { urn=>"6",
>> last_tx_time=>"8451234",},
>> ],
>> statistics => [
>> { time=>"8456823", visibility=>"123", accuracy=>"456", }, {
>> time=>"8456823", visibility=>"123", accuracy=>"456", }, {
>> time=>"8456823", visibility=>"123", accuracy=>"456", },
>> ],
>> last_sa_time=>"1000",
>> last_lat=>"35.1000",
>> last_long=>"-116.5",
>> },
>> );
>>
>> for $key (keys %RxTxData) {
>> print "Table key = $key\n";
>>
>> for $who ( @{ $RxTxData{$key}{current_transmitters} } ) {
>> print "$who->{urn},$who->{time},$who->{lat},$who->{long}\n";
>> }
>>
>> for $who ( @{ $RxTxData{$key}{all_transmitters} } ) {
>> print "$who->{urn}\t$who->{last_tx_time}\n";
>> }
>> for $who ( @{ $RxTxData{$key}{statistics} } ) {
>> print "$who->{time},$who->{visibility},$who->{accuracy}\n";
>> }
>>
>> print "$RxTxData{$key}{last_sa_time}\n"; print
>> "$RxTxData{$key}{last_lat}\n";
>> print "$RxTxData{$key}{last_long}\n";
>> }
>>
>>
>>
>>
>
------------------------------
Date: Tue, 21 Aug 2001 18:38:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Is element in array
Message-Id: <3B830CFA.EF08323F@stomp.stomp.tokyo>
Guy wrote:
> How can test a scalar to see if it is an element in a given array?
(snipped)
I am amused by responses to this article.
You will discover my method below my signature,
working under average program conditions, to be
exceptionally fast and equally efficient.
This methodology of mine also allows very nice
flexibility in matching whole strings or any
variety of partial string matches.
Godzilla! Queen Of Perl Heretics.
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
@Array = qw (Godzilla Rocks And Rolls!);
print "True Whole String Match:\n";
if (index (" @Array ", " Godzilla ") > -1)
{ print " True\n"; }
else
{ print " False\n"; }
print "\n\nFalse Partial String Match:\n";
if (index (" @Array ", " zilla ") > -1)
{ print " True\n"; }
else
{ print " False\n"; }
print "\n\nTrue Partial String Match:\n";
if (index (" @Array ", "zilla ") > -1)
{ print " True\n"; }
else
{ print " False\n"; }
exit;
PRINTED RESULTS:
________________
True Whole String Match:
True
False Partial String Match:
False
True Partial String Match:
True
------------------------------
Date: Wed, 22 Aug 2001 02:12:37 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: Last index of array referenced in a scalar??
Message-Id: <pyEg7.28559$1p1.2063219@bgtnsc04-news.ops.worldnet.att.net>
The referencing strikes me as a rather roundabout method. Why not use
simply $#data?
Kevin
In article <MPG.15ec7f5478d2cd5989787@news.edmonton.telusplanet.net>,
"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> wrote:
> Hi everyone,
>
> Is this the right way to obtain the last index of the @data array
> referenced by $new? Seems to work okay....
>
> The code:
>
> #!/usr/bin/perl -W
>
> use diagnostics;
> use strict;
>
> my @data = ("jack\@ardvark.com,Jack,020010812
> 18:34,Canada,Kissimee,Yes",
> "tammy\@kangaroo.com,Tammy,20010812 18:34,United
> States,Chicago,Yes",);
>
> my $new = \@data;
>
> print "Last element index: [ $#$new ]\n";
>
> Is there a way to rewrite [ $#$new ] so that it doesn't look like so
> much gibberish? Also although this code is producing the right output
> is it doing what I want it to do or is the 1 index produced a byproduct
> of something else?
>
> I just spent fifteen minutes trying different combinations of squiggly
> things =:) until I found one that worked. Can someone correct or check
> my understanding of what I did?
>
> I think "[ $#$new ]" means something like.....
>
> Return the last element "$#" of the array referenced by $new.
>
> If the "[]" were not there it would mean...return the last element "$#"
> of the reference value. Which would just produce an error or invalid
> index value.
>
> Thanks.
>
> ---
> Carlos
> www.internetsuccess.ca
> *NOTE*: Internet Success is NOT yet fully operational so please don't
> subscribe. Thanks.
------------------------------
Date: Wed, 22 Aug 2001 01:10:47 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: need to reformat file from variable to fixed length is Perl the best way
Message-Id: <3B830704.2D527489@acm.org>
johnthan wrote:
>
> We need to convert a file from a variable lenght delimted format to a fixed
> length format.
>
> we have a 24 gig file in 12 pieces. Currently the file is variable length
> delimited by | with fields enclosed with ^
> sample:
> ^717764002^|^71776401.^|^2000-09-11-19.23.00.000000^|^2000-05-25^
> ^300102^|^30011.^|^2000-06-28-19.57.29.670634^|^2000-05-30^
>
> we need to convert this to a fixed lenght format with each field taking a
> certain predined lenght.
> sample
> 717764002 71776401. 2000-09-11-19.23.00.000000 2000-05-25
> 300102 30011. 2000-06-28-19.57.29.670634 2000-05-30
>
> I am sure that this can be done in Perl couple of questions:
>
> 1 - would this involved just using reading and then fprint to format. How to
> handle the delimiters and ^. Would every single character need to be
> processed and examined? Is there are way to avoid that
>
> 2 - is Perl able to do this very quickly? i am looking at around 20-25 mins
> per 2 gig file.
while ( <> ) {
my @fields = /(?:^|\|)\^(.*?)\^(?=\||$)/g;
printf "%12s%12s%40s%10s\n", @fields;
# or
# print pack( 'A12 A12 A40 A10', @fields ), "\n";
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 22 Aug 2001 01:39:18 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Passing code pieces to program
Message-Id: <Xns9104BDC4ED388cberrycinenetnet1@207.126.101.92>
friedman@math.utexas.edu (Chas Friedman) wrote in news:3b82ed5c.13792869
@news.itouch.net:
> Is there a way to pass pieces of code to a script as arguments? For
> example, I have a script that uses File::Find, and contains the
> expression: if (-M $_<1)....
> I would like to be able to pass the "-M$_<1" to the script when it is
> run (so I could also pass in other conditions.) I suppose I could
> use an eval on some string made up partly of the passed in arg,
> but I wondered if there is any other way. Thanks for any comments.
Nope, eval() is about your only choice if you allow arbitrary code from the
user. Be sure to use taint checking and well-thought-out qualifying tests
to avoid eval-ing something deadly.
--
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake
------------------------------
Date: Tue, 21 Aug 2001 20:04:30 +0800
From: "andy huang" <bevis@ucdavis.edu>
Subject: perl builder
Message-Id: <9lv777$187$1@woodrow.ucdavis.edu>
i was trying this nice software, but whenever i tried to execute a cgi
program, it stated
"unrecognized character @ in the file example.cgi line 1
translation aborted due to syntax error"
what wrong is it?
i was just trying to run the tutorial example and it didn't work
this first line is like
#!/usr/local/bin/perl
anyone who has exp with this program please help thanx
------------------------------
Date: Tue, 21 Aug 2001 20:08:03 +0800
From: "andy huang" <bevis@ucdavis.edu>
Subject: Re: perl builder
Message-Id: <9lv7dq$18m$1@woodrow.ucdavis.edu>
dd
"andy huang" <bevis@ucdavis.edu> ¼¶¼g©ó¶l¥ó
news:9lv777$187$1@woodrow.ucdavis.edu...
> i was trying this nice software, but whenever i tried to execute a cgi
> program, it stated
>
> "unrecognized character @ in the file example.cgi line 1
> translation aborted due to syntax error"
>
> what wrong is it?
> i was just trying to run the tutorial example and it didn't work
> this first line is like
>
> #!/usr/local/bin/perl
>
> anyone who has exp with this program please help thanx
>
>
------------------------------
Date: 22 Aug 2001 03:19:26 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: perl builder
Message-Id: <slrn9o6obr.6os.trammell@haqq.hypersloth.net>
On Tue, 21 Aug 2001 20:08:03 +0800, andy huang wrote:
> dd
>"andy huang" wrote:
>> i was trying this nice software, but whenever i tried to execute a cgi
>> program, it stated
>>
>> "unrecognized character @ in the file example.cgi line 1
>> translation aborted due to syntax error"
>>
>> what wrong is it?
>> i was just trying to run the tutorial example and it didn't work
>> this first line is like
>>
>> #!/usr/local/bin/perl
>>
>> anyone who has exp with this program please help thanx
>>
Cripes, I was just reading AHBOU, and I could have *sworn* it
said I was now in CLPM... major dissonance for a bit there.
------------------------------
Date: Tue, 21 Aug 2001 22:40:05 -0400
From: "cyberian bear" <cyberian_bear@hotmail.com>
Subject: Re: PERL compiler for windows
Message-Id: <h_Eg7.7$Ci5.626@typhoon.nyu.edu>
well, I was able to install it. But then I have no idea what to do. I went
to the folder I installed it in and opened PERL.exe file and all it did was
to open dos windows and nothing happened.
Things were so much easier when I had access to UNIX account with PERL and
CGI bin. Just write proggie in Pico and execute it.
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:djkg7.21258$wZ3.1551481@news20.bellglobal.com...
>
> "cyberian bear" <cyberian_bear@hotmail.com> wrote in message
> news:cjig7.10$Ik4.282@typhoon.nyu.edu...
> > Is there any good ones other than Active PERL. Ive tried it and it's
very
> > hard to use and install.
> > thanks in advance for help.
> > cb
> >
>
> How's it hard to install? All you have to do is accept some defaults.
Sounds
> like you need to upgrade your Windows Installer before you try to run the
> setup.
>
>
http://aspn.activestate.com/ASPN/Downloads/ActivePerl/Requirements?#windows
>
> Matt
>
>
------------------------------
Date: 22 Aug 2001 02:53:36 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: PERL compiler for windows
Message-Id: <slrn9o67mc.h66.sholden@pgrad.cs.usyd.edu.au>
On Tue, 21 Aug 2001 22:40:05 -0400,
cyberian bear <cyberian_bear@hotmail.com> wrote:
>well, I was able to install it. But then I have no idea what to do. I went
>to the folder I installed it in and opened PERL.exe file and all it did was
>to open dos windows and nothing happened.
>Things were so much easier when I had access to UNIX account with PERL and
>CGI bin. Just write proggie in Pico and execute it.
What happened on UNIX when you just typed 'perl' and pressed enter?
Exactly what happened in that dos box...
Why don't you create a file with some perl code in it, and
open a DOS window and type 'perl <file you created>', the equivalent
of what you did under UNIX.
You might also find reading the documentation for software before you
just guess how to use them helps a bit...
http://aspn.activestate.com//ASPN/Reference/Products/ActivePerl/readme.html
There should also be some docs off the 'Start' menu...
------------------------------
Date: 21 Aug 2001 19:31:10 -0700
From: johnlin@chttl.com.tw (John Lin)
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <a73bcad1.0108211831.5f079f17@posting.google.com>
[Sorry, allow me to reply only partially. I need more time.]
Ren Maddox wrote
> On 20 Aug 2001, John Lin wrote:
> > Sorry, I meant:
> >
> > sub gen {
> > $self->pre_report_in_gen;
> > $self->report;
> > $self->post_report_in_gen;
> > }
> >
> > and also
> > pre_report_in_save_as_html;
> > post_report_in_save_as_html;
> > pre_report_in_print_to_printer;
> > post_report_in_print_to_printer;
> > ...
>
> That still misses the point. In your hypothetical VIRTUAL system, you
> said that all you have to change is the virtual implementation of
> report(). But if that is true, then in my system all you have to
> change is the middle-level implementation of pre_report and
> post_report. There is no need to create all these extra pre and post
> calls.
sub gen {
print "Now we are generating report:\n";
$self->report;
print "Done, hope you like it.\n";
}
sub save_as_html {
print HTML "<html><pre>\n";
$self->report;
print HTML "</pre></html>\n";
}
sub print_to_printer {
open STDOUT,">=PRN" or die $!;
$self->report;
close STDOUT; # Huh? I'm not sure what to do after the dup is done
}
The pre-report and post-report are all different codes for each caller.
Thus, only pre_report and post_report are not enough. You need
pre_report_in_gen, post_report_in_gen, pre_report_in_save_as_html, ...
So I said "you have to find out every spots where it is used/called,
and re-arrange the caller (gen, save_as_html, etc) into pieces of ugly codes."
> > Since we want to override the "interface", then orerride it, and
> > done!!!
>
> Hmm.. that doesn't seem like what you are saying. You don't want to
> just override it, you want to interpose the new method in such a way
> that the original method is still called.
Yes!!! Every sample I post here, as well as my problem in real case
are all "the middle layer interposes, and still call the original method",
just as you say. You are the one who understand my question most and best.
I think it is one typical type of programming in polymorphism, so I ask here.
But if you think all this kind of programming can be avoided or converted into
other types, I will still accept. But how?
Hmm... the only feasible solution up to now is your pre-post method.
(The "renaming" is not a solution because it doesn't work.)
But it is still too much effort and messy re-writing. Not clean enough to me.
Thank you.
John Lin
------------------------------
Date: 21 Aug 2001 20:07:01 -0700
From: johnlin@chttl.com.tw (John Lin)
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <a73bcad1.0108211907.aace6d6@posting.google.com>
Chris Fedde wrote
> John Lin wrote:
> >sub gen {
> > $self->pre_report_in_gen;
> > $self->report;
> > $self->post_report_in_gen;
> >}
> >
> >and also
> >pre_report_in_save_as_html;
> >post_report_in_save_as_html;
> >pre_report_in_print_to_printer;
> >post_report_in_print_to_printer;
>
> It seems to me that you are throwing too much behavior into the
> report class. Why does anything inheriting from Report need to
> know about HTML? or any other output format for that matter. The
> report object has report like atributes like parts and headings
> and items and subheadings and sums and other such data. An
> output class would translate this into an output format.
HTML, printer... Oh no, I was just giving examples to illustrate the idea:
"sub report() may be called from many places". Let's don't bother discussing
WHERE it is called from if you agree "it may be called from many places", OK?
> my $report = Inherits::From::Report->new(%subject_data);
Here, in my example, conceptually it is closer to write
my $report_preparer = ... blah blah
It's not the report itself. It's an object to generate report, and
$report_preparer->gen;
generates it. The preparation of the report is defined in sub report,
and overriding sub report can change the behavior of its preparation.
> print STDOUT Output->as_HTML($report);
>
> Because all the Report objects adhere to the interface then the Output class
> just has to be aware of that interface and do the right thing with it.
You can shift the formatting work to a dedicated class Output.
Actually the problem we are discussing may also be shift there, because
you still need to call the $report_preparer's gen
$report_preparer->gen;
which calls
$report_preparer->report;
to generate the report when Output wants to format it. Then the situation
to this question is still unchanged.
Anyway, we were discussing "sub report() may be called from many places".
Thank you.
John Lin
------------------------------
Date: Wed, 22 Aug 2001 03:12:18 GMT
From: Neil Conway <spam@klamath.dyndns.org>
Subject: PerlFS?
Message-Id: <3B832318.60304@klamath.dyndns.org>
Hi all,
Does anyone know what has become of PerlFS? The website is down -- the
domain name (assurdo.com) expired in July, the freshmeat entry has been
removed, there is no Google cache and search engine queries don't turn
up anything useful. Has development stopped? Does anyone have a copy of
the most recent source code?
If PerlFS has vanished, do any alternatives exist? I looked at 'userfs',
but the work required to hack it to compile with 2.4.x kernels looks
non-trivial.
(If anyone is not familiar with PerlFS, you can find a summary here:
http://linux-patches.rock-projects.com/v2.0-f/perlfs.html)
Any information or suggestions will be much appreciated. If this is too
off-topic, my apologies.
Thanks in advance,
Neil
------------------------------
Date: Wed, 22 Aug 2001 02:16:30 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: regex to edit config variable
Message-Id: <2CEg7.28567$1p1.2060679@bgtnsc04-news.ops.worldnet.att.net>
Is the pair stored in the file as "myVar=myVal" ? Just use
s/myVar\=.*?\;/myVar\=$newVal\;/
Kevin
In article <YBzg7.908$OG4.81926@newsread1.prod.itd.earthlink.net>, "Dale
Henderson" <projectobjects@earthlink.net> wrote:
> I know that App::Config can retrieve values from perl config variables.
> Is there a known function that can change the value of the config
> variable in a flat text file in the following format
>
> $var = "value1";
>
> or could someone post a regex that can do the replace for the value1.
> Obviously, I am a novice with regex.
>
> thanks for any replies,
> dalehend@yahoo.com
>
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 1583
***************************************