[7962] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1587 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 6 08:07:16 1998

Date: Tue, 6 Jan 98 05:00:43 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 6 Jan 1998     Volume: 8 Number: 1587

Today's topics:
     "shift @array" question <jerryl@connecti.com>
     Re: "shift @array" question <joseph@5sigma.com>
     bison for perl <rj@suse.de>
     Re: Calling 'require' on an arbitrary module <joseph@5sigma.com>
     Re: Camel Critiques: PERL: THE PROGRAMMER'S COMPANION <joseph@5sigma.com>
     Re: Capturing STDERR on NT <bowlin@sirius.com>
     CgiWrap - perl: can't map file error <makler@man.torun.pl>
     Re: Help im stuck <joseph@5sigma.com>
     Re: HTML Templates...Whats the best method <joseph@5sigma.com>
     HTTP::Request::Common, print, and other misc ?'s (SasEz! Publications and Design)
     Re: Lexical scope and embedded subroutines. <joseph@5sigma.com>
     Re: libwww-perl-5 and Win32 <pvhp@forte.com>
     Looping through hashes <boromir@mindspring.com>
     MIME Decoder <marty@kc3ltd.co.uk>
     Newbie: Problem with file handling under WindozeNT and  <Richard.Locke@sni.nl>
     Re: next == continue?? <rjk@coos.dartmouth.edu>
     Re: next == continue?? (Abigail)
     perldsc q: complex data from file (eric)
     problem parsing conditional operator. <robm@transmeta.com>
     readdir() and file named '0' <koos_pol@bigfoot.com>
     Re: readdir() and file named '0' (Casper H.S. Dik - Network Security Engineer)
     Re: readdir() and file named '0' tobez@plab.ku.dk
     Re: require not working <joseph@5sigma.com>
     Re: Review of CGI/Perl book <craig@patchett.com>
     Re: Review of CGI/Perl book <joseph@5sigma.com>
     Re: Two-byte characters substitution ? <pvhp@forte.com>
     Re: UNIX at job managment module/script? (Mark A. Scarton)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 6 Jan 1998 02:40:55 -0600
From: Jerry Lineberry <jerryl@connecti.com>
Subject: "shift @array" question
Message-Id: <Pine.GSO.3.95.980106022129.22281A-100000@mercury>

Hello,
	Ok, I have a script that works fine. However, I feel that it could
have been done better. For instance, at one point I have to use the shift
command three times in a row. Can this be done with one command?

#!/usr/bin/perl -w

