[10350] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3943 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 10 15:07:14 1998

Date: Sat, 10 Oct 98 12:00:22 -0700
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, 10 Oct 1998     Volume: 8 Number: 3943

Today's topics:
        $ENV{'HTTP_REFERER'} HELP <brant@webnautics.com>
    Re: $ENV{'HTTP_REFERER'} HELP (Matthew Bafford)
    Re: anyone got a rtf->html converter in perl? <flavell@mail.cern.ch>
        Authentication against NT <Steffen.Geschke@erlf.siemens.de>
        Broken CPAN Module.  IO modules no longer compile <cc047@ecs.pc.cranfield.ac.uk>
    Re: Broken CPAN Module.  IO modules no longer compile (Alastair)
    Re: bug in this subroutine <psdspss@execpc.com>
    Re: CGI perl book <brian@innovtech.com>
    Re: DBM File (Ronald J Kimball)
        File Permissions UNIX and NT <mortimer@renc.igs.net>
    Re: Fun with Arrays of Hashes <garry@america.net>
    Re: Fun with Arrays of Hashes (Ronald J Kimball)
    Re: Fun with Arrays of Hashes <garry@america.net>
    Re: Help Needed with Perl Script & PMWHO (Joergen W. Lang)
    Re: How do I use die? (Matthew Bafford)
    Re: How do I use die? <brettr@centuryinter.net>
    Re: How do I use die? (Larry Rosler)
    Re: How do I use die? <jeff@vpservices.com>
    Re: HTML extract problem (Kay Molkenthin)
        Question about locking files (Serial # 0)
        sort with dynamic sort expression help <jnn@serv1.jump.net>
    Re: sort with dynamic sort expression help (Larry Rosler)
    Re: sort with dynamic sort expression help (Ronald J Kimball)
    Re: Syntax error <psdspss@execpc.com>
    Re: WANTED: experienced web developers <syzygy@seanet.com>
        What do you need to run perl? <doe#m#_john@mmac.is.lmsc.lockheed.com>
        win 32 system() woes <brian@innovtech.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 10 Oct 1998 12:23:03 -0400
From: Brant <brant@webnautics.com>
Subject: $ENV{'HTTP_REFERER'} HELP
Message-Id: <361F89E6.20DBFC09@webnautics.com>

Hey,

	I have compiled apache so it will use RefererLogs, but the
$ENV{'HTTP_REFERER'} variable in PERL still does not work on my server.
I'm runnign Linux 5.01 and Perl 5.004_04.
	If anyone can tell me what I'm doing wrong, PLEASE help. I have down
loaded 5.005_02 but I am unsure how to compile and load it, and I'm
unsure what I can screw up on my server.  I have root access, and can do
most anything on the server. Any help would be gratefull!!
	Please e-mail me with your suggestions:
mailto:brant@webnautics.com

Thank You,
Brant


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

Date: Sat, 10 Oct 1998 13:06:38 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: $ENV{'HTTP_REFERER'} HELP
Message-Id: <MPG.10895e2b6b10d78c9896d1@news.scescape.net>

In article <361F89E6.20DBFC09@webnautics.com> on Sat, 10 Oct 1998 
12:23:03 -0400, Brant (brant@webnautics.com) pounded in the 
following text:
=> Hey,
=> 
=> 	I have compiled apache so it will use RefererLogs, but the
=> $ENV{'HTTP_REFERER'} variable in PERL still does not work on my server.
=> I'm runnign Linux 5.01 and Perl 5.004_04.
=> 	If anyone can tell me what I'm doing wrong, PLEASE help. I have down
=> loaded 5.005_02 but I am unsure how to compile and load it, and I'm
=> unsure what I can screw up on my server.  I have root access, and can do
=> most anything on the server. Any help would be gratefull!!

Sounds like your server isn't doing what you want it to.  First 
place I'd check is the documentation for the server.

Also, try running this CGI script:

#!/usr/bin/perl -w

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

foreach ( sort keys %ENV ) {
     printf "%-40s == %s\n", $_, $ENV{$_};
}
__END__

=> Thank You,

Hope This Helps!

=> Brant

--Matthew


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

Date: Sat, 10 Oct 1998 16:53:44 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: anyone got a rtf->html converter in perl?
Message-Id: <Pine.HPP.3.95a.981010165134.19813C-100000@hpplus01.cern.ch>

On Thu, 8 Oct 1998, Avshi Avital wrote:

> Chris Denman wrote in message <361cc9cb.0@norbert.cerbernet.co.uk>...
> >anyone got a rtf->html converter in perl?
> >
> >If not I'll code one myselft (not looking forward to it, really!)
> 
> if working in win95, you could load the doc in Word - which will cvrt to
> .doc. and then save as html

You call _that_ HTML??  No thanks.

Off-topic: I use rtftohtml, but it isn't written in perl.



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

Date: Sat, 10 Oct 1998 19:22:10 +0200
From: Steffen Geschke <Steffen.Geschke@erlf.siemens.de>
Subject: Authentication against NT
Message-Id: <361F97C2.27EFA63A@erlf.siemens.de>

Hello,

I am looking for a module or function which implements
authentication against NT. I've checked Win32:AdminMisc's
UserCheckPassword, but it wouldn't work at our site, because
password's are not allowed to match the x(th) prvious password
to force the user changing it after a while.

Does somebody know if there is a NT API function and even better,
somebody implemented this feature using a perl wrapper?!

Any help is very much appreciated.

Thanks for your time and help

Steffen


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

Date: Sat, 10 Oct 1998 18:32:22 +0100
From: Jeffrey Goldberg <cc047@ecs.pc.cranfield.ac.uk>
Subject: Broken CPAN Module.  IO modules no longer compile
Message-Id: <Pine.LNX.4.02.9810101822460.5569-100000@arpad.thegreen.private>

On Red Hat 5.0 Linux 2.0.32, perl version 5.004_01 I have managed to
load some modules off of CPAN so that my CPAN module no longer works.

In particular

$ perl -MCPAN -e shell
IO object version 1.20 does not match $ 1.15 at /usr/lib/perl5/i386-linux/5.00401/DynaLoader.pm line 172.
BEGIN failed--compilation aborted at /usr/lib/perl5/i386-linux/5.00401/IO/Seekable.pm line 50.
BEGIN failed--compilation aborted at /usr/lib/perl5/i386-linux/5.00401/IO/File.pm line 111.
BEGIN failed--compilation aborted at /usr/lib/perl5/CPAN.pm line 26.
BEGIN failed--compilation aborted.

Using 'r' in -MCPAN shell last night, I grabbed a few new packages as
recommended, one of them was IO.

Do I just need to install a more recent version of DynaLoader?

Obviously something isn't working well.  Any suggestions about
what to do an how to do it.  I would appreciate an answer by Email.
I will summerize to c.l.perl.misc.  If this is not the correct
place to ask, or if this is answered in some FAQ, please let me
know.  I have taken a quick look that the FAQs, but didn't find
anything appropriate.


-j

--
Jeffrey Goldberg                +44 (0)1234 750 111 x 2826
 Cranfield Computer Centre      FAX         751 814
 J.Goldberg@Cranfield.ac.uk     http://WWW.Cranfield.ac.uk/public/cc/cc047/
Relativism is the triumph of authority over truth, convention over justice.



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

Date: Sat, 10 Oct 1998 18:04:17 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Broken CPAN Module.  IO modules no longer compile
Message-Id: <slrn71vc54.7l.alastair@calliope.demon.co.uk>

Jeffrey Goldberg <cc047@ecs.pc.cranfield.ac.uk> wrote:
>On Red Hat 5.0 Linux 2.0.32, perl version 5.004_01 I have managed to
>load some modules off of CPAN so that my CPAN module no longer works.

This stuff has bitten me in the past. You could try just re-compiling CPAN (or a
newer version).

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Sat, 10 Oct 1998 12:50:32 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: bug in this subroutine
Message-Id: <6vo64m$a8v@newsops.execpc.com>

A few points to note :
1. Dont post the same question thrice.
2. do subroutine form is deprecated.
3. Use the string comparison operators like eq, ne for comparing strings.
    So, where you are writing ($str[$x] == "adjective"),
      write ($str[$x] eq "adjective").
4. There is no built in case statement in perl. But, u can build one like this
    SWITCH :  #just a label
   {
        if  (/^abc/) { $abc = 1; last SWITCH;}
        if  (/^def/)  { $def  = 1; last SWITCH;}
        $nothing = 1;
    }
    Read page 104 of Perl Programming by Larry Wall, Tom Christiansen, Randal
Schwartz

4. If  you have problems like this, run perl with -d option to debug your script
    perl -d x.pl
   (Once you are in debugger, type "h h" for help)

5. There is no built in case statement in perl. But, u can build one like this
    SWITCH :  #just a label
   {
        if  (/^abc/) { $abc = 1; last SWITCH;}
        if  (/^def/)  { $def  = 1; last SWITCH;}
        $nothing = 1;
    }
    Read page 104 of Perl Programming by Larry Wall, Tom Christiansen, Randal
Schwartz
6. READ PERL FAQ.
    http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html

Hope that helps.

Deva
zobsky@my-dejanews.com wrote:

> Hi, all out there,
>
> I am trying to construct a language parser but am being held up by this kind
> of bug. This segment of code and the associated subroutine analyses
> thecontents of an array @str.
>
> I first point to the first member of the array (noun) I then call the
> subroutine (for case np1 defined by the string $next). I intend for the
> subroutine to  goto case noun but it seems to go the case adjective ( $x is
> incremented in the output)
>
> Can anyone help me debug this tiny piece of code,please????
>
> Also, could someone show me how to impliment case structure in perl, i'm
> guessing it
> might be a more robust solution, but my text makes no mention of case
> structures.
>
> Help much appreciated
>
> Vinay B.
> balamuru@cs.unt.edu
>
> #code starts here
>
> $next = "np1";
> $x = 0;
>
> @ str = ("noun", "noun2", "noun");
>
> print "initially, next is $next and x is $x and str() points to $str[$x] \n";
>
> do &np1($str[$x], $x, $next);
>
> print "finally, next is $next and x is $x and str() points to $str[$x]\n";
>
> sub np1
> {
>     if ($next ne "np1")
>     {
>         $next;
>     }
>     else
>     {
>         if ($str[$x] == "adjective")        #case adjective
>         {
>             $x++;
>             $next = "np1";
>         }
>         elsif ($str[$x] == "noun")        #case noun
>             {
>             $next = "np2";
>         }
>         else
>         {
>             $next = "fail";
>         }
>     }
> }
>
> #code ends here
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own





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

Date: Sat, 10 Oct 1998 10:24:21 +0100
From: "Brian" <brian@innovtech.com>
Subject: Re: CGI perl book
Message-Id: <6vo59g$d30$1@nntp2.ba.best.com>

It's not only an excellent book on CGI, but also Perl programming techniques
in general.

The ISBN is: 0-471-24744-8.
Get it from Amazon.com. They will have it on your dor step in two days!

-Brian M
www.innovtech.com


madame philosophe wrote in message <361ECCE3.818CC15C@mkt2mkt.com>...
>
>
>dave@mag-sol.com wrote:
>> nguyen.van@imvi.bls.com wrote:
>
>> > >
>> > > Hi guys,
>> > >
>> > > I want to know which book is the excellent one for Perl CGI. I want
to buy
>> one so that I can write CGI scripts.
>> > >
>> > > Thanks
>> > > Van
>> > >
>>
>> Shisir's book is looking a little dated now (no mention of CGI.pm for
>> example). A new edition (renamed to 'CGI Programming with Perl') is
listed on
>> the O'Reilly web site as being published in January.
>>
>> In the meantime, you might also look at Licoln Stein's 'Official Guide to
>> Programing with CGI.pm' pbulished by Wiley (I think!)
>>
>> hth,
>>
>> Dave...
>>
>
>I think you must already know that I am a big CGI.pm fan.  I would second
that
>the 'Official Guide'  is the best CGI book I've found to date.
>
>check out:
>http://www.wiley/compbooks/stein
>
>There, the book's sample source is available for free if you'd rather not
buy the
>book.
>




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

