[7845] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1470 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 14 12:07:20 1997

Date: Sun, 14 Dec 97 09:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 14 Dec 1997     Volume: 8 Number: 1470

Today's topics:
     Re: A sort list problem ... (Abigail)
     Re: Another Sort problem, this time with numbers (Abigail)
     Can't catch output from cacls.exe on NT <knut@webcom.no>
     Re: CGI problems.. <jason.holland@dial.pipex.com>
     Re: Database Manager Problem (Peter J. Schoenster)
     Embedding Perl In A C++ Program (Greg Teets)
     German characters <jblazi@wuerzburg.netsurf.de>
     Re: HELP - Bulkmail - Does anyone know how to do it? (Bart Lateur)
     Help: How to get IP and full domain name of my host? (Alex Dong Li)
     Re: How to get everything in between <pre>....</pre> ta (Michael Budash)
     Re: mkdir command (Abigail)
     Re: mkdir command <tchrist@mox.perl.com>
     Re: perl http client via sockets <nospam@domain.com>
     perl4 -> perl5 upgrade - problems with db <chr@mediascape.de>
     Re: pgp encrypion via perl script (Michael Budash)
     Re: pgp encrypion via perl script <nospam@domain.com>
     Re: pgp encrypion via perl script <nospam@domain.com>
     Re: Shoving an array into a glob? or fixing IO::ScalarA schwern@rt1.net
     Teaching programing <jblazi@wuerzburg.netsurf.de>
     Re: Teaching programing <uzs7ci@ibm.rhrz.uni-bonn.de>
     Re: Teaching programing <adavid@netinfo.com.au>
     Re: Teaching programing <merlyn@stonehenge.com>
     Re: Which language pays most 17457 -- C++ vs. Java? (Kurt Watzka)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 14 Dec 1997 07:45:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: A sort list problem ...
Message-Id: <slrn6973np.50c.abigail@betelgeuse.wayne.fnx.com>

Kilrogg2_GS (kilrogg2@mindless.com) wrote on 1563 September 1993 in
<URL: news:66ppbu$dft@news2.snet.net>:
++ Hi !
++ 
++ Here is my problem, i want to reorder a list of word in the
++ alphabetical order.
++ I tried the script below but it doesn't work at all !
++ 
++ @list = ('HeLlo','how','arE','yOU','Today');
++ @list = sort @list;
++ 
++ Instead it gives the result : ('HeLlo','Today','arE','how','yOU')

Well, that's what it's supposed to do....

++ 
++ Does anybody have an idea of what to do here ?

You want to sort it case insensitive. So, you should compare
the strings when they have the same case, for instance, lowercase.
Like this:

    @list = ('HeLlo','how','arE','yOU','Today');
    @list = sort {lc $a cmp lc $b} @list;

Or to prevent doing too many lc's, use a Schwartzian Transform:

    @list = ('HeLlo','how','arE','yOU','Today');
    @list = map  {$_ -> [0];}
            sort {$a -> [1] cmp $b -> [1];}
            map  {[$_, lc];} @list;


For details about the syntax of sort, see the man pages.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 14 Dec 1997 09:19:13 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Another Sort problem, this time with numbers
Message-Id: <slrn69797r.50c.abigail@betelgeuse.wayne.fnx.com>

Martin Cohen (mcohen@netaxs.com) wrote on 1566 September 1993 in
<URL: news:34939965.2A20@netaxs.com>:
++ John Moreno wrote:
++ > 
++ > fTiwason <tiwason@aol.com> wrote:
++ > 
++ > > If i have a bunch of numbers to sort say
++ > > 5,7,2,1,21,4,11,32
++ > >
++ > > is there anyway to get around them sorting like
++ > >
++ > > 1,11,2,21,32,4,5,7
++ > 
++ > You know, I started to reply to this with a informative answer with a
++ > bit of sample code, then I realized that it's in the manual, not even in
++ > the faq but in the damn manual under the description of sort.  If you've
++ > learned how to use sort then you know how to do this.  I'm not too
++ > familiar with sort and thought you had probably tried the obvious and it
++ > didn't work because perl was treating the elements as strings and they
++ > just needed to be coerced into integers using int, but no that's not the
++ > cause, you haven't read the manual on how to use sort at all.  Look at
++ > the manual and THEN you'll know how to do it.  Hint: it's so
++ > pathetically easy that you'll feel stupid for not knowing how to do it.
++ > 
++ > --
++ > John Moreno
++ 
++ Seems like a pretty rough answer.  If you sort numerically you get
++  1,2,4,5,7,11,21,32 not 1,11,2,21,32,4,5,7
++ So I guess you have to sort using cmp, but that may not work if the
++ strings are different lengths.  Please show the code you were going to
++ post.