$finger = "finger -m ";
$list = "list";
$domain = "\@nym.alias.net";
@users = `$finger$list$domain`;
shift @users;             # How can I remove the first three lines
shift @users;             # without doing this?
shift @users;
open(OUTPUT, ">nym.users") or die "Can't open newfile nym.users: $!\n";
foreach $user (@users) {
	$user = $` if $user =~ m/\n/;
	@usrdomain = "$user$domain\n";
	print OUTPUT @usrdomain;
}
close(OUTPUT);

---
Jerry Lineberry
San Antonio, Texas
(210) 746-1787



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

Date: Tue, 06 Jan 1998 03:17:35 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: "shift @array" question
Message-Id: <34B2040C.76FA5B3A@5sigma.com>

The best way to delete more than one element of an array
is the splice operator:

  splice(@users,0,3) 

See the perlfunc man page or the blue camel for more info.

	-joseph
	 http://www.effectiveperl.com

Jerry Lineberry wrote:
> 
> Hello,
>         Ok, I have a script that works fine. However, I feel that it could
> have been done better. For instance, at one point I have to use the shift
> command three times in a row. C


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

Date: Tue, 06 Jan 1998 10:33:01 +0100
From: Richard Jelinek <rj@suse.de>
Subject: bison for perl
Message-Id: <34B1FA4D.2BAA72DE@suse.de>

Hi there,

I'm looking for a parser generator for perl. The only thing I've
found was:

http://www.cs.berkeley.edu/~sfink/perl-bison.release.html

But I wasn't able to find the executable itself. Any halp is
apreciated. Thank you.

-- 
Bye,

           Richard Jelinek(rj@suse.de)

------
S.u.S.E. GmbH                                   Fax:     +49-911-3206727
Gebhardtstr. 2                                  Mailbox: +49-911-3247122
D-90762 Fuerth               Mo&Do 13.00-18.00  Hotline: +49-911-3247130
Germany                                         WWW:  http://www.suse.de


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

Date: Tue, 06 Jan 1998 04:09:12 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Calling 'require' on an arbitrary module
Message-Id: <34B210D7.F8E9ACC1@5sigma.com>

There's always:

	do $filename;

Be careful with that weapon--it's loaded!

	-joseph
	 http://www.effectiveperl.com

Tom Hukins wrote:

> Any suggestions on how to 'require' arbitrary modules into the
> code or how to solve this problem any other way would be greatly
> appreciated!


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

Date: Tue, 06 Jan 1998 04:35:03 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Camel Critiques: PERL: THE PROGRAMMER'S COMPANION
Message-Id: <34B216E5.6F0D59AD@5sigma.com>

I remember thinking it was hideously ugly.  On the other hand,
I have always had great respect for Wiley's choices of titles
and authors.  (But never for Wiley's cover designers.)  Its
innards did pass the "laugh test."  I guess I'll have to take 
another look.

	-joseph
	 http://www.effectiveperl.com

Chris Nandor wrote:
> 
> In article <34A9DD41.687@forte.com>, Peter Prymmer <pvhp@forte.com> wrote:
> #   One other tiny technical problem I have with the text is the fixed
> # width font used for source code samples which suffers from the same
> # problem as Paul Hoffman's B<Perl 5 for Dummies> in that one cannot
> # distinguish between the backticks `` and the foreticks '' (Nigel's
> # book was apparently written up in LaTeX).
> 
> Funny, I mentioned I did not like his monospaced font just the other day
> as well, though I did not notice that problem (I just leafed through the
> book for a minute or two).  I simply think it is an ugly font.  :)


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

Date: Tue, 06 Jan 1998 00:40:58 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: Todd O'Connor <toconnor@adobe.com>
Subject: Re: Capturing STDERR on NT
Message-Id: <34B1EE1A.7A492AC7@sirius.com>

to the best of my knowledge there is no solution to this problem.
One thing you can try is to increase the number of lines that
are buffered in the DOS window.

In general, I explicitly send my error output to a file, and
optionally echo it to STDERR.

-- Jim

Todd O'Connor wrote:
> 
> I am having a hard time capturing STDERR on NT 4.0. Has anyone found a way
> to do this with Perl? I have a test that produces a lot of output and want
> to capture all STDOUT and STDERR to a logfile for reviewing. There is the
> chance that STDERR could scroll off the screen and I wouldn't know it.
> 
> Thanks,
> Todd
> toconnor@adobe.com


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

Date: 6 Jan 1998 10:15:08 GMT
From: Piotr Klaban <makler@man.torun.pl>
Subject: CgiWrap - perl: can't map file error
Message-Id: <68t07c$85v$1@flis.man.torun.pl>

Hello,
	I have compiled CGIWrapper 
	(ftp://ftp.cc.umr.edu/pub/cgi/cgiwrap/htdocs/index.html)
	I have apache serwer, and simple CGI script written in perl:
	 #!/usr/bin/perl
	 print("Content-type: text/html\n\n");
	 print('Click again: <a href="'.$ENV{"SCRIPT_NAME"}.'">test</a>');
	I have in the configuration srm.conf the following lines:
	 AddHandler cgi-wrapper .cgi
	 Action cgi-wrapper /cgi-bin/cgiwrap
	Shell script cgi runs OK, but perl script run through cgiwrap
	gives that error in the WWW error_log file:

ld.so.1: /usr/bin/perl: fatal: /usr/lib/libw.so.1: can't map file: errno=12
[Tue Jan  6 11:05:20 1998] access to
/home/torman/admin/makler/apache/server/cgi-bin/cgiwrap
failed for flis, reason: Premature end of script headers

	What would be the problem? If I run the same perl script directly
	there is no problem. It seems like perl could not be run from the
	cgiwrap.

Best regards,

Piotr Klaban
--
makler@man.torun.pl


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

Date: Tue, 06 Jan 1998 04:59:45 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
To: agtbjw <agtbjw@btinternet.com>
Subject: Re: Help im stuck
Message-Id: <34B21CAF.5E6EE063@5sigma.com>

I recommend Java for this application.  Or this programmer.
Or whatever.  :-/

	-joseph
	 http://www.effectiveperl.com
	 perl -e 'print"@{[keys%{{map({$_,1}grep/^[^\W\d_]\w*$/,map{split}<>)}}]}"'

agtbjw wrote:
> 
> Hello I am a first year student and studying perl.
> 
> Can anyone help with my problem
> 
> I have to write a program which searches for and outputs each word in an
> input file.  Each word must start with a letter and may include letters
> numbers and underline'_'
> 
> the space will act as the separator between the words.


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

Date: Tue, 06 Jan 1998 04:39:02 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: HTML Templates...Whats the best method
Message-Id: <34B217D5.37D43639@5sigma.com>

Knowing basically nothing about your application, I would say
nevertheless read in the whole thing and have your way with it.
It's not like 20k of text is going to break the camel's back.
So to speak.

	-joseph

Martyr wrote:
> 
> I am writing some scripts for a website and I want to
> use HTML templates.  What is the best way to go about
> this?  [...]h


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

Date: Tue, 06 Jan 1998 06:29:04 GMT
From: sase@sasezdesyn.com (SasEz! Publications and Design)
Subject: HTTP::Request::Common, print, and other misc ?'s
Message-Id: <34b1ca46.14186281@news.theriver.com>

Hi again everyone :)  Randall, thank you for your help with my POST
questions. I read and re-read lwpcook and couldn't find the example
you gave me but after much more reading I finally found the
common.pm file!  Now I have the basics of my program written but I
have more questions, hope no one minds :)

<snippet of code - currently untested via command line or other
means>

#open data file, read into an array, then do the work.
$file = '/etc/passwd';
open(INFO, $file);
@line = <INFO>;
close(INFO);

#for every line in the file, post the form data
foreach $line {
    use HTTP::Request::Common qw(POST);
    my $req = POST $line, [ %in ];
} or die "No can do: $!";

=Ok, now the onslaught of questions!
1-> Randal said the HTTP::Request::Common method will automatically
escape form data for me, does this mean I do not need a sub such as
&getcgivars ?

2 -> How do I print responses when using this module? Should I still
use the UserAgent for that part? Would it need to be inside of the
foreach statement to get the response for each $line? Is there a way
to use this in conjunction with wait/status message to the user? For
instance, if the file has 100 lines to go through, the user will
need to wait a few minutes for the script to complete. (I have
noticed a thread of this type in the cgi newsgroup but I haven't
seen any definative answers to the question yet.) Is it possible to
have a page come up after $line[0] is processed that shows the
status of that post, and/or asks them to wait because the process is
still in progress?
3 -> since $file is only being read from, do I need to worry about
using flock? Will I run into problems if the program is initiated by
user1, they get to $line[20], user 2 initiates the program, gets to
$line[10], user 3 trys to initiate....etc. Would this be a major
problem assuming the benchmarks show it not using too much of the
resources at once?

I think that's all of my questions for now. If any or all of these
answers are already asked/answered, feel free to point me in the
right direction. 
Thanks,
Kathy


-
SasEz! Publications and Design ~ Kathy Burns
Professional Web Design, Hosting, and Maintenance
Is your business set up to make money 24 hours a day, 7 days a week?
http://www.sasezdesyn.com  mailto:sase@sasezdesyn.com
ICQ #828499 ~Check out our Free web design planning guide!~
-


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

Date: Tue, 06 Jan 1998 03:39:37 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
To: rootbeer@stonehenge.com
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <34B20936.DD128609@5sigma.com>

That doesn't really seem like correct behavior.  Maybe this zipped
by in one of the great p5p closure debates, but I can't see why
embeddedsub is getting "cloned" in this case.  Possibly I'm just
ignorant of some larger issue.

	-joseph
	 http://www.effectiveperl.com

Tom Phoenix wrote:
> 
> On Mon, 5 Jan 1998, Steve Goldstein wrote:
> 
> > sub What_is_the_temp
> > {
> >     my $param =  shift;
> >     print "Outside it is $param.\n";
> >
> >     embeddedsub();
> >     return;
> >
> >     sub embeddedsub
> >     {
> >         print " Inside it is always $param.\n";
> >         return;
> >     }
> > }
> 
> Each time you call What_is..., it gets a new my() variable called $param.
> But the $param in embeddedsub is the one from the first call; it's neither
> regenerated with each new call nor somehow connected to the latest or
> current invocation of What_is.... Hope this helps!


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

Date: Mon, 05 Jan 1998 22:44:50 -0800
From: Peter Prymmer <pvhp@forte.com>
To: Michael Kishinevsky <mkishine@ix.netcom.com>
Subject: Re: libwww-perl-5 and Win32
Message-Id: <34B1D2E2.703F@forte.com>

Michael Kishinevsky wrote:

> Here is the results of runnign perl -V:
> 
> Summary of my perl5 (patchlevel 1) configuration:
                ^^^^^^^^^^^^^^^^^^^^
here's the problem
 
> If anybody knows how to make libwww-perl-5 work under WIN32, please let
> me know.


The following works for me:

C:\> perl -MLWP::Simple -e
"getprint('http://www.bridge.com/index.html')"

I used:

Summary of my perl5 (5.0 patchlevel 4 subversion 02) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32
    uname=''
    hint=recommended, useposix=true, d_sigaction=undef
    bincompat3=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='bcc32', optimize='-O', gccversion=
    cppflags='-DWIN32'
    ccflags ='-D_RTLDLL -DWIN32'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=n, randbits=15
  Linker and Libraries:
    ld='tlink32', ldflags =''
    libpth=c:\bc45\lib
    libs=import32.lib cw32mti.lib odbc32.lib odbccp32.lib
    libc=cw32mti.lib, so=dll
    useshrplib=undef, libperl=undef
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='', lddlflags='-Tpd'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING
  Built under MSWin32
  Compiled at Aug  9 1997 21:42:37
  @INC:
    c:\perl\lib\site
    c:\perl\lib
    c:\perl\lib
    c:\perl\lib\site
    c:\perl\lib\site
    .

You can find binary distributions of that Perl (with libwww already
built into it) on the CPAN.  Try:

 
http://www.perl.com/CPAN-local/ports/winNT/Standard/x86/perl5.00402-bindist04-bc.zip

Peter Prymmer


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

Date: Tue, 06 Jan 1998 02:36:49 -0500
From: Boris Statnikov <boromir@mindspring.com>
Subject: Looping through hashes
Message-Id: <34B1DF10.AFDE2E3B@mindspring.com>

I have two questions on this topic:

1.
Is there a way to know the number of elements in a hash IN ONE OPERATION
(is there an equivalent of $# for hashes)?  I don't think so, but maybe
someone knows better.

2.
It turns out one is not supposed to do this:

for (($key, $val) = each %myhash) {
    if ($val eq "donkey") {
        $myhash{"parrot"} = "silly bird";
    }
}

In other words, one is not permitted to ADD elements to a hash while
EACHing through it.  Now, how do I accomplish the same thing (and how do
I break out of each loop in order to accomplish it)?

Boris



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

Date: Tue, 06 Jan 1998 12:34:34 +0100
From: Martin Button <marty@kc3ltd.co.uk>
Subject: MIME Decoder
Message-Id: <34B216C7.59EF@kc3ltd.co.uk>

Please can anyone help me.

We are trying to develop a perl script to decode MIME messages, but are
unable to write the script ourselves. Can anyone give us a ready to use
script which we can simply implement. We are using Perl version 5.001
for Solaris 2.4.

We have been looking for a solution for 4 weeks now and would appreciate
any help.

Martin Button
Systems Administrator
KC3


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

Date: Tue, 06 Jan 1998 11:27:28 +0100
From: Richard Locke <Richard.Locke@sni.nl>
Subject: Newbie: Problem with file handling under WindozeNT and UNIX
Message-Id: <34B20710.2D40@sni.nl>

Hi,

I have just started to learn Perl, and I am working my way through the
'Learning Perl, 2nd Edition' (the llama) book.

I was going on fine and understanding everything as I went along, until
I cam up to the file handing section (I'm still in chapter 1 BTW). Now,
I understand file handling, but I can't get it to work under UNIX. I
have typed the Perl script in as in the book, and it works fine when
running under WindozeNT, the Win32 port, (Perl version 5.003_07), but it
won't work under the UNIX system here (Perl version 5.004_04 built for
RM600-svr4. The Perl script reads in from the external files OK (I'm
using 2 external file with the glob command), but the script refuses to
work with the contents as it should (and as it does under NT). The
script is the same as that in the book, and it is here below for quick
reference.

The 2 external file are 'fred.secret' and 'barney.secret'
'fred.secret' contains 2 lines as follows :-

fred
camel

and 'barney.secret' contains 2 lines as follows :-

barney
llama

The perl script is this :-

#!/usr/bin/perl
init_words();
print "What is your name? ";
$name = <STDIN>;
chomp ($name);
if ($name =~ /^richard\b/i) { # back to the other way :-)
	print "Hello, Richard! How good of you to be here!\n";
} else {
	print "Hello, $name!\n"; # ordinary greeting
	print "What is the secret word? ";
	$guess = <STDIN>;
	chomp ($guess);
	while (! good_word($name,$guess)) {
		print "Wrong, try again $name. What is the secret word? ";
		$guess = <STDIN>;
		chomp ($guess);
	}
	print "Good $name, you got it right.\n";
}

## Sub routines from here on down

sub init_words {

while (defined($filename = glob("*.secret")) ) {
	open(WORDSLIST,$filename) || die "can't open wordslist: $!";
	if (-M WORDSLIST >= 7.0) {
		die "Sorry, the wordslist is older than seven days.";
	}
	while ($name = <WORDSLIST>) {
		chomp $name;
		print "$name\n";  # added to see names read in OK
		$word = <WORDSLIST>;
		chomp $word;
		print "$word\n";  # added to see secret words read in OK
		$words{$name} = $word;
	}
}
close (WORDSLIST) || die "couldn't close wordslist: $!";
}

sub good_word {
	my($somename,$someguess) = @_; # name the parameters
	$somename =~ s/\W.*//;		 # get rid of everything after
						 # first word
	$somename =~ tr/A-Z/a-z/;	 # lowercase everything (name)
	$someguess =~ tr/A-Z/a-z/;	 # lowercase everything (guess)
	if ($somename eq "richard") {  # should not need to guess
		return 1;			 # return value is true
	} elsif (($words{$somename} || "groucho") eq $someguess) {
		return 1;			 # return value is true
	} else {
		open MAIL,"|mail Richard.Locke\@sni.nl";
		print MAIL "bad news: $somename guessed $someguess\n";
		close MAIL;
		return 0;			 # return value is false
	}
}


Does anyone have any suggestions to what might be causing this problem?
Thanks in advance,

Richard


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

Date: Tue, 06 Jan 1998 02:08:50 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: next == continue??
Message-Id: <34B1D882.8433E505@coos.dartmouth.edu>

Marek Rouchal wrote:
> 
> PS. You even could do (if your subs
>   return success)
> 
> while (defined($_ = shift(@ARGV))) {
>   /^-h/ && &help && next;
>   /^-v/ && &version && next;
>   ...
> }

They don't have to return success if you do this:

while (defined($_ = shift(@ARGV))) {
  /^-h/ && (&help, next);
  /^-v/ && (&version, next);
  ...
}


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

Date: 6 Jan 1998 07:38:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: next == continue??
Message-Id: <68sn22$sum$1@client3.news.psi.net>

Chipmunk (rjk@coos.dartmouth.edu) wrote on 1589 September 1993 in
<URL: news:34B1D882.8433E505@coos.dartmouth.edu>:
++ Marek Rouchal wrote:
++ > 
++ > PS. You even could do (if your subs
++ >   return success)
++ > 
++ > while (defined($_ = shift(@ARGV))) {
++ >   /^-h/ && &help && next;
++ >   /^-v/ && &version && next;
++ >   ...
++ > }
++ 
++ They don't have to return success if you do this:
++ 
++ while (defined($_ = shift(@ARGV))) {
++   /^-h/ && (&help, next);
++   /^-v/ && (&version, next);
++   ...
++ }


You don't even need next, if you really want to:

$h = {h => \&help, v => \&version};
map {/^-([hv])/ && $h -> {$1} -> ()} @ARGV;


Abigail
-- 
I guess I have a sick mind...


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

Date: 6 Jan 1998 10:34:01 GMT
From: mehu@deepblue.chubrock.com (eric)
Subject: perldsc q: complex data from file
Message-Id: <slrn6b425b.4hg.mehu@deepblue.chubrock.com>

Near the end of perldsc, it goes through the complex data structure w/ all the
TV shows, etc.  It then says that the easiest way to read it in from a file
is for the file to be in that format.  Great!  But I'm still stuck on how to
do the reading-in part.  I got my script to work by simply sticking the
declared hash in the script itself, but I don't particularly want that, as
it's going to be quite large... so what I'm looking for is something that will
give the same effect as an SSI file include.

Using their example, say I have the file "tv.db", which contains the little
%TV example, exactly as it appears in the declaration in perldsc.  Now how do
I access the %TV hash from a script?  I've tried various read & open
attempts, but am not quite sure what to do to get the info accessable by the
script.

In particular, the following attempt failed:

open(FILE,$tv_db);
%data=<FILE>;
close(FILE);

As did replacing the second line with something like:

%data=%TV;  

(assuming that since the file was open, %TV would be the info referred to -as-
%TV in the file... obviously not.)

Any suggestions?

-- 
Aaaahhh, unix.  It's good to be back.


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

Date: Mon, 05 Jan 1998 20:45:02 -0800
From: Rob Maniatis <robm@transmeta.com>
Subject: problem parsing conditional operator.
Message-Id: <34B1B6CE.484E@transmeta.com>

Hello all,

I recently ran into a problem while writing a test script for a module
that I wrote.  (Actually, I'm not sure it's a problem which is why I'm
writing this post.)

Let me include a simplified example:

#!/usr/local/bin/perl -w
$variable1 = 2;
$variable2 = 2;

print $var1 == $var2 ? "equal\n" : "not equal\n";  # TEST 1

print ($var1 == $var2) ? "equal\n" : "not equal\n";   # TEST 2

If you run this little script the TEST 1 line will produce "equal" while
the TEST 2 line will produce "1" and a warning about Useless use of a
scalar in a void context.

This is because the line TEST 2 is being parsed such that the print is
called as a function with the expression $var1 == $var2, while the
conditional operator is just sort of left hanging.

For this simple case the solution is obviously to remove the ()'s but
when I first encountered this problem I was trying to compare two more
complex expressions--something like:

print (EXPR1) == (EXPR2) ? "equal\n" : "not equal\n";

Again the parser sees the opening ( and passes EXPR1 to perl rather than
evaluating the conditional and passing it along.

This can be fixed in a number of ways including:

print "",(EXPR1) == (EXPR2) ? "equal\n" : "not equal\n";

Is it unreasonable to expect the parser to "look ahead" in such
situations and recognize the conditional?  I have only thought about
this particular case.  Any comments?  Is this a bug?

Thanks for your time,
--Rob


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

Date: Tue, 06 Jan 1998 12:08:32 +0100
From: Koos Pol <koos_pol@bigfoot.com>
Subject: readdir() and file named '0'
Message-Id: <34B210B0.BB4@bigfoot.com>

while ($next_entry = readdir ($dirh)) {

Why does it fall-through as soon as I reach a file named '0' (null) ?
Although '0' is FALSE in perl terms, what has it got to do with the
name of the file ?

-- 
Koos Pol
----------------------------------------------------------------------
S.C. Pol                                           tel: +31 20 3116122
PC Systems Administrator                   email: Koos_Pol@bigfoot.com
Compuware Europe                 PGP public key available upon request

      A little inaccuracy sometimes saves tons of explanation.
                        -- H. H. Munroe


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

Date: 6 Jan 1998 11:59:57 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: readdir() and file named '0'
Message-Id: <casper.884088422@uk-usenet.uk.sun.com>

[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

Koos Pol <koos_pol@bigfoot.com> writes:

>while ($next_entry = readdir ($dirh)) {

>Why does it fall-through as soon as I reach a file named '0' (null) ?
>Although '0' is FALSE in perl terms, what has it got to do with the
>name of the file ?


Use 
	while (defined($next_entry = readdir($dirh)))

Or as perl 5.004_04 -w says:

Value of readdir() operator can be "0"; test with defined() at foo.pl

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: Tue, 06 Jan 1998 12:48:05 +0100
From: tobez@plab.ku.dk
Subject: Re: readdir() and file named '0'
Message-Id: <34B219F5.49A8@plab.ku.dk>

Koos Pol wrote:
> 
> while ($next_entry = readdir ($dirh)) {
> 
> Why does it fall-through as soon as I reach a file named '0' (null) ?
> Although '0' is FALSE in perl terms, what has it got to do with the
> name of the file ?

Always use -w switch!  In this case you'll get a warning
  Value of readdir() operator can be "0"; test with defined()

So, your code should look like

  while (defined($next_entry = readdir ($dirh))) { ...

Hope this helps,

Anton.


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

Date: Mon, 05 Jan 1998 23:42:54 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: require not working
Message-Id: <34B1D1C1.209AEA6@5sigma.com>

Oh, give us a break!

Could you check back with us after you have read Tom Christiansen's
Idiot's Guide to Solving CGI Programming Problems:

  http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html

Sheesh.

	-joseph
	 http://www.effectiveperl.com

Mark wrote:
> 
> 
> Okay I am hitting a NT server and the script is "not working" in the
> fact that it simply returns "Document contains no data"
> 
> Please help


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

Date: Mon, 05 Jan 1998 23:52:58 -0800
From: Craig Patchett <craig@patchett.com>
To: joseph@5sigma.com
Subject: Re: Review of CGI/Perl book
Message-Id: <34B1E282.4764688D@patchett.com>

Joseph N. Hall wrote:

> Having gone back to Dejanews to inspect it, I don't think
> there was a great abuse of Randal's original quote.  Maybe it
> wasn't trimmed exactly as he would have liked, but it wasn't
> like they turned black into white.  This is probably more a
> lesson for someone writing a review/endorsement than anything
> else.  :-)

Here's Randal's original sentence (from his post):

     If you're a beginning scripter (or even an experienced
     website developer) looking to enhance your sites with
     additional interactivity, this book should definitely be
     on your shelf for ready-to-run programs and inspiration
     for your own custom programs."

The quote that is being bandied about for the book's marketing is:

     This book should definitely be on your shelf for
     ready-to-run programs and inspiration for your own
     custom programs."

Is this out of context given the original sentence? Only in that it loses
the reference to site development, which is implied by the fact that it's a
CGI book. I think the problem everyone seems to be having here centers not
around Randal's quote, but around the preface to his quote:

     Here's what I'd like to say about the book:

          perl4 is dead.  Long dead.  It's too bad these programs
          were not tightened up to use Perl5 which would have
          made things simpler.

     However, that's not what you're paying me for, so here's what I'll say
instead... :-)"

(For the record, I never saw the first part of this...the publisher only
forwarded on the second part. And I was never told that Randal was paid for
the endorsement.)  The bottom line is that Randal was paid to say something
nice about the book and he did. The publisher used a valid quote from what
he said ("here's what I'll say instead...") to promote the book.
Unfortunately, what Randal said obviously did not reflect what he felt. But
he said it nonetheless and the publisher used it. Does this make the
publisher (or the author, for quoting it) wrong? Hardly.

And while I'm at it, Perl 4 is far from dead. It lives on as a subset of
Perl 5, one that is far more accessible to the beginning programmer than
the whole set. It is elegant, concise, powerful, and has, on several
occasions, made me want to write passionate fan letters to Larry. But it is
also, above all else, extremely approachable and easy-to-learn (bar the
nuances of regexes). This, along with its fortuitous adoption as the CGI
programming language of choice, is why it has become so popular and, on
many technical bestseller lists, Perl books still outsell Java books.

The additional features offered by Perl 5 are an extension to the core of
the language (read "Perl 4") and, in my opinion at least, should be treated
as such. In other words, learn the basics first then move on to the rest.
The CGI/Perl Cookbook stops at the basics (and declares as much) and leaves
it up to the reader to explore the rest. It does reinvent the wheel at
times, to be sure, but only for the purpose of showing how a wheel is built
(a great way to learn). Perl purists may cringe (and have already, quite
vocally, in this newsgroup) but everyone else is raving (in a postiive
sense).

Bottom line: Don't sell Perl short by forgetting what attracted you to it
in the first place.

Craig

--------------------------------------------------------------------
Craig Patchett                           email : craig@cgi-perl.com
The CGI/Perl Cookbook                      www : http://cgi-perl.com
--------------------------------------------------------------------



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

Date: Tue, 06 Jan 1998 03:09:56 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Review of CGI/Perl book
Message-Id: <34B20242.24B88082@5sigma.com>

Craig Patchett wrote:
> And while I'm at it, Perl 4 is far from dead. 

I was with you until you said that.  Perl 4's shortcomings really
are odious, especially when you have (1) been around Perl 5 for a while,
and/or (2) taught Perl for a living for a while.

If only Perl 4 WERE dead.

	-joseph


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

Date: Mon, 05 Jan 1998 22:59:31 -0800
From: Peter Prymmer <pvhp@forte.com>
To: Wu <weihan@ziyou.math.ncu.edu.tw>
Subject: Re: Two-byte characters substitution ?
Message-Id: <34B1D653.7FE7@forte.com>

Wu wrote:
> 
> I use perl to match Chinese characters which are two-byte oriented.
> I know it is not easy for perl to handle the match.  However, here
> is the problem that I don't know how to solve.
> 
> I have a Chinese character with rear part of its two-byte is "[" ,
> which has special meaning in regexps and will certainly get compilation
> error.  How am I supposed to do ?
> 
> --
> Wu, Weihan
> weihan@math.ncu.edu.tw


The first thing (under single byte character sets at least) would be to
escape the "[" like so:

  $string = "abc[def";

  if ($string =~ /c\[/) {
      print "It matched!\n";
  }

But I am not sure if that would work with DBCS.  Have you looked at the
jperl distribution?  Although it was written for Japanese encodings it
might help you with yours (big 5 or whatever).  jperl is available on
CPAN.

Good luck.

Peter Prymmer


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

Date: Tue, 06 Jan 1998 08:00:53 GMT
From: mascarton@micron.net (Mark A. Scarton)
Subject: Re: UNIX at job managment module/script?
Message-Id: <34b1e3d9.12831590@news.micron.net>

"Barry and Beverly Solow" <Barry_Solow@msn.com> wrote:
> I have to write something in perl which will allow people who are not very
> familiar with UNIX to schedule, review, and manage a large number of 'at'
> jobs.   ....

Since you're still reviewing and assessing the requirements, you might want to
consider acquiring a commercial job scheduling package.  That would provide
things like support for priority, schedule aging, starvation avoidance, shift
management, etc.  Why rewrite what's already been effectively done?


Mark A. Scarton, ABD
Park City Software in cooperation with CompUtah, Corp.
Park City, Utah  USA
Home: 801.565.9835
Office: 801.265.4612


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1587
**************************************

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