[6422] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 47 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 4 11:27:35 1997

Date: Tue, 4 Mar 97 08:00:35 -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           Tue, 4 Mar 1997     Volume: 8 Number: 47

Today's topics:
     (no subject) <tonts@lpt.fi>
     @hash{@fields} = @values; <kstevens@theglobeandmail.com>
     [Q] Modem-Communication/Xmodem under Perl/WinNT <springm@ux0umw50.umw.lhm-net.de>
     Re: Autostart perl program (Christopher Hamilton)
     Re: can $_ be dissociated from its contents? (Rahul Dhesi)
     Re: College Students need help with perl script (1/1) <wkuhn@uconect.net>
     Re: File date from Perl5-NT <seay@absyss.fr>
     Re: for god sake (Markus Laker)
     Re: fork and alarm <ajs@ajs.com>
     Re: Getting list of files in a path <flg@vhojd.skovde.se>
     Re: Graphical Perl for Win32 (Markus Laker)
     help for beginner <tonts@lpt.fi>
     Re: Help!  Testing Perl CGI scripts on local Windows/DO (Christopher Hamilton)
     Help! Perl Sockets. <basole@uiuc.edu>
     Re: HELP: Is there some standard code to filter out htm <jander@ml.com>
     Re: How can I use #! w/o knowing where perl lives? (Andrew M. Langmead)
     How to convert a GIVEN date string to seconds (Rich)
     Re: HOW to set up alias to perl command in unix shell ? <rfi@uebemc.siemens.de>
     Re: Inline subroutines? (Malcolm Beattie)
     Looking for Perl OOP Book / Tutorial (TDS)
     Re: Looking for Perl OOP Book / Tutorial <tchrist@mox.perl.com>
     Re: More weird regular expressions. (Dave Thomas)
     Re: need some help here <ajs@ajs.com>
     Re: need some help here <eike.grote@theo.phy.uni-bayreuth.de>
     Re: Perl timing questions: <tchrist@mox.perl.com>
     Problem with LEARNING PERL Example <ddickerson@igc.apc.org>
     Re: Returning a reference to a 'my' variable <tchrist@mox.perl.com>
     Re: Starting with PERL: a question <rfi@uebemc.siemens.de>
     subscript assignment and splice equivalence (Tony Bass)
     Timer which can handle milliseconds.. (Daniel Sundin)
     UNIX commands in NT <webmaster@systecinc.com>
     Re: Web download script..???? <schajer@dircon.co.uk>
     Re: Web download script..???? (Nathan V. Patwardhan)
     Re: Where is FAQ? <tchrist@mox.perl.com>
     Re: Which one is the best (pattern matching) (Tad McClellan)
     Will pay money for CGI scripts <mogreen@ix.netcom.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Tue, 04 Mar 1997 14:36:30 +0200
From: Annika Tonts <tonts@lpt.fi>
Subject: (no subject)
Message-Id: <331C174E.6A68@lpt.fi>

Hi!
	I4m an artist and not quite technical person, but have used some design
programs. Now I4d like to make my new net pages. There will be some
gif-animated pictures and an image map I already made. 
	I`d like to use together with those pictures some texts, where any
guest of my pages could write his own data (some words) and after see
all the page with his own added data. I don`t need this data saved for
me (like in guestbooks). I have seen some similar pages made by
CGI-script, but do I need to use it in my case or can I do something
like that by java also? 
	How is it easier to start, if I have no experience in both of these
