[18503] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 671 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 10 21:06:03 2001

Date: Tue, 10 Apr 2001 18:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <986951113-v10-i671@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 10 Apr 2001     Volume: 10 Number: 671

Today's topics:
    Re: a question about * <mischief@velma.motion.net>
    Re: CGI.PM and Forms <bcoon@sequenom.com>
    Re: complaint about moderation of this group (Randal L. Schwartz)
    Re: Deleting one line from a file <mischief@velma.motion.net>
    Re: filecache tests -- abe's test <abe@ztreet.demon.nl>
        FINAL CODE II <NO_SPAM_klubbheads@home.com>
    Re: inheritance within one file? (Abigail)
    Re: linebreak in forms <brondsem@my-deja.com>
    Re: Perl Timer! <mischief@velma.motion.net>
    Re: Perl Timer! (Abigail)
        permanently change file name with regex <plusc@freeserve.net>
    Re: permanently change file name with regex (Damian James)
    Re: Please Help <mischief@velma.motion.net>
    Re: Private subroutine inside subroutine (Damian James)
    Re: registration script (David H. Adler)
    Re: Single character class including \n ??? <dan@tuatha.sidhe.org>
    Re: SMTP Connections <mischief@velma.motion.net>
    Re: So what do YOU use Perl for? (Martien Verbruggen)
    Re: THANK YOU & FINAL CODE <NO_SPAM_klubbheads@home.com>
    Re: Using References <bart.lateur@skynet.be>
        Why does DynaLoader fail? (Steve K. Brown)
    Re: Why won't this simple script work?? <mischief@velma.motion.net>
    Re: win32: *.pl > *.exe howto <brondsem@my-deja.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 10 Apr 2001 23:18:16 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: a question about *
Message-Id: <td755od81mgf3f@corp.supernews.com>

Remington Gao (¸ßÃ÷) <pangpang@writeme.com> wrote:
> Hi,

> I have a question when i study some code, there's some lines below:

> sub ReadParse {
>     local (*in) = @_ if @_;
>     ......

> Could you please tell me what the * mark means?

It means that `in' is a glob. 

You can read more about globs, and lots of other interesting things,
in the manual page named `perldata'.

> Thanks :-)

Welcome. :-)

Chris

-- 
Christopher E. Stith
For the pleasure of others, please adhere to the following
rules when visiting your park:
    No swimming.  No fishing.  No flying kites.  No frisbees.
    No audio equipment. Stay off grass.  No pets. No running.



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

Date: Tue, 10 Apr 2001 15:44:14 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: Re: CGI.PM and Forms
Message-Id: <3AD38CBE.B46D2407@sequenom.com>

Can you post the code so we can take a look at it?  There is almost certainly an
error in your script.

Bryan

speakeasy wrote:

> Well GET method works, but POST does not... I though POST allowed for more
> data... hmm....
>
> "John Joseph Trammell" <trammell@bayazid.hypersloth.invalid> wrote in
> message news:slrn9d6lfn.eoh.trammell@bayazid.hypersloth.net...
> > On Tue, 10 Apr 2001 14:23:03 -0400, speakeasy <artd@speakeasy.net> wrote:
> > > Are there memory restrictions applied to CGI.pm and forms?  My form will
> not
> > > submit a textarea that has more than 10 lines, the request eventually
> times
> > > out, and the perl process hangs in memory on the server...  I have the
> same
> > > problem with submitting a form with more than 5 checkboxes checked...
> Any
> > > ideas?  I am using ActivePerl on Windows 2000 IIS 5....  Any insights
> would
> > > be greatly appreciated...
> >
> > I've used CGI.pm to process forms much more complicated than
> > that.  More than likely you are looking at a server or coding
> > problem.  Do you have access to the server logs?  They're
> > likely to shed some light.
> >
> > --
> > According to the Genesis account, the tower of Babel was man's second
> > major engineering undertaking, after Noah's ark.  Babel was the first
> > engineering fiasco.
> >                                 - F. Brooks, _The Mythical Man-Month_



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

Date: 10 Apr 2001 15:41:59 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: complaint about moderation of this group
Message-Id: <m1lmp82x8o.fsf@halfdome.holdit.com>

>>>>> "Mark" == Mark Jason Dominus <mjd@plover.com> writes:

Mark> In article <3AD35A6E.29F6AF0D@fnal.gov>,
Mark> David J. Ritchie <ritchie@fnal.gov> wrote:
>> A name that would put off all but the bravest newbies might
>> help. E.g.,:
>> 
>> comp.lang.perl.advancedtopics