Djee. Are you really too lazy to look it up in the manual?
Here are the first lines:

     sort SUBNAME LIST
     sort BLOCK LIST
     sort LIST

     Sorts the LIST and returns the sorted list value.  If SUBNAME or BLOCK
     is omitted, sorts in standard string comparison order.

Could it be the answer is:

     @sorted = sort 5,7,2,1,21,4,11,32; 


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Sun, 14 Dec 1997 12:31:52 +0100
From: Knut Brobakken <knut@webcom.no>
Subject: Can't catch output from cacls.exe on NT
Message-Id: <3493C3A8.F82F7386@webcom.no>

I try to use two console programs, cacls.exe and fileowner.exe. Both of
these
return or set the users and groups that have rights to a file. For
instance:

cacls c:\mycatalog returns a list of which users/groups have access to
that file, and
what rights (full, read etc.) they have.

That is, it happily returns this list to the screen, but when I'm trying
to catch the output by
backticking the command from perl, I receive a garbled, unusable version
of the list.
Is there a way of catching the output or using Win32::API to read the
file permissions?

(I know about Win32::FileSecurity, but it crashes if a user tries
reading permissions for a file he/she doesn't have the right to. Also, I
have another console program called fileowner.exe, which reads/sets the
owner of a file. This can't be done from the FileSecurity module.)

Hope someone can give me a solution....



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

Date: Sun, 14 Dec 1997 15:48:54 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: Natural Alternatives <namaste@goodnet.com>
Subject: Re: CGI problems..
Message-Id: <3493FFE6.4EE8F6F@dial.pipex.com>

Natural Alternatives wrote:

> I am currently in the process of changing internet providers and
> transferring my CGIs from one site to another..
>
> No matter what I do I cant seem to get the CGIs to operate on the new
> server..
>
> I get one of 2 errors..
>
> 501 Not Implemented
> We are sorry to be unable to perform the method POST to non-script at
> this time or to this document.
>
> OR
>
> It displays the CGI instead of executing it...  it displays it like a
> text file ??
>
> I have never encountered these errors before and im not sure where to
> start..  All my file permissions and directory paths seem to be in
> order..

Hello J

If the server is a UNIX type one, then it sounds like the scripts have
not been set to execute perhaps, their modes need to be set to something
like:

    chmod a+x script.cgi

This will make 'script.cgi' executable.

If I remember correctly, I think that the 501 error basically means that
the web server was expecting to run a program, but the file it tried to
execute was not an executable?

Thanks accepted in advance

Jason

http://dspace.dial.pipex.com/jason.holland/




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

Date: Sun, 14 Dec 1997 12:39:27 GMT
From: pschon@baste.magibox.net (Peter J. Schoenster)
Subject: Re: Database Manager Problem
Message-Id: <3493d37b.89237466@news.magibox.net>

[ cc to author ]
On 9 Dec 1997 01:53:22 GMT, you wrote:

>Hi!
>I have installed selena sol's database manager version 5.01, all functions
>except the delete function work. When I delete any row from the database,
>the entire database size will be reduced to 0!!
>
>Anyone know how to solve this or recommend a newbie-configurable/freeware
>database manager?

I suggest you give up that database manager.  Use a rdbms like maybe
mSQL or mySQL which a lot of ISP's provide with webhosting.  Believe
me it is worth the effort and  money if you have to spend it.  I once
wrote a program with that database manager because the client wanted
it.  It was a  nightmare.  I usually have written my own db managers
for dbm's and flat files.  Going to rdbms like mSQL is like going from
a 14.4 to a 28.8 modem; you ask yourself why you didn't do it before.

Peter



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

Date: Sun, 14 Dec 1997 16:23:23 GMT
From: teetshd@email.uc.edu (Greg Teets)
Subject: Embedding Perl In A C++ Program
Message-Id: <3494079c.34276567@news.ececs.uc.edu>

I'd like to use some Perl string processing functions within a C++
program I'm doing.  Please point me in the right direction for
information on how to do this.

Thanks
Greg Teets
Cincinnati


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

Date: Sun, 14 Dec 1997 10:11:52 +0100
From: "Janos Blazi" <jblazi@wuerzburg.netsurf.de>
Subject: German characters
Message-Id: <6707qi$jad@news1.citylink.de>

I am using PERL ($]=5.00390) with NT 4.0 in Germany. I have noticed, that
the german v (i.e. an o with two dots on it) is not matched by \w. In the
camel book the authors say that would depend of my "locale". I do not
understand this. Anyway: Can I change this, i.e. can I have PERL reckognize
the german v as a word character?