programming languages? What else will I need?

	I`ll be very thankful for all good advices,
		Annika


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

Date: Tue, 04 Mar 1997 10:27:41 -0500
From: Ken Stevens <kstevens@theglobeandmail.com>
Subject: @hash{@fields} = @values;
Message-Id: <331C3F6D.1FBB@theglobeandmail.com>

Say, I've always wondered about this one.  Why does the following work?

@fields = ('a', 'b', 'c');
@values = (4, 7, 9);
@hash{@fields} = @values;
print $hash{'b'}; 		# will print "7"

I've read all the perl docs, and I can't find any reference to this very
useful syntax.  Is this an undocumented goodie?

-Ken


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

Date: 04 Mar 1997 09:11:30 +0100
From: Markus Spring <springm@ux0umw50.umw.lhm-net.de>
Subject: [Q] Modem-Communication/Xmodem under Perl/WinNT
Message-Id: <r4vi78yt3h.fsf@ux0umw50.umw.lhm-net.de>

For automated Filetransfer via Modem I would like to realize a perl 
application. In CPAN I didn't find modules for serial communication etc.
Has anybody solved a similar problem via perl? 
Any help would be appreciated.

markus
-- 
spring@umw.cube.net			Markus W. Spring
					Tel. 0049-89-23323597
					FAX  0049-89-23323442



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

Date: 3 Mar 1997 07:16:04 GMT
From: chrish@gstv.gsu.edu (Christopher Hamilton)
Subject: Re: Autostart perl program
Message-Id: <5fdtrk$9ut@arachnid.Gsu.EDU>

rlgolden@ngeorgia.com wrote:
: How do I tell a perl program to run at a certain time, even if I am not
: online?  Please email an answer.

UNIX System?

Check out 'crontab' and 'at'

-- 
 ...............................................................
 Christopher L. Hamilton        Systems Administrator/Programmer
 chrish@gstv.gsu.edu            http://gstv.gsu.edu/~chrish


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

Date: 4 Mar 1997 14:10:56 GMT
From: c.c.eiftj@66.usenet.us.com (Rahul Dhesi)
Subject: Re: can $_ be dissociated from its contents?
Message-Id: <5fhahg$h21@samba.rahul.net>

In <5ffei1$of0$1@mathserv.mps.ohio-state.edu> ilya@math.ohio-state.edu
(Ilya Zakharevich) writes:

>Why not use 
>	while (defined ($ARRAY[@ARRAY] = <STDIN>))

>instead? <> is optimized to directly set its "argument" (whether $_ or
>not).


Thanks, I would not have through of it, but it seems to work.
-- 
Rahul Dhesi <dhesi@spams.r.us.com>
a2i communications, a quality ISP with sophisticated anti-junkmail features
*** Now featuring Strategy C for junk-mail-proof News postings ***
|| "please ignore Dhesi" -- Mark Crispin <mrc@CAC.Washington.EDU> ||


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

Date: Tue, 04 Mar 1997 09:34:28 -0500
From: Bill Kuhn <wkuhn@uconect.net>
Subject: Re: College Students need help with perl script (1/1)
Message-Id: <331C32F4.57C3162D@uconect.net>

Uh, don't post unless you have some specific question.

The subject of the original posting implied that some help was needed,
but all that was posted was a CGI program written in perl and what I can
only guess is its associated HTML form.

So, what help is needed?

If you don't ask questions, you aren't going to get answers.

-Bill
-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: Tue, 04 Mar 1997 15:12:24 +0000
From: Douglas Seay <seay@absyss.fr>
To: Geoff Caras <GeoffC@igneous.com>
Subject: Re: File date from Perl5-NT
Message-Id: <331C3BD8.2B22@absyss.fr>

Geoff Caras wrote:
> 
> Hello,
> 
> The only method I have found to get the date for a file is the stat function
> that returns seconds since 1970.  This seems rather contorted to me!
> 
> Is there an easier method for getting the date of a file???
> 
> My task it to take a file say foo.doc and rename it to foo_03Mar97.doc
> I have the rest of the script working 100% and just need a "better"
> method for get the files date!
> 
> ANY assistance would be appreciated.
> 
> GeoffC@igneous.com


seconds since 1-1-1970 is the standard time reference in the unix world.
use localtime() or gmtime() to convert that into an array with month,
days,
and so on.


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

Date: Tue, 04 Mar 1997 15:31:36 GMT
From: mlaker@contax.co.uk (Markus Laker)
Subject: Re: for god sake
Message-Id: <5fhfbc$fn6$2@newsserver.dircon.co.uk>

nvp@shore.net (Nathan V. Patwardhan) wrote:

> Tony Facey (C-A-T-S@c-a-t-s.demon.co.uk) wrote:

> : Am i doing somthing wrong?

> Totally.  :-)  You should be looking at http://www.activeware.com for
> the Perl 5.003_07 NTPerl port (both in Intel binaries and source).

It's still a bit buggy, as is the nature of beta software.  I've been
hoping for a later release to come out, but not seen anything yet.

Here's the essential bit of a message I sent to ActiveWare (along with
some version numbers and vital statistics that I won't bore you with).
I report this in case anyone else is struggling with it.

>>
If I run this script

opendir DIR, 'c:\\' or die "Can't open the directory:\n$!\n";
print join "\n", readdir DIR;

then Perl returns 'No such file or directory'.  However, if I change
the directory from 'c:\\' to 'c:\\.' then I get a directory listing,
as you'd expect.
<<

This bug was not in 5.001m.

Markus Laker.


Markus Laker



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

Date: Tue, 04 Mar 1997 08:34:39 -0500
From: Aaron Sherman <ajs@ajs.com>
To: Yew Yap <gohyewya@iscs.nus.sg>
Subject: Re: fork and alarm
Message-Id: <331C24EF.6E6C22E8@ajs.com>

Yew Yap wrote:
> 
> Hi thanks for reading my posting, and please kindly mail me if u are
> willing to help.
> 
> Why after forking a child, alarm wont work any more?
> And after forking how to let the parent exit without waiting for the child?

First off, you need to be a little more specific. Code samples
wouldn't hurt.

alarm should work just fine, but don't expect the child to get
the alarm-call.

You can just exit the parent, and that will orphan the child, making
it (under all UNIXen that I am familiar with) a child of init. init
will then do the wait for you. If you are going to keep running
for a while, though, you might want to explicitly orphan the 
child (by forking twice) or set up a SIGCHLD handler.

			-AJS


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

Date: Tue, 04 Mar 1997 09:47:44 +0100
From: Fredrik Lindberg <flg@vhojd.skovde.se>
To: yu177535@yorku.ca
Subject: Re: Getting list of files in a path
Message-Id: <331BE1B0.482@vhojd.skovde.se>

yu177535@yorku.ca wrote:
> 
> Hi, I'm a newbie to Perl and I'm working on a script that needs to get the
> listing of all *.jpg files in a directory.
> 
> @files = (<*.jpg>);
> 
> gets the listing of jpeg files in the current directory, how would I go
> about getting a listing of the jpeg files in another directory?
> 
> I tried using chdir and then @files=(<*.jpg>) but it doesn't work.

You could simply do this:

@files = </usr/myfiles/pictures/*.jpg>;

Or you could use the opendir() and readdir() functions.

opendir(DIR, "/usr/myfiles/pictures") or die("Unable to open pictures
dir:$!\n");

while($entry = readdir(DIR)) {
  next unless ($entry =~ /\.jpg$/);  #Skip all but jpegs
  print "$entry\n";
}

__END__

Note that when using <*.*> style you get the whole path, but when
reading the directory with readdir() you only get the filename.
You have to prepend the path yourself if you want the whole path.

/Fredrik


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

Date: Tue, 04 Mar 1997 15:31:26 GMT
From: mlaker@contax.co.uk (Markus Laker)
Subject: Re: Graphical Perl for Win32
Message-Id: <5fhfb3$fn6$1@newsserver.dircon.co.uk>

scott@lighthouse.softbase.com () wrote:

> You could probably use OLE Automation to drive Internet Explorer or
> Word or something else with a powerful macro language to do your
> interface for you. For that matter, you could write your UI in HTML and
> JavaScript and kick off a perl program when you have all the data you
> need.

You're right; that would work.  But it would defeat the object of the
exercise.

The reason I moved from C++ to Perl for sysadmin tasks was the speed
with which you can write simple, reliable apps in Perl.  So many of
the things you have to do over and over again in C and C++ are done
for you as part of the language in Perl.  Perl is wonderfully concise,
powerful and expressive.  Quite simply, I have time to write things in
Perl -- important things -- that would never get done if I had to use
C or C++.  And, at this stage, my C++ is still a lot better than my
Perl.

But if I have to kludge around using OLE automation, HTML, macro
languages and all the rest of it just to bring up a dialogue box, I
might as well learn Visual Basic in the first place because the
advantage of programmer efficiency is lost.  Besides that, that
approach does seem to use more machine resources than are *strictly*
necessary for the job.  :-)

> I doubt anyone is going to do much more than port an existing
> widget-language like Java or Tk/Tcl to Win32. The monumental task of
> making Win32 API calls available in perl doesn't seem like it would be
> worth it. All you could do is write old-style C + SDK programs, and in
> this age of visual tools like Delphi and C++ Builder, who wants that?
> The monumental effort of providing a widget-library similar to java.awt
> doesn't seem worth it either. Maybe someone with too much time on their
> hands will create "Visual Perl" with an MFC-like Perl OOP library for
> UI widgets. I doubt it!

But that's more than I need.  I'm not trying to write an office suite
in Perl; I don't have time, and it would be too slow.  (Come to think
of it, that could explain some of the software to come out of Redmond
recently.)  I just want to bring up a file selector, a password box or
an are-you-sure message from time to time, and use Perl for the guts
of the program.

> Delphi is only about $60-80 now. Use it to write front ends and call
> your perl programs. Delphi is the perl for UIs, anyway.

*Sigh*

Markus Laker.


Markus Laker



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

Date: Tue, 04 Mar 1997 14:37:33 +0200
From: Annika Tonts <tonts@lpt.fi>
Subject: help for beginner
Message-Id: <331C178D.5A85@lpt.fi>

Hi!
	I4m an artist and not quite technical person, but have used some design
programs. Now I4d like to make my new net pages. There will be some
gif-animated pictures and an image map I already made. 
	I`d like to use together with those pictures some texts, where any
