[15670] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3084 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 18 06:10:39 2000

Date: Thu, 18 May 2000 03:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958644617-v9-i3084@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 18 May 2000     Volume: 9 Number: 3084

Today's topics:
    Re: my cgi script <gellyfish@gellyfish.com>
    Re: my cgi script <amcguigan@pinesoft.co.uk>
    Re: Newbie Question - find command in Perl <you.will.always.find.him.in.the.kitchen@parties>
        Object Oriented Perl Question baccou@my-deja.com
        Parsing a mail digest <woofer@thenut.eti.pg.gda.pl>
    Re: Passing Hash to Subroutine using Keys <gellyfish@gellyfish.com>
    Re: Perl Module Install Problems <bill.kemp@wire2.com>
    Re: Perl on 98 <gellyfish@gellyfish.com>
        problem for Perl coorperating with DLL <wstsoi@hongkong.com>
        Proxy authentication solution CPAN module <rjbragg@my-deja.com>
        Reading from file <marko.nikulainen@etela-savo.com>
    Re: Reading from file <scott@salmon.ltd.uk>
    Re: regex mind bender (for me) <billy@arnis-bsl.com>
    Re: Sendmail? <gellyfish@gellyfish.com>
    Re: suid problem under Solaris 2.7 <elaine@chaos.wustl.edu>
    Re: suid problem under Solaris 2.7 <gellyfish@gellyfish.com>
    Re: suid problem under Solaris 2.7 <you.will.always.find.him.in.the.kitchen@parties>
    Re: tracking the memory <iltzu@sci.invalid>
        Use/Require Difference <scott@salmon.ltd.uk>
    Re: using Net::Telnet without escape characters <gellyfish@gellyfish.com>
    Re: weirdness with symbol ref and new version of perl <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 18 May 2000 08:12:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: my cgi script
Message-Id: <8g054o$8mi$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 09:35:05 +0100 Andrew McGuigan wrote:
> All is going well so far with my web Form. I just need the code that
> collects the information on the Form and sends it to the server. That's
> all for the moment.
> 

And the question is ?

/J\
-- 
Mmmm, forbidden donut.
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 09:53:00 +0100
From: Andrew McGuigan <amcguigan@pinesoft.co.uk>
Subject: Re: my cgi script
Message-Id: <3923AF6C.70D7E0D7@pinesoft.co.uk>

there's no question as such, unless i could say,  now i know this may sound
simple, but i think i must be missing something here,
You see i just need the code (perl) that collects the info on the Form and
then writes it to a file on the server.That all. The bit i really like is
writing a Visual Basic App to process the file.

Andrew
Jonathan Stowe wrote:

> On Wed, 17 May 2000 09:35:05 +0100 Andrew McGuigan wrote:
> > All is going well so far with my web Form. I just need the code that
> > collects the information on the Form and sends it to the server. That's
> > all for the moment.
> >
>
> And the question is ?
>
> /J\
> --
> Mmmm, forbidden donut.
> --
> fortune oscar homer



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

Date: Thu, 18 May 2000 21:38:02 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: Newbie Question - find command in Perl
Message-Id: <958642651.139373@shelley.paradise.net.nz>


"Kevin Bass" <akil1@mindspring.com> wrote in message
news:8fv50q$45i$1@slb6.atl.mindspring.net...
> How does the following Unix command translate into Perl:
>
> find . -name 'samp*' -exec <command>
>

In addition to the other answers, look at find2perl (part of the standard
distribution)




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

Date: Thu, 18 May 2000 09:54:16 GMT
From: baccou@my-deja.com
Subject: Object Oriented Perl Question
Message-Id: <8g0ek4$jqg$1@nnrp1.deja.com>

Hi,

I have a question about Object Oriented programming using perl. My
question is: "How do I perform a 'cast' (like in C++) to transform an
instance in another class?".

Let's take an example:

I have an instance myShape of the class Shape. I want to transform this
instance into a specialized object Circle in order to perform the method
Circle::SetCenter(x, y).

