[12111] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5711 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 18 09:07:18 1999

Date: Tue, 18 May 99 06:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 18 May 1999     Volume: 8 Number: 5711

Today's topics:
    Re: *** What is wrong with this? *** <gellyfish@gellyfish.com>
    Re: *** What is wrong with this? *** <bie@connect.ab.ca>
        [ANNOUNCE]: bits & pieces: a sonic installation for the <ptraub@coos.dartmouth.edu>
    Re: A Perl Script <lone.wolf@net.ntl.com>
    Re: A Perl Script <t.klinger@mobilkom.at>
    Re: A Perl Script <news@thebeaches.to>
        Anyone can help ?? (Austin Ming)
    Re: changing drive letters on NT? (Scott McMahan)
    Re: DBI, mysql, perl <t.klinger@mobilkom.at>
    Re: FAQ 4.15: How do I find yesterday's date? <news@thebeaches.to>
    Re: File with TABS <news@thebeaches.to>
        Help, need Challenge Page <bie@connect.ab.ca>
    Re: Help, need Challenge Page <gus_goose@hotmail.com>
    Re: How to create passwords in .htpasswd <gellyfish@gellyfish.com>
    Re: inserting a byte into a file <news@thebeaches.to>
        NN creating random characters from Perl script output <news@thebeaches.to>
    Re: NN creating random characters from Perl script outp <gellyfish@gellyfish.com>
    Re: Occasional user <wyzelli@yahoo.com>
    Re: OOP and Perl-a good book? <fty@utk.edu>
    Re: Perl "constructors" <jdporter@min.net>
    Re: Perl "constructors" <jdporter@min.net>
    Re: Perl "constructors" <jdporter@min.net>
    Re: PERLFUNC: print - output a list to a filehandle (Bart Lateur)
    Re: PERLFUNC: print - output a list to a filehandle (Bart Lateur)
        Simple Time Manipulation <hannum@ohio.edu>
        Sorting problem II <t.klinger@mobilkom.at>
    Re: Sorting problem II (Bart Lateur)
    Re: Sorting problem II <t.klinger@mobilkom.at>
        Strange socket behavior <anno4000@lublin.zrz.tu-berlin.de>
    Re: Whats wrong? (Greg Andrews)
    Re: Windows NT Form Mail Response <gellyfish@gellyfish.com>
        WTD : Public key encryption code (chris losinger)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 18 May 1999 11:59:26 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: *** What is wrong with this? ***
Message-Id: <3741480e@newsread3.dircon.co.uk>

Tim <bie@connect.ab.ca> wrote:
> Please tell me what the error is that I can not find
> 
> 

No generally you tell us what the error message is and we tell you what 
caused it ;-}

> 
> #!/usr/bin/perl5
> 

No -w there ...

> require "subparseform.lib";

I have no way of knowing what is in this file so I cant possibly
say if that is part of your problem.

> &Parse_Form;
> 
> print "Content-type:text/html\n\n";
> 

Generally there would be a space expected on that line.

> $url = $formdata{'url'};
> $name = $formdata{'name'};
> $enter = $formdata{'enter'};
> $msg = $formdata{'msg'};
> $room = $formdata{'room'};
> 
> print <<"MYCODE"
                  ^
Missing Semicolon |


/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Sat, 15 May 1999 23:11:08 -0600
From: Tim <bie@connect.ab.ca>
Subject: Re: *** What is wrong with this? ***
Message-Id: <373E536C.5FAB@connect.ab.ca>

I've used that same libary on that same server, so it can't be wrong.
My isp hasn't told me how I can access my error log files


I R A Aggie wrote:
> 
> On Sat, 15 May 1999 00:48:36 -0600, Tim <bie@connect.ab.ca>, in
> <373D18C4.4A8E@connect.ab.ca> wrote:
> 
> + Please tell me what the error is that I can not find
> 
> I couldn't find one, syntactically speaking...and yes, I
> even turned on the -w switch...
> 
> + require "subparseform.lib";
> 
> But I don't have this, so I can't run it. Maybe this is the source
> of your problem? what do your server's error logs say?
> 
> James


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

Date: 18 May 1999 12:33:33 GMT
From: peter traub <ptraub@coos.dartmouth.edu>
Subject: [ANNOUNCE]: bits & pieces: a sonic installation for the WWW
Message-Id: <7hrmmt$ao2@senator-bedfellow.MIT.EDU>

**************************************
http://music.dartmouth.edu/~peter/bits