Mark> That's a nice theory, but it has been tried, and what happens is that
Mark> the beginners think "Ah!  That's the newsgroup where all the experts
Mark> hang out.  Just the people I need to help me solve me problem!"

Specifically, it was "comp.unix.questions" and "comp.unix.wizards".
In the FAQ for wizards, it said "post here only if you ARE a wizard".
That didn't stop the newbies from being attracted to that "wizard"
word like moths to a candle.

In the end, comp.unix.wizards got restructured as a moderated group,
just to keep the newbie questions out.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 10 Apr 2001 23:01:18 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Deleting one line from a file
Message-Id: <td745uhlci5u02@corp.supernews.com>

David Findlay <david_j_findlay@yahoo.com.au> wrote:
>> Here's a quickie for you, if you promise to read the FAQ:
>> 
>>     while(<>) { print unless /what I don't want matched/ }
>> 
>> This example assumes STDIN for input and STDOUT for output,
>> but you can change that in any text editor.

> So can I go

> while(<FILE>) { print unless @array }

> Where array contains an array of the values I want to remove.

If what you want is what your code suggests you want, then this
ugly approach may work:

my @array = (
    'foo',
    'bar',
);
while(<>) {
    my $regex = join '|', @array;
    print unless /$regex/;
}

This code does something reasonable with input, but it may not
do exactly what you're asking.

The key thing here is that you're using a regex op for matching.
An array is not a regex. Arrays are collections of scalars.
They don't do anything to data -- they simply are data. The
m// operator, on the other hand, operates on data according to
a regex. Read up on this in `perlre' (type `perldoc perlre' at a
command line) and `perlop' (ditto) to find out more.

Chris

-- 
Christopher E. Stith
Product shown enlarged to make you think you're getting more.



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

Date: Wed, 11 Apr 2001 01:49:03 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: filecache tests -- abe's test
Message-Id: <1a57dtgs6d2fg3kpr7keqjp8d9fat5g2uh@4ax.com>

[ If you want to follow-up, please do so in the actual thread. Now this
subject is al over the place. ]

On Tue, 10 Apr 2001 12:34:19 -0700, "B McDonald" <plz@righthere.com>
wrote:

> 
> Hi. I'm still trying to figure out how to use FileCache in order to write
> data to 12 simultaneously open files. My OP was on 4/4/2001.
> 
[ snip of code that lost indentation ]
> 
> First, does anyone know how I can specify that the file be opened for
> appending? Presently, this writes over the prior contents of each file.

Well it is not accommodated for, but you can use a hack. Set

	$FileCache::saw{ $filename }++;

before the first call to

	cacheout $filename;

and by the nature of the module, it opens for appending.

You might want to read the sourcecode of that module, its not that hard
to understand.

	perldoc -m FileCache

-- 
Good luck, Abe
Amsterdam Perl Mongers  http://amsterdam.pm.org
perl -e '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona tsuJ")'


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

Date: Wed, 11 Apr 2001 00:59:08 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: FINAL CODE II
Message-Id: <w%NA6.201456$A6.44801132@news4.rdc1.on.home.com>

sub template  {
my $filename = shift;
my $fillings = shift;

my $template = parse( $filename );

$template =~   s{ <% (.*? ) %> }
  { exists( $fillings->{$1} )
   ? $fillings->{$1}
   : ''
  }gsex;

return $template;
}

{
my %cache;

sub parse {
  my $filename = shift;
  return $cache{$filename} if exists $cache{$filename};

  local (*TEMPLATE, $/, $_);

  open (TEMPLATE, "< $filename") or return "[file does not exist:
$filename]";
  $_ = <TEMPLATE>;
  close(TEMPLATE) or die $!;

  s/<%include file="([^"\n]+)"%>/($1 ne $filename) ? parse($1) : ''/eg;

  $cache{$filename} = $_;
}
}




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

Date: Tue, 10 Apr 2001 22:29:41 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: inheritance within one file?
Message-Id: <slrn9d72al.o5k.abigail@tsathoggua.rlyeh.net>

Uri Guttman (uri@sysarch.com) wrote on MMDCCLXXIX September MCMXCIII in
<URL:news:x7zodoo5rt.fsf@home.sysarch.com>:
|| >>>>> "A" == Abigail  <abigail@foad.org> writes:
|| 
||   A> As for OO modules not exporter things, I fail to see why they never
||   A> should. Things that spring into mind that you might want to export:
||   A> constants and constructors.
|| 
|| exporting constants makes sense but i would be careful about exporting
|| constructors. typical perl object constructors expect their first
|| argument to be a class or an object. that is provided by the director
|| indirect method call of the constructor. but if the constructor sub is
|| exported and you have to be explicit about passing in that argument. you
|| could have the constructor not need the argument as it knows what class
|| it is in but that is not common OO perl style.


I was more thinking something like:

    use Exporter;

    @EXPORT = qw /constructor/;


    sub new {
	... yada, yada, yada ...
	bless $obj => $class;
    }

    sub constructor {
	__PACKAGE__ -> new (@_)
    }


Inheritors can call new(), or SUPER::new(), users can call constructor().



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Tue, 10 Apr 2001 22:46:11 GMT
From: "Dave Brondsema" <brondsem@my-deja.com>
Subject: Re: linebreak in forms
Message-Id: <T2MA6.164477$W05.31167755@news1.rdc1.mi.home.com>


"Sebastian Huber (SwissOnline AG)" <t_hispeed_05@solintern.ch> wrote in
message news:3AD1C997.99F366A2@solintern.ch...
> hello,
>
> i am facing the problem that i want to use a html-form with a
> textarea-input of several rows.
>
> if the user presses the enter-key, how is the newline encoded? what
> regex do i have to use if i do not want linebreaks?
>
> i tryed:
>
> FORM{'text'}=~ s/<!--(.|\n)-->//g;
>
> but it did not work
>
> thx sebastian
>

$text =~ s/\n//g;
$text =~ s/\r//g;




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

Date: Tue, 10 Apr 2001 23:14:35 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Perl Timer!
Message-Id: <td74urrcfuodd9@corp.supernews.com>

Hernux <hernux@etherac.com.ar> wrote:
> Hi, is there a way to make a timer in perl???

> like settimeout function in javascript.......

I don't grok javascript. Ar eyou looking for time(), localtime(),
gmtime(), sleep(), alarm(), select(), POSIX::alarm(), POSIX::ctime(),
POSIX::difftime, POSIX::gmtime(), POSIX::localtime(), POSIX::mktime(),
or POSIX::pause()? Or perhaps Time::HiRes on CPAN?

Chris

-- 
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.



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

Date: Tue, 10 Apr 2001 23:44:43 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Perl Timer!
Message-Id: <slrn9d76nb.o5k.abigail@tsathoggua.rlyeh.net>

Chris Stith (mischief@velma.motion.net) wrote on MMDCCLXXIX September
MCMXCIII in <URL:news:td74urrcfuodd9@corp.supernews.com>:
:) Hernux <hernux@etherac.com.ar> wrote:
:) > Hi, is there a way to make a timer in perl???
:) 
:) > like settimeout function in javascript.......
:) 
:) I don't grok javascript. Ar eyou looking for time(), localtime(),
:) gmtime(), sleep(), alarm(), select(), POSIX::alarm(), POSIX::ctime(),
:) POSIX::difftime, POSIX::gmtime(), POSIX::localtime(), POSIX::mktime(),
:) or POSIX::pause()? Or perhaps Time::HiRes on CPAN?


Perhaps he wanted Time::Local.



Abigail
-- 
perl -we '$| = 1; $_ = "Just another Perl Hacker\n";  print
          substr  $_ => 0, 1 => "" while $_ && sleep 1 => 1'


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

Date: Tue, 10 Apr 2001 23:07:06 +0100
From: "francesca" <plusc@freeserve.net>
Subject: permanently change file name with regex
Message-Id: <9b00ba$gs3$1@newsg1.svr.pol.co.uk>

I want to permanently change
some file names using this regex

$x =~ s/_/- /g;

I can change and print result
but dont know how to change the file names
in a directory permanent..
Ive looked at using rename  but not sure?

Thanks




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

Date: 10 Apr 2001 23:37:00 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: permanently change file name with regex
Message-Id: <slrn9d766l.ilj.damian@puma.qimr.edu.au>

francesca chose Tue, 10 Apr 2001 23:07:06 +0100 to say this:
>I want to permanently change
>some file names...

I'm really not sure what it might mean to change a file name
'temporarily'.

>using this regex
>
>$x =~ s/_/- /g;
>
>I can change and print result
>but dont know how to change the file names
>in a directory permanent..
>Ive looked at using rename  but not sure?
>

Then you already know how to do this. 

perldoc -f rename.

The snippet below should get you going.

[warning -- untested]

my @files = qw( file_1 file_2 );
my %modified = map { (my $x = $_) =~ s/_/-/g; $_ => $x } @files;
rename $_, $modified{$_} for keys %modified;

HTH

Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...


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

Date: Tue, 10 Apr 2001 23:30:03 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Please Help
Message-Id: <td75rri9ckem83@corp.supernews.com>

Waarddebon <Waarddebon@chello.nl> wrote:
> It quits at the die statement... The idea of these lines is to write the
> word hi in file $remote2. But for some reason the file isn't written.

No, it doesn't. At least it shouldn't, unless you really don't have
permissions to such a file.

The error I see is that you're opening a file for reading, trying to
write to said file, then closing the file. You'll never see the file's
contents updated by your script if you don't open it for writing.

I would quote your code and put corrections near it, but I felt the
need to snip all that Jeopardy-quoted text, and your code was in with
it.

Chris

-- 
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.



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

Date: 10 Apr 2001 23:16:45 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Private subroutine inside subroutine
Message-Id: <slrn9d750m.ilj.damian@puma.qimr.edu.au>

Brian E. Lavender chose Tue, 10 Apr 2001 21:49:00 -0000 to say this:
>
>I created a private subroutine inside another subroutine.  Rather than
>pass the variables to the private subroutine, I made them visible to
>the private subroutine using local. Is this good coding practice? I am
>still don't completely understand local, but it appears it is making
>$arg2 visible to any block inside outer. Here's my sample chunk of code.
>

I think you probably want to be using my() instead of local().

See the FAQ:

	perldoc -q scoping

	"What's the difference between dynamic and lexical (static)
	 scoping?  Between local() and my()?"


[ snipped code -- looks fine, apart from using local() instead of my() ]

Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...


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

Date: 11 Apr 2001 00:40:26 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: registration script
Message-Id: <slrn9d79vq.355.dha@panix6.panix.com>

On Tue, 10 Apr 2001 18:24:01 GMT, Atayarani <amazingkgb@earthlink.net> wrote:
>
>"PropART" <temp1@williamc.com> wrote in message
>news:3AD307F3.6D118F7A@williamc.com...
>> Atayarani wrote:
>> >
>> > I am very new to Perl, but hope that I will get some helpful responses.
>I
>> > am trying to create a script for my page, in which a user can register
>(for
>> > benefits unknown) and all information submitted is sent to a specified
>email
>> > address.  I currently am using a script copied from a book, for a start.
>It
>> > did not work, I got an Internal Server Error.  The permissions are
>correct,
>> > and the path is correct.  I have no idea where it went wrong.
>> >
>> > -atayarani
>>
>> Note: you shouldn't cross-post and you shouldn't ask questions that
>> are not related to the Perl language in this news group.
>
>How is this not related to the Perl language?  It is a perl script I had
>issues with.

No, you have issues with the server.  Your script may well be doing
exactly what it should be doing.  "Internal Server Error" is a server
issue, rather than a perl issue.  Hence the name.  :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
All right!  So I'm the daughter of poison gas!
	- Sybil Crane, The Big Bus


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

Date: Tue, 10 Apr 2001 22:17:20 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Single character class including \n ???
Message-Id: <QDLA6.98537$Ok4.7765968@news1.rdc1.ct.home.com>

Robert Lowe <Robert.H.Lowe@x-no.spam-x.lawrence.edu> wrote:
> Hi!

> Is there a character class that matches *any* character, including
> \n ??

Sure. The period will if you've got the s modifier on, or use the
embedded modifier syntax inside the regex itself. For example,
this:

  (?s:.*$)

in your regex will match all characters (including the newline)
from that point to the end of the string.

The info's in perlre, but it can sometimes be a bit tough
to dig out.

				dan


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

Date: Tue, 10 Apr 2001 22:46:31 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: SMTP Connections
Message-Id: <td73a7c4jjob4@corp.supernews.com>

A_Geekette <moiraine{NOSPAM}@qwest.net> wrote:
> Why don't you just answer my question, instead of being a snooty ass.
> Speaking of which, you should probably watch who you call rude.

Because your question has nothing to do with Perl. As a matter of fact,
your question doesn't even mention which MTA you use.

You're the one being snooty. Anyone who thinks the world owes her the
favor of bending all the rules for her advantage is as conceited as
can be.

I'm watching exactly who I call rude. I'm calling an impatient, selfish,
clueless child (whether or not in an adult body) rude. Yes, I'm talking
about `me' or ` moiraine' or `A_Geekette'. You are interminably rude.
Almost every post I see from you is rude in at least one way or another.
By the way, your statement about `should probably watch who you call
rude' sounds like a threat.

