[32071] in Perl-Users-Digest
Perl-Users Digest, Issue: 3335 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 27 06:09:27 2011
Date: Sun, 27 Mar 2011 03:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 27 Mar 2011 Volume: 11 Number: 3335
Today's topics:
Call for Papers: Conference on Domain-Specific Language <emilie.balland@inria.fr>
Re: How to avoid searching this folder? <jwkrahn@example.com>
Re: Problem <tadmc@seesig.invalid>
Re: Problem <rwv0115@gmail.com>
Re: using File::Find <gogala.mladen@gmail.com>
Re: using File::Find <uri@StemSystems.com>
Re: writing to different offsets of a file in parallel <jurgenex@hotmail.com>
Re: writing to different offsets of a file in parallel <xhoster@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 26 Mar 2011 09:51:04 +0100
From: Emilie Balland <emilie.balland@inria.fr>
Subject: Call for Papers: Conference on Domain-Specific Languages (DSL 2011)
Message-Id: <9d235$4d8da8f8$4d39d356$2272@news.hispeed.ch>
============================ Call for Papers ============================
DSL 2011: Conference on Domain-Specific Languages
(IFIP sponsorship pending approval)
6-8 September 2011, Bordeaux, France
http://dsl2011.bordeaux.inria.fr/
CALL FOR PAPERS
Domain-specific languages have long been a popular way to shorten
the distance from ideas to products in software engineering. On one
hand, the interface of a DSL lets domain experts express high-level
concepts succinctly in familiar notation, such as grammars for text or
scripts for animation, and often provides guarantees and tools that take
advantage of the specifics of the domain to help write and maintain
these particular programs. On the other hand, the implementation of a
DSL can automate many tasks traditionally performed by a few experts
to turn a specification into an executable, thus making this expertise
available widely. Overall, a DSL thus mediates a collaboration between
its users and implementers that results in software that is more usable,
more portable, more reliable, and more understandable.
These benefits of DSLs have been delivered in domains old and new, such
as signal processing, data mining, and Web scripting. Widely known
examples of DSLs include Matlab, Verilog, SQL, LINQ, HTML, OpenGL,
Macromedia Director, Mathematica, Maple, AutoLisp/AutoCAD, XSLT, RPM,
Make, lex/yacc, LaTeX, PostScript, and Excel. Despite these successes,
the adoption of DSLs have been stunted by the lack of general tools and
principles for developing, compiling, and verifying domain-specific
programs. General support for building and using DSLs is thus urgently
needed. Languages that straddle the line between the domain-specific
and the general-purpose, such as Perl, Tcl/Tk, and JavaScript, suggest
that such support be based on modern notions of language design and
software engineering. The goal of this conference, following the last
one in 2009, is to explore how present and future DSLs can fruitfully
draw from and potentially enrich these notions.
We seek research papers on the theory and practice of DSLs, including
but not limited to the following topics.
* Foundations, including semantics, formal methods, type theory, and
complexity theory
* Language design, including concrete syntax, semantics, and types
* Software engineering, including domain analysis, software design,
and round-trip engineering
* Modularity and composability of DSLs
* Software processes, including metrics for software and language
evaluation
* Implementation, including parsing, compiling, program generation,
program analysis, transformation, optimization, and parallelization
* Reverse engineering, re-engineering, design discovery, automated
refactoring
* Hardware/software codesign
* Programming environments and tools, including visual languages,
debuggers, testing, and verification
* Teaching DSLs and the use of DSLs in teaching
* Case studies in any domain, especially the general lessons they
provide for DSL design and implementation
The conference will include a visit to the city of Bordeaux, a tour
and tasting at the wine museum and cellar, and a banquet at La Belle
Époque.
INSTRUCTIONS FOR AUTHORS
Papers will be judged on the depth of their insight and the extent
to which they translate specific experience into general lessons
for software engineers and DSL designers and implementers. Where
appropriate, papers should refer to actual languages, tools, and
techniques, provide pointers to full definitions, proofs, and
implementations, and include empirical results.
Proceedings will be published in Electronic Proceedings in Theoretical
Computer Science (http://info.eptcs.org/). Submissions and final
manuscripts should be at most 25 pages in EPTCS format.
IMPORTANT DATES
* 2011-04-18: Abstracts due
* 2011-04-25: Submissions due
* 2011-06-10: Authors notified of decisions
* 2011-07-11: Final manuscripts due
* 2011-09-05: Distilled tutorials
* 2011-09-06/2011-09-08: Main conference
PROGRAM COMMITTEE
* Emilie Balland (INRIA)
* Olaf Chitil (University of Kent)
* Zoé Drey (IRIT)
* Nate Foster (Cornell University)
* Mayer Goldberg (Ben-Gurion University)
* Shan Shan Huang (LogicBlox)
* Sam Kamin (University of Illinois at Urbana-Champaign)
* Jerzy Karczmarczuk (University of Caen)
* Jan Midtgaard (Aarhus University)
* Keiko Nakata (Tallinn University of Technology)
* Klaus Ostermann (University of Marburg)
* Jeremy Siek (University of Colorado at Boulder)
* Tony Sloane (Macquarie University)
* Josef Svenningsson (Chalmers University of Technology)
* Paul Tarau (University of North Texas)
* Dana N. Xu (INRIA)
ORGANIZERS
Local chair: Emilie Balland (INRIA)
Program chairs: Olivier Danvy (Aarhus University),
Chung-chieh Shan (Rutgers University)
------------------------------------------------------------------------
------------------------------
Date: Fri, 25 Mar 2011 23:59:18 -0700
From: "John W. Krahn" <jwkrahn@example.com>
Subject: Re: How to avoid searching this folder?
Message-Id: <b9gjp.1485$pd.1070@newsfe01.iad>
geoff@invalid.invalid wrote:
> Hello
Hello,
> I am using Tom Boutell's simple search engine on my website but would
> like it to not index the files in a particular folder called archives.
>
> How would I modify the code for this? I have tried and so far failed.
>
> Thanks
>
> Geoff
>
> #!/usr/bin/perl
The next two lines should be:
use warnings;
use strict;
> $path = "/path/public_html";
> $webpath = "";
> $indexname = "/path/formmail/searchindex.txt";
my $path = "/path/public_html";
my $webpath = "";
my $indexname = "/path/formmail/searchindex.txt";
> $nextFd = 0;
It looks like you don't really need this variable, so what is it really
supposed to do for your program?
> open(OUT, ">$indexname");
You should *always* verify that the file was opened correctly before
trying to use what may be an invalid filehandle:
open OUT, '>', $indexname or die "Cannot open '$indexname' because: $!";
> &update($path, $webpath);
In modern versions of Perl you don't need to use ampersands on
subroutine calls:
update($path, $webpath);
> sub update {
> my($path, $webpath) = @_;
> my($dd) = $nextFd++;
Why are you storing a number in a variable that you are going to use for
a directory handle? That makes no sense.
> print "Updating in $path\n";
> if (!opendir($dd, $path)) {
> print STDERR "Warning: can't open $path\n";
> return;
> }
You should declare variables where you first use them and you should
include $! in the error message so you know why it failed:
opendir my $dd, $path or do {
warn "Warning: can't open '$path' because: $!";
return;
};
> while ($entry = readdir($dd)) {
while ( my $entry = readdir $dd ) {
> if ($entry =~ /^\.$/) {
> next;
> }
>
> if ($entry =~ /^\.\.$/) {
> next;
> }
Or simply:
next if $entry =~ /\A\.\.?\z/;
> if (-d "$path/$entry") {
> &update("$path/$entry", "$webpath/$entry");
> next;
> }
> if (($entry !~ /.html$/i)&& ($entry !~ /.htm$/i)) {
> next;
> }
You have to escape the period or it will match any character and you can
combine both regular expressions into one (same as example above):
next if $entry !~ /\.html?$/i;
> my($fd) = $nextFd++;
Why are you storing a number in a variable that you are going to use for
a filehandle? That makes no sense.
> if (!open($fd, "$path/$entry")) {
> print STDERR "Warning: can't open
> $path/$entry\n";
> next;
> }
You should declare variables where you first use them and you should
include $! in the error message so you know why it failed:
open my $fd, '<', "$path/$entry" or do {
warn "Warning: can't open '$path/$entry' because: $!";
next;
};
> my(%words) = ( );
Or just:
my %words;
> my($line);
> while ($line =<$fd>) {
Or just:
while ( my $line = <$fd> ) {
> # Support for turning off the search engine
> # indexer for parts of a page. These markers
> # must have a line to themselves. 3/13/00
> if ($line =~ /<\!\-\- SEARCH-ENGINE-OFF -->/)
> {
> while ($line =<$fd>) {
> if ($line =~ /<\!\-\-
> SEARCH-ENGINE-ON -->/) {
> last;
> }
> }
> next;
> }
> # Simple HTML flusher
> $line =~ s/\<.*?\>//g;
> # Case insensitive
> $line =~ tr/A-Z/a-z/;
> # If it's not a letter, it's whitespace
> $line =~ s/[^a-z]/ /g;
You could also use tr/// for that:
$line =~ tr/a-z/ /c;
> my(@words) = split(/\s+/, $line);
That might be better as:
my @words = split ' ', $line;
> my($p);
> for $p (@words) {
Better as:
for my $p ( @words ) {
> if (length($p)) {
Why would $p have zero length? Probably because you are using /\s+/
instead of ' ' as the first argument to split which will give you a zero
length string if there is leading whitespace in $line.
> $words{$p}++;
> }
> }
> }
> print OUT "$webpath/$entry ";
> my($first) = 1;
Why are you forcing list context on a scalar assignment?
> while (($key, $val) = each(%words)) {
Better as:
while ( my ( $key, $val ) = each %words ) {
> print OUT "$val:$key";
> if ($first) {
> $first = 0;
> } else {
> print OUT " ";
> }
So you want no space between the first and second "$val:$key" but a
space after every other occurrence of "$val:$key" including at the end
of the line?
> }
> print OUT "\n";
It looks like you could probably do that while loop like this instead:
print OUT join( ' ', map "$words{$_}:$_", keys %words ), "\n";
> close($fd);
> }
> closedir($dd);
> }
> close(OUT);
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
------------------------------
Date: Fri, 25 Mar 2011 21:36:21 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Problem
Message-Id: <slrnioqjvs.6ks.tadmc@tadbox.sbcglobal.net>
Buntownik <misio867@gmail.com> wrote:
> Subject: Problem
Please put the subject of your article in the Subject of your article.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Sat, 26 Mar 2011 14:32:25 -0700 (PDT)
From: bobbi <rwv0115@gmail.com>
Subject: Re: Problem
Message-Id: <04d2baf2-33c1-43c9-aa44-8fd54254b65e@k3g2000prl.googlegroups.com>
On Mar 25, 11:35=A0am, Buntownik <misio...@gmail.com> wrote:
> How to detect file upload abort using an upload hook in perl. When
> client aborts the upload i need to remove the info about the file from
> the db. I can't do it size base, because before upload ends i only
> have an approximate file size (request + file). I'm tryin to use
> mod_perl Apache2::Connection->aborted() but so far to no effect.
Are you saying that Apache2::Connection->aborted() is wrong?
------------------------------
Date: Sat, 26 Mar 2011 23:01:07 +0000 (UTC)
From: Mladen Gogala <gogala.mladen@gmail.com>
Subject: Re: using File::Find
Message-Id: <pan.2011.03.26.22.54.29@gmail.com>
On Thu, 24 Mar 2011 07:30:13 -0500, Tad McClellan wrote:
> If you don't want your code to be commented on, then do not post your
> code on Usenet.
At least not before running it through perlcritic. Although, there are
things flagged by perlcritic that I disagree with, bareword filehandle
open being one of them.
--
http://mgogala.byethost5.com
------------------------------
Date: Sat, 26 Mar 2011 23:17:52 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: using File::Find
Message-Id: <87zkohz1y7.fsf@quad.sysarch.com>
>>>>> "MG" == Mladen Gogala <gogala.mladen@gmail.com> writes:
MG> On Thu, 24 Mar 2011 07:30:13 -0500, Tad McClellan wrote:
>> If you don't want your code to be commented on, then do not post your
>> code on Usenet.
MG> At least not before running it through perlcritic. Although, there are
MG> things flagged by perlcritic that I disagree with, bareword filehandle
MG> open being one of them.
and why do you like bareword file handles? name one advantage they have
over lexicals. lexical handles are scoped so they close upon scope exit
and they don't pollute your package namespace. as declared my vars you
have to spell them correctly when used vs any bareword string is legal
as a handle anywhere.
i may disagree with perlcritic (and it is highly customizable) but that
is not one of them.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 25 Mar 2011 16:58:08 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: writing to different offsets of a file in parallel
Message-Id: <tnaqo6tps4pmgdnm0cb9vr5c759sf1072b@4ax.com>
Ironhide <gourabbaksi@gmail.com> wrote:
>On Mar 25, 1:03 am, "Uri Guttman" <u...@StemSystems.com> wrote:
>> >>>>> "I" == Ironhide <gourabba...@gmail.com> writes:
>>
>> I> perl-newbie, so please excuse if this is trivial
>> I> I need a simple way to write to different offsets of a file in
>> I> parallel.
>>
>> I> How can I achieve that with perl?
>>
>> before you code it in any language, please clarify what your goals
>> are. why do you need or want to do this? what do you mean by parallel?
>> anything done is parallel is not simple in general. you need to be much
>> better at explaining your problem (which is usually half the work in
>> getting it solved).
>>
>> uri
>>
>> --
>> Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com--
>> ----- Perl Code Review , Architecture, Development, Training, Support ------
>> --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com---------
>
>Well so here goes
>I am trying to write unique pattern to every file block, block size is
>512 bytes in this case.
>
>So if do this in perl
>
>my $hell=generate_pattern($file_block_number);
>
>for($i=0;$i<=(total_blocks-1);$i++) {
> system("/iotool seek=(512*$i) bs=512 pattern=$hell filename SIZE");
By far the most expensive part is this call to system(). As long as you
can't find a better way to generate your data you most likely out of
luck.
>}
>Seems to be taking much more time than if I simply fire the command
>from the unix command line,
>which is pretty obvious.
>
>So, since I have to coding up the i/o part in a perl script, I was
>wondering if I could make
>this write thingy happen in parallel since I have the benefit of
>writing different offsets.
That wouldn't help you one bit because you would still execute the most
expensive operation individually for each 512 byte block. Plus you would
have the overhead of synchronizing the parallel operations and the
parallel disk access.
My suggestion: generate and write your target data in much, much larger
blocks, if possible the whole file at once.
If you can't generate the target data in large blocks, then at least
collect it in RAM and then write large chunks to the HD.
jue
------------------------------
Date: Fri, 25 Mar 2011 17:11:20 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: writing to different offsets of a file in parallel
Message-Id: <4d8d3aa9$0$16414$ed362ca5@nr5-q3a.newsreader.com>
Ironhide wrote:
>
> Well so here goes
> I am trying to write unique pattern to every file block, block size is
> 512 bytes in this case.
>
> So if do this in perl
>
> my $hell=generate_pattern($file_block_number);
Where does $file_block_number come from?
> for($i=0;$i<=(total_blocks-1);$i++) {
$i certainly seems to be your file block number. So why
is there a different variable with that name, and $i is not
it?
> system("/iotool seek=(512*$i) bs=512 pattern=$hell filename SIZE");
> }
Well, that certainly sucks. If you did it in a way that didn't suck,
you probably wouldn't need to do it in parallel.
Since you seem to be writing the same pattern to each block in the file
consecutively, why not just do that in the obvious way?
foreach (1..$total_blocks) { print $fh $hell}
> Seems to be taking much more time than if I simply fire the command
> from the unix command line,
> which is pretty obvious.
Well, you are firing the command in a loop. Doing something hundreds of
times does tend to take longer than doing it once.
Xho
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3335
***************************************