December 1999 Archives

This Week on p5p 1999/12/26



Notes

Last year I fell behind on reports because I took three business trips in two weeks. I still haven't caught up, so I am going to skip the last couple of reports. I was going to skip this week's report also, but it was so small I decided to do it anyway. The next report should be for 9--15 January. Sorry for the inconvenience.

Meta-Information

The most recent report will always be available at http://www.perl.com/p5pdigest.cgi .

You can subscribe to an email version of this summary by sending an empty message to p5p-digest-subscribe@plover.com.

Please send corrections and additions to mjd-perl-thisweek-YYYYMM@plover.com where YYYYMM is the current year and month.

Module Interface and Version Meta-Information

Last week a discussion started about how to put version information into modules in a standard way, and Sam Tregar suggested that there be a convention that the version information and other module interface information be stored in the POD documents. Discussion on this continued. I should probably have mentioned it in the pervious report.

Sam's message

SVs by Default

When you create a GV (glob value) in Perl, it has its SV slot filled automatically. For example, when you define @foo or sub bar you get space allocated for $foo and $bar automatically. The rationale behind this is presumably that scalar variables are very common and you might as well preallocate them. (I suppose this is why defined *{foo}{SCALAR} always yields true.)

Nick Ing-Simmons complained about this, saying that many SVs are allocated that are never used, and that the original assumption, that SVs are very common, may not be true now that most scalar variables are lexical.

I did not see a resolution of this.

Another return of PREPARE

In an earlier report, I mentioned that Ilya's PREPARE feature had not gone innto 5.005_63. Sarathy added that it would not go into 5.005_64 either unless it was fixed to not use a new opcode.

I mention this because Ilya replied that Perl needs twenty or thirty new opcodes, and that last year he demonstrated that by introducing new opcodes that atomically combine two or more other opcodes that often appear in sequence, some operations might be sped up by a factor of two. This was interesting, although it is not clear that it has anything to do with PREPARE.

Original discussion

Later followup

More Flushing Problems

Someone with no name submitted a bug report that pointed out that if you call truncate Perl truncates the file without flushing the stdio buffer. This is only the most recent in a very long series of similar, related bugs. I wonder why this is so hard to get right? Is it just that nobody has taken it up?

Ilya said that the last time this had come up, he suggested that Perl should always flush the buffer between any buffered and unbiffered operation, and between any read and any write, but ``The result is nil.''

Array::Virtual

Last week's discussion

Andrew Ford reports that this is finished, and is available at http://www.ford-mason.co.uk/resources/. It will appear on CPAN eventually.

#line directives

Andrew Pimlott pointed out that a #line directive in a require'd file inherits its implicit filename not from the file it is in, but from the file that required it. Apparently this is a feature. Andrew submitted a patch changing the behavior. There was no followup discussion. I do not know if the patch was accepted.

DProf

Håkon Alstadheim supplied a patch to Devel::DProf that allows the user to specify the data output file, via an environment variable.

Various

A medium-sized collection of bug reports, bug fixes, non-bug reports, questions, and answers. Apparently the spammers were all on vacation.

Until next time I remain, your humble and obedient servant,


Mark-Jason Dominus

Virtual Presentations with Perl


This summer, at yapc in Pittsburgh and again at the third Perl Conference, I was very fortunate to meet with a lot of friends from other regional Perl Monger groups. A lot of our groups have similar problems and frustrations. While larger groups like phl.pm, ny.pm, boston.pm and others do have many active members who meet frequently, other groups have fewer than 5 or 10 members and don't get together for a variety of reasons - geography, time constraints, projects at work, and so on.

Talking about this problem with Sarah Burcham of St.Louis.pm, we hit upon the idea of starting "virtual presentations". If an active group like phl.pm can have regular technical meetings, why can't we host them live on the web, so a small, far-flung group in Missouri or Nebraska can join in?

So Sarah and I started to talk about this idea some more, and we started to understand how these "virtual presentations" needed to work. Cumbersome Java and proprietary clients were right out - we wanted to be promoting Perl, after all, and we needed this to be easy to use, easy to setup and easy to promote. We needed some way to synchronize the speaker's slides to his presentation, and we needed some way for the remote group to ask questions and give feedback. So we immediately reduced the problem to the bare essentials. This got rid of all of the needless complexity that is the source of both great demos and countless headaches.