guest of my pages could write his own data (some words) and after see
all the page with his own added data. I don`t need this data saved for
me (like in guestbooks). I have seen some similar pages made by
CGI-script, but do I need to use it in my case or can I do something
like that by java also? 
	How is it easier to start, if I have no experience in both of these
programming languages? What else will I need?

	I`ll be very thankful for all good advices,
		Annika


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

Date: 3 Mar 1997 06:56:05 GMT
From: chrish@gstv.gsu.edu (Christopher Hamilton)
Subject: Re: Help!  Testing Perl CGI scripts on local Windows/DOS system
Message-Id: <5fdsm5$9ut@arachnid.Gsu.EDU>

Geoff Wilkins (GeoffW@wordsmith.demon.co.uk) wrote:
: I've been trying without success to figure out a way to test Perl CGI
: scripts by running them, called from <FORM action=...> tags in HTML
: files, on my local Windows95/DOS system.  (I have of course got Perl
: installed on the system.)

Forms using METHOD=POST store the query data in STDIN. The best way to
use this is to set up a simple web server on your machine.

read(STDIN,$FormData,$ENV{"CONTENT_LENGTH"});

$FormData would contain all the information (delimited with &'s and +'s
and all that fun stuff that you can split() or s// out) from the form.

Hope this helps.

-- 
 ...............................................................
 Christopher L. Hamilton        Systems Administrator/Programmer
 chrish@gstv.gsu.edu            http://gstv.gsu.edu/~chrish


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

Date: Tue, 04 Mar 1997 09:13:12 -0600
From: Milind Basole <basole@uiuc.edu>
Subject: Help! Perl Sockets.
Message-Id: <331C3C08.7D1F@uiuc.edu>

a few weeks ago someone posted some perl code for a server for 
bi-directional communication over the socket on comp.lang.perl.misc.
i have attatched the file at the end of this message. however, after 
copying it over and trying on my machine i have been unable to get the
client to reproduce info the server sends to it and vice versa.

am i doing something silly here ? (i have very little experience with
sockets). can you tell me what i am doing wrong?

many thanks..

milind basole
basole@uiuc.edu
__________________________________________________________________
                  SERVER POSTED
#!/usr/bin/perl -Tw
require 5.002;
use strict;
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;

sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }

