[7570] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1196 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 19 14:07:07 1997

Date: Sun, 19 Oct 97 11:00:32 -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           Sun, 19 Oct 1997     Volume: 8 Number: 1196

Today's topics:
     Can I use DBM in windows NT ???? (B.S.LEE)
     Re: Date to integer (Toutatis)
     Re: Date to integer (Toutatis)
     Re: Date to integer (Mike Stok)
     Faked Messages Re: Cancel messages <lfoste1@gl.umbc.edu>
     help on Win32odbc(perl) (Connie Wang)
     Re: help on Win32odbc(perl) <Jan@chipnet.cz>
     How do I collect email address using perl? (guess)
     Include a file <nicolas.vasic@infoboard.be>
     Include files <nicolas.vasic@infoboard.be>
     Re: Include files (Toutatis)
     Re: Most efficient way to parse large text files (Tad McClellan)
     Re: Newbie Climbing the Walls! (Tad McClellan)
     Re: Perl for NT (Greg Zevin)
     qw not working as expected (beginner problem) <spectre@mousebyte.com>
     Re: qw not working as expected (beginner problem) (Daniel S. Lewart)
     Re: qw not working as expected (beginner problem) (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: Reading from an already-open file (Nem W Schlecht)
     Re: Reading from an already-open file (Andrew M. Langmead)
     Re: setuid doesn't change UID's? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     syscall tp Hp-UX pstat (C)
     Re: untie warning when using MLDBM module (Jeff Stampes)
     Web page greeking tool - has anyone done this? (Mark)
     WebSite: How to get Perl to execute in Browser <deb.schmid@mindspring.com>
     What's wrong with my script ???? (B.S.LEE)
     wwwboard.pl & cookies <MKronsbein@pop-stuttgart.net>
     wwwboard.pl & cookies <MKronsbein@pop-stuttgart.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Oct 1997 03:26:19 GMT
From: bslee@pl.jaring.my (B.S.LEE)
Subject: Can I use DBM in windows NT ????
Message-Id: <62cuuh$ngd@news2.jaring.my>

	
Usually, DBM(Database Management) is used under UNIX system. But my
web server is WindowsNT 4.0. So, can I use DBM to maintain a database
server under WindowsNT 4.0.  I personally don't want to use SQL or MS
Assess because I just want to maintain a small size of web database.
If anybody have any good suggestions, please help me.





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

Date: 19 Oct 1997 11:45:10 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Date to integer
Message-Id: <toutatis-ya023180001910971345120001@news.euro.net>

tessnrand@aol.com (TessnRand) wrote:

> I'm programming an AppZ under Linuxthat will handle dates.
> The thing I would like to do is to is to convert the date to an integer.
> 
> Ex: 
> Mon Oct 13 22/58:13 MET DST 1997
> 
> would be converted into:
> 
> 19971310

The ParseDate module combined with the localtime function should
do what you want.

#!/usr/bin/perl -w
use strict;
use Time::ParseDate;

my $date = 'Mon Oct 13 22/58:13 MET DST 1997';
my ($y,$m,$d) = (localtime(parsedate($date)))[5,4,3];
$y += $y > 69 ? 1900 : 2000;
for($m,$d){$_ = "0".$_ if /^\d$/}
print "$y$m$d\n";

-- 
Toutatis


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

Date: 19 Oct 1997 11:50:44 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Date to integer
Message-Id: <toutatis-ya023180001910971350470001@news.euro.net>

In article <01bcd819$94abcb80$0101a8c0@sexytop>, "Philippe CADIC"
<ccadic@cadic.com.REMOVE.THIS.NOSPAM> wrote:

> I'm programming an AppZ under Linuxthat will handle dates.
> The thing I would like to do is to is to convert the date to an integer.
> 
> Ex: 
> Mon Oct 13 22/58:13 MET DST 1997
> 
> would be converted into:
> 
> 19971310

The ParseDate module combined with the localtime function should
do what you want.

#!/usr/bin/perl -w
use strict;
use Time::ParseDate;

my $date = 'Mon Oct 13 22/58:13 MET DST 1997';
my ($y,$m,$d) = (localtime(parsedate($date)))[5,4,3];
$y += $y > 69 ? 1900 : 2000;
for($m++,$d){$_ = "0".$_ if /^\d$/}
print "$y$m$d\n";

-- 
Toutatis


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

Date: 19 Oct 1997 17:03:32 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Date to integer
Message-Id: <62deh4$ahi@news-central.tiac.net>

In article <toutatis-ya023180001910971345120001@news.euro.net>,
Toutatis <toutatis@_SPAMTRAP_toutatis.net> wrote:

>my ($y,$m,$d) = (localtime(parsedate($date)))[5,4,3];
>$y += $y > 69 ? 1900 : 2000;

You should just need to add 1900 to the year returned by localtime, see
the perlfunc man page which includes

       localtime EXPR
               Converts a time as returned by the time function
               to a 9-element array with the time analyzed for
               the local time zone.  Typically used as follows:

                   #  0    1    2     3     4    5     6     7     8
                   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

               All array elements are numeric, and come straight
               out of a struct tm.  In particular this means that
               $mon has the range 0..11 and $wday has the range
               0..6 with sunday as day 0.  Also, $year is the
               number of years since 1900, that is, $year is 123
               in year 2023.

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Fri, 17 Oct 1997 11:28:49 -0400
From: "A Long Time Ago In A Galaxy Far, Far Away...." <lfoste1@gl.umbc.edu>
To: Brendan O'Dea <bod@compusol.com.au>
Subject: Faked Messages Re: Cancel messages
Message-Id: <Pine.SGI.3.95.971017112257.6680A-100000@umbc9.umbc.edu>

On 17 Oct 1997, Brendan O'Dea wrote:

As one of the moderators for Rec.Games.Mecha, I'm posting this to let
everyone know that rgm@eyrie.org is the moderation address for the
newsgroup. If your messages are being cancelled, I'd suggest that you
track the headers instead of the From: line.
Any cancellation messages that look like they are coming from rgm are
being faked and should be handled appropriately.

> Any particular reason why these messages of mine were cancelled by you
> that I should be aware of?
> 
>   Subject: Re: goto &NAME on a method?
>   Date: 15 Oct 1997 05:07:23 GMT
>   Newsgroups: comp.lang.perl.misc
>   Cancelled By: rgm@eyrie.org
> In fact it would appear that your ``Usenet Cancel Engine (UCE)'' had
> quite a field day in comp.lang.perl.misc on the 16th of October,
> cancelling at least 474 messages in that group.
> 
> Since your cancel messages do not contain the original subject, From
> field, !cyberspam! path or any reason for the cancel it is rather
> difficult to judge whether these messages were sent due to broken
> software or malicious intent.

You can assume that whoever is faking the messages is doing it out of
malicious intent.

Linwood Foster

--
Legal Warning: ANYONE sending me unsolicited/commercial/
junk/spam E-mail will be charged a $500-US Proof-Reading Fee.  
DO NOT send unsolicited advertisements, and DO NOT add my 
E-mail addresses to your list(s):
	
Linwood J. Foster, III. 2nd Lieutenant (RRF) | Jerome of Loyal | Direwolf 
Ex-V. President. UMBC Anime Society   | Send All Legitimate Mail To:
President. Laugh, Inc. c.1985-1997    | lfoste1@umbc.edu   <*>
Gamesmaster and Mecha Extraordinaire  | http://www.gl.umbc.edu/~lfoste1
<a href="http://www.gl.umbc.edu/~lfoste1">Linwood</a>

If you have any questions about this Legal Warning, I suggest that you
read the following URL: http://www.gl.umbc.edu/~lfoste1/spamoff.htm 



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

Date: Sun, 19 Oct 1997 10:47:27 GMT
From: c0w0461@unix.tamu.edu (Connie Wang)
Subject: help on Win32odbc(perl)
Message-Id: <3449e527.58659097@news.tamu.edu>

I use win32odbc(perl) and MS Access to process a form from WWW. The
problems are:
1. The value of radio box or checkbox can not be added (inserted) to
Access database. Why?
2. If I leave a textbox blank, the all information from the Form
cann't be added to the Access database. Why?

Thanks.
Connie


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

Date: Sun, 19 Oct 1997 15:34:02 -0700
From: Jan Krynicky <Jan@chipnet.cz>
To: Connie Wang <c0w0461@unix.tamu.edu>
Subject: Re: help on Win32odbc(perl)
Message-Id: <344A8ADA.5289@chipnet.cz>

Connie Wang wrote:
> 
> I use win32odbc(perl) and MS Access to process a form from WWW. The
> problems are:
> 1. The value of radio box or checkbox can not be added (inserted) to
> Access database. Why?
> 2. If I leave a textbox blank, the all information from the Form
> cann't be added to the Access database. Why?
> 
> Thanks.
> Connie

ad 1. If you do not check a checkbox, the item is not sent at all.
so "INSERT (name,check) VALUES ('$QUERY{checkbox}' , $QUERY{checkbox}) "
is interpolated to 
"INSERT (name,check) VALUES ('some text' , )" whis is not a correct SQL.
You have to set $QUERY{checkbox} to zero if it's not defined.

	$QUERY{checkbox} = '0' unless defined $QUERY{checkbox}; 

Also, I'm not sure what value does the client send if the checkbox is
checked. Make sure it sends some value that may be inserted into
the database. <INPUT type=checkbox value='1' ...> or something.

About the radio box, use value parameter for all the <OPTION>s
so that all the values are propper data.


ad 2. Try to print out the SQL statement before you execute it.
There may be some silly syntactic error. Or maybe the table simply
doesn't allow this item to be empty. Check it's definition.

HTH, Jenda


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

Date: 18 Oct 1997 15:40:06 GMT
From: 56160@udel.edu (guess)
Subject: How do I collect email address using perl?
Message-Id: <62al8m$7pv@news.jhu.edu>

This is for a school project.
Your help is greatly appreciated.



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

Date: 19 Oct 1997 16:25:00 GMT
From: "Nicolas Vasic" <nicolas.vasic@infoboard.be>
Subject: Include a file
Message-Id: <01bcdcb3$e6b660e0$2bc24ac3@desk>

Hello,

I'm new in programming with Perl 5. I try to write CGIs with CGI.pm.

Can somebody help me to resolve this problem ?

I wish to make my CGIs answer in different langages as they receive the
param : 'lang=fr', or 'lang=en', and so on.

So I wrote files : fr.lex, en.lex ... which contain all the sentences, like
this:

fr.lex

$sentence1 = "Bonjour $name";
$sentence2 = "Au revoir $name";

and en.lex

$sentence1 = "Hello $name";
$sentence2 = "Good bye $name";

and my CGIs contain:

   $lang = $query->param('lang');

   if ($lang eq 'en') {require ("en.lex");  }
   elsif ($lang eq 'nl') {require ("nl.lex"); }
   elsif ($lang eq 'fr') {require ("fr.lex"); }
   else {require ("$local.lex"); $lang = "$local";}

I have the problem that only the sentences read at first by the instruction
"require" are returned correctly, and all the scalar variables given by the
CGI itself are unknown. 

Could someone give me the good way ?

Nicolas



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

Date: 19 Oct 1997 15:14:57 GMT
From: "Nicolas Vasic" <nicolas.vasic@infoboard.be>
Subject: Include files
Message-Id: <01bcdca9$e5ef9a00$LocalHost@desk>

Hello,

I'm new in programming with Perl 5. I try to write CGIs with CGI.pm.

Can somebody help me to resolve this problem ?

I wish to make my CGIs answer in different langages as they receive the
param : 'lang=fr', or 'lang=en', and so on.

So I wrote files : fr.lex, en.lex ... which contain all the sentences, like
this:

fr.lex

$sentence1 = "Bonjour $name";
$sentence2 = "Au revoir $name";

and en.lex

$sentence1 = "Hello $name";
$sentence2 = "Good bye $name";

and my CGIs contain:

   $lang = $query->param('lang');

   if ($lang eq 'en') {require ("en.lex");  }
   elsif ($lang eq 'nl') {require ("nl.lex"); }
   elsif ($lang eq 'fr') {require ("fr.lex"); }
   else {require ("$local.lex"); $lang = "$local";}

I have the problem that only the sentences read at first by the instruction
"require" are returned correctly, and all the scalar variables given by the
CGI itself are unknown. 

Could someone give me the good way ?

Nicolas


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

Date: 19 Oct 1997 17:33:36 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Include files
Message-Id: <toutatis-ya023180001910971933370001@news.euro.net>

Nicolas Vasic (nicolas.vasic@infoboard.be) wrote:

> Hello,
> 
> I'm new in programming with Perl 5. I try to write CGIs with CGI.pm.
> 
> Can somebody help me to resolve this problem ?
> 
> I wish to make my CGIs answer in different langages as they receive the
> param : 'lang=fr', or 'lang=en', and so on.
> 
> So I wrote files : fr.lex, en.lex ... which contain all the sentences, like
> this:
> 
> fr.lex
> 
> $sentence1 = "Bonjour $name";
> $sentence2 = "Au revoir $name";
> 
> and en.lex
> 
> $sentence1 = "Hello $name";
> $sentence2 = "Good bye $name";
> 
> and my CGIs contain:
> 
>    $lang = $query->param('lang');
> 
>    if ($lang eq 'en') {require ("en.lex");  }
>    elsif ($lang eq 'nl') {require ("nl.lex"); }
>    elsif ($lang eq 'fr') {require ("fr.lex"); }
>    else {require ("$local.lex"); $lang = "$local";}
> 
> I have the problem that only the sentences read at first by the instruction
> "require" are returned correctly, and all the scalar variables given by the
> CGI itself are unknown. 
> 
> Could someone give me the good way ?

I'd suggest the following approach:

make your lex files like this:
filename: fr.lex
start:Bonjour <name>
end:Au revour <name>
filename en.lex:
start:Hello <name>
end:Goodbye <name>

let your script start with:
#/usr/bin/perl -w
use strict;

my @languages = qw(en fr nl);
my $dir = '/path/to/your/lex/files';

my (%lex,$lang,$file,$key,$line);
foreach $lang(@languages){
   $file = "$dir/$lang.lex";
   open (F, $file) or die "cannot open $file: $!";
   while (<F>){
      chomp;
      ($key,$line) = split /:/,$_,2
      $lex{$lang}->{$key} = $line;
   }
   close(F);
}
my $cgi = new CGI;
my %replace = (name => $cgi->param('name'),
               host => $cgi->remote_host()); #ectera
                
sub compose {
   my $key = shift;
   my $line = $lex{$cgi->param('language')||'en'}->{$key};
   $line =~ s/<(.*?)>/$replace{$&}/eg;
   $line;
}

Then in the rest op your scripts you can merrily say:
compose('start'); 
to get a line in the proper language, (defaulting to english)
and tags substituted.
I did not test this code, so it may still contain bugs.
Good luck with it.

-- 
Toutatis


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

Date: Sun, 19 Oct 1997 07:33:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Most efficient way to parse large text files
Message-Id: <uluc26.a95.ln@localhost>

Thomas Munn (munn@bigfoot.com) wrote:
: Here is the code for the previous post:

: So Far, it is just supposed to turn this line:
: Thu Oct 16 00:00:15 EDT 1997
: and turn it into 10/16/97 (which it does)

: I ran it on the HUGE textfile (300+K) and the intrepreter kept cycling:
                                 ^^^^^

That isn't really that big. Substantial, but not what I would call "huge".


: Use of uninitialized value at monthchanger.pl line 28, <> chunk 5.
:     
: Code Follows:

: #!/usr/bin/perl -w
: while (<>) {
:      if (/Mon|Tue|Wed|Thu|Fri|Sat|Sun|/) {
:           @fields = split(/ /,$_);


   die "'$_' does not contain 6 fields\" unless @fields == 6;


:           $DayOfMonth=$fields[2];
:           $Year= $fields[5];
:           $Year =~ s/19//; 
                       ^^
                       ^^

   Your program will break in about 26 months...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Sun, 19 Oct 1997 07:43:29 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newbie Climbing the Walls!
Message-Id: <h9vc26.1a5.ln@localhost>

Rick Freeman (Rick@MarinWeb.com) wrote:
: I'm pretty new at this, but I feel like I've really looked this code
: over.  Still, it doesn't work. I don't think the pattern in the IF
: statement is matching -- even when I expect it to.

: Please show me the error of my ways -- I've wasted a lot of time with
: this already!

:     foreach $line (@file) {
:         if (/<!--$id-->/o) {
              ^^^^^^^^^^^

Philip already pointed out what is wrong here.

Even after that is fixed:


[
   $id is assigned a value only once in your entire script, right?

   If not, then you probably can't use m//o.

   But you did *not* use s///o ...
]


:             $line =~ s/<!--$id-->.*<!--f-->/<!--$id-->$copy<!--f-->/;
:             print FILE "$line";
                         ^     ^
                         ^     ^
Those double quotes don't do anything, except maybe slow down comprehension
of the code by a maintenance programmer.


:             $changescheck = 1;
               ^^^^^^^^^^^^

It may well be that *nothing* was changed. You didn't check the
return value from s///...


:         }
:         else {
:             print FILE "$line";
:         }
:     }


I think you can replace the whole thing above with this:

# Untested!

foreach $line (@file) {
   $changescheck=1 if $line =~ s/<!--$id-->.*<!--f-->/<!--$id-->$copy<!--f-->/;
   print FILE $line;
}


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 16 Oct 1997 10:53:20 +1000
From: greg@turing.une.edu.au (Greg Zevin)
Subject: Re: Perl for NT
Message-Id: <623oi0$q8u@turing.une.edu.au>

"Glen Kaatz" <gkaatz1@nycap.rr.com> writes:

>Can anyone direct me to where I can get a non-TARd Perl for Win NT? 
>Please, please,please help.

>Thanks in advance for your help.
>Glen Kaatz (GKaatz@Nycap.rr.com)

I thought that activeware releases of perl were zipped rather than tared?

try www.activeware.com

Greg



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

Date: 19 Oct 1997 08:17:56 GMT
From: "Chris Ray" <spectre@mousebyte.com>
Subject: qw not working as expected (beginner problem)
Message-Id: <01bcdc67$67fce360$6f5f0e26@fsu.edu.fsu.edu>

Hello all.

I am not only a beginner at Perl, but at programming in general, so please
be gentle.

I've just started working through the llama book, and I'm a little confused
at the error message I'm getting when I attempt to run the script on page
8, in the section introducing arrays. Here is the entire code:


	#!/usr/bin/perl -w
	@words = qw(camel llama alpaca);
	print "What is your name? ";
	$name = <STDIN>;
	chop ($name);
	if ($name eq "Randal") {
	    print "Hello, Randal! How good of you to be here!\n";
	} else {
	    print "Hello, $name!\n";
	    print "What is the secret word? ";
	    $guess = <STDIN>;
	    chop ($guess);
	    $i = 0;
	    $correct = "maybe";
	    while ($correct eq "maybe") {
	        if ($words[$i] eq $guess) {
	            $correct = "yes";
	        } elsif ($i < 2) {
	            $i = $i + 1;
	        } else {
	            print "Wrong, try again. What is the secret word?";
	            $guess = <STDIN>;
	            chop ($guess);
	            $i = 0;
	        }
	    }
	}



The error I get when I run this is


	syntax error in file secret.pl at line 2, next 2 tokens "qw("
	Execution of secret.pl aborted due to compilation errors.


Now, if instead of

	@words = qw(camel llama alpaca);

I substitute

	@words = ("camel", "llama", "alpaca");

everything works fine.

I'm running on Perl version 4.0 on a UNIX system, and I've also tried it
under Linux (I can't get to the Perl version on that system right now--the
hard drive is not in the machine). Both systems respond the same way.

Have I missed something in this file? I had a problem with "chomp" earlier,
which was fixed by substituting "chop" in its place. Is there a similar
problem with "qw" that I haven't found? Can anyone tell me why it isn't
working as expected?


Thanks,

Chris



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

Date: 19 Oct 1997 08:47:07 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: qw not working as expected (beginner problem)
Message-Id: <62cheb$3nc$1@vixen.cso.uiuc.edu>

"Chris Ray" <spectre@mousebyte.com> writes:

> ...
> I'm running on Perl version 4.0 on a UNIX system, and I've also tried it
> under Linux (I can't get to the Perl version on that system right now--the
> hard drive is not in the machine). Both systems respond the same way.
> ...

Perl 4.036 has been obsolete for three years.  If 'perl5' doesn't work,
contact your sysadmin.  If your sysadmin won't install perl5, find
a competent ISP.  Below is an excerpt from perlfaq(1).

Daniel Lewart
d-lewart@uiuc.edu
-------------------------------------------------------------------------------
      Which version of Perl should I use?

      You should definitely use version 5.  Version 4 is old, limited, and
      no longer maintained; its last patch (4.036) was in 1992.  The most
      recent production release is 5.004.  Further references to the Perl
      language in this document refer to this production release unless
      otherwise specified.  There may be one or more official bug fixes for
      5.004 by the time you read this, and also perhaps some experimental
      versions on the way to the next release.
-------------------------------------------------------------------------------


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

Date: Sun, 19 Oct 97 11:16:09 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: qw not working as expected (beginner problem)
Message-Id: <344a2474$2$ofn$mr2ice@speaker>

In <01bcdc67$67fce360$6f5f0e26@fsu.edu.fsu.edu>, on 10/19/97 at 08:17 AM,
   "Chris Ray" <spectre@mousebyte.com> said:
+-----
| I'm running on Perl version 4.0 on a UNIX system
+--->8

You need Perl 5 for that to work.  Some Linux distributions (especially older
ones) ship with Perl 4 by default and Perl 5 an option, invoked under the name
"perl5".

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                 KF8NH
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org
Memo to MLS:  End The Burn Scam --- Doug Logan MUST GO!  FORZA CREW!



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

Date: 19 Oct 1997 03:43:05 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: Reading from an already-open file
Message-Id: <62ch6p$74d@abattoir.cc.ndsu.nodak.edu>

[courtesy copy e-mailed to author(s)]

In comp.lang.perl.misc, John Goerzen  <jgoerzen+usenet@complete.org> wrote:
>
>I have a situation where a program will invoke my script with file
>descripter 3 pre-opened to a certain file that I need to write to.
>Under C, I could simply do write(3, ....) and it would work.
[deletia]
>already open.  Is there a way to assign an already-open file
>descriptor to a Perl file handle?  Or, is there a way to read from and
>write to a file descriptor without using a Perl file handle?

Well, you still have to open() it, but you *can* still use the file
descriptor.

$perldoc -f open
 ....

   If you specify "<&=N", where N is a number, then Perl will do an
   equivalent of C's fdopen() of that file descriptor; this is more
   parsimonious of file descriptors. For example:

       open(FILEHANDLE, "<&=$fd")

 ....

then after this, you could do:

print FILEHANDLE "blah\n";

etc.

-- 
Nem W Schlecht                  nem@plains.nodak.edu
NDUS UNIX SysAdmin         http://www.nodak.edu/~nem
"Perl did the magic.  I just waved the wand."


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

Date: Sun, 19 Oct 1997 16:09:03 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Reading from an already-open file
Message-Id: <EIB3J3.Ftu@world.std.com>

John Goerzen <jgoerzen+usenet@complete.org> writes:

>I have a situation where a program will invoke my script with file
>descripter 3 pre-opened to a certain file that I need to write to.
>Under C, I could simply do write(3, ....) and it would work.

You can dup the opened file descriptor and associate it with a
filehandle.

    open (FD3, '>&3') or die;
    syswrite FD3, $data, length $data;

This one is really hidden in the perlfunc man page. After it talks
about the "<", ">", etc. prefixes to the second argument. After it
talks about piping to another process. After it talks about maybe
needing binmode() if appropriate for your operating system. After some
examples of open() using the previous info. Then they tell you about
the "&" special character on the second argument.

-- 
Andrew Langmead


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

Date: Sun, 19 Oct 97 11:18:02 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: setuid doesn't change UID's?
Message-Id: <344a251f$3$ofn$mr2ice@speaker>

In <34492279.601450C6@blank.pages.de>, on 10/18/97 at 10:56 PM,
   "Ingo L|tkebohle" <ingo@blank.pages.de> said:
+-----
| I'm using the POSIX module setuid and setgid calls to change to the UID and
| GID of a setuid-root script to those of a user. When I look at $UID and $GID
| (with use English), the correct values appear. But when I try to open a file
| which I shouldn't be able to open, it still works! When I
+--->8

You missed the distinction between "real" and "effective" UID/GID.  You're
changing the *real* UID/GID, but setuid sets the *effective* uid/gid to root;
the effective UID/GID override the real ones.

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                 KF8NH
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org
Memo to MLS:  End The Burn Scam --- Doug Logan MUST GO!  FORZA CREW!



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

Date: Wed, 15 Oct 1997 10:34:13 -0700
From: "Frank Paturzo (C)" <fgp@cup.hp.com>
Subject: syscall tp Hp-UX pstat
Message-Id: <3444FE95.5F53@cup.hp.com>

Greetings.

I need a way in to determine a CPU's idle time on an HP-UX 10.x system.
I could use top, but I would rather use something a little closer to OS
internals. I was told pstat is the way to go, but I have been trouble
getting the syscall right.

Has anyone done this before?
Is there a better way?

Thanks,
frank


-- 
----------------------------------
Frank Paturzo
email: fgp@cup.hp.com
voice: (408)447-2771
FAX:   (408)447-4244


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

Date: 19 Oct 1997 13:45:15 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: untie warning when using MLDBM module
Message-Id: <62d2tb$fuu$1@neocad.com>

Gerben_Wierda@RnA.nl wrote:
: 	tie %::gorddb, 'MLDBM', $::gorddb_name, O_RDONLY, 0640 or warn $!;
: 	untie attempted while 1 inner references still exist at ./gord.pl 
: line 284.

: I like to reload this database at a certain point. Might this be because I am 
: doing this in an interrupt handler?

It wouldn't surprise me.  Signal handlers can be tricky...you never
know what internal functions were interrupted, or wht state the
stack is in.  Conventional Wisdom is to tnever do anything more
complicated than set a flag and return it in a signal handler.

Jeff

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


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

Date: Sun, 19 Oct 1997 11:39:33 -0600
From: Junge@supernews.com (Mark)
Subject: Web page greeking tool - has anyone done this?
Message-Id: <B06FA1F5966835ADE5@mg-20425422-56.ricochet.net>

I need to greek (replace real text with nonsense words) a few of my Web
sites, so I can display examples of my work without releasing clients'
proprietary information.

I was thinking of using perl, since it does wonderfully with find/replace. 
However, I am a complete perl beginner, and thus would love to get input
from some experienced folks before I re-invent the wheel or write something
absolutely stupid.

I need the tool to execute two major actions, I think - one for
machine-coded HTML (ie docs translated from MSWord, etc) and one for
hand-coded HTML (the assumption being that the formatting apporach won't
alway sbe standard.

For the machine-translated HTML where formtting should be standard, I need
the tool to find "<p>" and "</p>" marks and change every word there to some
random word from a Latin text, skipping HTML tags (anything between "<" and
">" as well as JavaScript (anything between "<script" and "</script>", the
line-break sequence "<p>&nbsp;</p>" and (unfortunately...) anything between
Cold Fusion Tags (a whole library of <CFIF></CFIF>,<CFQuery></CFQuery> and
so on).


For hand-coded HTML where code might use the old "<br>" instead of the
"<p></p>", I'd need the tool to simple change everything to random Latin
words that wasn't HTML, JavaScript, "<p>&nbsp;</p>", or between Cold Fusion
tags.

It seems like such  script must be relatively easy to write, if you truly
know what you are doing (which, clearly I don't) - and perhaps, considering
all the Web designers out there, it's already been done.

Any feedback would be greatly appreciated!

Cheers,
			

	Mark




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

Date: Sun, 19 Oct 1997 22:18:05 -0400
From: Deborah Jean Schmid <deb.schmid@mindspring.com>
Subject: WebSite: How to get Perl to execute in Browser
Message-Id: <344ABF5D.703A@mindspring.com>

Howdy all.
I have WebSite 1.1 running under Win95 and I can't get
my perl scripts to run in the browser.  I have the file
type (.pl) opening with build 307 (CPAN).  When I click
on a script in Explorer, an ms-dos window pops up briefly
and I can see the expected output.

I checked the registry and I have the following set:

HKEY_LOCAL_MACHINE\SOFTWARE\ActiveWare\Perl5 
  Default   "D:\dyanJen\Perl\bin"
  BIN       "D:\dynaJen\Perl\bin"
  COMSPEC   "D:\dynaJen\Perl\bin"
  HTML-DOCS "D:\dynaJen\Perl\docs"
  PRIVLIB   "D:\dynaJen\Perl\lib"

Not to mention the whole slew of items set by WebSite:

HKEY_LOCAL_MACHINE\SOFTWARE\Denny\WebServer\CurrentVersion
  A zillion things here from the server properties (I presume).

I have a feeling I'm missing something simple, but I've read
FAQ's and such until my eyes are sore.

Any ideas?  Or, if there is a list of explicit steps one must
take to get Perl to run, could you point me in that direction?

Thanks.
Tom Schmid


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

Date: Mon, 20 Oct 1997 07:56:21 GMT
From: bslee@pl.jaring.my (B.S.LEE)
Subject: What's wrong with my script ????
Message-Id: <62deou$rco@news2.jaring.my>

I have written a perl cgi script and I try to test it on my server but
it can't run. I really can't figure out what's wrong with my script. I
keep getting the error message as below:-

Can't modify subtraction in scalar assignment at
C:\WebShare\wwwroot\cgi-bin\test1.pl line 13, near "$value;"Execution
of C:\WebShare\wwwroot\cgi-bin\test1.pl aborted due to compilation
errors..

Below is my script:-



if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        @pairs = split(/&/, $buffer);
        foreach $index (0..$#pairs)
        {
                ($name1, $value) = split(/=/, $pairs[$index] , 2);
                $value =~ tr/+/ /;
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/eg;
                print "$name1 <br> ";
                print "$value <br> ";
                
                $regis-data{$name1}=$value;

        }
}

print <<"abc";

<html>
<body>
$buffer
<p>
@pairs
<p>
%regis-data
</body>
</html>

abc


Please can anybody help me to figure it out .



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

Date: Sun, 19 Oct 1997 17:29:05 +0200
From: Mark Kronsbein <MKronsbein@pop-stuttgart.net>
Subject: wwwboard.pl & cookies
Message-Id: <344A2741.DC21F764@pop-stuttgart.net>

I've a prob: i use the wwwboard and all works fine. now i want to use
the cookie option and it doesnt work! i have the cookie.lib but i dont
know how to configure it!

I hope anybody can help me. 

Mark


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

Date: Sun, 19 Oct 1997 17:29:23 +0200
From: Mark Kronsbein <MKronsbein@pop-stuttgart.net>
Subject: wwwboard.pl & cookies
Message-Id: <344A2753.64E1A318@pop-stuttgart.net>

I've a prob: i use the wwwboard and all works fine. now i want to use
the cookie option and it doesnt work! i have the cookie.lib but i dont
know how to configure it!

I hope anybody can help me. 

Mark


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

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

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