[6765] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 390 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 29 10:59:16 1997

Date: Tue, 29 Apr 97 07: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, 29 Apr 1997     Volume: 8 Number: 390

Today's topics:
     Can i use Perl/Tk for my projekt ? <mschmidt@hs-bremen.de>
     Re: Challenge (I R A Aggie)
     Re: file copy <gwhassan@prodigy.net>
     Re: file copy <gwhassan@prodigy.net>
     Genetic programming (revisited) (Zachary Brown)
     Re: hip/activeware perl site down? <jim.condit@fmr.com>
     Re: OOP & perl (Jay Flaherty)
     Re: Ousterhout and Tcl lost the plot with latest paper <np2@doc.ic.ac.uk>
     Re: Output of sorted dated from an array into a table? <seay@absyss.fr>
     Perl on the Mac - hep me! (Ed Young)
     Re: Perl String Check Glitch - HELP needed (David Alan Black)
     Re: push or unshift simple question (David Alan Black)
     Randal Teaching Open Perl Class in NYC/NJ on May 15th <s..vanechanos@postoffice.worldnet.att.net>
     Re: References in foreach loop variable (David Alan Black)
     regexp cribsheet <neiled@enteract.com>
     Re: regexp cribsheet (David Alan Black)
     Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Donal K. Fellows)
     Re: shtml extension from perl? (Eric Harley)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 29 Apr 1997 14:04:35 +0200
From: Michael Schmidt <mschmidt@hs-bremen.de>
Subject: Can i use Perl/Tk for my projekt ?
Message-Id: <3365E3D3.198A@iat.hs-bremen.de>

- Develop a projekt with an Graphical-User-Interface with Perl5 and the
Tk-Package-

My questions are the following:

1. Can i use Perl5 under Windows95 and/or Win Nt and/or Win311 with
all    functions of Tk ?
2. What module support the plot-functions and mouse-controll, like   
drag-and-drop, under Tk ?
    For example, i want to draw a line on screen and after then i
want     to move this line with the mouse. 
3. It is generally efficent to use Perl5 for this projekt ?


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

Date: Fri, 25 Apr 1997 18:44:19 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Challenge
Message-Id: <fl_aggie-ya02408000R2504971844190001@news.fsu.edu>

In article <01bc51a3$1d158540$6b0312c7@mstrohofer.cincom.com>, "Marty
Strohofer" <mstrohofer@cincom.com> wrote:

+ Can anyone figure this out?

Yeah, no problem. It just requires some thought. You should consider
giving it some...

+ The string would be something like 70425n14
 
+ where 7 is the last digit in the year (1997)
+ where 04 is the month
+ where 25 is the day of the month

Instead of using 0425 for month/year combination, why not use the
number of days from 1 January? this value is commonly called 'julian
date' (but isn't really). So that you end up with a seven character
string:

7115n14

If this is for a WWW based application, then you have an extra character
to play with, and can use it for a seconds field, and still be limited
to eight characters. It's not impossible that you might have more than
one order placed within one particular minute, and this will easily
give you room to differentiate between them.

Of course, if you have more than one order per second, you'll have
problems... :)

One way to overcome that would be to encode the minute field in a manner
similar to the hours and seconds.