Date: Sat, 10 Oct 1998 12:44:40 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: DBM File
Message-Id: <1dgoo9o.tgdhx2qj87woN@bos-ip-1-98.ziplink.net>

[posted and mailed]

Gavin <gaving@enter.net> wrote:

> I am using a multi level hash table

> When I put this in a DBM file I can not access the "2nd branch"
> I would get an error saying use of an unitialized value.

>From the perltie documentation:

BUGS

  ...

   **You cannot easily tie a multilevel data structure (such as a hash
   of hashes) to a dbm file.**  The first problem is that all but GDBM
   and Berkeley DB have size limitations, but beyond that, you also have
   problems with how references are to be represented on disk.  One
   experimental module that does attempt to address this need partially
   is the MLDBM module.  Check your nearest CPAN site as described in in
   the perlmodlib manpage for source code to MLDBM.

   [my emph]

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 10 Oct 1998 13:40:52 -0400
From: Bob Mortimer <mortimer@renc.igs.net>
Subject: File Permissions UNIX and NT
Message-Id: <361F9C23.21E801F8@renc.igs.net>

Hi Isabell & others

> results to be written in a hidden file


I too am at the stage of wanting some info placed into a file

I have done this with in  UNIX (BSDI, FreeBSD) and understand that the
owner must give permission for files to be accessed. There were answers
to your question showing the UNIX permission proceedures. Understanding
permissions is a must. Also learn about ownership ( owner, group, ALL )
in UNIX is a must.