Gee, I posted my reply after the last of Geekette's new content, 
doesn't that mean there shouldn't be any post content below this?
This is caused by exactly what nobull was saying is considered rude.

> nobull@mail.com wrote:

>> Please quoute _relevant_ parts of the message two which you are
>> responding _in_ context.  Quoting the whole of the message you are
>> responding to at the end of your messages is considered very rude.  Do
>> you want to be considered very rude?

[snip]

It doesn't sound to me as if nobull called you rude, Geekette. The
above (which is what something should be when you refer to it in a
post) reads as nobull giving helpful advice on how to post within
the established guidelines so you are not considered rude. For me,
though, it's too late. I consider you entirely and disgustingly rude.

  _Plonk!_

-- 
Christopher E. Stith
It's not the U in UBE that pisses people off. It's the B.
  -- Martien Verbruggen in clp.misc



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

Date: Wed, 11 Apr 2001 10:14:11 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: So what do YOU use Perl for?
Message-Id: <slrn9d78ej.e3o.mgjv@martien.heliotrope.home>

On Mon, 09 Apr 2001 22:23:53 GMT,
	Elaine Ashton <elaine@chaos.wustl.edu> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn9d07a5.3ud.mgjv@martien.heliotrope.home...
>> Maybe you should visit www.cpan.org, and have a look around to see how
>> many modules are available, and what sort of problem space they normally
>> fall in. You'll notice that the CGI related area is very small. Even the
>> Web related area is very small.
> 
> True but far and away the most searched for items on search.cpan.org are
> DBI, CGI, LWP, MIME::*, HTML::* and XML. While this doesn't
> indicate usage it does indate that 80% of the queries are related to
> CGI and the web in some form or another. The web related modules
> may be small by percentage to the rest of CPAN but they are the
> most sought after as Perl is still very closely associated with CGI.

