[6610] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 235 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 4 16:16:55 1997

Date: Fri, 4 Apr 97 13:00:22 -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           Fri, 4 Apr 1997     Volume: 8 Number: 235

Today's topics:
     [Win32] "Error: parse exception" loading module (AdminM <bmehling@uci.edu>
     Re: [Win32] "Error: parse exception" loading module (Ad (Nathan V. Patwardhan)
     Re: At-sign cancels backslash? (David Winfrey)
     Re: Basic procedure(merge 2 files) (Simon Hyde (aka Jeckyll))
     Re: current dir curiosity ("John Dallman")
     Re: Help desperately needed.  Perl errors need decypher (Douglas Young)
     Re: Help! --simple $ problem (Simon Hyde (aka Jeckyll))
     Re: HELP: trouble "making" perl5.003_94 <rootbeer@teleport.com>
     Re: How can i check that printer exists (Jeff Stampes)
     Re: Multidimensional Arrays! (Simon Hyde (aka Jeckyll))
     My perl script just died <mdperry@cougar.netutah.net>
     Perl and permissions <kll8927@garnet.acns.fsu.edu>
     Re: Perl book sugestions wanted (Robert Ducharme)
     Perl NT and CGI header failures <shisha@rice.edu>
     Re: Perl vs. C/C++ (Matthew H. Gerlach)
     Re: PERLscript with URL redirection (Douglas Young)
     Re: Please - need help with for loop on hostname script (Simon Hyde (aka Jeckyll))
     Re: print a hash with 2 columns <rootbeer@teleport.com>
     Re: Process Communication <rootbeer@teleport.com>
     Re: Redirection command from condition Statement (Simon Hyde (aka Jeckyll))
     Re: Redirection command from condition Statement <vladimir@cs.ualberta.ca>
     Re: Replacing text (Simon Hyde (aka Jeckyll))
     SafeCGIPerl <Bman99970@mindspring.com>
     Re: Simple array question by newbie... (Simon Hyde (aka Jeckyll))
     Re: string comparision <vladimir@cs.ualberta.ca>
     Re: Where is the FAQ list? (Simon Hyde (aka Jeckyll))
     Re: Wildcards for a list of filenames (Simon Hyde (aka Jeckyll))
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 04 Apr 1997 10:47:38 -0800
From: Ben Mehling <bmehling@uci.edu>
Subject: [Win32] "Error: parse exception" loading module (AdminMisc)?
Message-Id: <33454CCA.710F@uci.edu>

Hello,

We are trying to get Win32::AdminMisc (Dave Roth's added features to the
NetAdmin module) on our NT4(SP1a) Server.  We haven't even gotten the
module to load yet so I am thinking there is something wrong with our
install or its incompatible with our version of perl.  So anyway, if you
have any ideas please let me know.  Here is the specifics:

	C:\dev>perl -v
	This is perl, version 5.003_07
		        + suidperl security patch
        Perl for Win32 Build 303 - Built 14:27:31 Jan 29 1997

We installed the module under 'perl5.303\lib\Win32\adminmisc.pm' and
then added the .pll file under
'perl5.303\lib\Auto\Win32\adminmisc\AdminMisc.pll'.  I think this is all
that should be done to install a package.  Or did I miss anything?

Now for code: (I have tried this using both the perlis.dll and perl.exe
with the same results.)

	use Win32::AdminMisc;
	print "hello world";

Now to run it:

	C:\dev>admisc.pld
	Error: Parse exception

(BTW, if I "require" the module rather than "use" I get "Error: Runtime
Exception".)

As soon as I comment the use (or require) Win32::AdminMisc line, it of
course runs fine...  So I am at a loss, I can not get this module to
load, and it has a function I really need.

Any assistance is MUCH appreciated, Thank you.  Ben

http://www.gsm.uci.edu/~bmehling/perl
http://www.gsm.uci.edu/~bmehling/nt


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

Date: 4 Apr 1997 19:34:48 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: [Win32] "Error: parse exception" loading module (AdminMisc)?
Message-Id: <5i3l4o$npp@fridge-nf0.shore.net>

Ben Mehling (bmehling@uci.edu) wrote:

: We are trying to get Win32::AdminMisc (Dave Roth's added features to the
: NetAdmin module) on our NT4(SP1a) Server.  We haven't even gotten the
: module to load yet so I am thinking there is something wrong with our

Hmm, yes.  I noticed errors like this when using Socket.pm.  I think there
might be a bug with things like:

$foo = (function($param))[1];

where something like

($bar, $foo) = function($param);

seems to work just fine.

I'm still testing this theory, but the problem happens very frequently,
so I'm partially convinced.  :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 4 Apr 1997 18:48:09 GMT
From: do.not.spam.dwinfrey@cpcug.org (David Winfrey)
Subject: Re: At-sign cancels backslash?
Message-Id: <5i3id9$ifu@news3.digex.net>

Tom Phoenix (rootbeer@teleport.com) wrote:
: Both those lines print the same thing in current versions of Perl. You may
: need to get a newer version if this bothers you. :-) 

"Bother" isn't really the right word; I just wondered if @ had
some magic meaning in that context.  Thanks.



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

Date: Fri, 04 Apr 1997 17:00:03 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Basic procedure(merge 2 files)
Message-Id: <3346201a.3897553@news>

On Thu, 03 Apr 1997 14:48:09 +0000, Yoshiaki Murakami <rty333@email.sps.mot.com> wrote:

>Hello!
>I just start to learn Perl.
>I can creare very simple procedure for make report from tab 
>delimitted flat type file. 
>Next, I tried to merge 2 files by 2 or more key items as below. 
>Does anybody create procedure for me?
>I don't have any sample procedure alound me. 
>
>(File-1)                             (File-2)
>BookName(Key);Price         BookName(Key);Auther;Volume
>Perl Basic       ;$10            Perl Basic       ;Mr.A    ;100 pages
>                             
>(Merge File-1 and File-2)
>BookName;Auther;Volume     ;Price
>--------- ------ --------- -----
>Perl Basic Mr.A    100 pages  $10
>
>Thank you for your help. 
>
>Regards, 
>    Yoshi.

@outfields = ('Author','Volume','Price');
open(FIRST,'file-1') || die("Error opening input1: $!");
#Take, and use header line
@fields1 = split(/;/,scalar(<FIRST>));
shift(@fields1);
chomp(@fields1);
while(<FIRST>){
	next if /^\s*$/;
	chomp;
	@params = split(/;/);
	($key = shift(@params)) =~ s/^\s+|\s+$//g;
	foreach(0..$#fields1){
		$first{$key}{$fields1[$_]} = $params[$_] if defined($params[$_]);
	}
}
close(FIRST);

open(SECOND,'file-2') || die("Error opening input2: $!");
#Take, and use header line
@fields2 = split(/;/,scalar(<SECOND>));
$head1 = shift(@fields2);
chomp(@fields2);
while(<SECOND>){
	next if /^\s*$/;
	chomp;
	@params = split(/;/);
	($key = shift(@params)) =~ s/^\s+|\s+$//g;
	foreach(0..$#fields2){
		$second{$key}{$fields2[$_]} = $params[$_] if defined($params[$_]);
	}
}
close(SECOND);

open(OUTPUT, '>combined') || die("Error opening output: $!");
print OUTPUT $head1 . ';' . join(';', @outfields), "\n";
foreach $key (keys(%second)){
	if (defined ($first{$key})){
		print OUTPUT $key ;
		foreach $field (@outfields){
			print OUTPUT ';';
			if (defined($first{$key}{$field})){
				print OUTPUT $first{$key}{$field};
			}elsif(defined($second{$key}{$field})){
				print OUTPUT $second{$key}{$field};
			}	
		}
		print OUTPUT "\n";
	}
}
close(OUTPUT);


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

Date: Fri, 4 Apr 1997 18:18:19 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: current dir curiosity
Message-Id: <E84LIJ.M22@cix.compulink.co.uk>

> From: Ray Cromwell <ray@westlake.com>

> Recently, I had the problem of trying to obtain the current 
> directory. This hadn't been a problem, for years, I used `pwd` on
> unix. The problem is, it doesn't work on NT...

Yes, it does. You do have to get the \n off the end; this would be 
portable between UNIX and NT:

    $curdir = `pwd`;
    $curdir =~ s/\n//g;         # chop would damage it on UNIX
    $curdir =~ s/\r//g;         # get rid of \r just for paranoia's sake
    

John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked: 
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, Perl for 
NT/Win 95 can be found at http://www.activeware.com, with an excellent 
FAQ file at 
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html and no, 
I don't have the slightest idea what's wrong with your CGI script. Try 
http://www.perl.com/perl/faq/idiots-guide.html


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

Date: 4 Apr 1997 17:07:25 GMT
From: dougyoung@zap.wwdc.com (Douglas Young)
Subject: Re: Help desperately needed.  Perl errors need decyphering.
Message-Id: <5i3cgd$cdc@van1s03.cyberion.com>

Robert Pate (robert@ctllc.com) wrote:
: Hello there.  I am pretty new to Web programming.  I have written many Perl
: scripts that run perfectly in the NT world but I have now put them on my
: new ISP's server which is Linux and they don't work right.  I get the error
: "errno is 2" and "Premature end of script header".  Can anybody give me a
: hand at figuring out what this means and a way to fix it???  I would be
: very appreciative.  Thanks
Excuse the DUH?, but what lines of code produce the error?  You don't
suppose they have a call that's WHINDOWZE specific?  Just wondering...
-----------------------------------------------------------------------------
Douglas Young                    Senior System Administrator
dougyoung@wwdc.com               Worldwide Data Communications
div of Cyberion Networking Corporation.


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

Date: Fri, 04 Apr 1997 16:59:55 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Help! --simple $ problem
Message-Id: <3348f917.2388086@news>

On Thu, 03 Apr 1997 18:08:53 +0000, Dean Suko <dean_suko@opcode.com> wrote:

>Can someone help me with this easy question:
>
>How can I delete a number of elements within a string and return the
>"post-deleted" data back into the string?
>
>For example, lets say I have this string defined:
>
>$bob = "hello I am bob"
>
>I want to hack the first 3 elements and put the remainder back into a
>string. Thus my final string would contain only:
>
>"lo I am bob"
>
>The number of elements I would want to delete would change, which is
>why  it's specified as a number.
>
>Can anyone give me a hand? 
>Sorry for the simplistic question.
>
For this i'll get out a regular expression, a lot more beautiful than Nathan's  unpack's
and substr's, if not a little pointless for a simple task like this :-). If you don't get
what the regular expression is doing take a look at man perlre or
http://www.perl.com/perl/nmanual/pod/perlre.html

$bob = "hello I am bob";
$letters = 3;
($stuff_cut_off) = ($bob =~ s/^((.|\n){$letters})//); 
print "Cut off: $stuff_cut_off\n";
print "Left: $bob\n";




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

Date: Fri, 4 Apr 1997 12:15:12 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: David Combs <dkcombs@netcom.com>
Subject: Re: HELP: trouble "making" perl5.003_94
Message-Id: <Pine.GSO.3.96.970404121216.95H-100000@kelly.teleport.com>

On Fri, 4 Apr 1997, David Combs wrote:

> I am having trouble with doing a "make" on perl5.003_94.

On Solaris? Have you read the file hints/solaris_2.sh? If that file
doesn't show you the way, ask the folks on the Perl Porters Mailing List
<perl5-porters@perl.org> to make it clearer. Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 4 Apr 1997 17:15:01 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: How can i check that printer exists
Message-Id: <5i3cul$jka$1@neocad.com>

peglow (peglow@berlin.snafu.de) wrote:
: 		open(LPR,"|lpr -h -P nonexistentprinter") || &PrinterFault;
: or
: 		unless (LPR,"|lpr -h -P nonexistentprinter") {
: 			&PrinterFault;
: 		} else {
: 			# print all the stuff
: 		}
: this will not work. I get a (unix-)-error-message, but perl does not branch
: into the PrinterFault subroutine.
: Even 
: 		open(LP,"|lp -d nonexistentprinter") || &PrinterFault;
: will not work.

You're telling perl to either open the pipe, or do the &PrinterFault.  
It doesn't give a rat's turd whether your lpr command was successful, 
it opened the pipe, so it's successful and thus ignores the &PrinterFault.   


--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Fri, 04 Apr 1997 17:00:47 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Multidimensional Arrays!
Message-Id: <334533a4.8900385@news>

On 3 Apr 1997 19:50:45 GMT, desmond@lisa.cs.mcgill.ca (Desmond Ye-Ket NG) wrote:

>
>Hello, 
>
>I am having some trouble with 2D arrays in PERL5.

Actually it looks more like your having a problem writing perl than using 2D arrays

>This is my code
>[*snip*]
>				print "counter[i]: $counter[i]";

shurely this should be:
print "counter[i]: $counter[$i]";
                            ^ you missed the $ out

>				$counter[$i] = $counter[$i] + 1;
>				print OUT "array = "$arr[$i][$counter[$i]]"\n";
And here either you need a concatenation operator (.) or to have the quotes round
everything, ie:

print OUT "array = " . $arr[$i][$counter[$i]]."\n";
or
print OUT "array = $arr[$i][$counter[$i]]\n";

>				
>			}
>}
>                close (OUT); 
>                close (DATA); 
>
>
>at the print to the filehandle OUT, everything is blank. I printed the 
>counter and the input and it was fine. Can anyone please tell me what is 
>wrong here?
That should solve your problems.


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

Date: Fri, 04 Apr 1997 10:23:43 -0800
From: Mark Perry <mdperry@cougar.netutah.net>
Subject: My perl script just died
Message-Id: <3345472F.4ED5@cougar.netutah.net>

I am trying to implement a perl script for a website that I maintain. 
The sysadmin must review everything before it goes in the bin.  I sent
him the script, he put it in the bin, it worked fine.  
	
I then noticed that he had changed a variable in the script so I asked
him to change it back. After he changed it the script doesn't work.  It
gives the malformed header in script error.  I am pretty sure that the
permissions are set right.  The variable he changed has no real bearing
on what script does, it can be set to anything.  Perl -c myscript.pl
gives no syntax errors.  I can run it from the debugger and it works.    

I am out of ideas.

the script is at :  http://icstech.com/~copinion/addletter.html

Thanks for any help.


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

Date: Fri, 04 Apr 1997 14:43:05 -0500
From: =?iso-8859-1?Q?ANSEK=AE?= <kll8927@garnet.acns.fsu.edu>
Subject: Perl and permissions
Message-Id: <334559C9.74AB@garnet.acns.fsu.edu>

Is it possible to and a sting to a perl script that will execute a chmod
command so that the newly generate files by the script will be given a
specified set of permissions. My sever does not give read permisions to
other for sever generated files.

Any help will greatly apreciated
ANSEK=AE
kll8927@garnet.acns.fsu.edu


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

Date: 4 Apr 1997 11:29:57 -0500
From: duchar96@sparky.cs.nyu.edu (Robert Ducharme)
Subject: Re: Perl book sugestions wanted
Message-Id: <5i3aa5$crc@sparky.cs.nyu.edu>

How would the Waite Group book be for someone who doesn't know UNIX or any
other programming language? (Not me, but a friend.) In other words, how 
would it be for someone using perl as their first programming language and
using a Windows version of it?

thanks,

Bob DuCharme
bobducharme@acm.org


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

Date: Fri, 04 Apr 1997 14:47:11 -0600
From: Shisha van Horn <shisha@rice.edu>
Subject: Perl NT and CGI header failures
Message-Id: <334568CF.41C6@rice.edu>

Hi all.  We recently had to replace our NT server after a hardware
failure and perl cgi scripts which were workinf fine before are now
failing with an invalid header configuration.  We're running NT 4.0 with
the latest Perl Win32 build (downloaded yesterday) and a Netscape
Fasttrack 2.01 server.

I've configured the server to run cgi-shell scripts and NT has the
correct file association to run perl scripts.  I'm down to a dirt simple
script:

print "Content-type: text/html\n\n";
print "<HTML>".
	"<HEAD>";
print "<TITLE>Blah</TITLE>\n";
print "</HEAD>";
print "<BODY>";
print "<H2>Blah</H2>";
print "</BODY>";
print "</HTML>";

exit (0);


If I execute it from a DOS command prompt, it seems to output fine.  If
I redirect it to a text file (test.pl > foo.txt), the text file is
always empty.

If I try to run the script from Netscape, I get an invalid header
configuration.  I tried wrapping it in a batch file (2 line script: 
perl test.pl, exit).  If I try to run the batch file from Netscape, the
output always includes the path and DOS command prompt.  It looks like
this:

C:\[path]> perl test.pl Content-type: text/html

Blah [Correctly shown in H2]

C:\[path]> exit


Is there some variable to turn off passing the DOS prompt through?  I've
tried to read the docs, support files and FAQs before posting this.  I
know this *may* be a Netscape server problem, but I'm confused as to why
the redirected perl script would return an empty text file.

Thanks for any help.

- Shisha van Horn
shisha@rice.edu


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

Date: Fri, 4 Apr 1997 17:03:49 GMT
From: gerlach@netcom.com (Matthew H. Gerlach)
Subject: Re: Perl vs. C/C++
Message-Id: <gerlachE84I2D.J6K@netcom.com>

>	1) How easy is it to learn?
If one already knows C/C++, Perl isn't too bad to learn.