One answer mentioned an NT FTP chmod command.   Does one exist?  MY
WS-FTP reports that CHMOD may not work as the system I am dealing with
is an NT server.

The  ftp-log reports an error "500 'SITE CHMOD 755': command not
understood"  when attempting to change permissions on the NT server.

My script takes an environmental varialbs and attempts to put them into
a data file.

 sub log {

	if (! open(LOG,">>$logfile")) {
		print "Content-type: text/html\n\n";
		print "Couldn't open $logfile\n";
		exit;
	}
	print "$ENV{'REMOTE_HOST'}.\n";	
	close (LOG);
	}

The above causes the error essage to be returned.

I tested this script with the following:

 sub html {
	print "Content-type: text/html\n\n";
	print "<html><title></title><body>\n";
	print "$ENV{'REMOTE_HOST'}.\n";	
	print "</body></html>\n";
	}


The proper HTML file is sent bach to my browser.


My Question is....

ONly having FTP access to the server, how can I change permissions?

Does the administrator of the NT server have to set up permissions for a
file to be able to be used in this manner?


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

Date: Sat, 10 Oct 1998 16:10:55 GMT
From: "Garry T. Williams" <garry@america.net>
Subject: Re: Fun with Arrays of Hashes
Message-Id: <361F875D.486F1341@america.net>