my $port = shift || 2345;
my $proto = getprotobyname('tcp');
$port = $1 if $port =~ /(\d+)/; # untaint port number
socket(Server, PF_INET, SOCK_STREAM, $proto)        || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1))   || die
"setsockopt:
 $!";
bind(Server, sockaddr_in($port, INADDR_ANY))        || die "bind: $!";
listen(Server,SOMAXCONN)                            || die "listen: $!";


logmsg "server started on port $port";

my $paddr;

$SIG{CHLD} = \&REAPER;

for ( ; $paddr = accept(Client,Server); close Client) {
    my($port,$iaddr) = sockaddr_in($paddr);
    my $name = gethostbyaddr($iaddr,AF_INET);

    logmsg "connection from $name [",
            inet_ntoa($iaddr), "]
            at port $port";

    my $line = <Client>;
    $line =~ s/[\r\n]*$//;

    print "Hello there, $name, it's now ",
                    scalar localtime, " and you said '$line'\n";

    print Client "Hello there, $name, it's now ",
                    scalar localtime, " and you said '$line'\n";
}
___________________________________________________________________
                     CLIENT

#!/usr/bin/perl -w
      require 5.002;
      use strict;
      use Socket;
      my ($remote,$port, $iaddr, $paddr, $proto, $line);

      $remote  = shift || 'localhost';
      $port    = shift || 2345;  # random port
      if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
      die "No port" unless $port;
      $iaddr   = inet_aton($remote)     || die "no host: $remote";
      $paddr   = sockaddr_in($port, $iaddr);

      $proto   = getprotobyname('tcp');
      socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
      connect(SOCK, $paddr)    || die "connect: $!";
      while ($line = <SOCK>) {
          print $line;
      }

      close (SOCK)            || die "close: $!";
      exit;


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

Date: 04 Mar 1997 15:06:00 +0000
From: Jim Anderson  <jander@ml.com>
Subject: Re: HELP: Is there some standard code to filter out html tags.
Message-Id: <wkbafojhf3b.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Frank Meissner <meissner@wattenmeer.pixelpark.com> writes:

> mark@weymouth.gov.uk (Mark Perkins) writes:
> 
> > 
> > Hi,
> > 
> > Well from the subject you can probably tell that Im new to Perl
> > although I have a reasonable understanding of unix shell.
> > 
> > Q. Is there some standard Perl code that I can use to filter out the
> > html tags like, <CENTER>  or <B> from text held in a perl variable?
> perhaps something like
> $_=$VarWhereYourHtmlSourceIs;
> s/<[^>]+>//g;

I think this needs "minimal matching":

s/<[^>]+?>//g;

> $VarWhereYourHtmlSourceWas=$_;
> > 
> > Can anyone help please,
> > 
> > many thanks
> > 
> > Mark
> 
> -- 
>  "DOS Computers manufactured by companies such as IBM, Compaq, Tandy, and
>   millions of others are by far the most popular, with about 70 million
>   machines in use wordwide. Macintosh fans, on the other hand, may note that
>   cockroaches are far more numerous than humans, and that numbers alone do
>   not denote a higher life form."       (New York Times, November 26, 1991)

-- 
Jim Anderson			jander@ml.com
Consultant-at-large		jander@jander.com
				(212) 449-1598


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

Date: Tue, 4 Mar 1997 13:37:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How can I use #! w/o knowing where perl lives?
Message-Id: <E6ItuF.Gx3@world.std.com>

"Paul H. Hargrove" <hargrove@sccm.Stanford.EDU> writes:

>I am currently working on a perl script that needs to run on a few 
>different UN*X systems (with perl versions 4 and 5) on which I have
>accounts.  Unfortunately the perl interpreter is located in different
>directories on different systems.  




How about all the variations on 


           #!/bin/sh -- # -*- perl -*- -p
           eval 'exec perl $0 -S ${1+"$@"}'
               if 0;
 

That are found in the man pages and the camel book?

Otherwise, do all the systems on which you are trying to run your
scripts have /bin/env? You could say

           #!/bin/env perl
-- 
Andrew Langmead


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

Date: Tue, 04 Mar 1997 09:44:32 -0500
From: "Fu-Chiang (Rich) Tsui" <tsui@cbmi.upmc.edu>
Subject: How to convert a GIVEN date string to seconds
Message-Id: <331C3550.7674@cbmi.upmc.edu>

Hi there,

   Does anyone know how to convert a given date string, say 1/4/97, to
number of seconds since 1/1/1970 in Perl5.001UNIX?  Thank you in
advance.