"bits & pieces" is a Web installation that searches
the Web for sound files. Found sound is processed in
various ways, and the results broadcast back over
the Web via RealAudio. Thus you need RealPlayer
(available for free at http://www.real.com) to hear it.

http://music.dartmouth.edu/~peter/bits

**************************************

A Bit More About "bits & pieces."

"bits & pieces" is a Master's thesis project. The thesis
paper itself will be available on the Web (linked to from
the "b&p" site), on or shortly after June 1st.

"b&p" is written in a combination of PERL and Csound. PERL
scripts are used to drive the search and download processes,
and PERL generated Csound files are responsible for the sound
processing. New sound files are found every morning, and are
used as the sources for the day's various sound collages. A new
collage/piece is generated every 15 minutes. "bits & pieces"
will automatically play back the 10 most recent pieces through
your RealPlayer.


**************************************

A Note from the Author:

I apologize for any multiple copies of this mailing you may
receive from cross postings. Please forward this freely. If
you would like more information about me or my other work
(much of which is available via RealAudio on my Website),
please go to:

http://music.dartmouth.edu/~peter/pmt

Thank you and Enjoy!

peter m. traub



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

Date: Tue, 18 May 1999 14:15:17 +0100
From: "Lone Wolf" <lone.wolf@net.ntl.com>
Subject: Re: A Perl Script
Message-Id: <374157a0.0@145.227.194.253>

Thanks again.  I am getting the sysadmin to build nt server and IIS4 +
Activestate onto my personal Machine so that I can try config changes on my
own machine, Hopefully I can get the server working properly

:)


Collin Starkweather wrote in message <3740BB0D.A17BF64A@colorado.edu>...
>> It has to be a configuration problem with the server can you suggest
>> anything as I have had enough and am going to rebuild the server tomorow.
>
>That would be a problem since I'm running NT and MIIS and it works on my
>machine.  And this is a virgin machine which still has the default
>/scripts settings.  Nothing fancy.
>
>Knowing nothing else, I would use the Microsoft Solution for What Ails
>You:  Uninstall MIIS and Perl.  Reinstall MIIS.  Now reinstall Perl.
>
>At least with the scripts I forwarded, you know you've got code that
>works on an NT 4.0 build 1381 SP4 box with MIIS 3.0 running ActiveState
>Perl 5.00502 with CGI module 2.42.
>
>--
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Collin Starkweather                                 (303) 492-4784
>University of Colorado            collin.starkweather@colorado.edu
>Department of Economics          http://ucsu.colorado.edu/~olsonco
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




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

Date: Tue, 18 May 1999 14:23:26 +0200
From: "Thomas Klinger" <t.klinger@mobilkom.at>
Subject: Re: A Perl Script
Message-Id: <7hrm3u$e3n$1@fleetstreet.Austria.EU.net>

[...]
>print "HTTP/1.0 200 OK\n\n";
I think that line is not really needed. My scripts don't have this line and
functions very well.

>print "Content-Type: text/html\n\n";
Be aware if this space between  "..:" and "text/ht.....".


[...]
>print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
$ENV{4REMOTE_ADDR4} is needed here.

Hope this helps.

Best regards,
                  Thomas Klinger
========================================
 ......E-Mail: t.klinger@mobilkom.at.....
 .........WWW: http://www.mobilkom.at....
========================================




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

Date: Tue, 18 May 1999 08:26:42 -0400
From: "Jim The Perl Guy" <news@thebeaches.to>
Subject: Re: A Perl Script
Message-Id: <7hrmai$2v6$1@news.auaracom.net>

I don't see why you need the first header but it has too many new line
characters. All headers should have only one new-lien char except the last
header which tells the server to start outputing the page/content. Thus:

print "HTTP/1.0 200 OK\n\n";
print "Content-Type: text/html\n\n";

should be

print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n";

If you just have one header then it being the only and last header, it will
have two new line characters.

print "Content-Type: text/html\n\n";

Jim



Lone Wolf wrote in message <3740587d.0@145.227.194.253>...
>The books I have must be so full of rubbish :-
>
>Can someone explain to me WHY this will not run on my Microsoft IIS 4
>server?
>
>print "HTTP/1.0 200 OK\n\n";
>print "Content-Type: text/html\n\n";
>print "<HTML>\n";
>print "<HEAD>\n";
>print "<TITLE>Hello World</TITLE>\n";
>print "</HEAD>\n";
>print "<BODY>\n";
>print "<H4>Hello World</H4>\n";
>print "<P>\n";
>print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
>print "</P>\n";
>print "<H5>Have a nice day</H5>\n";
>print "</BODY>\n";
>print "</HTML>\n";
>
>I keep getting the error message :-
>CGI Error
>The specified CGI application misbehaved by not returning a complete set of
>HTTP headers. The headers it did return are:
>
>And thats all I get back.
>
>Thanks for shedding any light.
>
>




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

Date: 18 May 1999 12:11:28 GMT
From: austin95002887@yahoo.com (Austin Ming)
Subject: Anyone can help ??
Message-Id: <7hrldg$ji9$2@justice.csc.cuhk.edu.hk>


#!/usr/bin/perl

$myVar = 3;
mySub($myVar);
print $myVar;
print youSub();

sub mySub { $myVar = $myVar + 2 ; }
sub youSub { $a=1 ; $b=2; $a; }

I do not know if the above script is correct to use 
 call by reference and call by value.

Anyone can help ??



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

Date: 18 May 1999 12:21:17 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: changing drive letters on NT?
Message-Id: <37415b3d.0@news.new-era.net>

James T Uren (jturen@earthlink.net) wrote:
>      system 'g:';
>      $COMMAND = "g:"; `$COMMAND`;
>      system 'chdir /d g:\\';
>   ... but I am curious why simply specifying
>   a drive letter doesn't work. is this just impossible? or is
>   there a trick?