Thanks in advance.

Janos Blazi
(jblazi@wuerzburg.netsurf.de)




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

Date: Sun, 14 Dec 1997 13:20:35 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: HELP - Bulkmail - Does anyone know how to do it?
Message-Id: <3497dafe.5312785@news.tornado.be>

hector@csgm.com (hector Catre) wrote:

>I've been given a text based database of over 12,000 e-mails
>
>I write a simple program that referrances each e-mail one by one and sends an 
>e-mail through sendmail to each and every individual.
>
>problem:
>
>because my script is browser based (the message to be sent is posted from an 
>html form), the browser times out long before the 12,000 can be sent, and 
>instead get a 'no data error'.
>
>Suggestions, Advice, Theoretical solutions are always welcome.

Arghhh! I HATE bulk e-mail! Some bloody spammer even sent me several
bulk e-mails in Chinese! (I don't know any Chinese, if you might have
thought that... Most people in Europe don't know Chinese.)

But anyway, if you promise to be very, very careful...

You're trying to send the bulk e-mail in a CGI script, right? Well, you
should close the communication with the browser, by "closing" STDIN and
STDOUT. See Randal's Webtechniques, Column 20 for some nifty ideas.

	http://www.stonehenge.com/merlyn/WebTechniques/

HTH,
Bart.


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

Date: Sun, 14 Dec 1997 15:48:54 GMT
From: lidong@globalserve.net (Alex Dong Li)
Subject: Help: How to get IP and full domain name of my host?
Message-Id: <670vb9$5k5$1@titan.globalserve.net>

Hello, expert,

Could anyone tell me if there is a function to get IP and full domain name
of my host? 
Functions gethostbyaddr and gethostbyname reply on one of IP and full domain
name. Unix command "hostname" only gives the sub domain name.

Thanks for help in advance!

Alex Dong Li 

Email: ali@genet.sickkids.on.ca    URL: http://www.globalserve.net/~lidong/


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

Date: Sun, 14 Dec 1997 03:03:46 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: How to get everything in between <pre>....</pre> tags in html
Message-Id: <mbudash-1412970303470001@d134.pm11.sonic.net>

In article <343E8927.26E1@nt.com>, Daniel Lortie <dlortie@nt.com> wrote:
>> 
>> I have an HTML file that I read from the internet, but I want
>> to parse the file I receive to only keep the text between the
>> <pre> and </pre> tags. Is there a quick way to do this?
>> 

If you've only got one such occuring pair of <pre>'s, this should do it:

 open (FILENAME) or die("oops!");  # open the file (duh!)
 @lines = <FILENAME>;  # get all the records at once
 close (FILENAME);  # close the file
 $lines = join ('', @lines);  # make one big scalar
 $lines = lc($lines);  # make it lower case
 $tokeep = $1 if ($lines =~/<pre>(.*)<\/pre>/);  # find the pair and only
save what's between 'em

You get to keep any newlines...

If there's more than one pair of <pre>'s, it' be harder, considering the
possibilites of things like:

  <pre>Here's some pre-text
  and some more.</pre><hr><pre>Here's some more pre-text without starting
a new line.
  Darn! That makes it harder...</pre>

Does this help?
--
                   _____________________________

                       Michael Budash, Owner
                     Michael Budash Consulting
                           707-255-5371
                        707-258-7800 x7736
                   http://www.sonic.net/~mbudash
                         mbudash@sonic.net
                   _____________________________


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

Date: 14 Dec 1997 07:39:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: mkdir command
Message-Id: <slrn6973c4.50c.abigail@betelgeuse.wayne.fnx.com>

Randal Schwartz (merlyn@stonehenge.com) wrote on 1565 September 1993 in
<URL: news:8cd8j147ie.fsf@gadget.cscaper.com>:
++ >>>>> "Abigail" == Abigail  <abigail@fnx.com> writes:
++ 
++ Abigail> Given the fact Perl often uses function names that come from
++ Abigail> someplace else, and Perl isn't afraid to make exceptions,
++ Abigail> just "to do as you expect it to do", I don't think it is
++ Abigail> unreasonable to expect that C<umask 022; mkdir "newdir",
++ Abigail> 777;> creates a directory with permissions rwxr-xr-x.
++ 
++ Except that both umask and mkdir[1] were system calls before they were
++ functions, and the system calls certainly would have required 0777
++ instead of 777.

Of course. But regardless of where Perl got mkdir and umask from, there
will be many people who know the mkdir and umask commands from their
shell, and for the reason I gave above, expect it to behave the same as
the shell.

++ In fact, come to think of it, except for "grep", I don't know of any
++ Perl op that derives from a command, but I know of a dozen or three

What about 'eval'?

++ that derive from C-like system or library calls.  So, if a new Perl
++ operator named "ulimit" came along, I'd certainly expect it to have
++ the syscall interface, *not* the command interface.

I wouldn't, as I am much more familiar with shell programming than C
programming. Whatever choice you make in such cases, it will be natural
for one group, and counter intuitive for another. Combined with the fact
that perl is "supposed to do what you expect it to do" instead of "perl
is orthogonal" or "supposed to do what you expect it to do, but only if
you are a C programmer", you will always have people making these kind
of mistakes.

I am not at suggesting Perl should change - it's just that I am not
surprised this particular error is made over and over again.

Perhaps -w should trigger a warning if someone uses a numerical literal
with umask, mkdir or chmod that doesn't start with a 0.  The few who
use 511 instead of 0777 are smart enough to set $^W. ;)


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 14 Dec 1997 14:28:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: mkdir command
Message-Id: <670qe9$gmb$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, abigail@fnx.com writes:
:Perhaps -w should trigger a warning if someone uses a numerical literal
:with umask, mkdir or chmod that doesn't start with a 0.  The few who
:use 511 instead of 0777 are smart enough to set $^W. ;)

    jhereg(tchrist)% perl -wce 'chmod(44, "asdf")'
    chmod: mode argument is missing initial 0 at -e line 1, at end of line