In C++, I would write:
  myCircle = (Circle) myShape;
  myCircle->SetCenter(10, 10);

How can I do the cast (Cirlce) in Perl?

Thank you for your help,

Serge.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 May 2000 06:56:19 GMT
From: Bernard El-Hagin <woofer@thenut.eti.pg.gda.pl>
Subject: Parsing a mail digest
Message-Id: <8g046j$oja$1@sunrise.pg.gda.pl>

Hello,

	I'm trying to write a script which will do some funky stuff
with e-mail, but what I need to do first is take an e-mail digest and
store all of the headers in one array (@headers, perhaps?) and all of
the bodies in another (@bodies sounds like a good choice). For those
of you who may not know a header is everything from the pattern 
/^From\s/ to the frist empty line and the body is everything else.
I've managed to get the headers into an array, but I can't get the bodies.
Here's what I've got (btw, I'm sure there are modules that do this sort
of stuff, but I can't use them for this script):

-----------------
#!/blah/blah/blah/perl -w
use strict;

open (IN, "< $ARGV[0]") or die "A horrible death: $!\n";

$i = 0;
$j = 0;

while (<IN>){
	if (/^From\s/ .. /^$/){ #in the header
		if ($_ =~ /^$/){
			$i++;
		}
		else{
			$headers[$i] .= $_;
		}
	}
	else{	#if we're not in the header we're in the body
		$bodies[$j] .= $_;
		$j++;
	}	
}
-----------------
What this does is create an array @headers of which each element is
a seperate header and it creates the array @bodies which contains only
one line (the first line of the first header). Could someone please tell
me what I'm doing wrong?

Thanks very much,
Bernard


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

Date: 18 May 2000 07:53:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Passing Hash to Subroutine using Keys
Message-Id: <8g041g$52u$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 17:18:21 GMT mgray@wallacefloyd.com wrote:
> How do I pass this hash %infoformat to the subroutine called printit. I
> dont get any errors but the print statement only prints a :. Can this
> be done using foreach $keys (keys .....
> 
> # assign master hash (%infoformat) from from info hash
> while (($fieldname) = each (%infoformat)){
> 	while (($i,$j) = each(%info)) {
> 		if ($fieldname eq $i) {
> 			$infoformat{$fieldname} = $j;
> 		}
> 	}
> }
> 
> 
> #call printit
> &printit (\$infoformat);
> 
> # print hash that is sent to it
> sub printit {
> 	%y = $$_[0];
> 	foreach $key (keys %y) {
> 		print $key . ": " . $y->{$key} . "\n";
> 	}
> }
> 

I would run this with the '-w' switch and 'use strict' and fix the
problems they point out in the first instance - then read the perlsub
manpage to find how you might pass a hash to a subroutine.

/J\
-- 
Son, this is the only time I'm ever gonna say this. It is not okay
to lose.
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 09:04:13 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Perl Module Install Problems
Message-Id: <958637142.19872.0.nnrp-06.c3ad6973@news.demon.co.uk>

OS, version numbers etc. please

Gabe wrote in message <8funj3$c7r$1@news.service.uci.edu>...
>I'm trying to install DBI. I get the following error upon running Make:
>
>make: *** No rule to make target `blib/arch/auto/DBI/Driver.xst', needed by
>`Perl.xsi'.  Stop.
>
>What does this mean and what do I do?
>
>Gabe
>
>




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

Date: 18 May 2000 07:03:39 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl on 98
Message-Id: <8g013r$r4t$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 17:39:41 GMT amerar@my-deja.com wrote:
> 
> 
> Simple question.  I've never used Perl under Windows 98 before.  How the
> heck are you aupposed to get the system date?  Can't seem to figure that
> one out.......
> 

Type :

   perldoc -f localtime

at your command prompt.

/J\
-- 
D'oh!!!
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 13:38:04 +0800
From: "Lucas" <wstsoi@hongkong.com>
Subject: problem for Perl coorperating with DLL
Message-Id: <8fvvcb$sd$1@justice.csc.cuhk.edu.hk>

Cut from ActivePerl document:

>The number of elements in the list specifies the number of parameters, and
each element in the list specifies the type of an argument; allowed types
are:

>I: value is an integer
>N: value is a number (long)
>P: value is a pointer (to a string, structure, etc...)

>Our function needs two parameters: a number (DWORD) and a pointer to a
string (LPSTR):
>$GetTempPath = new Win32::API("kernel32", "GetTempPath", [N, P], ...

If the DLL got a fuction that a string would be passed, nut not I, N, P
How could I do then?

Thank you!!




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

Date: Thu, 18 May 2000 09:20:17 GMT
From: Myself <rjbragg@my-deja.com>
Subject: Proxy authentication solution CPAN module
Message-Id: <8g0ck7$htt$1@nnrp1.deja.com>

After playing for a day or so I have got my Perl on Solaris to speak
through an authenticating proxy.  Can't guarenttee if this is the best
solution or will always work but it seems to for me.

You may have to manually pull down and install some stuff first.

I have given sort of pseudo code, line numbers very appox

1)Edit UserAgent.pm in the LWP module in sub mirror (around line 555)

my $tmpfile = "$file-$$";

# proxy authentication code added
if (proxy authenication flag is set true) {
     $request->proxy_authorization_basic(userid,password);
}
# end of new code

my $response = $self->request($request,$tmpfile);

2)Edit CPAN.pm in sub localize (around line 2010)

replace the proxy seting lines starting with my($var) with

$Ua->proxy(['http','ftp'] => 'http://mast-cc0-sp01:8080');

3)Check you settings
$ perl -MCPAN -e shell
cpan> reload index


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 18 May 2000 12:52:03 +0300
From: "Marko Nikulainen" <marko.nikulainen@etela-savo.com>
Subject: Reading from file
Message-Id: <7ZOU4.120$p57.4213@read2.inet.fi>