I wouldn't count DBI, XML, MIME and LWP as CGI related. And even the
HTML modules aren't necessarily part of that. The CGI module on its own
does a good job creating HTML. What about any of the templating modules?
They'd be more CGI-ish..

I've used all of the modules mentioned above: The MIME modules in a mail
related project, the DBI modules in about any project that needs access
to Sybase, Postgres or MySQL databases, the LWP and HTML modules to
automate web-surfing tasks and Web site testing tasks, and the XML
modules for a prototype program to set up a platform independent data
transfer stream. The only project of a reasonable size that I used CGI
for, I also used the XML modules. It generates static HTML pages based
on a data file in XML.

None of the above is CGI related, and all modules (or module groups)
mentioned are used.

Besides that, I haven't actually seen much mention of CGI programming in
this thread yet. That may have several reasons:

1) The only vocal posters here are not CGI programmers
2) CGI programmers don't read clp.misc
3) CGI programmers can't type
4) People are ashamed to admin they programmed for the CGI.

> There are close to 2100 modules on CPAN at a size of over 800MB
> and 175 mirrors all over the planet. There is something for just about
> everyone these days and conveniently located at a mirror near you.

Indeed.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | In the fight between you and the
Commercial Dynamics Pty. Ltd.   | world, back the world - Franz Kafka
NSW, Australia                  | 


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