But not sysopen or mkdir or umask.  Patches welcome.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    Just don't create a file called -rf.  :-)
            --Larry Wall in <11393@jpl-devvax.JPL.NASA.GOV>


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

Date: Sun, 14 Dec 1997 16:13:15 GMT
From: John Nolan <nospam@domain.com>
Subject: Re: perl http client via sockets
Message-Id: <349406DA.1F70@domain.com>

mikane@shell3.ba.best.com wrote:
> 
> I want to write a perl script that will get an HTML
> page off a server on the Internet using http.
> 
> I assume the way to go about it is to go the socket
> route. My perl 5 book is a bit skimpy on this subject.
> 
> Can anyone suggest a reference?


Using Perl, the easiest way is to use the LWP module,
which you can get off of CPAN.  LWP will take care of 
the socket stuff for you.   You can write your
own code to access the sockets directly, but it's
a lot quicker to download and install LWP.  

The best general introduction to the LWP is the O'Reilly
book Web Client Programming.  This will tell you everything
you need to know, and probably a lot more than that. 

--John Nolan


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

Date: Sun, 14 Dec 1997 17:10:58 +0100
From: Christian Bruegmann <chr@mediascape.de>
Subject: perl4 -> perl5 upgrade - problems with db
Message-Id: <34940512.648@mediascape.de>