When you do a system() or ``, you *DO* change the drive letter.
It works. BUT: You change it in the new process that's spawned to do
the command. Your CURRENT process does not change.

chdir() in Perl for Win32 works with drive letters. It's a
non-obvious thing, but it works. Try "chdir("x:"). You
can also give it a path: chdir("x:/what/ever").

Scott



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

Date: Tue, 18 May 1999 14:30:54 +0200
From: "Thomas Klinger" <t.klinger@mobilkom.at>
Subject: Re: DBI, mysql, perl
Message-Id: <7hrmhv$e9j$1@fleetstreet.Austria.EU.net>

>require "/usr/lib/perl5/cgi-lib.pl" || die "Could not open cgi-lib";
>&ReadParse;
>
>the code for the cgi is this...   $adjective6=$in{'city'};
I hope that I don't blame myself with this response but....
 ... arethose 'city' the right ones? Should they be 4?

Just a look ....




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

Date: Tue, 18 May 1999 08:24:35 -0400
From: "Jim The Perl Guy" <news@thebeaches.to>
Subject: Re: FAQ 4.15: How do I find yesterday's date?
Message-Id: <7hrm6l$2sn$1@news.auaracom.net>

WHAT??????

No matter what day of the week, month, year, decade or century, there are
only 86,400 seconds unless it's a daylight savings switch. In that case,
you'll have to write a rather large sub to recognize those dates. Doable but
it only makes a difference twice a year. Is it that much of a difference?

Jim