>	2) How well does it handle files and strings?
I think there is no better language for file/string manipulation.

>	3) What about support and documentation?	
I have gotten better free support from the Internet, than any
support I have paid for, for any software.

>	4) What about all this CGI and webserver stuff, etc. 
Take a look at the O'Riely CGI Progamming book.

Matthew H. Gerlach



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

Date: 4 Apr 1997 17:04:29 GMT
From: dougyoung@zap.wwdc.com (Douglas Young)
Subject: Re: PERLscript with URL redirection
Message-Id: <5i3cat$cdc@van1s03.cyberion.com>

Anthony John Doyle (strad@mondenet.com) wrote:
: not sure if this is the best place to ask the question - but
:   here goes.
:   
:   i am working on a PERL script and i would like to be able to
:   test various conditions from a web based form which a client
:   uses to submit various information and then automatically have
:   the user redirected to the appropriate web page
:   
:   i have tried some various ways with codes 300, 301, and 302
:   for the redirection but keep getting a server error - i suspect
:   i am missing something in the equation here - can someone
:   point me in the right direction?
:   
:   thank you
I just use print "Location: http://www.foobar.net/wonderment.html\n\n";
if the location was determined as a variable you'd have
print "Location: $LOCATION\n\n";
How's that for a direction?

-----------------------------------------------------------------------------
Douglas Young                    Senior System Administrator
dougyoung@wwdc.com               Worldwide Data Communications
div of Cyberion Networking Corporation.


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