Hi

I want to upgrade from perl4.018 to perl5.004.

My Problem is that i have about 200 databases (dbm with .pag and .dir).
My new Version of Perl seems to use an other type of databases - there
is no .pag and .dir ending anymore. That will be ok - because the old
scripts will work - but i can't open the new type with my old "dbmopen
(...)" - - where can i set the type of the used database ????

Please email me your suggestions or hints too because i'm having some
problems to get allways the latest news... THANKS A LOT !!!

Christian
hamburg - germany


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

Date: Sun, 14 Dec 1997 04:13:32 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: pgp encrypion via perl script
Message-Id: <mbudash-1412970413320001@d134.pm11.sonic.net>

In article <66unui$rl6@bgtnsc02.worldnet.att.net>, comdog@computerdog.com
(brian d foy) wrote:

>> In article <mbudash-1312970304160001@d67.pm2.sonic.net>, mbudash@sonic.net
>> (Michael Budash) wrote:
>> 
>> > In article <34917ff8.17495498@news.scescape.net>, rgay@palmetto.net wrote:
>> > 
>> > >> Any ideas on  this one...
>> > 
>> > If I'm gathering your problem correctly, I just went thru the same thing
>> > on an Irix server, and the answer was incredibly simple:
>> 
>> > chdir "path_to_dir_containing_pgpe";
>> > $encrypted_data = `(echo "$unencrypted_data") | pgpe -at -r
>> > $recipient_email_address`;
>> 
>> > Pretty simple, eh?
>> 
>> THIS IS NOT THE RIGHT WAY TO DO IT (yes i'm yelling).
>> 
>> you cannot store the plaintext on disk.
>> you cannot store the plaintext on disk.
>> you cannot store the plaintext on disk.
>> you cannot store the plaintext on disk.
>> you cannot store the plaintext on disk.
>> you cannot store the plaintext on disk.
>> you cannot store the plaintext on disk.
>> 

ok, brian, i give up - what are you talking about? i'm _not_  storing the
plaintext on disk....

michael

-- 
                   _____________________________

                       Michael Budash, Owner
                     Michael Budash Consulting
                           707-255-5371
                        707-258-7800 x7736
                   http://www.sonic.net/~mbudash
                         mbudash@sonic.net
                   _____________________________


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

Date: Sun, 14 Dec 1997 15:55:33 GMT
From: John Nolan <nospam@domain.com>
Subject: Re: pgp encrypion via perl script
Message-Id: <349402B2.265C@domain.com>

> > In article <34917ff8.17495498@news.scescape.net>, rgay@palmetto.net wrote:
> >
> > >> Any ideas on  this one...
> >
> > If I'm gathering your problem correctly, I just went thru the same thing
> > on an Irix server, and the answer was incredibly simple:
> 
> > chdir "path_to_dir_containing_pgpe";
> > $encrypted_data = `(echo "$unencrypted_data") | pgpe -at -r
> > $recipient_email_address`;
> 
> > Pretty simple, eh?
> 
> THIS IS NOT THE RIGHT WAY TO DO IT (yes i'm yelling).
> 
> you cannot store the plaintext on disk.
> you cannot store the plaintext on disk.
> you cannot store the plaintext on disk.


1.  This script does not necessarily store anything to disk.
    Is uses "echo", not "cat".  $unencrypted_data is not a filename.
    It might prompt the user to enter data, and then echo it
    to pgp directly.  

2.  Storing unencrypted data to disk is not necessarily bad.
    Whether it's bad depends on how secure your disk is, 
    or how secret the data actually is.  Maybe we don't care
    if any other local users see it. 

3.  This script does have one problem, and that is that the text
    of $encrypted_data may show up in a "ps" list on that machine.
    Again, whether this is bad depends on your machine, and how
    secure you need to be.  
    
--John Nolan


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

Date: Sun, 14 Dec 1997 16:02:12 GMT
From: John Nolan <nospam@domain.com>
Subject: Re: pgp encrypion via perl script
Message-Id: <34940442.1A9F@domain.com>

rgay@palmetto.net wrote:
> Here's another example of code that produces the same webserver error.
> Again it works fine via the command line and I've paid very close
> attention to the file permissions.  The scalar variable $pgpprog is
> assigned an absolute path. The mailing works fine. As best that I can
> discern, the PGPPATH enviroment variable needs to be set in this
> script, what's the best way to set it??


>From Perl FAQ 9:

My CGI script runs from the command line but not the browser.
Can you help me fix it? 

Seriously, if you can demonstrate that you've read the following FAQs
and 
that your problem isn't something simple that can be easily answered, 
you'll probably receive a courteous and useful reply to your question 
if you post it on comp.infosystems.www.authoring.cgi (if it's something 
to do with HTTP, HTML, or the CGI protocols). Questions that appear to
be 
Perl questions but are really CGI ones that are posted to 
comp.lang.perl.misc may not be so well received. 

The useful FAQs are: 

    http://www.perl.com/perl/faq/idiots-guide.html
    http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
    http://www.perl.com/perl/faq/perl-cgi-faq.html
    http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
    http://www.boutell.com/faq/


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

Date: Sun, 14 Dec 1997 06:51:17 -0600
From: schwern@rt1.net
To: eryq@zeegee.com,rootbeer@teleport.com
Subject: Re: Shoving an array into a glob? or fixing IO::ScalarArray
Message-Id: <882103000.1135869959@dejanews.com>

You're all WRONG!  I fucking did it! :)  (Pardon my over zealousness)

The following gives the basic ideas.  I'll be hacking this into
IO::ScalarArray later... Enrq BEWARE!


### WARNING ROCKS AHEAD! ###

package Array;

use strict;
use Symbol;
# Straight forward TIEHANDLE routine.
# Array reference is stored on the scalar portion.
sub TIEHANDLE {
  my($class) = shift;
  $class = ref $class || $class || 'IO::Array';

  my $self = gensym;

  ${*$self} = shift;
  bless $self, $class;
  return $self;
}


# Here's the trick... since a tied variable is not technically blessed, we
# bless it again.
sub new {
  my ($class, $realSelf) = @_;
  $class = ref $class || $class || 'IO::Array';
  my $self = $realSelf;   # "Tell me what's in the box!!"
  bless $self, $class;
  return $self;
}


sub READLINE {
  my $self = shift;
  shift @$$$self;    # Triple ick!
}


sub print {
  my($self) = shift;
  push(@$$self, @_);  # ick, ick, ick!
  return 1;
}


sub FETCH {
  my($self) = shift;
  return $$$self;   # double ick
}

1;


Here's the test program...

use Array;
use Symbol;

@array = qw(yarblockos bar jar 13258 2345 23 j awoeiu);

$foo = gensym;

tie *{$foo}, 'Array', \@array;	# we tie, $foo $foo = Array->new($foo); 
# and then also make it an Array object.  # is tricky, no?

$line = <$foo>;

print "$line\n";     # prints "yarblockos", as it should.

$foo->print('argh!');

print "@$$foo";  # prints "bar jar 13258 2345 23 j awoeiu argh!",as it
should. print "@array";  # prints same as above, again as it should.


Now, I'm not entirely sure why this works, or why I need so many
dereferences. I really just figured it out by stepping through with the
debugger and then adding the appropriate number of derefs.  Further
investigation should produce further distasteful code.	Furthermore, I
haven't tested it very much, so it all might come tumbling down when I
try to do something real with it...

 ....but it works. :P

Now I get to do the 'I-told-you-so' dance!

BTW, Thanks for talking it through with me, Tom... even if you never
quite did figure out what I was talking about. ;)

I'm happy now.  Its time for a milkshake.

--

"I wanna job, I wanna job / I wanna good job  schwern@rt1.net  I wanna
job, I wanna job that pays.  www.envirolink.org/home/schwern  I wanna
job, I wanna job / I wanna real job  aka Floggo the Stupid  One that
satisfies my artistic needs"  - "Sid & Nancy"

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Sun, 14 Dec 1997 10:16:11 +0100
From: "Janos Blazi" <jblazi@wuerzburg.netsurf.de>
Subject: Teaching programing
Message-Id: <67082l$jb5@news1.citylink.de>

I have to teach programing to 15-years old pupils. Is PERL a good language
to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems to
be absolutely dead and the first steps in PERL are perhaps easier than the
first steps in C. Or should I take BASIC (oh horror!)?

THIS IS NOT A JOKE!

Janos Blazi
(jblazi@wuerzburg.netsurf.de)






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

Date: 14 Dec 1997 14:06:10 +0100
From: Oliver Much <uzs7ci@ibm.rhrz.uni-bonn.de>
Subject: Re: Teaching programing
Message-Id: <670lk2$5c@walras.econ.de>

Janos Blazi <jblazi@wuerzburg.netsurf.de> wrote:

JB>I have to teach programing to 15-years old pupils. Is PERL a good language
JB>to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems to
JB>be absolutely dead and the first steps in PERL are perhaps easier than the
JB>first steps in C. Or should I take BASIC (oh horror!)?

You shouldn't use perl for the first steps in programming as it is not that
'talky' as PASCAL or BASIC. Perl programs look a little weird for someone
who has never seen C. 


-- 
---
Oliver Much|@home: UZS7CI@ibm.rhrz.uni-bonn.de     | Sei P ein Punkt Q wir
           |@work: oliverm@addi.finasto.uni-bonn.de| wollen ihn Z nennen. 


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

Date: Mon, 15 Dec 1997 00:14:21 +1100
From: Anthony David <adavid@netinfo.com.au>
Subject: Re: Teaching programing
Message-Id: <3493DBAD.F59C0A33@netinfo.com.au>



Janos Blazi wrote:

> I have to teach programing to 15-years old pupils. Is PERL a good language
> to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems to
> be absolutely dead and the first steps in PERL are perhaps easier than the
> first steps in C. Or should I take BASIC (oh horror!)?
>

The following points are dug up (and filtered through time and flights of
hubris) frommy first steps in programming:-

When I was 15 we used APL. It was quite amazing that we were generating
"expected
results" in the limited time we had. (one hour a week to scribble on mark sense

cards then wait a week for the cards and output to be delivered). I think the
key
was the development of some understanding of algorithm and its translation. APL