Is this code correct?

#!/usr/bin/perl

use CGI;
$query = new CGI;

$user = $query->param('user');
$password = $query->param('password');

$file = '.passwd';

open (PASSWD, $file) or die "Can't open $file. ($!)\n";
while (<PASSWD>)
{
($loguser, $logpass)= split(":", $_);
}
close (PASSWD);
if (($loguser eq $user) && ($logpass eq $password))
{
Print "Content-type: text/html\n";
print "blaa blaa blaa...\n";
}
else
{
Print "Content-type: text/html\n";
Print "blaa blaa blaa...\n";
}

And that .passwd -file contains only test:test.
It always print out that else { blaa blaa blaa }.
Where is the problem? Reading from file or reading user input?




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

Date: Thu, 18 May 2000 10:56:37 +0100
From: "Scott Pritchett" <scott@salmon.ltd.uk>
Subject: Re: Reading from file
Message-Id: <8g0eor$adj$1@lure.pipex.net>

You may need to 'chomp' your file data before the 'split'.


"Marko Nikulainen" <marko.nikulainen@etela-savo.com> wrote in message
news:7ZOU4.120$p57.4213@read2.inet.fi...
> Is this code correct?
>
> #!/usr/bin/perl
>
> use CGI;
> $query = new CGI;
>
> $user = $query->param('user');
> $password = $query->param('password');
>
> $file = '.passwd';
>
> open (PASSWD, $file) or die "Can't open $file. ($!)\n";
> while (<PASSWD>)
> {
> ($loguser, $logpass)= split(":", $_);
> }
> close (PASSWD);
> if (($loguser eq $user) && ($logpass eq $password))
> {
> Print "Content-type: text/html\n";
> print "blaa blaa blaa...\n";
> }
> else
> {
> Print "Content-type: text/html\n";
> Print "blaa blaa blaa...\n";
> }
>
> And that .passwd -file contains only test:test.
> It always print out that else { blaa blaa blaa }.
> Where is the problem? Reading from file or reading user input?
>
>




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

Date: Thu, 18 May 2000 07:56:24 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: regex mind bender (for me)
Message-Id: <8g07n3$d1g$1@nnrp1.deja.com>