Date: Tue, 10 Apr 2001 23:48:26 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: Re: THANK YOU & FINAL CODE
Message-Id: <eZMA6.200402$A6.44677844@news4.rdc1.on.home.com>


"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m31yr076ro.fsf@mumonkan.sunstarsys.com...
> "Roman Filippov" <NO_SPAM_klubbheads@home.com> writes:
>
> > #### START CODE
> > sub template  {
> > my $filename = shift;
> > my $fillings = shift;
>
>   my ($filename, $fillings) = @_; # nitpick :-)
>
> > my $template = parse( $filename );
> >
> > # substitue all the fields that are in a following form in a text file
> > <%ANY_FIELD_NAME%>
> > $template =~   s{ <% (.*? ) %> }
> >   { exists( $fillings->{$1} )
> >    ? $fillings->{$1}
> >    : ''
> >   }gsex;
> >
> > return $template;
> > }
> >
> > sub parse {
> > my %cache if 0;
>  ^^^^^^^^^^^^^^^^
> *Don't* use this in real code- and especially not without a comment.
> It's an unsupported parlor trick and I apologize for encouraging you
> to use it in your program.  From
>


I thought you said it was not a bug, and nobody is going to fix it, so I
figured that I could use it. Well, if you say that I should not, then I
better not.


>   http://www.perl.com/pub/2000/05/p5pdigest/THISWEEK-20000521.html
>
> ...
> Jan Dubois: I think this behavior is a side effect of the implementation
>             and shouldn't be documented as a feature. It should at best
>             be "undefined" behavior that may change in the future (IMHO).
>
> Larry: In Ada parlance, use of this feature would be considered erroneous.
> ...
>
>
> If this is anything more than a throwaway script, it would be far
> better to write it correctly:
>
>   {
>     my %cache;


As far as I understand - you defined %cache before the actual sybrouting. It
means that I will have to define it just in the begining of the code, is it
right?


>
>     sub parse {
>
> > my $filename = shift;
> >
> > my $template = $cache{$filename} ||
> >  do {
> >   local *TEMPLATE;
> >   local $/;
> >   open (TEMPLATE, "< $filename") or return "[file does not exist:
> > $filename]";
> >   my $template = <TEMPLATE>;
> >   close(TEMPLATE) or die $!;
> >
> >   # include other templates from the initial template ( <%include
> > file="template_name.tpl"%> )
> >   $template =~ s/<%include file="([^"\n]+)"%>/($1 ne $filename) ?
parse($1)
> > : ''/eg;
> >
> >   $cache{$filename} = $template;
> >
> >   return $template;
> >  };
> >
> > return $template;
> > }
> > #### END CODE
>
>
> Cool- using recursion! Now you really *are* memoizing the results of
> parse(). In that case, here's another way to do it:
>
>     my $filename = shift;
>     return $cache{$filename} if exists $cache{$filename}; # use memo
>
>     # ordinary control flow for non-cached files
>
>     local (*TEMPLATE, $/, $_);
>
>     open TEMPLATE, "< $filename" or die "'$filename' won't open:$!";
>     $_ = <TEMPLATE>;
>     close TEMPLATE or die "'$filename' closed with error: $!";
>
>     # parse file for includes
>     s/<%include file="([^"\n]+)"%>/($1 ne $filename) ? parse($1) : ''/ge;
>
>     $cache{$filename} = $_; # keeps return value for future memoization
>
>     }
>
>   } # extra bracket to eliminate "my %cache if 0;" trick.
>
> [...]
>
> > Any comments? Maybe there is something to simplify?
>
> Despite your aversion to using modules, you really ought to look at
> some of the SSI and Template stuff on CPAN, if for nothing else, to
> see how other people achieve the same (or better) effect.  It's one
> of the best ways to learn Perl, and to appreciate how effective some
> of those modules really are.