Rich Tsui
University of Pittsburgh


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

Date: 04 Mar 1997 15:09:44 +0100
From: Ronald Fischer <rfi@uebemc.siemens.de>
Subject: Re: HOW to set up alias to perl command in unix shell ?
Message-Id: <xz2ohczsq8n.fsf@uebemc.siemens.de>

josin alvistur <josin@dimensional.com> writes:

| 
| i am trying to set up an alias in tcsh to do:
| 
| alias xx perl -e 'print "VAR1 = ", `printenv VAR1`;'

There are several ways to skin the cat. A fairly general
solution (which you could use as a base to adopt to
real useful aliases) would be

alias xx "perl -e 'print qq:VAR1 = "'$'"ENV{q.VAR1.}\n:'"

Of course you could alternatively write
    alias xx 'echo VAR1=$VAR1'
;-)
-- 
Ronald Otto Valentin Fischer
business:	ronald.fischer@uebemc.siemens.de
private:	ronald.fischer@acm.org
http://ourworld.compuserve.com/homepages/ronald_fischer


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

Date: 4 Mar 1997 15:18:25 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: Inline subroutines?
Message-Id: <5fheg1$8sb@news.ox.ac.uk>

In article <E6I7J7.KxK@nonexistent.com>, Abigail <abigail@ny.fnx.com> wrote:
>On Mon, 3 Mar 1997 19:44:55 -0800, Tom Phoenix wrote in comp.lang.perl.misc:
>++ On Mon, 3 Mar 1997, Markus Laker wrote:
>++ 
>++ > Are you thinking of C++'s ability to inline functions for you?  That
>++ > isn't quite what the writers of the Camel had in mind.  In Perl you
>++ > have to do the job yourself.
>++ 
>++ ...except that in the upcoming 5.004, some function calls may be inlined
>++ by perl. If a function call has an empty prototype, and if it's called
>++ with the new-style &-less syntax, and if Perl can tell at compile time
>++ that it has a constant return value, then that value will be used in place
>++ of a subroutine call.
>
>Surely the function shouldn't have side effects either?

Don't worry: the inlining happens only if the only thing a sub
does is return a constant. This happens in addition to constant
folding so that if you write
    sub FLAG_SHIFT () { 8 }
    sub FLAG_FOO () { 0x1 << FLAG_SHIFT }
    sub FLAG_BAR () { 0x2 << FLAG_SHIFT }
    sub FLAG_MASK () { FLAG_FOO | FLAG_BAR }
then any instance of FLAG_MASK in your code will be inlined to
a constant 768 and any instance of (FLAG_MASK + 1) will be
inlined to 769. This is much much faster than all that run-time
sub calling. In fact, it was when I found myself hardcoding flag
values like that because of the performance that I found the
incentive to write the inlining optimiser. It's possible that
there will be more inlining ability in 5.005 or 5.006 but it
may only be feasible for the (external) compiler to do it. The
compiler has more knowledge about the arguments that are being
passed into a sub than the standard perl parser.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee


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

Date: Tue, 04 Mar 1997 14:38:13 GMT
From: uschwarz@wwa.com (TDS)
Subject: Looking for Perl OOP Book / Tutorial
Message-Id: <331c3336.604734231@news.wwa.com>

I'm looking for a good book or tutorial on the OOP features of PERL.
Currently, I have the O'Reilly "Programming Perl" book, but find it
seriously lacking in a basic tutorial on this subject.  The "Learning
Perl" book is too old to deal with the OOP features.

If you know of a good book or tutorial on this subject, please let me
know.



Tom Schwarz


WWW ...............http://sashimi.wwa.com/~uschwarz/poetry.html
E-mail ........................................uschwarz@wwa.com


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

Date: 4 Mar 1997 15:46:26 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Looking for Perl OOP Book / Tutorial
Message-Id: <5fhg4i$anf$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    uschwarz@wwa.com writes:
:I'm looking for a good book or tutorial on the OOP features of PERL.
:Currently, I have the O'Reilly "Programming Perl" book, but find it
:seriously lacking in a basic tutorial on this subject.  The "Learning
:Perl" book is too old to deal with the OOP features.
:
:If you know of a good book or tutorial on this subject, please let me
:know.

    http://www.perl.com/CPAN/doc/FMTEYEWTK/perltoot.html
    ftp://ftp.perl.com/perl/FMTEYEWTK/perltoot.html

You can also find perltoot.man, perltoot.ps, and perltoot.pod
in the same directory.

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

	    Seven is right, but so is even,
	    Hyphen, roughen, nephew Stephen,


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

Date: 4 Mar 1997 14:27:05 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: More weird regular expressions.
Message-Id: <slrn5hoc38.3s9.dave@fast.thomases.com>