In article <Pine.GHP.4.21.0005172342320.3970-100000@hpplus03.cern.ch>,
  "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> On Wed, 17 May 2000, Ala Qumsieh wrote:
>
> > Ilja <billy@arnis-bsl.com> writes:
> >
> > > P.S. Never trust a user - may be he is a HaCkEr.
> >
> > Hackers are not necessarily bad people.
>
> I think the context was deliberately case-sensitive.
>
> :-}
>

Yes!

'Hacker' ne 'HaCkEr'

(perldoc perlop for more details ;-)))






Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 May 2000 07:02:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sendmail?
Message-Id: <8g011a$qrk$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 17:35:14 GMT Marcus wrote:
> I am using Matt's cgi script to send a form via email. It used to work fine
> on my old
> server but now I am having the weirdest thing happen to me on my new
> dedicated server (Red Hat Linux 6.1). The script will send out to any email
> address like: hell@hello.com or hi@hi.ca but when you try and send to
> something like: hello@mindlink.bc.ca or hello@sk.sympatico.ca it won't send.
> I have verified the email address' I am trying to send to and it they work
> otherwise. Any suggestions on where the problem lies or how I can fix it?
> 

There's probably a bug in the program.  What happens when you send a 
message to 'foo@tackleway.co.uk' - my guess is that it wont work.

/J\
-- 
Dear Baby, Welcome to Dumpsville. Population: You
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 04:09:37 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <B548E540.43F9%elaine@chaos.wustl.edu>

in article Pine.GSO.4.10.10005171010250.25459-100000@user2.teleport.com, Tom
Phoenix at rootbeer@redcat.com quoth:

> Maybe your Solaris installation is broken, and lacks the /dev/fd
> directory, or the proper entries in that directory? If you're not sure,
> though, you'll probably need an expert on Solaris.

If Solaris can't find /dev/fd you'll be fixin' to be havin' a few more
problems than a setuid script. :)  Read 'perldoc perlsec' and your default
build *should* have built a Perl capable of suid, but stranger things have
been known to happen on Solaris.

I don't like suid root scripts. I prefer to make either create an admin
group and make certain files writeable for that group or use sudo. Security
is really more about common sense than it is about following a recipe.

e.



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

Date: 18 May 2000 07:59:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <8g04ch$671$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 16:25:30 GMT riglerej@my-deja.com wrote:
> 
> Now, as of a few months ago, I was running PERL 5.004.  It was an
> installation put in before I began working at my job.  IMHO, it was a
> botched installation, so I decided to upgrade to 5.005_3, and try to
> install it properly.  Everything has gone beautifully, except that a
> SUID root script I wrote no longer works properly.
> 

In what way does it no longer work properly ? 

/J\
-- 
Woohoo!! See that boy, your old man was right, not Flanders, we are
doomed! In your face, Flanders!!
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 21:29:22 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <958642131.5987@shelley.paradise.net.nz>


<riglerej@my-deja.com> wrote in message news:8furvi$ro9$1@nnrp1.deja.com...
> In article <3922CD92.7236F5E9@walgreens.com>,
>   "Andrew N. McGuire" <andrew.mcguire@walgreens.com> wrote:
> > [ posted & mailed ]
> >
> > riglerej@my-deja.com wrote:
> > >
> > > Before I get hundreds of responses telling me that writing suid
> scripts
> > > is BAD, I will just say that I am very aware of the potential
> problems,
> > > and trust my own programming skills to create a simple, secure
> script
> > > for modifying my /etc/group file.
> >
> > What is wrong with groupadd, groupmod, and groupdel?
> > You will find them on both Solaris and Linux.
> >
>
>
>
> If you know of a way for an ordinary user to use these, I would be very
> indebted to you for the information, but I've not seen a way to do this
> to my satisfaction.  I suppose I could make these commands suid, but I
> think that would definitely open up some security problems.  My program
> limits the ability to modify the /etc/group file solely to the first
> user listed for that group, and only allows them to change entries for
> that specific group.  I don't think groupmod is capable of anything like
> this.