Date: Fri, 04 Apr 1997 17:11:41 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Please - need help with for loop on hostname script
Message-Id: <334633c1.8929046@news>

On Thu, 03 Apr 1997 11:51:35 -0600, jsykes@tartar.ulib.albany.edu wrote:

>hello!
>
>this may or may not have been posted by me already - my system went down
>during the post confirmation.
>
>i would like to put in a for loop into the code that enables me to do a
>one time hostname lookup of all the machines and not be prompted for each
>one.  i have been experimenting with creating a text file of the addresses
>and reading each line in as an array, but there must be a simpler way.
>can i not tell perl to create an array beginning at 111.111.111.1 and
>ending at 111.111.111.999 and to check every number in between?

Surely you want to go up to 111.111.111.255 since that's as high as an IP address will go?

>
>here is the code:
>
># p14_5.pl
>
>print ("Enter an Internet address:\n");
>$machine = <STDIN>;
>$machine =~ s/^\s+|\s+$//g;
>@bytes = split (/\./, $machine);
>$packaddr = pack ("C4", @bytes);
>if (!(($name, $altnames, $addrtype, $len, @addrlist) =
>    gethostbyaddr ($packaddr, 2))) {
>    die ("Address $machine not found.\n");
>}
>print ("Principal name: $name\n");
>if ($altnames ne "") {
>    print ("Alternative names:\n");
>    @altlist = split (/\s+/, $altnames);
>    for ($i = 0; $i < @altlist; $i++) {
>        print ("\t$altlist[$i]\n");
>    }
>}
>
>
# p14_5.pl