>>
>>  How do I find yesterday's date?
>>
>>    The `time()' function returns the current time in seconds since the
>>    epoch. Take one day off that:
>>
>>        $yesterday = time() - ( 24 * 60 * 60 );
>
>Except that 24*60*60 isn't always "one day", and thus can give the wrong
>answer. Refer to DejaNews for a more complete discussion of this
>problem, which takes place in this group on a regular basis.
>




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

Date: Tue, 18 May 1999 07:58:15 -0400
From: "Jim The Perl Guy" <news@thebeaches.to>
Subject: Re: File with TABS
Message-Id: <7hrkld$1cb$1@news.auaracom.net>

Use a REgExp:

$filename = "/bin/foo.tl";
$filename =~ s/\t+//g;
or if that doesn't work correctly for you, then:
$filename =~ s/\W//g;

Jim


John Wilkinson wrote in message <37411912.6DAA766B@soton.sc.philips.com>...
>Hi all,
>First, thanks for all the help with my first question.
>
>Now I have a little problem I cannot solve on my own, I need help.
>
>I have a text file that contains, amongst other things, filenames that
>need to be processed by a perl script. I read in these in my program,
>and all is well, unless someone has put a TAB or several spaces after
>the end of the filename, so when I come to add the filename extension,
>the filename becomes corrupted, with a number of TABS between the
>filename and its extension part, i.e.
>
>should be
>
>/bin/foo.tl
>
>with TABS is
>
>/bin/foo        .tl
>
>
>I need to be able to read in the file and strip off the TABS before I
>add the extension. I have tried using chomp, to no avail.
>
>Any ideas please.
>
>Regards,
>John.
>




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

Date: Sat, 15 May 1999 23:27:18 -0600
From: Tim <bie@connect.ab.ca>
Subject: Help, need Challenge Page
Message-Id: <373E5736.658E@connect.ab.ca>

Hello,


I just finished a basic, but good book on cgi/perl recently. But the
thing it didn't have was Challenge Scripts. I need some ideas on what I
should try to make. If you know of any site that lists projects from
beginner level to advanced, please post them.

Also if you could tell me what kind of scripts (maybe simple, but
useful, aka no Hello World type) you made while getting better at cgi
please email those to me.


Thank You


Tim


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

Date: Tue, 18 May 1999 12:48:51 +0100
From: gus <gus_goose@hotmail.com>
Subject: Re: Help, need Challenge Page
Message-Id: <374153A3.BA315C27@hotmail.com>

I am learning perl as well. One thing I have found very useful is a
process for me to be able to control / manage the modem attached to the
linux macnine on my home network. I have it dialing up, logging, and
more from a web page using unbuffered pages through an apache web
server. It is quite slick, and provided a project which involves:
"standard Perl", CGI, non-parse-headers, unbuffered pipes, OS
interaction, HTML, and plenty more. My next task is to provide a web
front-end to the Linux man pages which allows for searching the pages as
well. (I think I am going to incorporate database access as well, for
kicks).

One other thing I have already found useful is the dynamic listing of
the available "howtos" with links to the actual documents. I have done
similar things with the mini-howtos, and the package documentation
(/usr/doc/packages). By getting the man pages on-line, I will basically
have all my linux documentation available through a web interface.

I presume you are using a unix system ... most people are.

send me a mail if you want some of the scripts, otherwise I will forget
when I get home.

Another project for the near term is the graphical representation of
some of the server statistics. Something like a load manager, or a
network traffic meter. (apache access counter ...).

gus

Tim wrote:
> 
> Hello,
> 
> I just finished a basic, but good book on cgi/perl recently. But the
> thing it didn't have was Challenge Scripts. I need some ideas on what I
> should try to make. If you know of any site that lists projects from
> beginner level to advanced, please post them.
> 
> Also if you could tell me what kind of scripts (maybe simple, but
> useful, aka no Hello World type) you made while getting better at cgi
> please email those to me.
> 
> Thank You
> 
> Tim


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

Date: 18 May 1999 12:21:38 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to create passwords in .htpasswd
Message-Id: <37414d42@newsread3.dircon.co.uk>

Holger Kasten <hkasten@abm-soft.de> wrote:
> How can I create passwords in a .htpasswd
> file with a perl script???
> 

There is a module called HTTPD::UserManage available from CPAN:

<http://www.perl.com/CPAN/modules/by-module/HTTPD/HTTPD-User-Manage-1.53.tar.gz>

This will probably do most of what you want.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 07:56:25 -0400
From: "Jim The Perl Guy" <news@thebeaches.to>
Subject: Re: inserting a byte into a file
Message-Id: <7hrkhp$1c2$1@news.auaracom.net>

This isn't easy but it's a workaround:

open(TEMP1, "<$file") || die "Can't open $file: $!\n";
open(TEMP2, "<New_$file") || die "Can't open $file: $!\n";
while(<>) {
    if($_ =~ /your_pattern_match/) {
        print TEMP2 "$new_input\n";
    } else {
        print TEMP2 "$_\n";
    }
}
close(TEMP1);
close(TEMP2);
rename("New_$file", "$file");

Jim
news@thebeaches.to




Alexandre Kuhn wrote in message <374141CD.5373664B@iphysiolsg1.unil.ch>...
>Hi,
>
>I am trying to read and write to a file. I thus opened my file with the
>following:
>open(FILEHANDLE, "+<filename");
>I then read several lines until I wish to insert something. As I am
>already to far in the file I use a "tell-seek" combination to move back.
>The problem is that when I then use a "print" command it only overwrites
>the current byte, instead of inserting my byte.
>I was adviced to overcome this problem by simultaneously writing a
>second file as I am reading the original one. Then print the insertion
>to the second one, and complete it by reading-writing the rest of the
>original one.
>Does a command exist with which I would be able to easily insert
>something in my file?
>
>Thanks a lot,
>
>Alexandre
>




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

Date: Tue, 18 May 1999 07:36:51 -0400
From: "Jim The Perl Guy" <news@thebeaches.to>
Subject: NN creating random characters from Perl script output
Message-Id: <7hrjd4$bl$1@news.auaracom.net>

HELP!!!

I've written a Perl program that outputs and HTML file with JavaScript. The
first time a user runs through theprogram the output is fine, if they miss a
question (it's an exam) and then the program re-loads the question page, it
converts the following print statement:

print "<!-- In hiding!\n";

to this output:

<!C- In hiding!

Can anyone tell me why this is happening? The error doesn't occur in
Explorer, only Netscape is the bugger that converts characters for no
reason.

If you can help, please respond to news@thebeaches.to

ManyManyMany Thanks!!!!





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

Date: 18 May 1999 13:34:02 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: NN creating random characters from Perl script output
Message-Id: <37415e3a@newsread3.dircon.co.uk>

Jim The Perl Guy <news@thebeaches.to> wrote:
> HELP!!!
> 
> I've written a Perl program that outputs and HTML file with JavaScript. The
> first time a user runs through theprogram the output is fine, if they miss a
> question (it's an exam) and then the program re-loads the question page, it
> converts the following print statement:
> 
> print "<!-- In hiding!\n";
> 
> to this output:
> 
> <!C- In hiding!
> 
> Can anyone tell me why this is happening? The error doesn't occur in
> Explorer, only Netscape is the bugger that converts characters for no
> reason.
> 
> If you can help, please respond to news@thebeaches.to
> 

Of course this is a bug in Netscape and has nothing to with Perl - it
actually also highlights a bug in Explorer - Your comments are not right
- it is probably a missing --> at the end or whatever.  But as I say its
nothing to do with Perl and would be better asked in a newsgroup that is
interested in  the behaviour of  browsers.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 20:52:32 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Occasional user
Message-Id: <Z3c03.7$gJ3.701@vic.nntp.telstra.net>

Bart Lateur <bart.lateur@skynet.be> wrote in message
news:3740749c.814702@news.skynet.be...
> Andre Giroux wrote:
>
> >The installation of perl added the following line to the  autoexec.bat
file :
> >  path "%path%;C:\Perl\bin;"
> >I guess this would be adequate. Or is it ?
>
> Yes, provided that you did at least one reboot since Perl was installed.
>
> You can test it, in the DOS windows, by the command "path" (you'll see
> if indeed it IS in there), and if "perl -v" responds properly, saying
> what version it is, your perl installation probably is alright.
>
> I took a quick glance at the script, and I noticed that it supports some
> command line options, including "help". That should get you on your way.
> A simple "perl epstopdf -help" gave me the explanation for the command
> line switches.
>
> BTW the script seems to need Ghostscript as well. Do you have THAT
> installed?
>
> Bart.

on my PC Perl is located in:

C:\Perl\5.00502\bin\MSWin32-x86-object

but the path said c:\perl\bin after installation.

You may want to check your actual location matches your path statement.

Wyzelli




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

Date: Tue, 18 May 1999 08:36:15 -0400
From: Jay Flaherty <fty@utk.edu>
Subject: Re: OOP and Perl-a good book?
Message-Id: <37415EBF.4FBE040E@utk.edu>

Damian Conway wrote:
> 
> "%GIVEN NAME% o'regan" <"%GIVEN NAME%.o'regan"@port.ac.uk> writes:
> 
> >Would any be able recommend a good book that addresses OO in Perl
> >comprehensively?
> 
> I have written such a book. It will be published by Manning
> Publications in August this year. See http://www.manning.com/Conway/.

I can't wait myself :-) In the mean time you can look at the following
sources that has helped me get over the OO hurdle:

Books:
"Advanced Perl Prograqmming" by S. Srinivasan (ISBN 1-56592-220-4)
"The Perl Cookbook" by T. Christiansen & N. Torkington (ISBN
1-56592-243-3)

Online:
http://language.perl.com/CPAN/doc/FMTEYEWTK/perltoot.html
http://language.perl.com/CPAN/doc/FMTEYEWTK/pdsc/index.html
http://language.perl.com/CPAN/doc/manual/html/pod/perlobj.html
http://w3.stonehenge.com/merlyn/UnixReview/col13.html
http://w3.stonehenge.com/merlyn/UnixReview/col14.html

jay


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

Date: Tue, 18 May 1999 12:00:31 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hrkov$4ah$1@nnrp1.deja.com>

In article <7hqp4j$ibh$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> In article <7hpar3$hdh$1@nnrp1.deja.com>,
>   John Porter <jdporter@min.net> wrote:
> > In article <7hjioj$rks$1@nnrp1.deja.com>,
> >   armchair@my-dejanews.com wrote:
> > > ... records are fixed in the number and type (but not
> > > possible in Perl) of fields they hold, whereas a hash or array can
> > hold
> > > 0 to n fields and has to be checked if the code is going to be
> > "robust"
> > > and handle invalid passed parameters gracefully.
> >
> > You know, an analogous situation exists in C++ (and in OO langs
> > in general, including Perl).
> >
> > 	class A;
> >
> > 	class B : A {
> > 		public:
> > 		int foo();
> > 	};
> >
> > 	class C : A {
> > 		public:
> > 		int bar();
> > 	};
> >
> > 	int f( A& a ) {
> > 		a.foo();  // can I call this?
> > 		a.bar();  // or this?  and how do I know?
> > 	};
>
> This code is not valid, at least not in C++, as it won't compile:
>
> ERROR: A has no member foo
> ERROR: A has no member bar

You seem to have missed my point.
Since it's possible that the A passed in is actually B or C, in
which case I would like to call foo or bar, respectively, some
kind of "type testing" must be done, so that I only call foo or
bar in the legal cases (i.e. where a is a B or a C, respectively).
So you can't really escape "type testing" even in C++.
And it's rather more work than the simple 'exists' in Perl.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Tue, 18 May 1999 11:55:55 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hrkgb$413$1@nnrp1.deja.com>

In article <7hqo8k$hte$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> I think I am catching on. It is okay to criticize a programmer's
style,
> but not Perl's style.

That must be qualified: it's ok for those who know what they're
talking about to criticize Perl.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Tue, 18 May 1999 12:42:58 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7hrn8j$5q6$1@nnrp1.deja.com>

In article <7hqm3h$gej$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> In article <7hp5o4$dko$1@nnrp1.deja.com>,
>   John Porter <jdporter@my-dejanews.com> wrote:
> >
> > And how is this different from C++ exactly?
> > (Answer: It's not.
> >
> >   p = new SomeStruct;
> >   p->ptr1 = new Foo( 10, 20 );
> >   p->ptr2 = new That( 10, 20 );
>
> The difference is that p is a pointer to a struct, and Perl has no
> structs (records).

The NON-difference is that they are both pointers.  Pointers hold
one thing: an address.  So let's hope your original complaint
that "objects can hold only one thing" has been laid to rest.


> And yet is has something that is only a special
> symbol away from being one as I illustrated elsewhere:
>
> my #time_record
> ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst )
>  = localtime(time);
>
> And just what is the big horrid taboo about records? What is so
> outrageous about the concept? What would happen to Perl programmers if
> you had
> my ^record ( $name, $address, $city, $state, $zip, $ref_other ); in
the
> language? Would they all say the language is no longer usable and try
> something else?

Nothing's outrageous about the concept, but it's not necessary to
have a distinct syntactic construct in the language.
We have hashes and arrays.  See fields.pm.

If it would mean that much to you to add this to the language...
well, you have the source code.  ;-)



> > 	$n = $x + 5;    # a number
> > 	print $n;       # convert to string
> > 	$s = "$n zots"; # use the cached string value again
>
> If I followed your description, it seems the comments would be
> $n = $x + 5; # convert string to number add 5, convert number to
string
>              # assign to other string
> print $n;    # print string
> $s = "$n zots"; # combine string var with string literal,
>                 # assign result to string

I'm sorry if I lost you on that -- I might have assumed too much
about your understanding of the inner workings of perl scalars.
Put simply, each has a 'numeric' part, a 'string' part, a
'reference' part, and others.  If the numeric part has a value,
but the string version is needed by the current operation, perl
converts automatically and stores the result, so that both the
numeric and string parts are "current", and any use of either one
of them proceeds without any conversions being necessary.
If, say, a new string value is assigned to the scalar, the numeric
part is marked as invalid.  And at such time as the numeric part
is needed, the conversion is done and the result cached, as before.

If the only role a scalar ever plays is numeric, no conversion of
its value to a string is ever done.  It's all handled for you
automatically by the interpreter.


> I am not looking for a separate type for short, int, double, just one
> that holds numeric values.
> What technique do you use to validate that the $var you as being
passed
> is actually a numeric value?

Ah! a FAQ!  See perlfaq4: "How do I determine whether a scalar is a
number/whole/integer/float?"  The short answer is: test the string
representation for "appropriateness", e.g. is it all digits?  All
digits and a dot?  etc.


> > It's all in how you understand the work "LOOK".
> > You can't do this and expect sensible results:
> >
> > 	$n = 5;  # a number
> > 	$n->();  # deref as a function reference?
>
> I am not sure how showing me code that illustrates how dollar sign
does
> not differentiate the type of the variable, helps your case.

Well it certainly doesn't help my case when you don't have the
slightest clue what the point of my code example is.


> > perl (the interpreter) is far more concerned with the types of the
> > *values* than the types of any things which hold values.
>
> It's concerned enough to require you to explicitly specify the "type"
as
> a prefix to every variable both at declaration and at every usage.

It wouldn't have to, except that the design decision was made early
on to allow variables of the same name with different types.
The symbol allows $foo, @foo, %foo, etc. to be unambiguously
distinct variables.*

If you're really interested in these things, you might want to check
out Gisle Aas's "Perl Guts Illustrated"; go to
    http://gisle.aas.no/perl
and follow the "illguts" link.


> ...the $ type symbol is obviously ambiguous -
> string? number? reference to another variable?

The whole idea was to have all different kinds of scalars stored
in a single "type" of variable, so that the "automatic conversion
with caching" scheme I described above can be possible.  And as
I said, it's a load off my mind, not to have to think about the
types when I'm programming.  I want a number -- I use a scalar.
I want to use that number's string representation -- I use the
same scalar.  It makes life *easier*.  Of course, this may not
be ideal if you're writing numerical analysis routines -- matrix
math, FFT, and so on.  But those kinds of applications are
uncommon enough these days; and for them we have APL after all. ;-)

--
John Porter
Put it on a plate, son.  You'll enjoy it more.

*Yes, I know about $foo[0], $foo{X}.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Tue, 18 May 1999 12:16:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERLFUNC: print - output a list to a filehandle
Message-Id: <37425950.18900626@news.skynet.be>

Tom Christiansen wrote:

>NAME
>    print - output a list to a filehandle
>
>SYNOPSIS
>    print FILEHANDLE LIST
>    print LIST
>    print
>
>DESCRIPTION
>    Prints a string or a comma-separated list of strings. Returns TRUE
>    if successful. FILEHANDLE may be a scalar variable name, ....

This whole discription does not give even ONE mention of the special
variables $, and $\ or their English synonyms.

Are these variables even used for anything else? If not, they definitely
deserve a mention, if only a reference to perlop.

	Bart.


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

Date: Tue, 18 May 1999 12:50:33 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERLFUNC: print - output a list to a filehandle
Message-Id: <3741617c.20837007@news.skynet.be>

Bart Lateur wrote:

>This whole discription does not give even ONE mention of the special
>variables $, and $\ or their English synonyms.

> they definitely
>deserve a mention, if only a reference to perlop.

Damned! Of course, I ment "perlvar".

	Bart.


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

Date: Tue, 18 May 1999 12:48:33 GMT
From: "Newsworthy" <hannum@ohio.edu>
Subject: Simple Time Manipulation
Message-Id: <FBxI1F.2En@boss.cs.ohiou.edu>

Hello,

I want to be able to add 24 hours to the (timelocal) funciton.  Could
somebody tell me how I can best do this?

Thanks,
Dave





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

Date: Tue, 18 May 1999 13:59:30 +0200
From: "Thomas Klinger" <t.klinger@mobilkom.at>
Subject: Sorting problem II
Message-Id: <7hrkn4$dji$1@fleetstreet.Austria.EU.net>

Arjun Ray schrieb in Nachricht <37d5f89d.2693474261@news1.newscene.com>...
>In <m1vhdrm4jj.fsf@halfdome.holdit.com>,
>merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
>| Naaah... I'd go with more of:
>|
>|     print
>|       map "<tr>$_</tr>",
>|       map { join "", map { "<td>".(/^$/ ? "-" : $_)."</td>" } @$_ }
>|       sort { $b->[2] <=> $a->[2] }
>|       grep { $_->[1] =~ m/$FORM{'TNSET'}/i }
>|       map { chomp; [ split /;/ ] }
>|       @techlines;
>
>Hey, pretty cool. (Reminds me of APL!)
>
>I suppose the only thing that might be dodgy is the 'join ""' part.
>Wouldn't a strategic 'print @array' take care of this automatically?
>(Also, looking back at Thomas' problem, there's also the cases from
>split dropping trailing delimiters, whereas the sorry state of current
>browsers generally behooves us to get the number of <td>s right.) So,
>how about this
>
>    print
>      map  { ('<tr>', @$_, '</tr>', "\n") }
>      map  { [ map { '<td>'.(/^$/ ? "-" : $_).'</td>' } @$_ ] }
>      sort { $b->[2] <=> $a->[2] }
>      grep { $_->[1] =~ m/$FORM{'TNSET'}/i }
>      map  { chomp; [ split /;/, $_, 8 ] }
>      @techlines;
>
>| But no, that's not the canonical Schwartzian Transform either, not
>| as coined by Mr. Christiansen.
>
>Well, it starts with a map, has a sort somewhere, and ends with a map.
>Good enough for me...
>
>
>:ar


Well, I don't want to disturb a deeply philosophical discussion on sorting
:) but the last 3 posting were completly too high to me (as I am new at PERL
and no perlhacker (learning nealry 1 year but can't guess what I'm doing
[:)])).
Anyway, the article from tbsmith@deltacom.net answered my question in a way
I can reproduce and sounds easy to me.

Now, how should I work to get the orderdescending (700, 699, 698, ....)
instead of 698, 699, 700?

BTW: Thanks to Randal Schwartz. I'm trying hardly to read your perlbook(s)
and I still think that he's one of the best teachers out there.


--
Best regards,
                  Thomas Klinger
========================================
 ......E-Mail: t.klinger@mobilkom.at.....
 .........WWW: http://www.mobilkom.at....
========================================




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

Date: Tue, 18 May 1999 12:26:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Sorting problem II
Message-Id: <37445c1b.19615475@news.skynet.be>

Thomas Klinger wrote:

>Now, how should I work to get the orderdescending (700, 699, 698, ....)
>instead of 698, 699, 700?

Two ways. You know of 

	@sorted = sort { $a <=> $b } @array;

to sort numerically?

A) Reverse that result.

	@sorted = reverse sort { $a <=> $b } @array;

B) Swap the $a and $b in the block.

	@sorted = sort { $b <=> $a } @array;

Oh, and here's a third way:

	@sorted = sort { -($a <=> $b) } @array;

	Bart.


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

Date: Tue, 18 May 1999 14:49:18 +0200
From: "Thomas Klinger" <t.klinger@mobilkom.at>
Subject: Re: Sorting problem II
Message-Id: <7hrnkf$epj$1@fleetstreet.Austria.EU.net>

Thanx a lot Bart (and to all others, too).
After checking my script and trying your tip A) made the race.

Thomas

Bart Lateur schrieb in Nachricht <37445c1b.19615475@news.skynet.be>...
>Thomas Klinger wrote:
>
>>Now, how should I work to get the orderdescending (700, 699, 698, ....)
>>instead of 698, 699, 700?
>
>Two ways. You know of
>
> @sorted = sort { $a <=> $b } @array;
>
>to sort numerically?
>
>A) Reverse that result.
>
> @sorted = reverse sort { $a <=> $b } @array;
>
>B) Swap the $a and $b in the block.
>
> @sorted = sort { $b <=> $a } @array;
>
>Oh, and here's a third way:
>
> @sorted = sort { -($a <=> $b) } @array;
>
> Bart.




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

Date: Tue, 18 May 1999 14:52:45 +0200
From: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Subject: Strange socket behavior
Message-Id: <3741629D.93C3B958@lublin.zrz.tu-berlin.de>

I am trying to set up what should be, in its present skeleton stage,
a quite general proxy server.  What I mean is this:

Suppose I have a server running on my machine (think sendmail on port
25, that
is the intended use).  Now I want to monitor the traffic and maybe
manipulate
it just a tiny bit.  So what I do is, let sendmail use a different port
where no-one expects it.  Let my proxy run on the original sendmail port
and relay everything it sees to sendmail, and everything senmail says
out
to the world.  Thus, the behavior of sendmail should be reproduced on
its
original port and no-one should be the wiser.

I tested this, setup running a copy of sendmail on port 2026 for the
purpose,
and running the proxy on port 2025 (in case someone cares to look at the
code
below), using telnet on port 2025.  Things work as expected, except for
one
little quirk:  When I send the original sendmail a "quit" via telnet,
telnet
exits.  It doesn't when I'm connected to my proxy, instead I either have
to kill the proxy or explicitly exit telnet using "^]" and "quit".

A little experimentation showed this isn't the whole story.  The above
(mis-)
behavior happens only with the very first connection I open to the proxy
process.  All later ones work just as intended.  So a "solution" to the
problem
would be to open a dummy connection on startup that is never closed.  Of
course
this is more than ugly, and besides I'd like to know what's going on.

I'm using IO::Socket with perl 5.004_05 on a linux system.  Can anyone
help?

Anno

----------------------here comes the
code-------------------------------------

#!/usr/local/bin/perl -wT

use strict;
use IO::Socket;

my( $sendmail_port,    $proxy_port ) =
  ( "smtp_test(2026)", "smtp_proxy(2025)" );

my( $proxy, $smtp, $client, $kidpid1, $kidpid2, %kidpids);

# set some traps
$SIG{ INT} = sub { kill( "TERM", keys %kidpids); exit; };
$SIG{ CHLD} = \&cleanup_kids;

$proxy = setup_proxy( $proxy_port);

while ( $client = accept_client( $proxy) ) {
  $smtp = connect_smtp( $sendmail_port);

  $kidpid1 = spawn_relay( $client => $smtp);
  $kidpid2 = spawn_relay( $smtp => $client);

#setup partnership:
  $kidpids{ $kidpid1} = $kidpid2;
  $kidpids{ $kidpid2} = $kidpid1;
  warn "partners $kidpid1 (client => smtp) and $kidpid2 (smtp =>
client)\n";
}

#####################################################################

sub connect_smtp {
  # set up a tcp connection to smtp (client style)
  my( $port ) = @_;
  my( $smtp ); # indirect filehandle to socket
  $smtp = IO::Socket::INET->new( Proto => "tcp",
                                 PeerAddr => 'localhost',
                                 PeerPort => $port) or
    die "can't connect to port $port on localhost: $!\n";
  $smtp->autoflush( 1); # not strictly necessary but good for
portability 
  warn "[Connected to localhost:$sendmail_port]\n";
  return $smtp;
}

sub setup_proxy {
  my( $port ) = @_;
  # set up a tcp connection to the proxy port, where everyone believes
  # the real setver is running (server style)
  my( $proxy);
  $proxy = IO::Socket::INET->new( Proto => "tcp",
                                  LocalPort => $port,
                                  Listen => SOMAXCONN,
                                  Reuse => 1) or
    die "can't set up proxy server on $port: $!\n";
  warn "[proxy sever acceppting clients on port $port]\n";
  return $proxy;
}

sub accept_client {
  my( $proxy ) = @_;
  $client = $proxy->accept();
  $client->autoflush( 1);
  my( $foreign_sockaddr) = $client->peername;
  my( $foreign_port, $foreign_addr ) = unpack_sockaddr_in(
$foreign_sockaddr);
  my( $foreign_host);
  $foreign_host = gethostbyaddr( $foreign_addr, AF_INET);
  warn "[Connect from $foreign_host:$foreign_port]\n";
  return $client;
}

sub spawn_relay {
  my( $inport, $outport ) = @_;
  my( $pid, $line );
  if ( not defined ( $pid = fork) ) {
    return undef;
  } elsif ( $pid ) {
    return $pid; # parent
  } else {
    # this is the kid, let him do the work

    while ( defined ( $line = <$inport>) ) {
      print $outport $line;
    }
    exit;
  }
}

sub cleanup_kids {
  my( $pid_done) = wait;
  my( $partner) = delete( $kidpids{ $pid_done});
  if ( $partner ) {
    $kidpids{ $partner} = 0; # invalidate
    warn "cleanup_kids: $pid_done done, killing partner $partner\n";
    kill( "TERM", $partner);
  } else {
    warn "cleanup_kids: $pid_done done, no partner\n";
  }
}


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

Date: 18 May 1999 05:39:13 -0700
From: gerg@shell1.ncal.verio.com (Greg Andrews)
Subject: Re: Whats wrong?
Message-Id: <7hrn1h$bkt$1@shell1.ncal.verio.com>

Jonathan Feinberg <jdf@pobox.com> writes:
>warlock@eskimo.com (Jim Richardson) writes:
>
>> use backtics rather than single quotes would help :) 
>> 
>> ` rather than '
>                ^ Hmm?
>