Grab a copy of sudo or super from http://sunfreeware.com/
They allow a normal user to run specified privileged commands.




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

Date: 18 May 2000 07:02:52 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: tracking the memory
Message-Id: <958632640.21067@itz.pp.sci.fi>

In article <392322da$1_4@goliath.newsfeeds.com>, Baris wrote:
>I am using a hash to check and avoid duplicates.
>I am initializing this hash in  the beginning of each loop and clearing at
>the end. At each loop, this hash grows to about 1000 keys. Unfortunately
>undef %hash;
>doesn't mean that memory is returned to the OS.
>from Perlfaq("How can I free an array or hash so my program shrinks?")
>But perl is supposed to reuse that memory, right? My feeling is that, for
>arrays, it does, but for hashes, if your new hash has different keys, the
>old memory doesn't seem to be reused???

Could you try to isolate the problem to a small program, less than a
dozen or so lines, that does nothing except demonstrate the leak?  If
you can, please post it here so we can try it.  If you can't, the
problem may in fact be in one of the parts you removed.

I already tried something like that, but, as expected, the following
code does _not_ leak any memory at least on perl 5.004_04:

  while (++$i) {
      undef %hash;
      for (1..1000) {
          $hash{$i.(" "x1024).$_}++;
      }
      sleep 1;
  }

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 18 May 2000 10:33:48 +0100
From: "Scott Pritchett" <scott@salmon.ltd.uk>
Subject: Use/Require Difference
Message-Id: <8g0dj7$9mo$1@lure.pipex.net>

I know this may be wrong but... I needed to have a way of inserting perl
code from a common file which was not a subroutine, so I have :-

    #!perl -w
    use strict;
    $::x=5;
    use isb;
    print "x is $::x\n";
    exit;

In isb  :-

    $::x=4;
    print "in isb x is $::x\n";

This returns :-

    in isb x is 4
    x is 5

When I replace the 'use' with 'require' I get what I expected, namely :-
    in isb x is 4
    x is 4

Why?!






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

Date: 18 May 2000 07:30:34 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: using Net::Telnet without escape characters
Message-Id: <8g02ma$ks$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 17:24:37 GMT bahram22@my-deja.com wrote:
> 
> I am using Net::telnet on ActivePerl on an WIN NT PC.  I was wondering
> if there is a setting or an option that will turn off the escaper
> character sequences and have a normal stream output.  For example, if I
> do a 'dir', I like to get a clean output stream with the dir listing
> only, and no escape sequences present.

Its down to whatever is on the other end I'm afraid.

/J\
-- 
You never know when an old calendar might come in handy. Sure, it's not
1985 right now, but who knows what tommorow will bring. And these TV
Guides, so many memories. Gomer upset's Sgt. Carter. I'll never forget
that episode.
-- 
fortune oscar homer


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

Date: 18 May 2000 07:28:52 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: weirdness with symbol ref and new version of perl
Message-Id: <8g02j4$9q$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 17:36:48 GMT riglerej@my-deja.com wrote:
> In Perl 5.004 I had something like the following...
> 
>   use strict;
>   use vars qw($F);
>   $F = "/some/file";
>   #
>   # Lock the output file. This returns a filehandle
>   #
>   my $OUT = lock($F);
>   print $OUT "Some text here\n";
> 
> 
> "lock" is a subroutine that sets up a temporary file, and looks like
> this...
> 
>   sub lock {
> 
<snip>
> 
> I think this has something to do with how I return the filehandle from
> the "lock" subroutine, but I'm not sure. Any ideas, suggestions?  I am
> far from a Perl guru, so please don't hesitate to dummy up your answer,
> I won't be offended!
> 

It had me for a second too.  Change the name of the lock() subroutine.

/J\
-- 
All right, brain. You don't like me and I don't like you, but let's just
do this and I can get back to killing you with beer.
-- 
fortune oscar homer


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 3084
**************************************


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