print ("Enter a base address: ");
$base = <STDIN>;
$base =~ s/^\s+|\s+$//g;
# Make sure there is a . on the end of $base
$base =~ s/\.*$/\./;
foreach $add(0..255){
# or should that be 1..256?
	$machine = $base . $add;
	@bytes = split (/\./, $machine);
	$packaddr = pack ("C4", @bytes);
	if (!(($name, $altnames, $addrtype, $len, @addrlist) =
	    gethostbyaddr ($packaddr, 2))) {
	    warn ("Address $machine not found.\n");
	}
	print ("Principal name for $machine: $name\n");
	if ($altnames ne "") {
	    print ("Alternative names for $machine:\n");
	    @altlist = split (/\s+/, $altnames);
	    foreach (@altlist) {
	        print ("\t$_\n");
	    }
	}
}



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

Date: Fri, 4 Apr 1997 12:24:45 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Candice Chauve <chauve@info.univ-angers.fr>
Subject: Re: print a hash with 2 columns
Message-Id: <Pine.GSO.3.96.970404122249.95K-100000@kelly.teleport.com>

On Fri, 4 Apr 1997, Candice Chauve wrote:

> I've got to print a hash composed of students'names and of their best
> mark.On the first, column we should see the name of the student and on
> the other column,we should see the students'mark.The first problem is
> that the second column must begin at the same position for all the marks
> and I don't know how to do that!