Jim was saying
                          ` rather than '
                          ^             ^
                          |             |
  Use this quote mark  ---+             |
     rather than                        |
   that quote mark     -----------------+


  -Greg


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

Date: 18 May 1999 13:39:47 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Windows NT Form Mail Response
Message-Id: <37415f93@newsread3.dircon.co.uk>

In comp.lang.perl.misc Jorge Torres <info@gate.on.ca> wrote:
> Anybody with an script that response to an email address using WINNT and
> exchange or NT mail.
> 

Assuming that you have an SMTP server available to you then you should
be able to use one of the possibilities mentioned in perlfaq9.

Alternatively you might find:

   <http://www.geocities.com/SiliconValley/Park/8312/mail.htm>

Useful although I cant vouch for the contents.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 11:43:19 GMT
From: my_addr_is-chrisdl@pagesz.net (chris losinger)
Subject: WTD : Public key encryption code
Message-Id: <37415069.69996421@news.pagesz.net>


	i would like to get my hands on some public-key _encryption_ code
(RSA, ElGamal or LUCELG). i don't want any of those 2-line .sig RSA
implementations because i will probably need to tweak it to make it
like me and i'd rather not have to bother with unravelling any clever
tricks.

	ideally, it would be a stand-alone package, with no external
modules.

	can anyone help?

	-c
-----------------------------------------------------------------------
                c  h  r  i  s    l  o  s  i  n  g  e  r
        chrisdl@pagesz.net       http://www.pagesz.net/~chrisdl
     smallest@smalleranimals.com     http://www.smalleranimals.com
            Win95 Software | MFC JPG code | Records | more
                We taught our parrot to say "dockers".

     ReplyTo address has been corrupted to deter unwanted e-mail.
                        Use the address above.



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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