Actually I did go and look at CGI-FastTemplate and i think it was CGI-SSI.


>
> HTH
> --
> Joe Schaefer         "Everything that can be invented has been invented."
>                                                -- Charles H. Duell




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

Date: Wed, 11 Apr 2001 00:07:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Using References
Message-Id: <qt77dton9asscb1jpkhvbtj2o4gi2uogct@4ax.com>

Lou Moran wrote:

>my $outer;
>{
>	my $inner = 42;
>	$outer = \$inner;
>}
>print "$$outer\n" ; #prints 42
>
>Makes perfect sense.  
>
>Why would I do this?  When would this be useful? 

	push @stack, $current = { foo => 123 };

Now you can access the record (hash) on the top of the stack either
through $stack[-1] or through $current. Both point to the same item.

-- 
	Bart.


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

Date: 11 Apr 2001 00:16:01 GMT
From: skbrown@vcd.hp.com (Steve K. Brown)
Subject: Why does DynaLoader fail?
Message-Id: <9b07o1$dii$1@news.vcd.hp.com>

I just loaded the Spreedsheet::WriteExcel module on to my 
system (HPUX 10.20).  I wrote the
following code:

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

use strict;
use Spreadsheet::WriteExcel;

my $WB = Spreadsheet::WriteExcel->new("Test.xls");
my $WS1 = $WB->addworksheet('Colors');
my $F1 = $WB->addformat();
my(
$row, $col 
);
$F1->set_pattern(1);
$F1->set_fg_color('black');