[Copied to poster]

	#!/opt/perl/bin/perl -w
	use strict;

	my @array;
	#my %hash;
	my $var1 = 'one';
	my $var2 = 'two';

	#  Here's your original: 

	#$array[0] = (%hash = ('var1',$var1,'var2',$var2) );

	#  Original source was missing ending quote (').
	#  This actually assigns a list to the scalar 
	#  $array[0].  That (in this case) results in the 
	#  value of $var2 being assigned to $array[0] -- the
	#  last item in the list.  

	#print $array[0]->{$hash}->{'var1'}, "\n";

	#  How did $hash get any value assigned?  

	#  Here's the way to do what I think you want to do: 

	$array[0] = { var1 => $var1, var2 => $var2 };

	#  This assigns a reference to an anonymous hash to 
	#  the scalar $array[0].  If you want to work with a 
	#  named hash, take a reference to it and assign that 
	#  to $array[0].  E.g., 
	#
	#    $array[0] = \%hash;  

	print $array[0]->{var1}, "\n";

	#  Either way (anonymous or named), you then can 
	#  dereference using the above.  

Now, run, don't walk, to perldoc perldsc.  

-Garry Williams

Darren Greer wrote:
> 
> Howdy.....Ive got an aray of hashes...and am trying to print one of
> hte values in one of the hashes.....for example:
> 
>         $array[0] = (%hash = ('var1',$var1,'var2,$var2) );
> 
> Now I want to print 'var1' from the hash.......how do I do it....I
> looked through the camel...and cant seem to figure it out...I tried
> this:
> 
>         $array[0]->{$hash}->{'var1'}
> 
> But it does not seem to work......any help would be
> appreciated......thanks,


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

Date: Sat, 10 Oct 1998 12:44:41 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Fun with Arrays of Hashes
Message-Id: <1dgoodk.124rfx23gpvnkN@bos-ip-1-98.ziplink.net>

Garry T. Williams <garry@america.net> wrote:

>   my @array;
>   #my %hash;
>   my $var1 = 'one';
>   my $var2 = 'two';
> 
>   #  Here's your original: 
> 
>   #$array[0] = (%hash = ('var1',$var1,'var2',$var2) );
> 
>   #  Original source was missing ending quote (').
>   #  This actually assigns a list to the scalar 
>   #  $array[0].  That (in this case) results in the 
>   #  value of $var2 being assigned to $array[0] -- the
>   #  last item in the list.  

Actually, $array[0] gets 4, the number of items in the list.

Which seems odd, because

$scalar = ('var1', $var1, 'var2', $var2);

assigns the value of $var2 to $scalar, and

%hash = ('var1', $var1, 'var2', $var2);
$scalar = %hash;

assigns '2/8' (2 buckets used out of 8 allocated in %hash) to $scalar.


But either way, it wasn't what the original poster intended.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 10 Oct 1998 18:04:53 GMT
From: "Garry T. Williams" <garry@america.net>
Subject: Re: Fun with Arrays of Hashes
Message-Id: <361FA215.4DCCAC6A@america.net>

Ronald J Kimball wrote:
> 
> Garry T. Williams <garry@america.net> wrote:
> 
> >   #$array[0] = (%hash = ('var1',$var1,'var2',$var2) );
> >
> >   #  Original source was missing ending quote (').
> >   #  This actually assigns a list to the scalar
> >   #  $array[0].  That (in this case) results in the
> >   #  value of $var2 being assigned to $array[0] -- the
> >   #  last item in the list.
> 
> Actually, $array[0] gets 4, the number of items in the list.

Yup.  You're right.  The reason is that this is an *array* assignment --
not a *list* assignment as I had thought.  (I didn't actually print the
value of the assignment before posting.  Tsk, tsk.)  

> Which seems odd, because
> 
> $scalar = ('var1', $var1, 'var2', $var2);
> 
> assigns the value of $var2 to $scalar, and

Here, a *list* assignment.  

> %hash = ('var1', $var1, 'var2', $var2);
> $scalar = %hash;
> 
> assigns '2/8' (2 buckets used out of 8 allocated in %hash) to $scalar.

As defined.  From perldata: 

     If you evaluate a hash in a scalar context, it returns a
     value which is true if and only if the hash contains any
     key/value pairs.  (If there are any key/value pairs, the
     value returned is a string consisting of the number of used
     buckets and the number of allocated buckets, separated by a
     slash.  ...

The poster used $scalar = (%hash = (...));  I think that this is an
array assignment because of the second assignment.  (I couldn't find
this in perldata, but I didn't look too hard.)  I still feel like this
is fuzzy to me.  I seem to know it when I see it, but I can't seem to
define it.  For example, $scalar = (@array); will get the number of
elements in @array.  The parentheses in $scalar = (%hash); don't do
anything.  

> But either way, it wasn't what the original poster intended.

Well, at least I got that part right.  :-)

-Garry Williams

> --
>  _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
> ( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
>     /                                  http://www.ziplink.net/~rjk/
>         "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 10 Oct 1998 17:40:00 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Help Needed with Perl Script & PMWHO
Message-Id: <1dgp09g.8jatyy1d32a00N@host012-210.seicom.net>

Greg Lunar <gluniz@3dws.com> wrote:

> We have a Livingston PM3 and the PMWHO script connects to the PM3 and gives
> an output of who is online.  What I am trying to do is work with another
> script that I got from a friend that is supposed to use PMWHO to get a list
> of who is online and then checks to see if there are any multiple logins,
> and if there are any, it will e-mail us with the output showing who was
> logged in more than 1 time.  Can anyone help us?
> 
> I have attached the script to this message.

<snipped uuencoded stuff>

$plain = unpack "u*", $your_script;
for a start.

hth,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Sat, 10 Oct 1998 13:01:33 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How do I use die?
Message-Id: <MPG.10895cf4daf94df09896d0@news.scescape.net>

In article <6vo153$s9m$1@newsread1-mx.centuryinter.net> on Sat, 
10 Oct 1998 11:12:59 -0500, brettr (brettr@centuryinter.net) 
pounded in the following text:
=> I'm using the command line perl -w test.cgi to execute this program now. I
=> have also included the $! so I will capture the error string. Here's first
=> part of the script I'm running using die():
=> #!/usr/bin/perl
=> chdir('/user/printer') or die("$!");
=> print "Content-type: text/html\n\n";
=>    print "<HEAD>\n";
=> 
=> The script will run fine if I do not include or die("$!"). What did I do
=> wrong here?
=> 

The code looks fine, so try three things:

1) Add a -w to the #! line.
2) Replace the or with || (you may be running an older version of 
   perl)
3) Check perl -v.  You should be running Perl5.

=> Thanks,

HTH,

=> brettr

--Matthew


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

Date: Sat, 10 Oct 1998 11:12:59 -0500
From: "brettr" <brettr@centuryinter.net>
Subject: Re: How do I use die?
Message-Id: <6vo153$s9m$1@newsread1-mx.centuryinter.net>

I'm using the command line perl -w test.cgi to execute this program now. I
have also included the $! so I will capture the error string. Here's first
part of the script I'm running using die():
#!/usr/bin/perl
chdir('/user/printer') or die("$!");
print "Content-type: text/html\n\n";
   print "<HEAD>\n";

The script will run fine if I do not include or die("$!"). What did I do
wrong here?

Thanks,
brettr




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

Date: Sat, 10 Oct 1998 10:34:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I use die?
Message-Id: <MPG.10893a94dee70cc99898ab@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6vo153$s9m$1@newsread1-mx.centuryinter.net> on Sat, 10 Oct 
1998 11:12:59 -0500, brettr <brettr@centuryinter.net> says...
> I'm using the command line perl -w test.cgi to execute this program now. I
> have also included the $! so I will capture the error string. Here's first
> part of the script I'm running using die():
> #!/usr/bin/perl
> chdir('/user/printer') or die("$!");
> print "Content-type: text/html\n\n";
>    print "<HEAD>\n";
> 
> The script will run fine if I do not include or die("$!"). What did I do
> wrong here?

When 'die' is invoked, by default it writes to STDERR, which is usually 
directed to your server's error log, not to your browser.  If you do not 
want to get involved with the CGI.pm module, which handles this for you, 
you need to intercept the 'die' and direct its output to the browser, 
with an appropriate MIME-type header.

Put this first in your program:

$SIG{__DIE__} = sub { print "Content-Type: text/plain\n\n", @_; exit };

If your perl is 5.002 or earlier, you will need quotes around the 
'__DIE__'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 10 Oct 1998 17:06:33 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How do I use die?
Message-Id: <361F935C.FEED492F@vpservices.com>

What error message did you get when you ran the script from the commmand
line?  Knowing that is the *only* way to answer your question.

- Jeff

brettr wrote:
> 
> I'm using the command line perl -w test.cgi to execute this program
> now. I
> have also included the $! so I will capture the error string. Here's
> first
> part of the script I'm running using die():
> #!/usr/bin/perl
> chdir('/user/printer') or die("$!");
> print "Content-type: text/html\n\n";
>    print "<HEAD>\n";
> 
> The script will run fine if I do not include or die("$!"). What did I
> do
> wrong here?
> 
> Thanks,
> brettr


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

Date: 10 Oct 1998 15:42:17 GMT
From: molkiheg@sp.zrz.tu-berlin.de (Kay Molkenthin)
Subject: Re: HTML extract problem
Message-Id: <slrn71uvd9.6k.molkiheg@kay.chaos.network>

Jonathan Stowe <gellyfish@btinternet.com> wrote:
>On 9 Oct 1998 23:17:46 GMT Kay Molkenthin <molkiheg@sp.zrz.tu-berlin.de> wrote:
>> Jonathan Feinberg <jdf@pobox.com> wrote:
>>>molkiheg@sp.zrz.tu-berlin.de (Kay Molkenthin) writes:
>>>
>> 
>>>If you'd show us the perl code that's giving you trouble, we'll be
>>>better able to help you.
>> 
As I said I needed an extract/convert script and this part takes 99% of the
script and I am not very experienced in text-pattern search & replace.
>
>You mean you want us to do your work for you when you dont want to go out
>and hire a programmer who can ?

OK, you programming gods out there!

1. This code and the result of the datas is NOT FOR COMMERCIAL USE, so I don't
hire a god to program this and pay god-prices for that.

2. Something that pisses me really on is that most of: admins, programmers,
edp-people are gods from the date they were born. And the best is that:

3. If you REALLY need them to solve a difficult problem the answers are:
	- Sorry, no time
	- OK, i'll make this
	- OK, i'll make this tomorrow, because I have to do more important
	  work to do now (most times this is reading news and email!)

4. So most of the time I take my good old MS VisualBasic and start to make it
by myself. That tooks more time but in the end I have the result I wanted to
have.

5. Same situation in our company. I wonder what we pay them for? That is the
work they HAVE TO DO!

In VB the problem tooks me 1 hour and 40 lines of code but I have my result.
95% of my time I work under Linux so I wanted to solve the problem with perl
under linux. I worked with perl before and did some CGI jobs but have not used
any pattern matching things under perl.

So please excuse my question, go on and flame people who ask for help (if they
ask, most time they REALLY need help), tell them to read the fucking manual
and other documentation... In the end they should be fit with programming BUT:
Do they want to be programmers??? See 5. and tell me what we have to pay
for (that we read everything and in the end do it by ourselves)????????????

OK, start to flame me, *plonk* me but that is the truth from a view of a
non-professional-programmer.

Kay.



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

Date: Sat, 10 Oct 1998 19:00:40 GMT
From: Webchick@Cry.com (Serial # 0)
Subject: Question about locking files
Message-Id: <361faea0.11532993@news.iaehv.nl>

Hello,

I'm making some changes to a script for my own use. I noticed that
the script always locks a file before it reads it! But I think you
should only lock a file when there are more users writing to the
same file. So if your are going to read a file or if you are the only
one writing to a file, then there is no need to lock the file!!
Am I right or do I have it all wrong??


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

Date: 10 Oct 1998 17:19:02 GMT
From: John Newman <jnn@serv1.jump.net>
Subject: sort with dynamic sort expression help
Message-Id: <6vo4u6$duc$1@news.jump.net>


I'm a relative perl newbie, so I apologize in advance if my question
seems screwy.  Basically, I want to be able to have a scalar that 
represents an expression to use for sorting so I can use different
sorts based on command line parameters.  Here's what it should look
like:

$sorteq = "$a cmp $b";

foreach (sort $sorteq keys %hash) { .... }

When I try this I get the error:
Undefined sort subroutine "main::cmp" called at ./2week.pl line 59, <FH> chunk 112.

This seems to indicate it's doing something somewhat close to the
general idea of what I'm trying to get done <g>.

Perl actually segfaults when I try this:
$sorteq = "$a cmp $b";

foreach (sort eval $sorteq keys %hash) { ... }

I realize I'm lacking in some basic concept here.  Any help would be much  
appreciated.

---
John Newman (jnn@jump.net)



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

Date: Sat, 10 Oct 1998 11:12:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sort with dynamic sort expression help
Message-Id: <MPG.1089437c81defdc9898ac@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6vo4u6$duc$1@news.jump.net> on 10 Oct 1998 17:19:02 GMT, John 
Newman <jnn@serv1.jump.net> says...
> I'm a relative perl newbie, so I apologize in advance if my question
> seems screwy.  Basically, I want to be able to have a scalar that 
> represents an expression to use for sorting so I can use different
> sorts based on command line parameters.  Here's what it should look
> like:
> 
> $sorteq = "$a cmp $b";
> 
> foreach (sort $sorteq keys %hash) { .... }
 ...
> foreach (sort eval $sorteq keys %hash) { ... }

If you don't want the default sort, you must use either a block or the 
name of a subroutine.  But don't put the 'eval' in there -- it will be 
incredibly slow to perform the eval on every comparison.

Try something like this:

#!/usr/local/bin/perl -w
use strict;

my $sorteq = '$b cmp $a'; # Your sort comparison -- note single-quotes
                          # to prevent substitution here for $a or $b.

$sorteq =~ s/\$/\\\$/g;   # Protect the dollar signs for the eval.

my $sortsub = eval "sub { $sorteq }"; # Note double-quotes to cause
                                      # substitution here for $sorteq.

# Now 'sortsub' points to the equivalent of your sort comparison.
print sort { &$sortsub } 'a' .. 'z', "\n";

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 10 Oct 1998 14:39:54 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: sort with dynamic sort expression help
Message-Id: <1dgotl4.iaiwz21c7ub4oN@bos-ip-1-54.ziplink.net>

John Newman <jnn@serv1.jump.net> wrote:

> $sorteq = "$a cmp $b";

Double-quotes interpolate.  $a and $b are undefined.  Thus, the value of
$sorteq is " cmp ";

> foreach (sort $sorteq keys %hash) { .... }

Have you read the documentation for sort?

  sort SUBNAME LIST   

    ...

       SUBNAME may be a scalar variable name, in which case the value
       provides the name of the subroutine to use.

So sort thinks you want to use a subroutine named ' cmp ', which, of
course, doesn't exist.


[If you had tried $sorteq = '$a cmp $b', which doesn't interpolate, sort
would have tried to call the subroutine named '$a cmp $b', which also
doesn't exist.]


Here are a few valid ways to specify a sort subroutine:


sub sorteq { $a cmp $b };
sort sorteq keys %hash;

sub sorteq { $a cmp $b };
$sorteq = 'sorteq';
sort $sorteq keys %hash;

sort { $a cmp $b } keys %hash;


Hope that helps!

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 10 Oct 1998 12:52:35 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: Syntax error
Message-Id: <6vo68f$a8v@newsops.execpc.com>

Array subscript notation is square bracket.
So,
$FORM{'sessions'} = $hold(21);
should be
$FORM{'sessions'} = $hold[21];
                                            ^^^
Imran Zalfackruddin wrote:

> Hello:
>
> I have attached a snip of a code. I am getting a syntax error on the
> assignment to the
> FORM array. What is wrong with the code??? Any help would be greatly
> appreciated.
>
> Regards.
> Imran.
>
> --------------------------------------------
> open(IN,"</var/apps/xxxx.dat");
> while(<IN>)                             # For each line of the file:
> {
>    #
>
>   #
>   # SPlit the inputline into its subcomponets
>   # Each line has 40 sub components
>   #
>
>  @hold = split(/:/,$_);
>
>  if(/^#/) { next; }                     # Discard comments.
>
>   $FORM{'sessions'} = $hold(21);       <------- syntax error here
>   $FORM{'expiration'} = $hold(9);
>
> ......





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

Date: Sat, 10 Oct 1998 10:33:02 -0700
From: "Stuart Updegrave" <syzygy@seanet.com>
Subject: Re: WANTED: experienced web developers
Message-Id: <6vo5oo$qts@news.dns.microsoft.com>

WMWilson wrote in message <361EA7E7.2A0B04A5@erols.com>...
:echiu@imservice.com wrote:
<munch>

:> Required Experience:
<munch>
:> Java Script
:
:You'd thinks these people might actually check these newsgroups out
:before posting job offers to them.  Then maybe they'd see the flaming
:happening to one job poster and decide to take the hint.  At least this
:guy _did_ post to misc.jobs.offered though.

well, at least the post does mention JavaScript. I'm amazed at the number of
job posts to CLJ that don't ...

</STUART>




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

Date: Sat, 10 Oct 1998 23:02:13 -0700
From: John Doe <doe#m#_john@mmac.is.lmsc.lockheed.com>
Subject: What do you need to run perl?
Message-Id: <362049E5.34F3@mmac.is.lmsc.lockheed.com>

I would like to distribute perl scripts on a CD to machines that do not
always have it installed. Can most of perl be kept on the CD and only a
small working directory be maintained in the machine running it? Is it
necessary to require a full installation in the machine running the
scripts?

                            chuck.meyers@lmco.com


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

Date: Sat, 10 Oct 1998 10:39:18 +0100
From: "Brian" <brian@innovtech.com>
Subject: win 32 system() woes
Message-Id: <6vo656$ff0$1@nntp2.ba.best.com>

I have read the win 32 faqs, Perl programming guide and the Perl Cook Book
but still can't seem to get this right.

OS = NT 4.0 (not my choice)
Perl Version = 5.005_02

I am trying to use system() to call an executable (not an NT executable)
that I can run easily from a batch file, but can't seem to make it work from
perl. Here is a example of the syntax for the executable:

cmd -arg1 {parameter1} -arg2 {parameter1} -argn {parametern}

Following the suggestions in the perl manual (and others) I try this
approach:

@args = ("cmd", "-arg1 parameter1", "-arg2 parameter2");

system @args;

A dos prompt opens and closes so quickly I can't really see whats happening,
I just know the program isn't running. Grr, I really hate programming on NT,
but I have to.

The funny thing is, I used this same approach on another executable, and it
worked as far as I can tell.


Any suggestions on a good general approach to this type of thing on NT? I
predict that I am going to be doing this alot. I admit I am new to
programming on an NT platform, been spoiled too long on UNIX.

Thank in advance for the help.

-Brian M.










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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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