hours   - 0-23 -> a-w
minutes - 0-59 -> A-Z[\]^_`a-z{ (60 characters, arbritrarily chosen to start
                                 with 'A')

Once more, you've compressed your string to seven characters: 7115nN
Now, if things get tight, you have an extra field to use and still get
eight characters. Some instance of seconds.

James

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Tue, 29 Apr 1997 05:59:52 +0000
From: Greg Hassan <gwhassan@prodigy.net>
To: rebecc60@pobox.upenn.edu
Subject: Re: file copy
Message-Id: <33658E58.26900801@prodigy.net>

Becky Schonfeld wrote:
> 
> I have used the following bit of perl to attempt to get file $A to be
> copied to $B except for one line ($break of file $A).  However it seems
> to not skip line $break.  Can anyone help?
> 
> $records=0;
> open(IN, "$A") || die "cannot open $A for reading";
> open(OUT, ">$B") || die "cannot create $B";
> while (<IN>){
> if ($records != $break){
> print OUT $_;}
> $records++;
> }

sorry about that last post, i think i will have to
get rid of netscape 4, 3.0 seems to work better with news.

anyways, I was original thinking your were trying to
compare the actual line but now i see you are 
going by line number.  

I would say print out $records and $break inside the loop
and see what they look like.  Maybe put a character on
either side of them so you can see their exact value.

print ":$records,$break,\n";

this is just to make sure that you are getting the values
you think you should.  One of those print's should be equal
then i wouldnt really know what to suggest.  Maybe somewhere
else in your program is buggy, causing this weird problem.

-Greg
-- 
============================================
                Greg Hassan
          The Independent Solution
 Web Developer (CGI, Java, C, Perl, Oracle)
           http://www.hassan.com/        
    gwhassan@prodigy.net, 1-415-969-5856
============================================
New:  World-Wide Classified Listings
      (http://www.hassan.com/.classifieds/)
============================================


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

Date: Tue, 29 Apr 1997 05:49:30 +0000
From: Greg Hassan <gwhassan@prodigy.net>
To: rebecc60@pobox.upenn.edu
Subject: Re: file copy
Message-Id: <33658BEA.72CF176E@prodigy.net>

Becky Schonfeld wrote:
> 
> I have used the following bit of perl to attempt to get file $A to be
> copied to $B except for one line ($break of file $A).  However it seems
> to not skip line $break.  Can anyone help?
> 
> $records=0;
> open(IN, "$A") || die "cannot open $A for reading";
> open(OUT, ">$B") || die "cannot create $B";
> while (<IN>){
> if ($records != $break){
> print OUT $_;}
> $records++;
> }

try :

 if ($records ne $break){

-- 
============================================
                Greg Hassan
          The Independent Solution
 Web Developer (CGI, Java, C, Perl, Oracle)
           http://www.hassan.com/        
    gwhassan@prodigy.net, 1-415-969-5856
============================================
New:  World-Wide Classified Listings
      (http://www.hassan.com/.classifieds/)
============================================


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

Date: 29 Apr 1997 09:05:52 -0400
From: zbrown@lynx.dac.neu.edu (Zachary Brown)
Subject: Genetic programming (revisited)
Message-Id: <5k4rng$d4r@lynx.dac.neu.edu>

No reply to my question if anyone had written a library for creating 
random perl code within user defined parameters. I did get an email from 
someone else interested in the same problem, though.

Any takers? I tried and failed, but if it were done right, it would be 
great. Perl is an ideal genetic programming environment.

Zack



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

Date: Tue, 29 Apr 1997 08:58:30 -0400
From: Jim Condit <jim.condit@fmr.com>
Subject: Re: hip/activeware perl site down?
Message-Id: <3365F076.3BB9@fmr.com>

It works for me also, they turned off their hip.com URL, which is what I
had bookmarked. All is well in the world :)


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

Date: 29 Apr 1997 12:30:29 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: OOP & perl
Message-Id: <5k4pl5$g5a$1@gaia.ns.utk.edu>

Tom Christiansen (tchrist@mox.perl.com) wrote:
: In the next 6-8 weeks, I have publisher's deadlines
: for one existing book to update, another one to write from scratch,
: plus three books to tech-edit, and to top it off I have a bogus 7-figure
: nuisance lawsuit to try to get dismissed.  
: 

1.	Randal Schwartz, a renowned Perl hacker, fighting a criminal lawsuit from 
an over-reacting Company.

2. Tom Christiansen, a renowned Perl hacker, fighting a bogus 7-figure
nuisance lawsuit. 

I am not saying there is a conspiracy here but if you are a 
"renowned Perl hacker", I would lay low for awhile :-)

Jay  
-- 
**********************************************
Jay Flaherty          fty@hickory.engr.utk.edu

    ------visualize whirled peas------
**********************************************


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

Date: 29 Apr 1997 13:12:05 GMT
From: "Nat Pryce" <np2@doc.ic.ac.uk>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <01bc549f$c5a17f80$490ea992@shub-niggurath>

Christopher Eltschka <celtschk@physik.tu-muenchen.de> wrote in article
<3364DD2D.86195F2@physik.tu-muenchen.de>...
> John Ousterhout wrote:
> 
> [...]
> 
> >     >The button example requires about 25 lines of code in three procedures
> >     >when implemented in C++ with Microsoft Foundation Classes. Just
> >     >setting the font requires 7 lines of code ...
> > 
> >     Come on! All this shows is the inconveniece of using the MFC
> >     classes. An interface exactly the same as the Tcl one could easily be
> >     written in C++.
> > 
> > I invite anyone who believes this to try to do it, and post the results.
> > I've had this argument before, and when people do this, one of two things
> > happens: either they eventually concede that this is hard to do in C++, or
> > they define new C++ APIs that are essentially untyped (e.g. they use
> > strings for everything).  This just supports my arguments that types get
> > in the way of gluing.  You can build untyped APIs in strongly typed
> > languages, but they tend to be clumsy because the languages are designed
> > to encourage strong typing.  If you need an untyped approach, you might
> > as well use a language designed for that.
> 
> Well, I found this discussion just now, but this is IMHO easy to answer:
> 
> void action() { cout << "Hello" << endl; }
> 
> button b=buttonstyle().text("Hello").font("Times",16).execute(action);


Indeed!  I have written such a C++ GUI toolkit myself.  I started writing it
because I found MFC and Borland's OWL to be so useless.  Because I'm a Tcl/Tk
programmer, I used Tk's model of layout managers and configurable GUI 
components.

E.g, here's how a main window with some buttons would be created, first in Tk:


proc Quit { ... }
proc Beep { ... }

proc MyMainWindow {w} {
	toplevel $w
	wm title $w "An Example Main Window in Tk"
	
	# Create and configure user-interface widgets
	#
	button $w.quit -text "Quit" -command Quit
	button $w.beep -text "Beep" -command Beep
	
	# Layout widgets
	#
	grid $w.quit -row 0 -column 0 -sticky nsew
	grid $w.beep -row 0 -column 1 -sticky nsew
}


And now in my framework, WOOL.  This is a little larger, but is more
explicit about the relationship between components:


#include <mainwin.h>
#include <button.h>
#include <action.h>

class MyMainWindow : public MainWindow
{
private:
	void quit();  // Closes the main window and quits the application
	void beep();	// Makes a beep noise - just an example

	GridLayout _grid;		// Layout manager
	TextButton _quit, _beep;	// GUI components

public:
	MyMainWindow( HINSTANCE app ) :
		MainWindow(app,"An Example Main Window in the WOOL libary"),
		_quit(this), _beep(this)
	{
		/*  Configure the user-interface widgets
 		 */
		_quit.text("Quit")
		     .action(new MemberAction<MyMainWindow>(&MyMainWindow::quit))
		_quit.text("Beep")
		     .action(new MemberAction<MyMainWindow>(&MyMainWindow::beep))
		
		/*  The grid layout manager will fill the window, allocating the
 		 *  space to its slaves
		 */
		this->manage(_grid);
		
		/*  Tell the layout manager which slaves to layout and where to
		 *  to put them.
		 */
		_grid.manage(_quit).row(0).column(1).anchor(fill);
		_grid.manage(_beep).row(0).column(0).anchor(fill);
	}
};

And using C++ has a number of other advantages.  Because the interactions 
between layout managers and layout slaves are defined in terms of abstract
interfaces, a layout manager can lay out any object which provides the
LayoutSlave interface and so can lay out Widgets, canvas objects and even
other layout managers.  The latter is useful because it reduces the need
for extra frame widgets which only exist to create pleasing layouts.

I haven't found the need to use weak typing, probably because I make
full use of C++'s template mechanisms, and because I find it natural
to design frameworks in terms of roles and interactions defined using
strongly-typed abstract interfaces.  I also designed the framework to
interact with other frameworks by providing interfaces through which
event loops can be merged and support for multiple threads.

There is nothing in C++, strongly typed languages or object orientation
which makes it impossible to glue components together or implement reusable 
software components.  Its just that you have to design things that way 
from the start.  It is exactly the same with Tcl/Tk. It is as possible to 
design an infexible and un-reusable component for Tcl/Tk as it is for 
C++ or any language.  It's not a platform or language issue, but a 
design issue.

IMHO, The flaw in Dr. Ousterhout's paper is that it can essentially be 
boiled down to the argument "A well designed framework is better than a 
poorly designed framework" with which nobody can argue but which says 
nothing about the usefulness of Tcl or scripting languages in general.

Cheers,
	Nat.

-- 
+-------------------------------------------+---------------------------------+
| Name:   Nat Pryce MEng ACGI            O- | Mail:  Department of Computing, |
| Email:  np2@doc.ic.ac.uk                  |        Imperial College,        |
| Tel:    +44 (0)171 594 8394 (Direct Dial) |        180 Queen's Gate,        |
| Fax:    +44 (0)171 581 8024               |        London SW7 2BZ,          |
| WWW:    http://www-dse.doc.ic.ac.uk/~np2  |        United Kingdom           |
+-------------------------------------------+---------------------------------+





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

Date: Tue, 29 Apr 1997 14:08:56 +0100
From: Douglas Seay <seay@absyss.fr>
To: r.polanskis@nepean.uws.edu.au, grove@zeta.org.au
Subject: Re: Output of sorted dated from an array into a table?
Message-Id: <3365F2E8.21263795@absyss.fr>

> Can anyone help me with some suggestions, to get my table formatted
> the way I want it?

I'm afraid that this might confuse more than it clears, so be prepared.

I would do it slightly differently, I would not use arrays (LISTS), but
I would use associative arrays (HASHS) instead.  Partially because I
think hashes are cool, partially because it kinda helps here.

I would open a file, read in the interesting stuff into variables $time,
$host and $status and then do something like

	$my_data{$time} = {};
	$my_data{$time}->{$host} = $status;

where %my_data is a hash table where the keys are the time stamps (ie -
"Fri 13/12/97") and the values are references to anonymous hashes (that
is what that empty {} pair is doing in the first line, that is Perl5, so
you won't find it in you Perl4 book).  Each of these unnamed hash tables
have machine names as keys and status codes as values.

Once this table is loaded with values, you could print everything out
with

	my @hostlist = sort ( 'fred', 'foobar', ...);
	print join(' ', 'date', @hostlist), "\n";
	foreach $date ( sort datesorter keys %my_data )
		{
		print $date, ;
		foreach $machine ( @hostlist )
			{
			my $status = $my_data{$date}->{$machine} || 'unknown';
			delete $my_data{$date}->{$machine};
			print $status;
			}
		if ( keys %{my_data{$date}} )
			{
			print "unknown_machines=", join(', ', keys %{$my_data{$date}});
			}
		print "\n";
		}

# warning - this code is untested, so it may contain syntax errors or
worse.

The idea was to sort the keys of %my_data, go through them in order,
look at each machine that you are interested in, print out its status,
and go on.  Delete each  machine from the table when it is handled, and
when that inner loop is done, any entries left in the table belong to
unknown machines, so print out the names of these machines.  Finally,
end the line and go back to the main loop.

Sure, this has absolutely nothing to do with the code that you wrote. 
Here are a few comments about your code block.


> #!/opt/local/bin/perl -w
> use strict;

Very good opening lines, both -w and strict.  You already have some good
habits.

> 
> my ($header, $wkday, $date, $hdr, $host, $table, $junk, $status);
> 
> open (SPOOL, '/export/home/rachel/.Mail/backups') or die "can't find mailbox\n";
> 
> while (<SPOOL>){
>         if ( $_ =~ /^Subject/ ){
> ( $header, $hdr, $host, $wkday, $junk, $status, $junk) = split('\s+',$_);
> 
> # read the status out of the header, and turn it into a 2 letter code.
>    if ($status eq "REWIND") { $status = "RF";}
> elsif ($status eq "VERIFY") { $status = "VF";}
> elsif ($status eq "NO")     { $status = "NT";}
> elsif ($status eq "BACKUP") { $status = "BF";}
> # otherwise the status is "OK"

Then shouldn't you code that?
  else                        { $status = 'OK';}


>         }
> 
> # read the first line of the message body, to get the backup start time
> 
>         if ( $_ =~ /^cpio/ ){
>         ($junk, $junk, $junk, $junk, $junk, $junk, $date) = split ('\s+',$_);

That could be written
	$date = ( split('\s+', $_) )[6];
Remember that arrays start at 0, just like C.  (Don't worry about $[ as
mentioned in the Perl4 camel, that has gone out of fashion.)

> 
> # stuff the data into an array
> 
> my @data = ($host, $wkday, $date, $status, "\n");

Here is your problem.  Actually, here are several problems.  @data is
local, so when you exit your loop, it will be destroyed.  I understand
that you are still in the early debugging stage, but that has to be
changed.  Second, you are replacing the value of @data with the
assignment statement.  That means data from any past iterations will be
overwritten.  That line should look more like

push(@mydata, $host, $wkday, $date, $status, "\n");


> foreach $table (@data) { print "$table\n"; }
> next;

Loops will loop automatically at the end of the block.  The "next" is
only if you want to end the loop early.  Just delete that line as it
isn't useful.

>   
>   }
> }
> close (SPOOL);

You didn't check the exit status of close(SPOOL).  Here it isn't too
bad, but if you had opened a pipe, you would never check the exit
status.  Just get into the habbit of checking both open() and close().

The main logic weakness I'm seeing is that the information in @mydata is
not sorted and it will be a pain in the rear to sort.  Now, if you could
be sure that the info in your SPOOL file was already sorted, you'd be
home free, but I somehow doubt if that is the case.  Life would be
easier if you changed the @mydata assignment to look like

	push(@mydata, [$host, $wkday, $date, $status]);

so now @mydata has a list of lists (basically a two dimensional array)
(yes, this is another Perl5 thingie that you won't find in your Perl4
book).   Sorting has now become much easier as when you sort $a and $b
(the two magic variables for sort routines) will be references to lists
and you can sort something like

sub my_sorter
{
my ($host_a, $date_a) = @{ @$a )[0,2];
my ($host_b, $date_b) = @{ @$b }[0,2];

# if the dates are the same, return the comparison of the hostnames
(cmp)
# convert dates to seconds and return the difference (<=>)
}

and when you're done sorting, they will be sorted by date and hostname. 
Now when you go through your @mydata list, don't forget to check that
every system has an entry.  Don't just blindly grab the next on of the
list and print it because maybe one email log got lost.

I hope that this helps more than it hurts.

Good luck.

- doug


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

Date: Tue, 29 Apr 1997 08:38:25 -0600
From: eyoung@ncsa.uiuc.edu (Ed Young)
Subject: Perl on the Mac - hep me!
Message-Id: <eyoung-2904970838250001@bopc3.ncsa.uiuc.edu>

Ok, I'm just learning...know very little...and going nowhere fast.

I'm learning perl from the "learn Perl" book (the one with the camel)
This book was written with a unix platform in mind. They don't allow cgi
on our unix servers so I turned my mac into a server (webstar) and I'm
learning Perl/finding and trying to get scripts, I find on the web,
working, so I too can have a guestbook.

Trouble is, there's enough diffrences between MacPerl and Unix Perl,
learning this is not the easiest thing. 
I've tried to take scripts others have made and get them to work on my mac
with no results.

Are there any MacPerl scripts out there and where...and where can I find
something that shows me the diffrences between Unix Perl and MacPerl?

Thanks


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

Date: 29 Apr 1997 13:44:03 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Perl String Check Glitch - HELP needed
Message-Id: <5k4tv3$hgj@pirate.shu.edu>

Hello -

Step Firth <step@punters.co.uk> writes:

>Hello, I am trying to put a registration onto a Web Site.
>The CGI scripts are coded in PERL and I need to check the details
>without case sensitivity.
>I found the following condition in a search routine and lifted it, it
>works fine, except that it only validates a subsection, even though the
>case bit is fine

>ie var1=abc, var2=zabcdef - causes the error because (I think) it only
>checks for var1 being within var2.
>is that what the '=~' means?

>&error(the same) if ($var1 =~ /$var2/i);

Moments ago, in response to another posting, I wrote:

>I would
>tend to advise against a cut-and-paste approach to regular expressions,
>unless you know exactly what the regex is doing and exactly why it's
>right for your needs.

Thank you for saving me some typing.  I would add: if you want to
program in Perl, get hold of some tutorial materials and study
them.  You will encounter =~ before lunch.

And to think, I used to be the relatively-though-by-no-
means-absolutely mushy one when it came to fielding ground-zero
questions....


David Black
dblack@icarus.shu.edu


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

Date: 29 Apr 1997 12:59:04 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: push or unshift simple question
Message-Id: <5k4rao$dg4@pirate.shu.edu>


Hello -

soccer@microserve.net (Geoffrey Hebert) writes:

>I have one element I want to add to an array.  I can do it several
>others ways,  But I can not seem to use push or unshift.

>unshift @myarray $one_element;

You need a comma:

unshift @myarray, $one_element;

or even:

unshift (@myarray, $one_element);


David Black
dblack@icarus.shu.edu


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

Date: 29 Apr 1997 12:25:24 GMT
From: Steve Vanechanos <s..vanechanos@postoffice.worldnet.att.net>
Subject: Randal Teaching Open Perl Class in NYC/NJ on May 15th
Message-Id: <5k4pbk$glj@mtinsc03.worldnet.att.net>


We are sponsoring an open to the public, on day advanced perl class,
taught by Randal Schwartz on May 15th.

Details at http://www.dynamicweb.com/perl_class.html

-- 
Steve Vanechanos, CEO                   http://www.dynamicweb.com
DynamicWeb Enterprises, Inc             Voice: 201-244-1000
271 Rt 46 West; Building F              Fax:   201-777-7428
Fairfield NJ 07004                      Email: stevev@dynamicweb.com




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

Date: 29 Apr 1997 13:15:14 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: References in foreach loop variable
Message-Id: <5k4s92$eua@pirate.shu.edu>

Hello -

mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:

>David Alan Black <dblack@icarus.shu.edu> wrote:
>>If it were a glob reference:
>>
>>$i = \*foo;
>>
>>then you'd get "123" again - but, as in the third example, the
>>assignment would be to $foo.

>That's not _quite_ right.   Trying

>$i = \*foo;
>foreach $$i (1..3) { print $$i };

>prints

>*main::foo*main::foo*main::foo

Your right - I was using "get" in a slipshod way, not
properly related to the code.

>whereas

>$i = \*foo;
>foreach $$i (1..3) { print $$$i };

>prints

>123

>Perhaps you can explain that  -  I can't.

This is more a report on further examination than an
explanation.

If you change the examples above to  foreach $$$i (1..3),
then eveything works "as expected" (with respect
to degrees of indirection, numbers of $'s, etc.).
$i is a typeglob ref,
$$i is a typeglob,
$$$i is the scalar member of that typeglob.

It's the fact that foreach $$i (1..3) (with two $'s) also
works that seems to be the anomaly.

Anyway, for what it's worth, here's some tinkering and a
few further comments.

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

# It's interesting that, given this:

$j = \*bar;

# each of these prints 'z':

foreach $bar        ('z') { print "$bar\n" }
foreach ${bar}      ('z') { print "$bar\n" }
foreach ${*bar}     ('z') { print "$bar\n" }
foreach ${\*bar}    ('z') { print "$bar\n" }
foreach ${$j}       ('z') { print "$bar\n" }
foreach $$j         ('z') { print "$bar\n" }
foreach ${$$j}      ('z') { print "$bar\n" }
foreach $$$j        ('z') { print "$bar\n" }

__END__

Dare I suggest that this is a case of implicit
dereferencing?  If it is, it may even be documented
somewhere... (Right now, the only "actually-there-
is-some" example I can find in the Camel has to do
with file handles.)

Pursuing implicit deref theory:

     foreach $$j ()

$j is dereferenced, yielding a typeglob (*bar), and then the
first $ constrains the variable to the scalar member of
that typeglob.

Or - perhaps the deferencing is as it appears (explicit),
and foreach(), requiring a scalar lvalue, implicitly constrains the
typeglob expression to its scalar member.  That would mean that
foreach() was, in effect, supplying its own left-most $ on the loop
variable.  But if that's what happening, then why isn't foreach willing
to do it with things like:

     foreach *bar ()  # syntax error

In short, I can see what's happening, and (having tinkered
with it) can predict which expressions will do what, but
I still do not entirely understand where the functional
equivalence between $$j and $$$j, as foreach() variable
expressions, is coming from.

Comments and/or Camel page numbers welcome :-)


David Black
dblack@icarus.shu.edu


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

Date: 29 Apr 1997 13:07:41 GMT
From: "Neil Edmondson" <neiled@enteract.com>
Subject: regexp cribsheet
Message-Id: <01bc549e$77bbe5e0$a59a70cf@nedmondson.iclretail.com>


OK - I admit it, and I know this isn't macho, but I am functionally
deficient when it comes to regexp.  I've gotten by in perl for the past 3
months by stealing and plagiarizing other peoples' regexp work.  Now I need
to do something original.  Yes - I've got Camel and Llama, but I'm sick of
falling asleep trying to get through "The Gory Details".  To speed my
learning curve, what I really need is a crib sheet that I can write on my
shirt sleeve, with LOTS of worked examples (I don't need lot's of words -
my mind is pretty good at pattern matching ;),  Seems like examples are the
only way I can learn these days.

Is there such a CRIBSHEET anywher, and where can I get it?

(Phew! that's admitted - now for step 2)


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

Date: 29 Apr 1997 13:27:09 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: regexp cribsheet
Message-Id: <5k4svd$fu0@pirate.shu.edu>

Hello -

"Neil Edmondson" <neiled@enteract.com> writes:

>OK - I admit it, and I know this isn't macho, but I am functionally
>deficient when it comes to regexp.  I've gotten by in perl for the past 3
>months by stealing and plagiarizing other peoples' regexp work.  Now I need

Sounds pretty mainstream so far. :-)

>to do something original.  Yes - I've got Camel and Llama, but I'm sick of
>falling asleep trying to get through "The Gory Details".  To speed my

Well, ummm....

>learning curve, what I really need is a crib sheet that I can write on my
>shirt sleeve, with LOTS of worked examples (I don't need lot's of words -
>my mind is pretty good at pattern matching ;),  Seems like examples are the
>only way I can learn these days.

It sounds like what you need are exercises, not examples.  I would
tend to advise against a cut-and-paste approach to regular expressions,
unless you know exactly what the regex is doing and exactly why it's
right for your needs. 

Jeffrey Friedl's "Mastering Regular Expressions" is a magisterial
work on the subject, but it's addressed to people who actually want
to learn about regexes in depth.  I can't think of any way to
reconcile your defeatism with any eventual ability to write
accurate and robust code.

David Black
dblack@icarus.shu.edu


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

Date: 29 Apr 1997 12:21:07 GMT
From: fellowsd@cs.man.ac.uk (Donal K. Fellows)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5k4p3j$qmm@m1.cs.man.ac.uk>

In article <3070390128524499@naggum.no>, Erik Naggum  <erik@naggum.no> wrote:
> Charles Lin
>> Now, perhaps I completely misunderstood what Ousterhout did, but I was
>> under the impression that he said everything in Tcl (the external
>> representation) is a string.  Why are we talking about internal
>> representations at all?
> 
> because the internal representation in Tcl is the string.

In some implementations for some objects.  Not all of either.  Get
your facts straight Erik (by having a look at Tcl8 :^)

>> Internal representations aren't going to be important because they are
>> hidden from the user (mostly).
> 
> I think you're missing the point all over the place.  Tcl's purpose is to
> glue different applications together, but also to do something with the
> returned "values" (i.e., output) of these programs.  of course we're
> dealing with interfaces where external representations will be used, but
> Tcl uses the same external representations for internal purposes, too.
> when you execute a numeric operation, the string is converted to a number,
> the operation is performed, and then converted back to a string.  in
> contrast to this view, AWK converts a string to a number when it is used
> for a numeric purpose, and a number to a string when it is used for a
> string purpose, but not otherwise.  (at least, this is what I have
> understood from what I have read about Tcl.)

Tcl (well, Tcl8) does better than AWK, in that when it converts a
string to a number (because it has been used numerically) it keeps the
old string representation around[*] in case the programmer refers to
that symbol in a string context, instead of having to convert back and
forth.  The same is true for Tcl8 lists - then you program with them
you use a string representation of them, but when they are referred to
in a list context, an efficient internal list representation is
generated, and if the list is created internally in the program, then
a string representation may never actually exist at all (it would only
be created if the programmer did something like interpolating the list
into a string, as you'd expect.)  This system of lazy type-conversion,
when coupled with an on-the-fly bytecode compiler (Tcl doesn't match
well with compilation to the JVM, compilation to native code is much
more difficult to make portable between architectures, and static
compilation is, in general, probably nigh-on impossible) gets the
performance boost that many of Tcl's detractors and advocates have
been after for years.

Donal.

[* Naturally, if the numberic representation is then modified, the
   string rep. is discarded and may need regenerating.  But you would
   have expected that...]
--
Donal K. Fellows   http://r8h.cs.man.ac.uk:8000/  (SAY NO TO COMMERCIAL SPAMS!)
(work) fellowsd@cs.man.ac.uk     Dept. Comp. Sci, Univ. Manchester, U.K.
 |     donal@ugglan.demon.co.uk  6,Randall Place, Heaton, Bradford, U.K. (home)
 +-> ++44-161-275-6137  Send correspondence to my office  ++44-1274-401017 <-+


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

Date: Tue, 29 Apr 1997 06:48:51 -0700
From: erich@powerwareintl.com (Eric Harley)
Subject: Re: shtml extension from perl?
Message-Id: <erich-2904970648520001@ppp-207-104-16-44.snrf01.pacbell.net>

In article <3365A385.4C7@rxlist.com>, "Neil Sandow, Pharm.D."
<rx@rxlist.com> wrote:

> I'm currently running a perl script on my website that searches
> the input (drugname) and outputs the results as an html file
> with a url which ends with ?drugname   I'd like to modify the script
> to have the url end with ?drugname.shtml so I can run a server side
> script with the new html file.  Is adding this .shtml extension easy to
> do?  Can somebody point me in the right direction?  

$cgi_object->redirect($url);


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

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

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