[22120] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4342 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 4 21:06:06 2003

Date: Sat, 4 Jan 2003 18:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 4 Jan 2003     Volume: 10 Number: 4342

Today's topics:
    Re: Generating extra whitespace in for loop (Jay Tilton)
    Re: Generating extra whitespace in for loop (Tad McClellan)
    Re: Generating extra whitespace in for loop <goldbb2@earthlink.net>
        help writing regular expression (les)
    Re: How can split ignore quoted characters? ctcgag@hotmail.com
    Re: How can split ignore quoted characters? ctcgag@hotmail.com
    Re: lwp install ONE test failure in html/form <wlcna@nospam.com>
    Re: Need help with split <Jodyman@hotmail.com>
    Re: Need help with split <jurgenex@hotmail.com>
    Re: Need help with split <andrew underscore lee at earthlink dot net>
        new "use Threads" vs old  "use Thread" <webmaster@neverseenbefore.com>
    Re: new "use Threads" vs old  "use Thread" <goldbb2@earthlink.net>
        Preventing Perl from trying to execute printed ASCII te <sbryce@singlepoint.net>
    Re: Preventing Perl from trying to execute printed ASCI <NO.koos.JUNK.pol.MAIL@raketnet.nl>
    Re: Preventing Perl from trying to execute printed ASCI <erutiurf@web.de>
    Re: Preventing Perl from trying to execute printed ASCI <sbryce@singlepoint.net>
    Re: Preventing Perl from trying to execute printed ASCI <jurgenex@hotmail.com>
    Re: Printing and copying lists of lists <uri@stemsystems.com>
    Re: Printing and copying lists of lists <jurgenex@hotmail.com>
        Problem concerning returned data from hash (OO-object r <marcsimone@arcor.de>
    Re: Problem concerning returned data from hash (OO-obje (Jay Tilton)
    Re: Problem concerning returned data from hash (OO-obje <marcsimone@arcor.de>
    Re: Require only if required <mdudley@execonn.com>
    Re: Require only if required <goldbb2@earthlink.net>
        Updating to 804 from 802 <jopat@telusplanet.net>
    Re: Updating to 804 from 802 (Tad McClellan)
    Re: Updating to 804 from 802 <bobx@linuxmail.org>
    Re: While loop + several conditions problem <usenet@tinita.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 04 Jan 2003 19:21:17 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Generating extra whitespace in for loop
Message-Id: <3e173249.150004367@news.erols.com>

tadmc@augustmail.com (Tad McClellan) wrote:

: LeshPhilling <lesh_philling@hotmail.com> wrote:
: 
: >         print "$result\n";
: 
: > and the extra
: > lines after the numbers?
: 
: You should always enable warnings when developing Perl code.

This is weird.  I get no "uninitialized value" warnings with this
code.

    #!perl
    use warnings;
    use strict;
    while( <DATA> ) {
        my($result) = m#list(.*?)files#;
        print "$result\n";
    }
    __DATA__
    Received list 1432 files
    debug output: print() processed
    Received list 38012 files
    debug output: print() processed
    debug output: log file opened

Also no warnings if the print() is changed to

    print $result . "\n";

But change the print() to

    print $result, "\n";

or

    print "'$result'\n";

and I get the warnings one would expect.

This is under Activestate Perl 5.6.1.  No clue how other versions
behave.

What gives here?  Is perl doing some peculiar code optimization that
inadvertently bypasses the warning mechanism?



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

Date: Sat, 4 Jan 2003 14:45:55 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Generating extra whitespace in for loop
Message-Id: <slrnb1ei03.ul7.tadmc@magna.augustmail.com>

Jay Tilton <tiltonj@erols.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote:
>: LeshPhilling <lesh_philling@hotmail.com> wrote:
>: 
>: >         print "$result\n";
>: 
>: > and the extra
>: > lines after the numbers?
>: 
>: You should always enable warnings when developing Perl code.
> 
> This is weird.  I get no "uninitialized value" warnings with this
> code.
> 

>         print "$result\n";

> Also no warnings if the print() is changed to
> 
>     print $result . "\n";
> 
> But change the print() to
> 
>     print $result, "\n";
> 
> or
> 
>     print "'$result'\n";
> 
> and I get the warnings one would expect.
> 
> This is under Activestate Perl 5.6.1.  


I get the same thing with 5.6.1 under Linux.


> No clue how other versions
> behave.


All of the above make warnings with 5.8.0.


> What gives here?  Is perl doing some peculiar code optimization that
> inadvertently bypasses the warning mechanism?


Looks like a bug that got fixed.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 04 Jan 2003 20:56:50 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Generating extra whitespace in for loop
Message-Id: <3E1790E2.881D4AA6@earthlink.net>

Jay Tilton wrote:
[snip]
> This is weird.  I get no "uninitialized value" warnings with this
> code.
[snip stuff which makes $result sometimes contain undef]
>         print "$result\n";
[snip]
> Also no warnings if the print() is changed to
> 
>     print $result . "\n";
[snip]
> This is under Activestate Perl 5.6.1.  No clue how other versions
> behave.
> 
> What gives here?  Is perl doing some peculiar code optimization that
> inadvertently bypasses the warning mechanism?

It was originally intended that if you had
   my $x;
   $x .= "something";
That this not warn -- this might not seem useful here, but consider when
you've got stuff like:
   $hash{ $key } .= $value;
Where there might not have been anything in $hash{$key} previously.

Sometime during developement, this no-warning behavior of the ".="
operator accidentally was expanded so that *any* time that undef was
concatenated with something (even using ".", not just with ".="), it
wouldn't warn.

Since the exclusion was intended only apply to an undef lvalue getting
something added to it, you still get the warning if you have a defined()
value getting an undef being added to it (as is the case with your print
"'$result'\n").  And of course, when you do print $result, "\n", then
the undefined value gets passed into print directly, without
concatenation.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: 4 Jan 2003 17:51:07 -0800
From: abidnego25@yahoo.com (les)
Subject: help writing regular expression
Message-Id: <653cf871.0301041751.7ccd7c91@posting.google.com>

Hi,
i have a file with lines such as this

word1 = " some text here . G{\"o}del wrote ..."
word2 = { some other text here ... }
word3 = 1234

in other words: numbers need not be surrounded by 
quotes or brackets. Text must be surrounded by quotes or brackets. If
there is a nested bracket then this text must be surrounded by quotes.

i would like to make a hashtable with key and value value pair:

word1 => 'some text here ..G{\"o}del wrote ..."
word2 => 'some other text here ...'


i have the following now but it does not work for lines which have brackets 
inside the quotes.

if( $line =~ m/(\w+) = ["{]? (\w+) ["}]?){
   $k = $1; $v = $2;
}

thanks in advance


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

Date: 04 Jan 2003 23:44:02 GMT
From: ctcgag@hotmail.com
Subject: Re: How can split ignore quoted characters?
Message-Id: <20030104184402.570$GO@newsreader.com>

Matija Papec <mpapec@yahoo.com> wrote:
> X-Ftn-To: Robert Nicholson
>
> robert@elastica.com (Robert Nicholson) wrote:
> >How do you specific the pattern for split to ignore the quoted
> >characters of the character you want to split on?
> >
> >ie. you want to split on ',' but you want to ignore \, in the text

That's escaped, not quoted.

> >
> >if I use
> >
> >split (/[^\\],/);
> >
> >that will chop of the last character of any matching field
> >
> >how can I match without chopping off that last character?
>
> split(/(?<=[^\\]),/);

This will fail to split off an empty field on a leading comma, i.e.
',a,b,c,d' will return ',a' as it's firt element.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 05 Jan 2003 00:08:17 GMT
From: ctcgag@hotmail.com
Subject: Re: How can split ignore quoted characters?
Message-Id: <20030104190817.640$NM@newsreader.com>

"John W. Krahn" <krahnj@acm.org> wrote:
> Robert Nicholson wrote:
> >
> > How do you specific the pattern for split to ignore the quoted
> > characters of the character you want to split on?
> >
> > ie. you want to split on ',' but you want to ignore \, in the text
> >
> > if I use
> >
> > split (/[^\\],/);
> >
> > that will chop of the last character of any matching field
> >
> > how can I match without chopping off that last character?
>
> split /(?<!\\),/;

That will do what he asked, but probably not what he wanted.
For example, it will fail to split a field that ends in a literal
\ which has been itself escaped.  (The Data::Table module
had a similar bug until recently).

In general, you have to split on a comma preceded by an even number
of backslashes.  Since lookbehind assertions have to be fixed width,
there isn't a simple way to do this.

warn "Inadequately tested code";
my @x= map {scalar reverse $_} reverse split /,(?=(?:\\\\)*(?:[^\\]|$))/,
reverse $_;

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Sat, 04 Jan 2003 20:58:14 GMT
From: "wlcna" <wlcna@nospam.com>
Subject: Re: lwp install ONE test failure in html/form
Message-Id: <GVHR9.5217$qU5.4149368@newssrv26.news.prodigy.com>

"wlcna" <wlcna@nospam.com> wrote in message
news:Z8GR9.5198$qU5.4130955@newssrv26.news.prodigy.com...
> libwww-perl-5.67
> Is this an important failure?  I get an error in installing while testing
> HTML::Form that seems to indicate a warning is expected from parsing HTML
> containing "<input name=x type="xyzzy">" in a form, the warning expected
> that the type "xyzzy" is not expected as an input tag type, but evidently
no
> such warning occurs.
>
> So does this failure have any general significance?  I'll be running all
> kinds of things relying on perl on this machine.
>
> BACKGROUND:
>
> I get this (partial) output from make test while trying to install
> libwww-perl-5.67 (installation of which I actually invoked via CPAN
module):
>
> Running make test
> /usr/local/perl/bin/perl t/TEST 0
> [...everything else ok...]
> base/common-req........ok
> html/form..............FAILED test 11
>         Failed 1/14 tests, 92.86% okay
> [...everything else ok...]
>
> test 11 can be found in libwww-perl-5.67/t/html/form.t
>
> and is:
>
> # try some more advanced inputs
> $f = HTML::Form->parse(<<'EOT', "http://localhost/");
> <form method=post>
>    <input name=i type="image" src="foo.gif">
>    <input name=c type="checkbox" checked>
>    <input name=r type="radio" value="a">
>    <input name=r type="radio" value="b" checked>
>    <input name=t type="text">
>    <input name=p type="PASSWORD">
>    <input name=h type="hidden" value=xyzzy>
>    <input name=s type="submit" value="Doit!">
>    <input name=r type="reset">
>    <input name=b type="button">
>    <input name=f type="file" value="foo.txt">
>    <input name=x type="xyzzy">
>
>    <textarea name=a>
> abc
>    </textarea>
>
>    <select name=s>
>       <option>Foo
>       <option value="bar" selected>Bar
>    </select>
>
>    <select name=m multiple>
>       <option selected value="a">Foo
>       <option selected value="b">Bar
>    </select>
> </form>
> EOT
>
> #print $f->dump;
> #print $f->click->as_string;
>
> print "not " unless $f->click->as_string eq <<'EOT'; print "ok 10\n";
> POST http://localhost/
> Content-Length: 73
> Content-Type: application/x-www-form-urlencoded
>
> i.x=1&i.y=1&c=on&r=b&t=&p=&h=xyzzy&f=foo.txt&a=%0Aabc%0A+++&s=bar&m=a&m=b
> EOT
>
> print "not " unless @warn == 1 && $warn[0] =~ /^Unknown input type
'xyzzy'/;
> print "ok 11\n";
> @warn = ();
>
>
>
>

[correction, title should just say lwp, i put LWP::UserAgent in there
reflexively b/c I install LWP via install LWP::UserAgent in CPAN module
shell.]




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

Date: Sat, 04 Jan 2003 19:22:29 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: Need help with split
Message-Id: <VvGR9.14548$9N5.1379871@newsread2.prod.itd.earthlink.net>


"Jürgen Exner"  wrote in message
>> Jodyman wrote:
> > If you never think for yourself, you never learn.  I like jumping into
> > the modules and learning from the pros.  If you never do that and
> > blindly "use the modules/packages" you'll never learn the language
> > well.
>
> Au contraire, mon ami. Here I strongly(!) disagree.
> A very important part of learning to program as well as learning a new
> programming language is to learn about existing libraries/modules. Can you
> imagine programming in C without using any library? You can't even print
> anything to the screen without using a module!
> Or programming in Windows without using libraries? Or creating an X11
> application without using libraries?
> And in a professional environment you must be able to use those modules,
> which are provided by your co-workers. There is simply no way for you to
> re-implement the wheel over and over again, even if your data in this
> particular instance is simpler than what your coworkers code can handle.
>
> Modules and libraries (aka programming in the large; aka re-usable code)
is
> the one big step forward from the early programming paradigms (say COBOL,
> Fortran, Basic) to more modern approaches. Learning which modules are
> available and learning how to use them properly is just as important as to
> learn how to use the for condition or the split function. And this does
> include learning when not to reinvent the wheel.
> This step is not easy, but if you don't make it then you will always be
> stuck with programming in the small and never be able to graduate from a
> mediocre bulk programmer of last century 80s.
>

I concede that one must know how to use and where to find modules/packages
in any programming language or environment.  Sometimes I just like to think
for myself.  It makes me grow.

Using smoking as an example, I know smoking is bad, so, I can learn from
others
mistakes and never smoke, I don't think this is alway the case with
programming.
Sometimes you need to get caught missing that 1% to learn and increase your
thought process to include a larger picture or grander view.  Sometimes you
need
to experience things for yourself.




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

Date: Sat, 04 Jan 2003 20:26:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need help with split
Message-Id: <wrHR9.14649$ta5.6666@nwrddc01.gnilink.net>

Jodyman wrote:
> Sometimes you need to get caught missing that 1% to learn and
> increase your thought process to include a larger picture or grander
> view.  Sometimes you need
> to experience things for yourself.

Quite true.
How can you learn from your mistakes if you never make any?

jue




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

Date: Sat, 04 Jan 2003 20:06:03 -0500
From: Andrew Lee <andrew underscore lee at earthlink dot net>
Subject: Re: Need help with split
Message-Id: <bqve1vo3ptu64i066cv8ed707g8s9c3dch@4ax.com>

On Sat, 04 Jan 2003 16:12:55 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>Jodyman wrote:
[snipped some]
>> If you never think for yourself, you never learn.  I like jumping into
>> the modules and learning from the pros.  If you never do that and
>> blindly "use the modules/packages" you'll never learn the language
>> well.
>
>Au contraire, mon ami. Here I strongly(!) disagree.
>A very important part of learning to program as well as learning a new
>programming language is to learn about existing libraries/modules. Can you
>imagine programming in C without using any library? You can't even print
>anything to the screen without using a module!

True, and I basically agree . But look at all the problems of porting
C, even between different versions of the same compiler.  And many
compilers try to conform to ANSI or POSIX standards (with widely
varying results). Perl module writers have no such constraint!  As a
more experienced developer I have learned to avoid relying on CPAN too
much for code I expect to be around a while ... or at least do my
homework before I use a module and put my code into production.

>Or programming in Windows without using libraries? Or creating an X11
>application without using libraries?

Don't go there  :-)

**


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

Date: Sun, 5 Jan 2003 00:18:10 +0100
From: "Dieter D'Hoker" <webmaster@neverseenbefore.com>
Subject: new "use Threads" vs old  "use Thread"
Message-Id: <av7q3v$d01pf$1@ID-155251.news.dfncis.de>

In the old 5.0 iplemntation of threads ("use Thread") you could use
$thread->done  to check if the thread was finished ,

zo you could use this in your serverloop without blokking the loop ..

while (1)
{
if ($thread->done) {$thread->join;}
}

but know with ithreads is this still possible ?

(using the old "Thread interface" of the new "Threads" ? )


I also found a old Async module that uses fork ,
but I don't think I could use this because my shell account only permits me
to run one background process ,
and forking starts an new process doen't it ?



--
Dieter D'Hoker
http://dieter.dhoker.com/
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker




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

Date: Sat, 04 Jan 2003 21:12:30 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: new "use Threads" vs old  "use Thread"
Message-Id: <3E17948E.B643E29E@earthlink.net>

Dieter D'Hoker wrote:
> 
> In the old 5.0 iplemntation of threads ("use Thread") you could use
> $thread->done  to check if the thread was finished ,
> 
> zo you could use this in your serverloop without blokking the loop ..
> 
> while (1)
> {
> if ($thread->done) {$thread->join;}
> }
> 
> but know with ithreads is this still possible ?

Not directly, but you can have your thread set something in a global
shared variable just before exiting.

use threads;
use threads::shared;
my $done : shared;
my $thread = threads->create(sub {
   # do stuff which takes a while.
   lock $done;
   $done = 1;
   cond_signal $done;
});

{
   lock $done;
   cond_wait $done until $done;
   $thread->join;
}

Of course, with the example bit of code you gave, you could simply call
$thread->join, and not try and wait for it to be "finished" -- I assume
that you've got something else in mind?

> (using the old "Thread interface" of the new "Threads" ? )
> 
> I also found a old Async module that uses fork, but I don't think I
> could use this because my shell account only permits me to run one
> background process, and forking starts an new process doen't it ?

Out of curiosity, what operating system is your shell account on?  I
seem to recall that on at least one variant of linux, threads are
actually implemented using processes.

Thus, the limit on the number of processes you can create might also
limit the number of threads you can create.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Sat, 04 Jan 2003 16:07:23 -0700
From: Scott Bryce <sbryce@singlepoint.net>
Subject: Preventing Perl from trying to execute printed ASCII text
Message-Id: <3E17692B.1080506@singlepoint.net>

I am writing a CGI script that prints the contents of a TXT file which 
contains the HTML for the top portion of a web page. In the TXT file I 
want to include a link tag that links to a style sheet. When the Perl 
script prints the link statement, it wants to execute it.

I have a snippet of code that looks like this:

# Code snippet starts here

print "Content-type: text/html\n\n";

open FILE, '<top_of_page.txt';

while (<FILE>)
{
	print;	
}

close FILE;

# Code snippet stops here

The TXT file looks like this:

<html>
<head>
<LINK rel=stylesheet type="text/css" href="standard.css">
</head>
<body>

When the Perl script encounters the link tag, I get these errors:

d:/some_dir/cgi-bin/standard.css is not executable; ensure interpreted 
scripts have "#!" first line

couldn't spawn child process: d:/some_dir/cgi-bin/standard.css

How do I prevent Perl from trying to execute the link?

Perl 5.00503
Win 98
Apache 1.3.24



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

Date: Sun, 05 Jan 2003 00:20:52 +0100
From: Koos Pol <NO.koos.JUNK.pol.MAIL@raketnet.nl>
Subject: Re: Preventing Perl from trying to execute printed ASCII text
Message-Id: <av7q8l$cum8l$1@ID-171888.news.dfncis.de>

On zondag 5 januari 2003 00:07 Scott Bryce wrote:

> I am writing a CGI script that prints the contents of a TXT file which
> contains the HTML for the top portion of a web page. In the TXT file I
> want to include a link tag that links to a style sheet. When the Perl
> script prints the link statement, it wants to execute it.
> 
> I have a snippet of code that looks like this:
> 
> # Code snippet starts here
> 
> print "Content-type: text/html\n\n";
> 
> open FILE, '<top_of_page.txt';


    You should *always* check the return value of open() to see if
    it was succesful:

    open FILE, '<top_of_page.txt' or die "Could not open file ($!)\n";


> while (<FILE>)
> {
> print;
> }
> 
> close FILE;
> 
> # Code snippet stops here
> 
> The TXT file looks like this:
> 
> <html>
> <head>
> <LINK rel=stylesheet type="text/css" href="standard.css">
> </head>
> <body>
> 
> When the Perl script encounters the link tag, I get these errors:
> 
> d:/some_dir/cgi-bin/standard.css is not executable; ensure interpreted
> scripts have "#!" first line
> 
> couldn't spawn child process: d:/some_dir/cgi-bin/standard.css
> 
> How do I prevent Perl from trying to execute the link?
> 
> Perl 5.00503
> Win 98
> Apache 1.3.24


    This is not a Perl error. When your browser recieves

    <LINK rel=stylesheet type="text/css" href="standard.css">

    it will load the file "standard.css". As this URL is relative,
    your webserver wants to run it from the current location. As that
    is the cgi-bin directory, your webserver decides to fire up Perl to
    have it execute the CGI script "standard.css". But that will ofcourse
    fail misserably. The fix is to use a non-CGI URL for "standard.css".
    E.g:

    <LINK rel=stylesheet type="text/css" href="/style/standard.css">

HTH.

-- 
KP
koos _ pol @ raketnet nl


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

Date: Sun, 05 Jan 2003 00:28:36 +0100
From: Richard Voss <erutiurf@web.de>
Subject: Re: Preventing Perl from trying to execute printed ASCII text
Message-Id: <av7qqd$quo$06$1@news.t-online.com>

Scott Bryce wrote:
> I am writing a CGI script that prints the contents of a TXT file which 
> contains the HTML for the top portion of a web page. In the TXT file I 
> want to include a link tag that links to a style sheet. When the Perl 
> script prints the link statement, it wants to execute it.

It doesn't. Perl does not do nonsense as long as you don't explicitly force it to.

> I have a snippet of code that looks like this:
> 
> # Code snippet starts here
> 
> print "Content-type: text/html\n\n";
> 
> open FILE, '<top_of_page.txt';

If this was good code, it would say somethin similar to:

	open FILE, '<top_of_page.txt' or die "something wrong here: $!";

> while (<FILE>)
> {
>     print;   
> }
> 
> close FILE;
> 
> # Code snippet stops here
> 
> The TXT file looks like this:
> 
> <html>
> <head>
> <LINK rel=stylesheet type="text/css" href="standard.css">
> </head>
> <body>
> 
> When the Perl script encounters the link tag, I get these errors:

The Perl Script does not encounter any tags. It just reads and writes text from 
a dumb file. It does in no way try to interprete that text.

> d:/some_dir/cgi-bin/standard.css is not executable; ensure interpreted 
> scripts have "#!" first line
> 
> couldn't spawn child process: d:/some_dir/cgi-bin/standard.css

These errors result from the _second_ request your browser send to the server in 
order to retrieve 'standard.css', because the browser _does_ interprete the text 
as html and "encounters the link tag". Because 'standard.css' happens to be a 
relative URL, it's requested in the same "pseudo-directory" as it's refering 
resource.

The cgi-bin is configured to contain executables, which 'standard.css' isn't. 
The Apache tries to execute it and fails, because 'standard.css' cannot be executed.

> How do I prevent Perl from trying to execute the link?

There's no need, Perl doesn't do that.

> Perl 5.00503
which is quite old, but even old perl's don't do what you think.

> Win 98
This is a different problem ;)

> Apache 1.3.24

Apache2 is out, but that won't change anything. Put 'standard.css' somewhere 
else, far away from cgi-bin.

-- 
sub{*O=*Time::HiRes::usleep;require Time::HiRes;unshift@_,(45)x 24,split q=8=
=>55.52.56.49.49.55.56.49.49.53;do{print map(chr,@_[0..(@_/2-1)])=>"\b"x(@_/2
);O(0xA**6/6)=>push@_=>shift}for@_,++$|}->(map{$_+=$_%2?-1:1}map ord,split//,
'u!`onuids!Qdsm!i`bjds')#my email-address is reversed!   http://fruiture.de



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

Date: Sat, 04 Jan 2003 17:09:30 -0700
From: Scott Bryce <sbryce@singlepoint.net>
Subject: Re: Preventing Perl from trying to execute printed ASCII text
Message-Id: <3E1777BA.7070402@singlepoint.net>

Richard Voss wrote:
> Scott Bryce wrote:
> 
>> I am writing a CGI script that prints the contents of a TXT file which 
>> contains the HTML for the top portion of a web page. In the TXT file I 
>> want to include a link tag that links to a style sheet. When the Perl 
>> script prints the link statement, it wants to execute it.
> 
> 
> It doesn't. Perl does not do nonsense as long as you don't explicitly 
> force it to.

Which is what I would have expected, thus my confusion.


> If this was good code, it would say somethin similar to:
> 
>     open FILE, '<top_of_page.txt' or die "something wrong here: $!";

It is a hastily written snippet to isolate the problem. I should know 
better. Thanks for the reminder.


> The Perl Script does not encounter any tags. It just reads and writes 
> text from a dumb file. It does in no way try to interprete that text.

Again, what I would have expected.

> Put 'standard.css' 
> somewhere else, far away from cgi-bin.

That was it. Thanks for the help. And thanks for your patience, since it 
turned out not to be a Perl question after all.



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

Date: Sun, 05 Jan 2003 00:44:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Preventing Perl from trying to execute printed ASCII text
Message-Id: <UdLR9.12710$tQ6.9580@nwrddc02.gnilink.net>

Scott Bryce wrote:
> I am writing a CGI script that prints the contents of a TXT file which
> contains the HTML for the top portion of a web page. In the TXT file I
> want to include a link tag that links to a style sheet. When the Perl
> script prints the link statement, it wants to execute it.

Nonsense.
For a Perl program to execute something you must call that something with
'system', backquotes, 'qx', 'open' and a pipe, or something similar. A mere
'print' will never execute any external program.

Your problem must be with some other part of your system.

jue




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

Date: Sat, 04 Jan 2003 19:49:21 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Printing and copying lists of lists
Message-Id: <x7el7swv9c.fsf@mail.sysarch.com>

>>>>> "JR" == J Romano <jl_post@hotmail.com> writes:

  JR>    I was thinking a while back about both Lisp and Perl, and I
  JR> realized that when Lisp prints out list of lists ("lol"), every
  JR> element is displayed (no matter how far nested), whereas Perl will
  JR> only print references to lists that are inside lists.

  JR>    Shouldn't there be some easy way to make Perl display all the
  JR> nested elements of a list-of-lists?  (After all, Perl's motto "Making
  JR> easy things easy and hard things possible" would seem to imply it.) 
  JR> Likewise, is there an easy way to make a deep copy of an lol?

hmm, could that have been thought about before? i think so. your perl
comes with Data::Dumper which does this. 

also YAML.pm (from cpan) offers another format for dumping. i use both
in debugging data structures.

  JR>    I read through some newsgroups and read the perldoc on perllol and
  JR> couldn't find any quick way to do this.  Therefore, I wrote my own
  JR> subroutines.  The "lister" function takes a lol as a parameter and
  JR> returns a string representation of the list that's fit to be printed. 
  JR> The "copyList" function also takes a list-of-lists and returns an
  JR> identical copy of that list.

you didn't look hard enough. :)

  JR>    Keep in mind that my code only works on lists that contain lists
  JR> and scalars (and lists-of-lists, of course).  It will not work with
  JR> lists that contain hash or object references (those references won't
  JR> break the code; they'll just be represented by the string "UNK"). 
  JR> However, they should be easy enough to modify so that they will allow
  JR> hash (and other) references.

the ones i mention work for all perl data.

  JR> sub copyList {
  JR>    my @originalList = @_;
  JR>    my @copy;
  JR>    foreach my $item (@originalList) {
  JR>       if (! ref($item)) {
  JR>          push @copy, $item;
  JR>       } elsif (ref($item) eq "ARRAY") {

cuddled elses are frowned upon by many. start the else on a new line.

also i prefer to not need nested if/else when in a loop like this. 

	unless( ref($item) ) {
		push @copy, $item;
                next ;
	}

	if (ref($item) eq "ARRAY") {

		push @copy, [ copyList(@$item) ] ;
		next ;
	}

IMO that is much more readable without the else/elsif


  JR>          my @deref = copyList(@$item);
  JR>          push @copy, [ @deref ];

save yourself the temp array

	push @copy, [ copyList(@$item) ] ;


  JR>       } else {
  JR>          push @copy, "UNK";  # unknown element
  JR>       }

since the previous clauses all do a next, you can drop the else
altogether and save an indent level and don't waste those precious braces.

	push @copy, "UNK" ;


  JR>    }
  JR>    return @copy;
  JR> }

there are deep copy modules on cpan as well.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Sat, 04 Jan 2003 20:27:59 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Printing and copying lists of lists
Message-Id: <jtHR9.11377$tQ6.10146@nwrddc02.gnilink.net>

J. Romano wrote:
>    I was thinking a while back about both Lisp and Perl, and I
> realized that when Lisp prints out list of lists ("lol"), every
> element is displayed (no matter how far nested), whereas Perl will
> only print references to lists that are inside lists.
>
>    Shouldn't there be some easy way to make Perl display all the
> nested elements of a list-of-lists?

Please see
    perldoc Data::Dumper
It's even more generic than what you are asking for.

jue




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

Date: Sat, 4 Jan 2003 23:16:33 +0100
From: "Marc Heravi" <marcsimone@arcor.de>
Subject: Problem concerning returned data from hash (OO-object referencing)
Message-Id: <3e175d2a$0$29790$9b622d9e@news.freenet.de>

Hi all,

since i never had any problems with perl/Perl this is my first post here.

My problem is, that i cannot imagine why
$_[0]  should be a reference to a different hash (or object)
than  my $self = shift  should assign to $self?

Here comes the (shortened) source for my problem, this is ready
to run and should show my problem. The function where the
problem shows up is  getSectionCount  in class  p2

tia,
Marc.

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

# --------------------------------------------------------------------------
---
package p0;

our($SINUS);

$SINUS = 0;

# --------------------------------------------------------------------------
---
package p1;

sub new {
 my $proto = shift;
 my $class = ref($proto) || $proto;
 my $self = {};

 bless ($self, $class);

 $self->init( @_ );
}

sub init {
 my $self = shift;

 $self->WaveForm( shift || $p0::SINUS );

 $self;
}

sub clone {
 my $self = shift;
 ( $self->WaveForm(),
 );
}

# getters and setters
sub WaveForm {
 $_[0]{WaveForm} = $_[1] if defined($_[1]);
 $_[0]{WaveForm};
}

# --------------------------------------------------------------------------
---
package p2;

@ISA = qw(p1);

sub new {
 my $proto = shift;
 my $class = ref($proto) || $proto;
 my $self = {
  count => 0,
  data => []
 };

 bless ($self, $class);

 $self->init( @_ );
}

sub getSectionCount {
 #
 # Here comes the funny stuff...can anyone explain?
 # It seems to me that   $_[0]   differs from   $self = shift
 # but how and why do they differ?
 #
 my (@ret, $self);

 print "Ref1=".ref($_[0])." at ".\$_[0]." returns {$_[0]{count}}, huh?\n";
 push @ret, $_[0]{count}; # this returns 0

 $self = shift;
 print "Ref2=". ref($self)." at ".\$self." returns {$self{count}}, okay!\n";
 push @ret, $self{count}; # that returns the correct value of 5

 @ret;
}

sub addSection {
 # store some data with max index position
 my ($self, $index, $section) = @_;
 $$self{data}[$index] = $section;
 $self{count} = ( $index > ( $self{count} || 0 ) ? $index : $self{count} );
}

# --------------------------------------------------------------------------
---
# MAIN
# --------------------------------------------------------------------------
---

package main;

use Data::Dumper;

my ($k);

# create
my $i = new p1;

# create p2 from cloned p1
my $t = new p2 $i->clone();

$t->addSection( 1, "bar" );
print "getSectionCount=". join( " ", $t->getSectionCount() )."\n";
print Dumper( $t );

1;

# OS is w2k (NT5 SP2): Microsoft Windows 2000 [Version 5.00.2195]
#
# Perl is the ActiveState Distribution:
#
#perl -v
#This is perl, v5.6.0 built for MSWin32-x86-multi-thread
#(with 1 registered patch, see perl -V for more detail)
#
#Copyright 1987-2000, Larry Wall
#
#Binary build 623 provided by ActiveState Tool Corp.
http://www.ActiveState.com
#Built 16:27:07 Dec 15 2000
#
#perl -V
#Characteristics of this binary (from libperl):
#  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
#        PERL_IMPLICIT_SYS
#  Locally applied patches:
#        ActivePerl Build 623
#  Built under MSWin32
#  Compiled at Dec 15 2000 16:27:07
#  @INC:
#    C:/Perl/lib
#    C:/Perl/site/lib
#    .
#

__END__





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

Date: Sat, 04 Jan 2003 23:07:53 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Problem concerning returned data from hash (OO-object referencing)
Message-Id: <3e1766e2.163471100@news.erols.com>

"Marc Heravi" <marcsimone@arcor.de> wrote:

: My problem is, that i cannot imagine why
: $_[0]  should be a reference to a different hash (or object)
: than  my $self = shift  should assign to $self?

Try it with strictures enabled.  You'll see lots of "Global symbol
"%self" requires explicit package name..." errors.

: sub getSectionCount {
:     #
:     # Here comes the funny stuff...can anyone explain?
:     # It seems to me that   $_[0]   differs from   $self = shift
:     # but how and why do they differ?
:     #
:     my (@ret, $self);
:     print "Ref1=".ref($_[0])." at ".\$_[0]." returns {$_[0]{count}}, huh?\n";
:     push @ret, $_[0]{count}; # this returns 0
:     $self = shift;
:     print "Ref2=". ref($self)." at ".\$self." returns {$self{count}}, okay!\n";
                                                         ^^^^^^^^^^^^
:     push @ret, $self{count}; # that returns the correct value of 5
                 ^^^^^^^^^^^^
:     @ret;
: }
 
$self{count} has nothing at all to do with $self.



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

Date: Sun, 5 Jan 2003 00:35:02 +0100
From: "Marc Heravi" <marcsimone@arcor.de>
Subject: Re: Problem concerning returned data from hash (OO-object referencing)
Message-Id: <3e176f98$0$29792$9b622d9e@news.freenet.de>


"Jay Tilton" <tiltonj@erols.com> wrote

> Try it with strictures enabled.  You'll see lots of "Global symbol
> "%self" requires explicit package name..." errors.

I "use strict;" now (i usually do that and know better now ;)

>
> : sub getSectionCount {
> :     #
> :     # Here comes the funny stuff...can anyone explain?
> :     # It seems to me that   $_[0]   differs from   $self = shift
> :     # but how and why do they differ?
> :     #
> :     my (@ret, $self);
> :     print "Ref1=".ref($_[0])." at ".\$_[0]." returns {$_[0]{count}},
huh?\n";
> :     push @ret, $_[0]{count}; # this returns 0
> :     $self = shift;
> :     print "Ref2=". ref($self)." at ".\$self." returns {$self{count}},
okay!\n";
>                                                          ^^^^^^^^^^^^
> :     push @ret, $self{count}; # that returns the correct value of 5
>                  ^^^^^^^^^^^^
> :     @ret;
> : }
>
> $self{count} has nothing at all to do with $self.

I can see clearly now: $_[0] contains a reference to the object (hash),
its data is to be referenced by using $_[0]->{somekey} or
by "my $self=shift; $self->{somekey};".

So %self in p2-namespace contained $self{count} as defined elsewhere,
but of course has nothing to do with the object reference i meant to use.
Works great now, many thanks to you, Jay,

Marc (should have read the perltootc with more attention ;-)





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

Date: Sat, 04 Jan 2003 13:46:27 -0500
From: Marshall Dudley <mdudley@execonn.com>
To: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Subject: Re: Require only if required
Message-Id: <3E172C03.1A930DAC@execonn.com>

Anno Siegel wrote:

> Marshall Dudley  <mdudley@execonn.com> wrote in comp.lang.perl.misc:
> > I have a program that is about 100,000 lines long, including all the
> > files required by the main script.  I am looking at ways to speed it up,
> > and have noticed that all the library files that may be required
> > anywhere in the program or libraries, are preloaded by requiring them at
> > the start of the script, thus bloating the memory requirements, and
> > wasting cpu on unneeded compilations.
>
> Looks like a clear-cut case for "autouse".  You can say
>
>     use autouse 'Module' => qw(func1 func2);
>
> instead of
>
>     use Module qw(func1 func2);
>
> The "autouse" line doesn't load "Module", but arranges for "Module"
> to be loaded the first time func1() or func2() is called.  This works
> along similar lines as those you sketched in the part I snipped, but
> it's tried and tested.
>
> See "perldoc autouse" for the details and some limitations.
>
> Anno

Hmmm, having trouble getting this to work.  The library files I am trying to
require I have written, they are not modules. This seems to only want to work
with modules.  Is there any way to get it to compile with routines I have
written and placed in the cgi-bin/library directory, instead of standard
modules?

Thanks,

Marshall





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

Date: Sat, 04 Jan 2003 20:58:12 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Require only if required
Message-Id: <3E179134.DBC1B321@earthlink.net>

Marshall Dudley wrote:
[snip]
> Hmmm, having trouble getting this to work.  The library files I am
> trying to require I have written, they are not modules. This seems to
> only want to work with modules.

Read perldoc perlmod, and *make* them into modules.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Sat, 04 Jan 2003 19:56:32 GMT
From: Patrick <jopat@telusplanet.net>
Subject: Updating to 804 from 802
Message-Id: <Q%GR9.103032$k13.3820280@news0.telusplanet.net>

Do I have to uninstall Perl 802 before I install Ver.804 (the newest Perl 
Version) or can I install over the older version?

Pat


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

Date: Sat, 4 Jan 2003 14:49:05 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Updating to 804 from 802
Message-Id: <slrnb1ei61.ul7.tadmc@magna.augustmail.com>

Patrick <jopat@telusplanet.net> wrote:

> Do I have to uninstall Perl 802 before I install Ver.804


Those are not Perl version numbers.

Maybe they are version numbers for a pre-compiled bundle of some sort?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 04 Jan 2003 22:01:59 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Updating to 804 from 802
Message-Id: <rRIR9.2912$Fj2.1846667@news2.news.adelphia.net>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb1ei61.ul7.tadmc@magna.augustmail.com...
> Patrick <jopat@telusplanet.net> wrote:
>
> > Do I have to uninstall Perl 802 before I install Ver.804
>
>
> Those are not Perl version numbers.
>
> Maybe they are version numbers for a pre-compiled bundle of some sort?
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

I believe that he is using ActiveState Perl 5.8. The first beta was 802 and
the release was 804. If this is the case I would say "YES" uninstall 5.8.802
and then install 5.8.804. I would warn you that it takes a bit for some
modules to catch up.

Bob




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

Date: 4 Jan 2003 22:07:27 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: While loop + several conditions problem
Message-Id: <av7luv$csr0g$1@ID-24002.news.dfncis.de>

Tad McClellan <tadmc@augustmail.com> wrote:
> Stephen Adam <00056312@brookes.ac.uk> wrote:

>> while ((@array[$temp] ne (">" or " ")) && (not $error)){

> You have many different errors all on that one line.

> @array[$temp] is an array slice, warnings would have told
> you to write $array[$temp] instead.

> the     or " "       part is NEVER evaluated, because 
> the ">" part is always "true".

>    $array[$temp] ne '>' or $array[$temp] ne ' '
> or
>    $array[$temp] =~ /^[> ]$/

> You compare $array[$temp] to the "true" value (probably "1") from the "or",
> I doubt if that is what you want.

"or" doesn't return boolean-like values.
  $array[$temp] ne (">" or " ")

is equivalent to:
  $array[$temp] ne ">"

because "or" returns the left argument (if it's true), else the
right argument.
but anyway, this is, as you said, probably not what the OP wanted =)

reagrds, tina
-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


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

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


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