Since phl.pm had a technical meeting scheduled a month after the Perl Conference, we started talking about how we could broadcast that presentation to the mongers in St. Louis.

We thought about RealAudio/RealVideo broadcasting to bring a presentation to a remote location. Neither RealAudio nor RealVideo require a large investment in hardware or software to capture and broadcast a presentation in real time. This approach, while perfectly valid, didn't work for us, since the Philly side of the presentation was taking place behind a firewall. Assuming that we had the resources to transmit in real time, we couldn't get the packets out of the building. There was also the problem of bandwidth utilization - ISI, The Institute for Scientific Information, was kind enough to host the meeting, and we didn't want to overload the network by providing dozens of RealVideo feeds.

So, rather than trying to solve this problem with too many layers of technology, we just routed around it and used speaker phones. After all, if we are targeting small, far-flung groups, it should be easier to find a location with a speaker phone and a slow net connection than it is to find a location with sufficient unused bandwidth on a T1 line for realtime audio/video. A good host site can also use three-way calling to bring in two remote sites instead of one. While this technique may be much more limiting than using RealAudio or other internet audio broadcast, it is also much more accessible.

Now that we had the two-way communication problem solved, all that was left was synchronizing the audio presentation to the slides. Luckily, Kevin Lenzo had already solved this exact problem already with his two 'SlideShow' scripts (http://www.cs.cmu.edu/~lenzo/SlideShow/).

Kevin's scripts are actually quite crafty. 'SlideShow' is actually a pair of scripts: one used in the presenter's browser, and one used in each participant's browser. The idea is very simple -- whatever the presenter sees in his browser, the participants see in their browsers. When the presenter follows a link to a new web page, the presenter and all particiapnts should see the new page. (This includes pages that are part of the slide show as well as any other web page, such as www.perl.com.)

The first of these two scripts, master.cgi is used by the person giving the presentation. This is the script which fetches web pages and keeps everyone synchronized. After fetching a URL, master.cgi rewrites all HREF attributes in the page it fetches so that all links appear as HTTP GET requests to master.cgi. The rewritten links contain the original target URL as a parameter. The new version of the page is returned to the presenter's browser, so that once he starts using master.cgi, all links followed are part of the presentation.

The master.cgi script also saves a version of each page to a shared file for the second script, nph-view.cgi to use. The nph-view.cgi is a server-push script which can send a multiple distinct web pages back in a single, long-lived response. Every time master.cgi updates the shared file, each nph-view.cgi instance sends another part in it's multipart response to one participant's browser. There is no limit to the number of users of nph-view.cgi, so long as the web server has enough resources to process one instance of this script for every participant. To avoid complications, master.cgi removes all hyperlinks before saving a page to the shared file, so that participants don't inadvertantly stop nph-view.cgi from doing it's job.

At this point, we have all the tools we need for a virtual presentation. We have a host site, with conference phone (or RealAudio/RealVideo server) a web server configured with the SlideShow scripts, and a network connection for the presenter to display his slides. All the remote users need is a speaker phone (or a high bandwidth connection for realtime audio) and a simple network connection. We can continue down this path and decorate this setup with an IRC channel, a perl/tk whiteboard and so forth. Here, we've used Perl where appropriate to make the simple things simple, and other techniques to make the hard things possible.

Since August, when Kevin, Sarah and I started discussing this idea, phl.pm has hosted two of these virtual presentations. In September, we hosted Mark-Jason Dominus' presentation on Strong Typing and Perl, with St. Louis.pm. In October, we hosted Abigail's presentation on Damian Conway's Parse::RecDescent with both St. Louis.pm and Boston.pm.

Both of these talks worked reasonably well. Many of the problems we encountered were not technical in nature. For example, when presenting dry material in front of a live audience, a good presenter can see the audience start to lose interest. When making the same presentation over a long-distance connection, it is difficult to discern whether the silence on the other end of the line means that the remote audience is rivited to their seats or asleep.

When presenting to both live and remote audiences simultaneously, it is more important for a speaker to project his voice in a manner so that everyone can hear him clearly. This is different from presenting unamplified to a small group, or using a microphone in front of a live audience.

Here are some other lessons we learned from our presentations:

  1. Test the audio connection early and often.

    This means getting the remote phone numbers as soon as possible. If using a conference phone, make sure that there are no long distance blocking issues to overcome. Test three way calling, if necessary.

  2. Test the SlideShow CGI scripts on your webserver.

    Make sure that you have the CGI scripts configured so that any change made in the 'master' window comes up in the 'remote' window. This testing can be done with two browser windows on one computer.

  3. Have a backup webserver configured and ready to use.

    Nothing is worse than starting a presentation and finding 'no route to host' to your shared server. Having a backup server on another host (on another network, if possible) can overcome some of these problems.

  4. Make many small HTML pages. Avoid scrolling.

    While a speaker standing in the front of a room can scroll down the page to show an example, remote sites do not have the same cues and cannot see the presenter scroll down the page. Try and rework the content so that you can click to the next point or example instead of scrolling down to it.

  5. Be clear on what you are highlighting.

    When making a point in view of your audience, moving the mouse around to highlight or underscore a point works nicely. Since remote viewers cannot see what you are doing with your mouse, be clear on what points you are highlighting. If possible, rework your slides to make the important points more obvious.

A lot of Perl Mongers are interested in sharing what they know, and many groups are active enough to hold regular technical meetings. If you are interested in spreading your knowledge around, consider inviting a remote group of mongers to your technical meeting. It's not too difficult, and it's actually easier if you use Perl!

Happy Mongering!

This Week on p5p 1999/12/19



Notes

Meta-Information

The most recent report will always be available at http://www.perl.com/p5pdigest.cgi .

You can subscribe to an email version of this summary by sending an empty message to p5p-digest-subscribe@plover.com.

Please send corrections and additions to mjd-perl-thisweek-YYYYMM@plover.com where YYYYMM is the current year and month.

More 5.005_63 Results

Sarathy's Announcement includes a list of changes and a substantial TODO list for 5.005_64.

There was the usual collection of bug reports that follows a new release, mostly concerning compilation and configuration issues.

$^H and %^H

Stéphane Payrard complained that even though %^H is mentioned in perldiag, it is not described in perlvar. Ilya protested that you cannot get that diagnostic unless you actually use %^H, in which case he assumes that you understand the diagnostic.

Nevertheless, he provided doc patches that discuss $^H and %^H in perlvar. I deem this patch Important Reading for Perl Expert Wanna-Bes.

Perl RPMs

Johann Vromans supplied an RPM for Perl 5.005_63.

Elaine Ashton suggested sending it to Red Hat, and this sparked a discussion about whether it was a good idea to widely advertise the existence of an RPM for an experimental development release of Perl---the fear was that beginners would come along and grab the RPM and install a development version of Perl on their systems, and then be puzzled and upset when it didn't work.

Sarathy said that he would distribute the RPM with future development releases, so that the people who test the Perl development releases could test the RPM also.

In the course of this, someone named Pixel said that he or she make a `hackperl package for Linux-Mandrake'. I don't know what this is, but People using Mandrake might be interested to read the message.

Another interesting sideline: Randy J. Ray mentioned that he had tried to make the RPM C library into a Perl module, but had not been successful, because h2xs cannot parse rpm.h. Perhaps someone else would like to take a look at this.

Bennett Todd worked on an automatic RPM packager for Perl modules. Details are here. Andy Dougherty advised caution:

Andy: It would indeed be far nicer to have helpful feedback and discussions from various "vendors" before everything is set in stone to make sure we do something reasonable and don't have folks feel they are continually fighting a system.

I'd be happy to discuss such issues with anyone interested.

There was a rather long discussion, most of thish I did not follow, since I am not very familiar with RPMs. People who use Red Hat systems might find it illuminating.

The discussion included a sidetrack about support for version number literals in Perl 5.6. You will be able to write v5.3.40 and it will be compiled as if you had written "\x{5}\x{3}\x{28}" instead; this means that (for example) v5.3.40 lt v5.29.12 is true. The root of this part of the discussion is here.

Development Continues on Ilya's Patches

This is getting to be my favorite part of the report, because even if the rest of the week is a bunch of boring flamage or irrelevant nattering, there is always something interesting going on in the Ilya department. Many thanks to Ilya and Sarathy for tirelessly supplying me with an endless stream of interesting technical content.

Change to xsubpp

Last week, Sarathy declined to put in Ilya's improvement to xsubpp unless he also provided a way to turn it off. Ilya did this. There is now an environment variable that will turn it off.

Closed Filhandle in Signal Handler

Thomas Stromberg reported an interesting bug. He has a filehandle through which he is writing to a pipe. A close on this filehandle waits for the command on the other end of the pipe to terminate. While his program is doing this, it gets an alarm signal. Tom wants to terminate the program and clean up. If he simply returns from the signal handler, the close call is restarted and the program hangs again. So he tries closing the filehandle in the signal handler; this make Perl dump core.

He supplied a sample test program, but there was no discussion, perhaps because the sample program uses /bin/pax on the other end of the pipe, or perhaps because everyone knows that Perl signal handlers are hopeless. In any case, I was able to demonstrate the problem by changing /bin/pax to sleep 10.

pad_findlex Needs to be Recursive

Mr. or Ms. Pixel reported a bug in lexical closures. Here it is a demonstration:

	for (1..5) {
	  my $t = $_;
	  push @subs, sub { sub { $t }};
	}
	
	for (@subs) {
	  print "-- ", &{&$_};
	}

This should print out --1--2--3--4--5but unfortunately the wrong $t has been captured by the closures. If you are still not sure that this is a bug, note that changing sub { sub { $t }} to sub { $t; sub { $t }} produces the correct behavior. (Thanks to Randy J. Ray and Jeff Pinyan for pointing this out.)

Larry predicts that Sarathy will fix this in the course of rewriting the pad code for 5.005_64. Sarathy remained mute.

Conversion Specifier Bug

Nicholas Clark reported a test failure for 5.005_63: Warning test #247 was yielding

/[a\b]/: Unrecognized escape \ in character class passed through at - line 3.

when it should have said

/[a\zb]/: Unrecognized escape \ in character class passed through at - line 3.
instead. That does not sound like a big problem, does it? I initially filed this in the `not interesting' folder.

Robin Barker tracked down the problem. The variable that held the missing z character was actually a UV, which is an unsigned long. But it was being printf'ed with a %c conversion specifier. On a little-endian machine, this would probably have worked properly.

And now you know why we have regression tests.

Robin submitted a very interesting patch which enables printf format checking throughout the Perl code. he turned up a number of potential problems.

The Trivial Test

Mike McFaden submitted a perlbug report with no report; all we have is his Perl configuration.

François Désarménien: Whoa ! This is really the simplest perl program I've ever seen !

But then it turned out to be interesting after all: Hans Mulder pointed out that if you run the Perl test harness and tell it to execute no tests, it dies with a divide-by-zero error. Hans submitted a patch for this.

eof() at the Beginning of the Input

Background

Ralph Corderoy submitted a patch for this. I belatedly award Ralph Corderoy the `New Perl Person to Watch' for December 1999. Thank you, Ralph.

Missing $VERSIONs

Michael Schwern posted a list of eighty standard modules that do not set $VERSION. He proposed modifying all of them to say that their version was 1.00. Sarathy objected:

Sarathy: What we really need is a mechanism to attach meta-information about a module (in the form of structured pod/XML, for instance). If done correctly, this would allow modules to "publish" their interfaces for run time type-discovery and other COM/CORBA-like functionality.

Simon Cozens reported that CTAN is doing something like this.

In the course of this, Ask Bjørn Hansen mentioned something I thought was very valuable and should be better known: The CPAN.pm module has a wh command. Try it.

Overly magical range operator

Tom Phoenix discovered that the magical range generation operator .. is magical even when its second argument is a number:

	@items = "0" .. -1;
	print scalar(@items);

This prints 100, because the string "0" is autoincremented until its length is greater than the length of "-1". He supplied a patch.

Array::Virtual

Tim Bunce forwarded a message from Andrew Ford, who is working on an Array::Virtual module that will let him tie a Perl array to a very sparse memory-mapped array of numbers. Most of the discussion apparently went on in the modules mailing list. This module as been on the module list in the `idea' stage for a long time. There was some discussion about the appropriate calling interface for it. Read about it.

Reloading Modules that use fields

Apparently this doesn't work--- fields.pm tries to insert the field names into the %FIELDS array twice. John Tobey provided a patch.

However, there was no discussion.

New Improved File::Find

Johan Vromans reports that the new, improved File::Find does not work on /, because it normalizes the directory name to the empty string. Whoops.

Various

A large collection of bug reports, bug fixes, non-bug reports, questions, and answers. And spam.

Also, we got a perlbug report from someone named ################################################################################@cso.fmr.com.

Until next time, I remain, your humble and obedient servant,


Mark-Jason Dominus

Happy Birthday Perl!

According to the perlhist man page, Perl was first released twelve years ago today, on December 18, 1987.

Congratulations to Larry Wall on the occasion of Perl's twelfth birthday!

This Week on p5p 1999/12/12



Notes

This report covers the week of the release of 5.005_63, so traffic suddenly surged. Catching up by Sunday now looks unlikely, but I am getting closer.

Meta-Information

The most recent report will always be available at http://www.perl.com/p5pdigest.cgi .

You can subscribe to an email version of this summary by sending an empty message to p5p-digest-subscribe@plover.com.

Please send corrections and additions to mjd-perl-thisweek-YYYYMM@plover.com where YYYYMM is the current year and month.

5.005_63 Released

Sarathy's Announcement includes a list of changes and a substantial TODO list for 5.005_64.

There was the usual collection of bug reports that follows a new release, mostly concerning compilation and configuration issues.

Dan Sugalski: Too late to slip in support for open(RW, "| foo |")?
Sarathy: Yes, unless you can convince me that it's life-threatening. :-)

Tom also posted a to-do list about messages that are in the source but not documented in perldiag.

Sarathy and Dan Sugalski's discussion of the new threading model continued. Read about it.

Development Continues on Ilya's Patches

Regex Optimizations

Sarathy's failure case for Regex Optimization Patch does not fail when Ilya tries it. Ilya suspects version slippage. It looks like this did make it into 5.005_63.

PREPARE

Sarathy and Ilya discussed the PREPARE patch. Unfortunately, I cannot evaluate the discussion yet. Ilya did submit an additional patch to fix a bug about which Sarathy had said ``I don't know how this could have ever worked at your end.''

PREPARE did not get into 5.005_63.

XSLoader

Sarathy supplied a patch to eliminate the many warnings caused by replacement of DynaLoader.pm with XSLoader.pm. The XSLoader stuff went into 5.005_63.

Change to xsubpp

In spite of the favorable test reports from last week, Ilya's xsubpp patch did not get into 5.005_63. I was not quite clear on why not. Sarathy said that the patch was incomplete and not robust, but only specified that there was a lack of documentation and that there was no way to disable the change. Ilya protested that there are zillions of xsubpp features that cannot be disabled.

Patch Location

Ilya made up packages of his patches that were not accepted for 5.005_63. Read about it.

New Improved File::Find

Helmut Jarausch contributed a new and improved version of File::Find. Here is Helmut's original message, which summarizes the new features. (Or see perldelta in 5.005_63.)

DB_File Locking Technique

Paul Marquess reported that the file locking strategy suggested by the DB_File documentation didn't work. It suggested something like this:

	$db = tie(%db, 'DB_File', ...) or die ...;
	$fd = $db->fd;
	open(DB_FH, "+<&=$fd") or die ...;
	flock (DB_FH, LOCK_EX) or die ...;
	...
	flock(DB_FH, LOCK_UN);
	undef $db;

Problem: The tie itself opens the file, which causes the stdio library to read and cache some data from the database. But this occurs before the file is locked. Therefore there is a race condition here. This method also appears in the Camel and Ram books. Paul posted a message describing the problem in detail, including solutions. One of these solutions is to simply lock some other file instead of the database file itself; this is also a general solution to many similar problems.

David Harris was the person who originally reported this problem to Paul. He has a detailed description of it online.

Some other miscellaneous discussion of locking followed. Raphael Manfredi posted a new version of his LockFile::Simple module that provides simple lock and unlock functions to do advisory locking. This did not appear in 5.005_63.

use Parameters in XS Module Initializations

Ilya posed this problem: He has a module, Math::Pari, which is dynamically loaded. He wants to be able to say

	use Math::Pari qw(:primelimit=1e8 :stack=20e6 :prec=128);

and have the qw(...) items affect the initialization of the Math::Pari module, which is done when it is bootstrapped. But the items are passed to the import() function, which is called after the module is loaded, bootstrapped, and initialized, and therefore too late. One possibility, advocated by Joshua Pritikin, is to ask the user to write this instead:

	use Math::Pari::Init qw(:primelimit=1e8 :stack=20e6 :prec=128);
	use Math::Pari;

Ilya does not like that.

Larry suggested that

	use Math::Pari qw(:primelimit=1e8 :stack=20e6 :prec=128);

could be made to mean

	BEGIN {
	    local @Math::Pari::ARGV = qw(:primelimit=1e8 :stack=20e6 :prec=128);
	    require Math::Pari;
	    Math::Pari->import(@Math::Pari::ARGV);
	}

next in XS-invoked Perl subroutines

Gisle Aas and Michael A. Chase report that if you try to use next in a Perl subroutine that was invoked from an XS procedure, Perl dumps core. No news on this this week.

-Dp improvement

The -Dp option prints debugging information for parsing and tokenizing. It is extremely verbose, so you would like to use

	BEGIN { $^D |= 1 }
	somecode
	END  { $^D &=  ~1 }

to enable -Dp just for the code of interest. Formerly, this worked for tokenizing but not for parsing; Stéphane Payrard submitted a patch to make it work for parsing also.

Log::Agent

Raphael Manfredi announced his Log::Agent module, which allows modules to issue log messages in the way that the main application directs. The same module might log to a file, to nowhere, or to syslog, depending on the wishes of the application into which it is embedded.

I think this is a good idea. It can be very difficult to get modules to shut up. I identified this as one of the Sins of Perl in my article last month.

It did not appear in 5.005_63.

Getopt::Long Documentation

Johan Vromans rewrote the Getopt::Long documentation.

lex_fakebrack Horrors

Last week, Mike Guy complained that the lexing of forms involving ${a[0]} and ${h{k}} was inconsistent. (These are in there so that you can force Perl to interpret the [0-9] in /...$a[0-9]/ as an array subscript rather then a character class.) Larry supplied a patch.

Larry: I'm working on this one, in case anyone else was thinking about it. Basically, lex_fakebrack needs to go away.
Ilya: Thanks. There are not so many totally incomprehensible places in toke.c, andlex_fakebrack is one of them.

I wanted to include the relevant code so that everyone would have a chance to see what it was that Ilya considers totally incomprehensible. But of course this is impossible, because if it were a small, compact piece of code then it would not have been totally incomprehensible. Instead it riddled toke.c like a small but virulent fungus.

Link to dmake

dmake is a version of make for win32 systems. The README.win32 file in the perl distribution refers people to a copy of the sources in one of Sarathy's personal directories at University of Michigan; Elaine Ashton asked why there was no link to the official site. Sarathy explained that the copy on the official site was severely broken but that his copy worked properly. Elaine also asked why Sarathy's version wasn't in his CPAN directory; Sarathy said he had not been sure about whether to put it there or not since it was not directly related to Perl.

Mike Guy pointed out that it would not set a new precedent to put such things on CPAN and suggested that it would be a good idea to put it there.

defined Bug?

Helmut Jarausch points out that

	print "is defined\n"  if defined($H{'x'}++);

does in fact print the message. There was no discussion and I did not see a patch. The behavior persists in 5.005_63.

strict vars Fails to Detect $a and $b

I wouldn't mention this, except that Robin Berjon suggested compiling a list of the ten most frequently reported non-bugs. I am interested in doing this. It would be useful to me if people would suggest things that I should watch out for. The aforementioned strict vars non-failure is one, and the various localtime Y2Knonbugs are some others. If you have suggestions, please send them to me.

Various

A large collection of bug reports, bug fixes, non-bug reports, questions, and answers. No spam this week, but several people sent messages to the list asking how to unsubscribe, and this prompted an apparently fruitless discussion of how this might be avoided in the future.

Until next time (probably Sunday) I remain, your humble and obedient servant,


Mark-Jason Dominus

This Week on p5p 1999/12/05



Notes

I'm still catching up from my three consecutive trips. I hope to be back on schedule by Sunday.

Meta-Information

The most recent report will always be available at http://www.perl.com/p5pdigest.cgi .

You can subscribe to an email version of this summary by sending an empty message to p5p-digest-subscribe@plover.com.

Please send corrections and additions to mjd-perl-thisweek-YYYYMM@plover.com where YYYYMM is the current year and month.

m//g in List Context

Ralph Corderoy reported a non-bug: ``Assigning a /gx regexp to a list breaks \G in the following regexp.'' His example went something like this:

	$s = '123456';
	($a, $b) = $s =~ /(.)(.)/g;    # line 2
	($c, $d) = $s =~ /\G(.)(.)/g;  # line 3

He wants $c to contain 3 and $d to contain 4. Instead, they contain 1 and 2.

What happened here? In scalar context, m//g finds one match, starting from where it left off. However, in list context, it finds all the remaining match, and returns a list of all the results. LIine 2 above matched and generated the list (1,2,3,4,5,6). It assigned this list to $a and $b, throwing away 3, 4, 5, and 6; then the match on ilne 3 started over again at the beginning.

This recalled a similar complaint from Randal Schwartz, which I neglected to mention at the time.

Ilya Zakharevich: I remember some discussionfor making list context m//gc behave differently. What wasthe result?

Apparently the result was that it was forgotten. It might be nice to reopen this. As Ralph says, `` /g means two things (many matches and enable \G), it means you can't just enable \G.''

His second message has a very clear statement of the problem, and a proposal for what to do instead. Read about it.

eof() at the Beginning of the Input

Ralph Corderoy also reported a bug in the eof() operator. eof() gets my award for `obscure feature of the month.' It is different from just eof with no parentheses, because eof by itself tests the last-read filehandle, but eof() with empty parenthese tests the special null filehandle, the one read by <>. Anyway, now the bug. If you call eof() before you've read any input at all, it yields true, and Ralph thought it should yield false:

	plover% perl -le 'print eof()'
	1

A bunch of people then posted arguments about why this was actually correct behavior, or documented behavior, or how Ralph should work around it, or confused the issue with plain eof.

Ralph: But shouldn't eof(), associated as it is with the magic <>, have a little magic of its own and trigger the first getc+ungetc from <>?
Mb>Larry: Makes sense to me, as much as eof() ever makes sense.

Sarathy then reported that eof() was not even behaving as documented, and would in fact apply to the least-read filehandle even if it was not ARGV. He then provided a patch that made it behave as documented and also fixed Ralph's bug.

Shadow Passwords Continue

Discussion continued from last week about the behavior of Perl's getpw* functions on systems with shadow password files. I said that I'd follow up this week, but I think the summary I posted last time suffices. People argued about school #1 vs. school #2. Last week's summary.

Perl, EBCDIC, and Unicode

Geoffrey Rommel asked for pointers to docmuentation about unicode support in Perl so that he could understand the implications for his Convert::IBM390 module. He got two excellent responses: James Briggs is writing a document called `Perl, Unicode and I18N' which he expects to have done by 7 January.

Peter Prymmer posted some links and pointers to relevant mailing lists.

He also suggested that the techniques of the utf8 pragma could be adapted to provide an analogous utfebcdic pragma which would enable an EBCDIC internal representation.

lock Keyword

Dan Sugalski observed that the lock keyword is interpreted as a function name if there is any global variable main::lock, even a scalar. In this case the main::lock function is invoked. Sarathy supplied a patch which makes the determination at compile-time based on the existence of the subroutine main::lock.

Safe::Hole

A few weeks ago, I reported on a new module, Safe::Hole. Mike Heins posted a glowing testimonial for it, so I thought I'd mention it again.

Change to xsubpp

Back in early November, I reported:

Ilya submitted a patch to xsubpp which will change the value return semantics of XSUBs to be more efficient. It needs wide testing because almost all XSUBs will be affected.

Sarathy said that it was risky enough that it should be enable only when explicitly requested; Ilya objected, saying that it needed wide testing and that if it were only enabled by a command-line argument it would not receive wide testing.

Nick Ing-Simmons then offered to test it with Tk, but I did not see the outcome. Andreas K&omul;nig tested it with many important modules (including Tk,) and reported that it caused no problems that were not already present.

Euphoria

Simon Cozens reported that Freshmeat had announced a programming language, `Euphoria', which purported to be `simple, flexible, and easy to learn and outperforms all popular interpreted languages'. (No URL, unfortunately, just that it was in Freshmeat on 29 November.) Larry says that the benchmarks are somewhat cooked.

Talarian SmartSockets

This sounds like a joke, doesn't it? But Tim Bunce wants to know if there is a Perl interface for Talarian SmartSockets, whatever that is. If anyone knows, please mail Tim, or send me your message and I will forward it.

perlxstut and perlxs Additions

Ilya made some substantial additions to the perlxstut man page. He added a section on troubleshooting the examples in the document, and some notes about how to detect old versions of Perl. He added a lot of details about the contents of .xs files and the generated .c files.

Changes to perlxstut

Changes to perlxs

Sarathy edited the prose in the perlxs changes and added some additional text. He also suggested that it could use some going-over by other people.

Reset umasks

Norbert Goevert reported a bug in the way that ExtUtils::Install handles setting the umask value. This spawned a brief discussion of why ExtUtils::Install was setting the umask in the first place, and therefore specifically overriding the permission policy specified by the person running the script. Sarathy agreed, and patched installman, installperl, ExtUtils/Install.pm, and ExtUtils/Manifest.pm to leave the umask alone. Hoewever, he said that the right approach would be for these programs and modules to check for an inappropriate umask value and issue a warning if it was set to something suspicious. He asked for a patch that would do this, but nobody contributed one. Nick Ing-Simmons suggested an alternative approach: Configure could ask something like

	Should I honor your umask (currently 060) during installs?

Mailling List Archives Unavailable

Achim Bohnet, who maintains the p5p mailing list archive at www.xray.mpe.mpg.de, reported that it would be unavailable between 31 December and 2 January. Chaim Frenkel noted that the list is being archived at www.egroups.com.

Perl Art

Some time ago I reported an entertainment. Since then, Michael Henning has gone ahead and produced a camel and a llama.

Floating-Point Numbers

Ilya posted the locations of some web resources he recommended for people interested in floating-point numbers.

Development Continues on Ilya's Patches

Sarathy rejected Ilya's PREPARE patch. He made some changes to it, but not all the changes he wanted. Earlier summary of this work

Sarathy also found a failure case for Ilya's Regex Optimization Patch.

Ilya's replacement of Dynaloader.pm with his new, much smaller XSLoader.pm yielded many many warnings in at least one example. Earlier summary of this work

I'm eagerly looking forward to catching up further so I can see what Ilya did next.

A Note About Bug Reports

This item is here primarily because I thought it was amusing.

Someone reported a core-dumping error in Perl and, to comply with the request in perlbug to supply the minimum subset of code necessary to reproduce the error, enclosed 18 files totalling 2,725 lines.

Note to future users of perlbug: This is too much. Submissions should be no more than 100 lines and no more than three files; better still is one file with ten lines.

Various

A large collection of bug reports, bug fixes, non-bug reports, questions, and answers. No spam this time, although there was a small amount of well-deserved flamage.

Until next time (probably Friday) I remain, your humble and obedient servant,


Mark-Jason Dominus
Visit the home of the Perl programming language: Perl.org

Sponsored by

Monthly Archives

Powered by Movable Type 5.13-en