On 4 Mar 1997 06:06:11 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to Darrel Riekhof 
> <riekhof@primenet.com>],
> who wrote in article <331BB930.52E3@primenet.com>:
> > I was toying around with more regular expressions and came up
> > with this one:
> > 
> > 	(([a-z])+([A-Z])+)+
> > 
> > with input:
> > 
> > 	abcABCdefgABChijklmnop
> > 
> > To my suprise, Perl put the following in the backrefs:
> > 
> > 	\1 "defgABC"
> > 	\2 ""
> > 	\3 ""
> > 
> > I wouldn't have been suprised if I replaced the '+'s with '*'s.
> > Anyone know why \2 and \3 are empty?
> 
> Looks like a bug to me...

  dave[~/tmp 23:13:29] perl -w x.pl  # 5.003_27
  Matched:  abcABCdefgABChijklmnop
  1=defgABC
  2=
  3=
  dave[~/tmp 23:13:48] perl4.036 x.pl
  Matched:  abcABCdefgABChijklmnop
  1=defgABC
  2=g
  3=C

There's definitely a change in behaviour here.

Dave

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Tue, 04 Mar 1997 08:26:22 -0500
From: Aaron Sherman <ajs@ajs.com>
To: surber@earthlink.net
Subject: Re: need some help here
Message-Id: <331C22FE.5E180FA4@ajs.com>

Christopher M. Surber wrote:

> ($lname,$fname,$location,$mailstop,$phone) = split(/ /);

> part of the list im using is below , all the list looks the same, each
> item is seperated by a space or tab.
> 

split / / will split on EACH SPACE CHARACTER that it finds. Your file
contains data that breaks that split because there are tabs. Try:

	($lname,...) = split;

Or, to be more verbose:

	($lname, ...) = split(/\s+/,$_);

Or, if your fields can be empty, you will need to:

	($lname, ...) = split(/ \t/,$_);

That should get you started.

			-AJS


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

Date: Tue, 04 Mar 1997 16:02:38 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: need some help here
Message-Id: <331C398E.167E@theo.phy.uni-bayreuth.de>

Hi,

Christopher M. Surber wrote:
> 
> hey all,
>         im trying to get this script to take a list and from one line at
> a time
> take each word or whatever and put it into a variable so that i can
> insert the information into a different format. what i have don't work
> and im gittin crazy. the script i have so far is

There are two problems in your script ... see the marks:


> #!/usr/bin/perl -w
                  ^^
  (just a hint: add this option to make a programmer's life easier ...)

> print "what file?";
> chop($filename = <STDIN>);
> open (THATFILE, "$filename") || die"cannot open $filename";
> 
> while (<THATFILE>) {
> 
> ($lname,$fname,$location,$mailstop,$phone) = split(/ /);
                                                     ^^^
                     this should better be '/\s+/', because you don't
                     want to match only one space, but also tabs
> 
> write;
> }
> format STDOUT =
> 
> @<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<@<<<<<<<@<<<<<<<<<<
> $lname,$fname,$location,$mailstop,$phone,$real
                                          ^^^^^^
                                        remove this
> .


Bye, Eike

=====================================================================
 Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
            email : eike.grote@theo.phy.uni-bayreuth.de
           URL : http://www.phy.uni-bayreuth.de/~btpa25/ 
=====================================================================


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

Date: 4 Mar 1997 13:53:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl timing questions:
Message-Id: <5fh9hb$8ko$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    albury@csee.usf.edu writes:
:Can anyone clue me in as to a way to time operations in perl witha
:granularity of less than 1 sec? 
:
:I'm writing some socket based code to send packets around the internet
:and i'd liek to be able to measure packet response time in milliseconds;
:however the time module only supports increments as fine as 1 second.
:
:Is it neccessary to somehow use syome type of system event of interupt
:to count in milliseconds??
:
:I'm at a loss here for the moment and i'd appreciate any pointers anyone
:might have,

    require 'sys/syscall.ph';

    if (-1 == syscall( &SYS_gettimeofday, $start, 0)) { die "gettimeofday 1: $!" }

    #############################
    #				#
    # your operation goes here	#
    #				#
    #############################

    if (-1 == syscall( &SYS_gettimeofday, $done,  0)) { die "gettimeofday 2: $!" }

    printf "That took %.2f seconds\n", $done - $start;

--tom

-- 
	Tom Christiansen	tchrist@jhereg.perl.com


At MIT the server is the unit of invention.  --Rob Pike


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

Date: Mon, 03 Mar 1997 20:15:33 -0800 (PST)
From: David Dickerson <ddickerson@igc.apc.org>
Subject: Problem with LEARNING PERL Example
Message-Id: <APC&1'0'50775d89'3e1@igc.apc.org>



Greetings!

I am currently reading the first edition of LEARNING PERL and working
my way through the examples. I seem to be stumped, however, by the
example on page 10, which introduces arrays. (I should mention that
I am using the latest Macintosh port of Perl 5, MacPerl 5.1.3.r2.)

I have compared my code to the code in the book and cannot find what
obviously must be a mistake in my code, which is as follows.

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

#!/usr/bin/perl

@words = ("camel","llama","oyster");
print "What is your name? ";
$name = <STDIN>;
chop($name);
if ($name eq "Randal") {
        print "Hello, Randal! How good of you to be here!\n";
} else {
        print "Hello, $name!\n";        # ordinary greeting
        print "What is the secret word? ";
        $guess = <STDIN>;
        chop($guess);
        $i = 0;                         # try this word first
        $correct = "maybe";             # is the guess correct or not?
        while ($correct eq "maybe")  {  # keep checking until we know
            if ($words[$i] eq $guess  { # right?
                $correct = "yes";       # yes!
            } elsif ($i < 2) {          # more words to look at?
                $i = $i + 1;            # look at the next word next time
            } else {                    # no more words, must be bad
              print "Wrong, try again. What is the secret word? ";
              $guess = <STDIN>;
              chop($guess);
              $i = 0;            # start checking at the first word again
            }
        }                        # end of while not correct
}                                # end of "not Randal"

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

When I attempt to run the script or check its syntax, I get the following
errors:

  # syntax error, near "}"
  File secret-word-2.pl'; Line 19
  # syntax error, near "} else"
  File Line 21
  # Execution of secret-word-2.pl aborted due to compilation errors.

I apologize if this problem is a platform-specific one (and will direct
it to the MacPerl discussion list if it is).

I would greatly appreciate any assistance. Thank you, in advance, for
your time, help and consideration.

Cordially,

David Dickerson
http://www.igc.apc.org/ddickerson/

P.S. -- According to the information at O'Reilly and Associates' Web
site, the second edition of LEARNING PERL, which includes Perl 5, is
expected in May.

___________________________________________________________
   David Dickerson     / / /     ddickerson@igc.apc.org

   "In a world of absurdity, we must invent reason; we
    must create beauty out of nothingness." - Elie Wiesel







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

Date: 4 Mar 1997 14:04:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Returning a reference to a 'my' variable
Message-Id: <5fha51$8ko$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, stijnvd@cwi.nl (Stijn van Dongen) writes:
:Is there a difference in performance between doing
:
:	my $x = [];
:	# .. 
:	return $x;		# and
:
:	my @x;
:	# ..
:	return \@x;

Did you try the timing?  They are nearly identical, 
but having to go through -> access while in the 
subroutine tends to be minisculely slower.

    use Benchmark;

    $count = shift || 10_000;

    sub makeref {
	my $x = [];
	my $i;
	for ($i = 0; $i < 20; $i++) {
	    $x->[$i] = $i;
	} 
	return $x;
    } 

    sub makeary {
	my @x;
	my $i;
	for ($i = 0; $i < 20; $i++) {
	    $x[$i] = $i;
	} 
	return \@x;
    } 

    timethese $count, {
	allref => q{ makeref() },
	allary => q{ makeary() },
    }; 


Or even this if you have enough memory:

    timethese $count, {
	allref => q{ push(@a, makeref()) },
	allary => q{ push(@b, makeary()) },
    }; 

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

    Actually, you'll know we're nearing the end when I make |$foo| mean
    "absolute value"...  :-) Larry Wall in <1994Feb25.192042.17196@netlabs.com>


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

Date: 04 Mar 1997 14:30:11 +0100
From: Ronald Fischer <rfi@uebemc.siemens.de>
Subject: Re: Starting with PERL: a question
Message-Id: <xz2pvxfss2k.fsf@uebemc.siemens.de>

Hugh Blandford <hugh@island.net.au> writes:


| From the website, it appears that the only basic instruction material is
| from O'Reilly in the form of the 'llama' book.  Yet this only deals with
| PERL version 4. Is this where I will have to start?  Does anyone know of
| any tutorial docs at universities around the world that might be of
| help?
I experienced the same when asking at my bookstore. Nevertheless, O'Really
issued a new edition in 1996, which is said to deal with Perl 5 - so keep 
looking.

-- 
Ronald Otto Valentin Fischer
business:	ronald.fischer@uebemc.siemens.de
private:	ronald.fischer@acm.org
http://ourworld.compuserve.com/homepages/ronald_fischer


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

Date: 4 Mar 1997 12:47:09 -0000
From: aeb@calf.saltfarm.bt.co.uk (Tony Bass)
Subject: subscript assignment and splice equivalence
Message-Id: <5fh5kd$rso@calf.saltfarm.bt.co.uk>

perlfunc(1) asserts of splice,

   The following equivalencies hold (assuming $[ == 0):

   $a[$x] = $y         splice(@a,$x,1,$y);

but experiment shows that the equivalence is at best partial,

   calf$ cat try
   #! /usr/local/bin/perl -w
   use strict;

   sub show {
    join ' ', map { (defined $_) ? $_ : 'undef'; } @_;
   }

   my @a = ('a', 'b', 'c');
   $a[7] = 'd';
   print show(@a), "\n";
   @a = ('a', 'b', 'c');
   splice @a, 7, 1, 'd';
   print show(@a), "\n";
   calf$ 


   calf$ try
   a b c undef undef undef undef d
   a b c d
   calf$ 


   calf$ /usr/local/bin/perl -v

   This is perl, version 5.001

        Unofficial patchlevel 1m.

I reckon the behaviour of subscript assignment is semantically sound and
useful here, and certainly would not want to see it change.

The behaviour of splice is less clear.  I lean towards wanting the
equivalence maintained, for consistency, but would be interested to hear
any arguments for semantic soundness or practical use in this splice
behaviour.  But if the different splice behaviour is preserved then
perhaps the man page and blue camel should draw their horns in and add a
qualification to the assertion of equivalence.

A separate issue is that in any case the values of the subscript
assignment and splice expressions will differ even if the side-effects
are the same, but this is the sort of thing a reader can easily realise,
and seems less important.  But will/should

   splice @a, 7, 1, 'd'

return (undef) or ()?  I guessed wrong when I tried to predict it.

    Tony Bass

-- 
# Tony Bass                                     Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


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

Date: Mon, 03 Mar 1997 19:47:25 GMT
From: daniel.sundin@engelholm.se (Daniel Sundin)
Subject: Timer which can handle milliseconds..
Message-Id: <331b2a8b.13446493@skarjeke.ind.mh.se>

I need to be able to measure short periods of times, 
less than a second. Preferably as small as milliseconds.

So far, I havent been able to find any timer that can handle
milliseconds. If anyone knows how to do this, or knows 
of a script that does it, please tell me about it

Thanks In Advance,
Daniel



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

Date: 4 Mar 1997 13:44:39 GMT
From: "Shawn Bernard" <webmaster@systecinc.com>
Subject: UNIX commands in NT
Message-Id: <01bc28a2$60d1b3a0$a7fce59b@shawnb.systecinc.com>

I found a neat little program called WinXs which simulates UNIX commands
(such as cat, col, csplit, du, fmt, grep, grex, hd, etc.) for any Windows
environment.  Would this little program, installed on a an NT server
installed with Perl, help save time in converting a UNIX Perl script to an
NT computer?  How much of a help would this be?  Thanks.

-- 
Shawn
webmaster@systecinc.com
http://www.systecinc.com


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

Date: Tue, 04 Mar 1997 14:23:47 +0000
From: Alex Schajer <schajer@dircon.co.uk>
Subject: Re: Web download script..????
Message-Id: <331C3073.167E@dircon.co.uk>

Len Wilson wrote:
> 
> Sebastien (sebast@hrnet.fr) wrote:

> : I just want to know how to make a unix script like cgi to auto download
> : a given web page.
> 
> #!/usr/local/bin/perl
> 
> use LWP::Simple
> 
> $fetchfile = "http://thesite.dom/thepage.html"
> $localfile = "/path/temp.html"
> $bytes = 0
> 
> $bytes = getstore($fetchfile, $localfile)
> 
> die "Can't get the page. \n" unless $bytes
> 
> etc.
> 

Does anybody know how to do EXACTLY that for Perl for NT?
Our problem is that we are having difficulty installing the libraries
onto our NT machine,

Thanks

Alex


> That's from memory but I think it's right. You can get the LWP modules
> from CPAN if you don't already have them.
> 
> Len Wilson


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

Date: 4 Mar 1997 15:15:25 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Web download script..????
Message-Id: <5fhead$n57@fridge-nf0.shore.net>

Alex Schajer (schajer@dircon.co.uk) wrote:

: Does anybody know how to do EXACTLY that for Perl for NT?
: Our problem is that we are having difficulty installing the libraries
: onto our NT machine,

Yes.  Check out the Sockets documentation that came with Perl 5.003_07.
I was able to take one of the existing examples, and the socket client
from Programming Perl, Second Edition, and create a simple client to 
grab pages from a remote server, and save output to a file.

I'd include an example, but I'm not in front of my Windows machine right
now.

--
Nathan V. Patwardhan
nvp@shore.net


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

Date: 4 Mar 1997 14:12:01 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Where is FAQ?
Message-Id: <5fhajh$8ko$3@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
:The FAQ used to be posted to this newsgroup. The last time I saw it was
:early '96. Back then, it wasn't too big to be posted, and posting it
:would certainly be a large part of getting people to read it before
:asking questions. 
:
:Could whomever used to post it start doing it again? Please? 

Let's not be so accusative; s/whomever/whoever/ :-)

But yes, it's being worked on quite hard right now.  It'll be in like
10 or 12 different sections.  Prelimary copies of about half of the sections
have been posted to the perl-porters list for comment, so you could look
at the mailing list archive or its mail-2-news gateway if you'd like to see
what we're doing.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    If I allowed "next $label" then I'd also have to allow "goto $label",
    and I don't think you really want that...  :-) 
            --Larry Wall in <1991Mar11.230002.27271@jpl-devvax.jpl.nasa.gov>


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

Date: Tue, 4 Mar 1997 06:06:35 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Which one is the best (pattern matching)
Message-Id: <b83hf5.ah.ln@localhost>

Abigail (abigail@ny.fnx.com) wrote:
: On 03 Mar 1997 18:04:38 GMT, Jeffrey wrote in comp.lang.perl.misc:
: ++ 
: ++ Comments on this point from perl.gods would be appreciated here,

: Are you trying to start a religion?
                    ^^^^^

Too late.   ;-)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 04 Mar 1997 08:26:11 -0500
From: Scott Green <mogreen@ix.netcom.com>
Subject: Will pay money for CGI scripts
Message-Id: <331C22F3.14A5@ix.netcom.com>

Hello!   Anybody interested in writing a few CGI scripts exclusively for
my business and getting paid for those scripts can send me an email at
mogreen@ix.netcom.com and tell me what they would charge and how soon
the work can be done.  I have experience in programming myself but have
little time to develop and test a script.  Interested and accomplished
parties need only apply.  Thank You!


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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