seemed to fit the bill for inscribing algorithms concisely.

The first language thrown at us in Uni was Pascal, strict Wirth. It was here
that I learnt
how tedious programming can be, how beneficial high level string handling and
I/O can
be (because Pascal had none - though I am sure newer variants overcome that).
One thing that was beneficial was its block structure and parameter passing
("refined" by Wirth in Modula2).

If you teach them Pascal they are probably going to hate you but you may get to
teach
them some good programming habits. In hindsight,  most of the 250,000+ lines of

COBOL,  I wrote when I started my career were very strongly influenced by the
structured discipline I learnt while being tortured by Pascal. In fact most of
the
coding in any language I have done has been influenced by it.

When I got my first microcomputer, I played around writing games in BASIC.
The limitations I found while trying to impose a structured discipline on BASIC

found me often "coding up blind alleys".

Coding in C seems to force you broach the pointer subject faster than any of
the
other languages mentioned above due to the fact that std libraries are required
to
be able to do anything worthwhile in the language.

The only language where pointers really became clear to me was Assembler.
You deal with pretty much the raw computer and storing addresses is such a
natural thing to do. Now that would be a REAL computer course.

As someone who is a passionate proponent of Perl, the temptation is to say
"forget the rest, don't taint their minds", however I think that would be doing
them
a disservice. As Chip Salzenburg said once, "The ability to think
algorithmically
is an essential trait of a programmer". The next is to be able to describe that
algorithm
according to the language at hand. Without the discipline of something like
Pascal, the majority of your students are not going to automatically code in a
structured
manner. You can stand at the front of the class and tell them to code in a
particular
manner, but that is (I feel) why Wirth  attempted to automate those rules in
the
form of the Pascal (and subsequent Modula-2) language.