for($i=8;$i<=63;$i++){
   $F1->set_color($i);
   $WS1->write(3,$i,$i,$F1);
}
$WB->close();

I received the following error:

Can't load '/usr/local/bin/perl5/lib/5.00503/PA-RISC1.1/auto/IO/IO.sl'
for module IO: Permission denied at 
/usr/local/bin/perl5/lib/5.00503/PA-RISC1.1/DynaLoader.pm line 169.
 at /usr/local/bin/perl5/lib/5.00503/PA-RISC1.1/IO/Handle.pm line 248
BEGIN failed--compilation aborted at 
/usr/local/bin/perl5/lib/5.00503/PA-RISC1.1/IO/Seekable.pm line 50.
BEGIN failed--compilation aborted at 
/usr/local/bin/perl5/lib/5.00503/PA-RISC1.1/IO/File.pm line 111.
BEGIN failed--compilation aborted at
/usr/local/bin/perl5/lib/site_perl/5.005/
Spreadsheet/WriteExcel/OLEwriter.pm line 19.
BEGIN failed--compilation aborted at
/usr/local/bin/perl5/lib/site_perl/5.005/
Spreadsheet/WriteExcel/Workbook.pm line 21.
BEGIN failed--compilation aborted at
/usr/local/bin/perl5/lib/site_perl/5.005/Spreadsheet/WriteExcel.pm line 17.
BEGIN failed--compilation aborted at ./writesheet line 4.

So the question is why?  I have looked in the perl5 directory and 
found that all of the files named in the error statement are there.
I have looked in the FAQ and at the module listing but there isn't 
any information about this problem.  

Your help is appreciated!

Steven K Brown


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

Date: Tue, 10 Apr 2001 23:45:55 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Why won't this simple script work??
Message-Id: <td76pjr5s84529@corp.supernews.com>

Corey <ccoogan@speakeasy.net> wrote:
> I have this script that is supposed to do this:
> Go through an entire dir, including subdirs, and look for matching file
> names with a .shtml and .loc extension.  Then it should add an X to the
> .shtml file.  This works, but only at the root dir where I run it.  It won't
> recurse.

> I am new to PERL and didn't write this.  Could someone tell me what -e does?
> Also, what is this doing?  What is the purpose of the *, to say all?:

`-e' checks for the existence of a file.
    perldoc -f -X

`*' in the place you find it means the variable is a typeglob.
    perldoc perldata

> *name = *File::Find::name;

>    if ( -e $name ) {

Sadly enough, I don't use File::Find uch, and am too tired to look
anything up right now. I hope what I have given you is helpful of
itself.

Chris

-- 
Christopher E. Stith
Where there's a will, there's a lawyer.



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

Date: Tue, 10 Apr 2001 22:51:09 GMT
From: "Dave Brondsema" <brondsem@my-deja.com>
Subject: Re: win32: *.pl > *.exe howto
Message-Id: <x7MA6.164484$W05.31171980@news1.rdc1.mi.home.com>


"Jonathan Stowe" <gellyfish@gellyfish.com> wrote in message
news:9avqpf$9p8$2@plutonium.btinternet.com...
> Alessandro <alessandro.augusto@br.bosch.com> wrote:
> > Jonathan Stowe wrote:
> >
> >> alexander gausa <alexander.gausa@gmx.de> wrote:
> >> > hi!
> >> > i want to generate an exe-file from an pl-file.
> >> >
> >>
> >> renaming the file works for me.
> >>
> > I think Johnathan, that it works to you because you have the interpretor
> > Perl instaled on that machine.
> >
>
> Yes, that is correct.
>
> > When you install perl, the files with the extension .pl are linked
> > to Perl.exe.  Try to remove or change Perl.exe´s name and see if still
> > working? I haven´t test this, but I think it won´t work.
>
> Nope.  When I install Perl nothing is linked in that manner.  I dont think
> I even have a perl.exe on this machine.  I think that a Perl program
> with the correct shebang line will execute on this machine whatever the
> suffix of the file is.
>
> /J\
> --
> Jonathan Stowe                      |
> <http://www.gellyfish.com>          |      This space for rent
>                                     |

according to your posts' headers you're running a linux machine.  linux and
windows act quite differently.

--
Dave Brondsema




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

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:

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.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.

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 V10 Issue 671
**************************************


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