Use (s)printf, documented in perlfunc(1) and your local man pages.

> Secondly, I've got to sort the students by the level of their mark.And
> if several students have the same mark ,I should sort them by
> alphabetical order.

There are good examples of sorting in perlfunc(1). Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 4 Apr 1997 12:10:27 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Dipti V. Sonak" <dsonak@us.oracle.com>
Subject: Re: Process Communication
Message-Id: <Pine.GSO.3.96.970404120852.95F-100000@kelly.teleport.com>

On Thu, 3 Apr 1997, Dipti V. Sonak wrote:

> I wish to run some commands in [ a ] new shell. What is the simplest way
> to do this ?

Use perl's system() function, but first read your shell's manpage to see
how to pass a file of commands to it. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 04 Apr 1997 16:59:35 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Redirection command from condition Statement
Message-Id: <3344f0ef.299686@news>

On Thu, 03 Apr 1997 21:07:20 -0500, "Bala S. Chidambaram" <subramani@washington.xtn.net>
wrote:

>Could someone please help me. I have wasted too much time on this 
>already. How do I give a command to go to a URL from a condition
>
>eg: If (.......) { goto http://myserver/index.htm }
>elsif  (.......) { goto http://someotherserver/index.htm }
>
This sounds like basic CGI, not the same as basic perl at all, but anyway, u'd do it by:
if(...){
	print "Location: http://myserver/index.htm\n\n";
	exit;
}elsif(...){
	print "Location: http://someotherserver/index.htm\n\n";
	exit;
}


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

Date: 04 Apr 1997 13:44:28 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: Redirection command from condition Statement
Message-Id: <omlo6y5xhv.fsf@tees.cs.ualberta.ca>

Good answer. My advice is, use CGI.pm and then
  $cgi->redirect('http://foo.com');



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

Date: Fri, 04 Apr 1997 16:59:36 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Replacing text
Message-Id: <3345f3cb.1031904@news>

On 3 Apr 1997 20:54:43 GMT, "Stephen Hill" <scs@huron.net> wrote:

>I have written a script that searches a database and then prints out the
>search results. I want the words that were used for the search to be
>printed it red. The portion of script below does it, with one PROBLEM. 
>
>If @keywords has one item in it, when the results are printed, the one
>keyword that was searched on does not appear!?!
>if @keywords has two items, the first word appears in red and the other is
>missing
>if @keywords has three items......1 & 2 show up and the 3rd is missing
>if @keywords has four itmes they ALL appear!!!
Before I even start answering this I must point you to the following, from section 4 of
the Perl FAQ (which can be found at http://www.perl.com/perl/nmanual/pod/perlfaq.html):

What is the difference between $array[1] and @array[1]? 

The former is a scalar value, the latter an array slice, which makes it a list with one
(scalar) value. You should use $ when you want a scalar value (most of the time)
and @ when you want a list with one scalar value in it (very, very rarely; nearly never,
in fact). 

Sometimes it doesn't make a difference, but sometimes it does. For example, compare: 

    $good[0] = `some program that outputs several lines`;

with 

    @bad[0]  = `same program that outputs several lines`;

The -w flag will warn you about these matters. 

So:
>
>@lines[$i] =~ s/@keywords[0]/<FONT COLOR=\"FF0000\">@keywords[0]<\/FONT>/i;
>@lines[$i] =~ s/@keywords[1]/<FONT COLOR=\"FF0000\">@keywords[1]<\/FONT>/i;
>@lines[$i] =~ s/@keywords[2]/<FONT COLOR=\"FF0000\">@keywords[2]<\/FONT>/i;
>@lines[$i] =~ s/@keywords[3]/<FONT COLOR=\"FF0000\">@keywords[3]<\/FONT>/i;

should be:
$lines[$i] =~ s/$keywords[0]/<FONT COLOR=\"FF0000\">$keywords[0]<\/FONT>/i;
$lines[$i] =~ s/$keywords[1]/<FONT COLOR=\"FF0000\">$keywords[1]<\/FONT>/i;
$lines[$i] =~ s/$keywords[2]/<FONT COLOR=\"FF0000\">$keywords[2]<\/FONT>/i;
$lines[$i] =~ s/$keywords[3]/<FONT COLOR=\"FF0000\">$keywords[3]<\/FONT>/i;

And to make this even more reliable it should really be:
$lines[$i] =~ s/(\Q$keywords[0]\E)/<FONT COLOR=\"FF0000\">$1<\/FONT>/i;
$lines[$i] =~ s/(\Q$keywords[1]\E)/<FONT COLOR=\"FF0000\">$1<\/FONT>/i;
$lines[$i] =~ s/(\Q$keywords[2]\E)/<FONT COLOR=\"FF0000\">$1<\/FONT>/i;
$lines[$i] =~ s/(\Q$keywords[3]\E)/<FONT COLOR=\"FF0000\">$1<\/FONT>/i;

(if you don't understand what i've done here take a look at "man perlre" or
http://www.perl.com/perl/nmanual/pod/perlre.html)

And to save you code and searching for null strings:
foreach $keyword(@keywords){
	$lines[$i] =~ s/(\Q$keyword\E)/<FONT COLOR=\"FF0000\">$1<\/FONT>/i;
}

And again you want to chage this:
>
>@item = split(/\t/,@lines[$i]);
>print "<I>Order Number:</I><B>@item[0]</B><BR>";
>print "<I>Item:</I> <B>@item[1]</B><BR>";
>print "<I>Medium:</I> <B>@item[3]</B><BR>";
>print "<I>Company:</I> <B>@item[4]</B><BR>";
>print "<I>Retail:</I> <B>\$@item[8]</B><BR><HR>\n";

To:
@item = split(/\t/,$lines[$i]);
print "<I>Order Number:</I><B>$item[0]</B><BR>";
print "<I>Item:</I> <B>$item[1]</B><BR>";
print "<I>Medium:</I> <B>$item[3]</B><BR>";
print "<I>Company:</I> <B>$item[4]</B><BR>";
print "<I>Retail:</I> <B>\$$item[8]</B><BR><HR>\n";

See if those fixes help


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

Date: Fri, 04 Apr 1997 12:00:00 -0500
From: Michael Burdick <Bman99970@mindspring.com>
Subject: SafeCGIPerl
Message-Id: <33453390.5EDB@mindspring.com>

Hello,
   My admin has safecgiperl installed..I keep getting all of these
errors like -w. Are there any scripts that are compatible with this?
Also is there a way to get around this? Like..A way to disable it?
hehe..

Thanks,
Michael

E-mail: Bman99970@mindspring.com


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

Date: Fri, 04 Apr 1997 17:00:10 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Simple array question by newbie...
Message-Id: <334829f1.6416239@news>

On Thu, 03 Apr 1997 16:08:32 -0500, Bill Kuhn <wkuhn@uconect.net> wrote:
[*snip*]
>$month_to_next = ('Jan','Feb',
>    'Feb','Mar',
>    etc.,etc.,etc.) ;
Hrm...I think you might want to take another look at this bit of code, and change it to:
%month_to_next = ('Jan','Feb',
    'Feb','Mar',
    etc.,etc.,etc.) ;
if you just do $month_to_next you will end up with a scalar who's value is 24
>
>Then you could just do:
>$nxtMonth = $month_to_next{'Mar'} ;
>
>There are probably a dozen other ways to do it...




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

Date: 04 Apr 1997 13:42:20 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: string comparision
Message-Id: <omn2re5xlf.fsf@tees.cs.ualberta.ca>

In article <334422BB.429DF349@enteract.com> Eryq <eryq@enteract.com> writes:

> If you meant "strings of unsigned bytes"... then 'eq' works fine.

I think he means cmp, not eq. The answer is, you can't unless you install a
locale that provides appropriate collating functions. cmp invokes strcmp
(correct me if I'm wrong) which uses char which actually means signed char.
   $ perl -e 'print "\x80" cmp "\x7F", "\n";'
   -1

The fact that 
  $ perl -V
  Compiler:
    stdchar='unsigned char'
notwithstanding :-(



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

Date: Fri, 04 Apr 1997 17:00:07 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Where is the FAQ list?
Message-Id: <334728a2.6081761@news>

On Thu, 03 Apr 1997 08:29:05 -0500, Allen May <allenm@lexis-nexis.com> wrote:

>I just picked up the camel book and there is a reference to
>a FAQ on comp.lang.perl.misc.  I didn't see it listed here...
>I whent to www.perl.com/perl/faq and didn't have much luck.
>Can someone re-post it so I can take a look?
>
There is one at http://www.perl.com/perl/nmanual/pod/perlfaq.html


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

Date: Fri, 04 Apr 1997 17:00:01 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Wildcards for a list of filenames
Message-Id: <33451ece.3565347@news>

On 3 Apr 1997 15:29:40 GMT, jhamlin@ai.uga.edu (Jon Hamlin) wrote:

>I have a pattern for filenames (say, *.bak) which is user specified (so
>it's not hard coded into the Perl code).  Is there a way to take this and
>get a list of files that match that pattern using readdir and grep?  I'm
>at a loss since the regular expressions in Perl wouldn't really see *.bak
>the same way the shell would -- Perl would really want .*bak or something 
>similar, right?
I came accross a similar problem to this when writing a wildcarded rename command that
used File::Find to go through subdirectories, this is how I solved the problem of
generating a regex:

$filename = '*.bak'
$filename =~ s#([^\w\?\*])#\\$1#g;
$filename =~ s#\*#\(\.\*\)#g;
$filename =~ s#\?#\(\.\)#g;
print $filename . "\n";


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

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

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