The beauty to me of Perl is that after struggling with a number of languages, I
can
have a true sense of  "I can get there from here". The language does not get in
the way
of what I want to do and how I want to express it (I'm sure there are
exceptions!!).

In summary, teach them Pascal then teach them Perl. Teach them any of the
languages
I mentioned above too.

Regards

Anthony


> THIS IS NOT A JOKE!

But this is   >> The Ricky Lake Show <<

--
Anthony David     |     Opinions expressed ARE
Anthony David & Associates |     those of my employer




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

Date: 14 Dec 1997 08:32:18 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Teaching programing
Message-Id: <8csorw2b5p.fsf@gadget.cscaper.com>

>>>>> "Anthony" == Anthony David <adavid@netinfo.com.au> writes:

Anthony> The language does not get in the way of what I want to do and
Anthony> how I want to express it (I'm sure there are exceptions!!).

In fact, some argue that "Exceptions" are one of those exceptions.

:-)

I agree with most of adavid's comments... I was stuck in BASIC-land
for the first six years of my hacking, although I had learned FOCAL on
paper before that, and hacked my HP-41C a bit.  (I'm probably dating
myself here... but if I don't, who will? :-)

The biggest and best mindshift for me was taking some Pascal classes
at the local science museum (at which Tom Phoenix, aka
rootbeer@teleport.com, was an employee for many years).  All of a
sudden, I saw how code could be concise, elegant, and even (gasp!)
designed!

Had it not been for the Pascal experience, I would probably have never
grokked C or any other structured language until way later, mostly
because the Pascal instructor was *very* good at motivating proper
subroutine/function design, and limited-scope variables, and using
subroutines to keep the program flow visible.  Things I usually ignore
in my five-line Perl hacks, but you'll notice that the columns I write
at http://www.stonehenge.com/merlyn/WebTechniques/, I'm pretty careful
to keep a variable alive *only* for the time it is needed.

I lost track at about 50 languages on my resume after a 20-year
career, but those formative days with Pascal (and later C) helped to
undo the chaos of my BASIC training, and let me be truly productive
in the majority of the block-structured languages.

And for OO, I'd recommend Smalltalk.  There are public implementations
out there ("Squeak" even fits the Blue Book smalltalk very closely),
and it's really pure OO, unlike that C++ abomination or the Java
half-breed.  Sure, the real market never took off on Smalltalk, but
once you get it down, learning how half-object solutions like Perl and
Java works becomes much easier (and then you start wishing that
everything was an object instead of just the higher life forms :-).

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 261 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@ora.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: 14 Dec 1997 14:30:48 GMT
From: watzka@stat.uni-muenchen.de (Kurt Watzka)
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <670qio$8a$1@sparcserver.lrz-muenchen.de>

Guillermo Schwarz <gschwarz@netup.cl> writes:

>For a language to be succesful, 6 things must happen:
>1. Actual programs must be written in it.
>2. Lots of libraries must be written for it.
>3. Most computer architectures must have a compatible version of it.
>4. Source code must be easily understable (by good coders).
>5. Lots of programmers must know the language in deep.
>6. The syntax must be simple. The semantics must be well defined.

>C is ok with 1, 2 and 3, but not with 4, 5 and 6.
>Smalltalk is ok with 1, 2, 3, 4, 5 and 6.
>Take a look at Squeak.

You forgot to mention that this is your opinion, and nothing but
your opinion. C is a relatively simple language, and I doubt that
there are too many people around who both qualify as good coders 
and do not understand C after learning it.

Can you come up with any substantial facts that support the claim 
that more programmers know Smalltalk "in deep" than C? The syntax
of C is well defined. As long as you write code with well defined
semantics, well, the semantics are well defined in C. Whether 
the liberty to write code with undefined or implementation defined
semantics is a weak or a strong point for C, even I do not care to 
argue about.

Kurt

-- 
| Kurt Watzka                             Phone : +49-89-2178-2781
| watzka@stat.uni-muenchen.de


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

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 1470
**************************************

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