[17528] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4948 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 22 09:05:36 2000

Date: Wed, 22 Nov 2000 06:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974901911-v9-i4948@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 22 Nov 2000     Volume: 9 Number: 4948

Today's topics:
    Re: [Parse::RecDescent or yacc] question ? raptor555@my-deja.com
        ANNOUNCE: Expect 1.09 RGiersig@cpan.org
        ANNOUNCE: Expect 1.10 RGiersig@cpan.org
    Re: Binding Variables and DBI (Martien Verbruggen)
        die melet@my-deja.com
        Executing own module as root? <meisl@amvt.tu-graz.ac.at>
    Re: Executing own module as root? (Martien Verbruggen)
        Extracting data from a ps command <vivekvp@spliced.com>
    Re: HELP! bring variables out of a subroutine? webbgroup@my-deja.com
    Re: how would you know the no of people accessing a per (Csaba Raduly)
    Re: I am sorry for posting this so many times! (Csaba Raduly)
    Re: Most easy way to get IP from a local NIC by device  mexicanmeatballs@my-deja.com
    Re: need some help with regex (Martien Verbruggen)
    Re: OT:Re: Eurodate mysteries (Martien Verbruggen)
    Re: OT:Re: Eurodate mysteries (Tony L. Svanstrom)
        passing as argument ... <nuno@fccn.pt>
    Re: passing as argument ... nobull@mail.com
    Re: Perl Illiterate (Csaba Raduly)
    Re: Perl question no on form results <anders@wall.alweb.dk>
        Problem with simple del file script jkipp@mbna.com
    Re: Reg Exp Learning? <webmaster@860.org>
    Re: rounding with "printf %f" (Honza Pazdziora)
    Re: rounding with "printf %f" (Martien Verbruggen)
    Re: rounding with "printf %f" (Sander van Gennip)
    Re: rounding with "printf %f" <bart.lateur@skynet.be>
    Re: running a script as root nobull@mail.com
    Re: running a script as root (Martien Verbruggen)
    Re: sybperl CTlib character set <W.Hielscher@mssys.com>
        trouble blessing object <davidwaters@bigfoot.com>
    Re: uploading files over web nobull@mail.com
    Re: using exec cgi in a perl program (Csaba Raduly)
        Using exists with hashes <cloughie@dcs.shef.ac.uk>
    Re: Using exists with hashes <philipg@atl.mediaone.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Nov 2000 13:15:20 GMT
From: raptor555@my-deja.com
Subject: Re: [Parse::RecDescent or yacc] question ?
Message-Id: <8vggt2$ih2$1@nnrp1.deja.com>

hi Terrence,all,
Yes I use Parse::RecDescent.
thanx for the help... the way I presented in my post works .. I
extended it
a bit and now it can handle multiply nested-ops i.e.
for, while, blah etc... :")
I was wondering is this the right way to do it ?
Also I wonder how I can handle following scenario too. Say "for"
operator.

for ..... blah .....
for
   .....balh ....
end

did U see... if the "for" body spans several rows I place "end".
but if the "for" body can be on one row i.e. on the next row I have
another
"keyword" in currnet case another "for" operator
I don't need "end" keyword .
Did U gotcha my idea ?
=====
iVAN
raptor@unacs.bg
=====
> > Curently I'm using something like this :
> >
> > start : 'for' word(s) 'end'
> >
> > word  : ...!'end' ( start | token )
> >
> > token : /\S+/
> >


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


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

Date: Wed, 22 Nov 2000 08:41:25 GMT
From: RGiersig@cpan.org
Subject: ANNOUNCE: Expect 1.09
Message-Id: <t1nbd64spqps60@corp.supernews.com>

Expect v1.09 has been uploaded to CPAN and
Sourceforge (http://sourceforge.net/projects/expectperl/).

This is a bugfix release: exp_before didn't get set on timeout,
the expect call didn't return on matching EOF, spawn didn't
die when exec failed, Expect crashed in certain cases.

I'm sure there are still other bugs, so keep those problem
reports coming!

Yes, I know, the documentation is bad, but I have now started
a new FAQ (Expect_FAQ.pod, in the distribution) that should help
until I find the time to give the docs a complete overhaul.

Roland


NAME

	Expect.pm - Expect for Perl

SYNOPSIS


Expect.pm is built to either spawn a process or take an existing
filehandle
and interact with it such that normally interactive tasks can be done
without operator assistance. This concept makes more sense if you are
already familiar with the versatile Tcl version of Expect.

--
RGiersig@cpan.org


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




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

Date: Wed, 22 Nov 2000 12:28:15 GMT
From: RGiersig@cpan.org
Subject: ANNOUNCE: Expect 1.10
Message-Id: <t1nfpd3el95v57@corp.supernews.com>

It's so sad: Expect 1.09 had a syntax error!! Don't ask me how it
slipped through, I tried it with two test scripts that worked, but
must have botched when upping the version number for the release...

Anyhow, Expect 1.10 has entered CPAN and 1.09 is scheduled for
deletion, so I hope there was no major harm done.

With humblest apologies,

Roland
--
RGiersig@cpan.org


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




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

Date: Wed, 22 Nov 2000 22:40:11 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Binding Variables and DBI
Message-Id: <slrn91nc4r.imr.mgjv@martien.heliotrope.home>

On Wed, 22 Nov 2000 09:27:29 GMT,
	Honza Pazdziora <adelton@fi.muni.cz> wrote:
> On Wed, 22 Nov 2000 01:37:52 GMT, Sangam <mysangam@my-deja.com> wrote:
>>  I am binding variable names using DBI with Oracle to call Stored
>> Procedure. For each variable I have to seperately name them.
>> Any idea how I can do the same thing using an array or hash.
>> I have tried simple thing, but it didn't work.
> 
> 	$dbh->do('begin procedure_name(?, ?, ?); end;', {},
> 		$param1, $param2, $param3);
> 
> is the generic way, so you can use
> 
> 	$dbh->do('begin procedure_name(?, ?, ?); end;', {},
> 		@param_array);
> 
> but make sure the array really has three elements or you get
> an error.

Of course, if you're too lazy to make sure of that, you can do:

    $dbh->do('begin procedure_name(?, ?, ?); end;', {},
        @param_array[0..2]);

undef does get translated to a NULL, doesn't it?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | What's another word for Thesaurus?
NSW, Australia                  | 


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

Date: Wed, 22 Nov 2000 13:26:47 GMT
From: melet@my-deja.com
Subject: die
Message-Id: <8vghig$j7l$1@nnrp1.deja.com>

hello


die do not work in my perl script. I have no output. I don't understand.

could you help me?

thanks

fred


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


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

Date: 22 Nov 2000 12:22:19 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Executing own module as root?
Message-Id: <m3d7foqmj8.fsf@famvtpc59.tu-graz.ac.at>

I have written an extension by using the h2xs program. The extension
works perfectly if I use it as root. But it creates a memory error if
I execute it as a normal user. So I think that I have to do a kind of
"suid-root" for that package, but how can I do this?

Thanks for any hints,
best regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
------- I think there's a world market for about five computers --------
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Wed, 22 Nov 2000 23:22:55 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Executing own module as root?
Message-Id: <slrn91nekv.imr.mgjv@martien.heliotrope.home>

On 22 Nov 2000 12:22:19 +0100,
	Christian Meisl <meisl@amvt.tu-graz.ac.at> wrote:
> I have written an extension by using the h2xs program. The extension

I assume that what you're saying is that you actually did have a C
library, and used its header file as a template for h2xs? Because I use
h2xs all the time to create template module directories when there's no
C code involved at all.

> works perfectly if I use it as root. But it creates a memory error if
> I execute it as a normal user. So I think that I have to do a kind of
> "suid-root" for that package, but how can I do this?

I doubt that that is necessary. I doubt it very much. I suspect that
you've made a coding error somewhere that on your particular system
triggers a 'memory error' (whatever that is) for people who are not
root. There could be lots of causes for that. 

Many modules with C code run without any setuid bits. Besides all that,
you can't setuid to root in a module without the invoking program having
the permissions to do that. Your module would be next to useless if it
could only be used by programs with root priveleges. Unless of course
that is its purpose. But then, why would you be asking?

> Thanks for any hints,

You didn't give us any hints. It's impossible for us to give you any,
except my firm belief that you're barking up the wrong tree.

What is the exact error? What sort of module is this? What C code is
this? Is the C code clean? debugged, purified, whatever you normally do
to make sure it doesn't leak or cross memory boundaries anywhere? What
system calls do you use? Have you tried debugging this to see where that
'memory error' occurs? Tried to fiddle the compiler flags to make the
compilation phase as tight and pedantic as possible?

Instead of battling the symptoms with brute force, maybe you should
concentrate on trying to find the cause.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I'm just very selective about what I
Commercial Dynamics Pty. Ltd.   | accept as reality - Calvin
NSW, Australia                  | 


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

Date: Wed, 22 Nov 2000 11:51:53 GMT
From: vivekvp <vivekvp@spliced.com>
Subject: Extracting data from a ps command
Message-Id: <8vgc0n$es0$1@nnrp1.deja.com>

 I am trying to extract the time from a ps unix command - but it does
not have regularly spaced columns.  So the split command does not work

What I am trying to do is get the time - if it greater that a certain
amount - send the PID and user via email to the sysadmin.  How do I
separate the time?

Thanks,

V



     UID   PID  PPID  C    STIME TTY       TIME COMMAND
    root     0     0  0  Nov 18  ?         1:26 swapper
    root     1     0  0  Nov 18  ?         0:04 init
    root     2     0  0  Nov 18  ?         5:55 vhand
    root     3     0  0  Nov 18  ?         5:57 statdaemon
    root     4     0  0  Nov 18  ?         0:20 unhashdaemon
    root     7     0  0  Nov 18  ?         0:00 ttisr
    root    13     0  0  Nov 18  ?         0:11 lvmkd
    root    14     0  0  Nov 18  ?         0:11 lvmkd
    root    15     0  0  Nov 18  ?         0:11 lvmkd
    root    16     0  0  Nov 18  ?         0:12 lvmkd
    root    17     0  0  Nov 18  ?         0:12 lvmkd
    root    18     0  0  Nov 18  ?         0:12 lvmkd
    root    19     0  0  Nov 18  ?         7:45 netisr
    root    20     0  0  Nov 18  ?         6:51
netisr

--
He who fights and runs away, lives to run another day!


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


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

Date: Wed, 22 Nov 2000 13:07:56 GMT
From: webbgroup@my-deja.com
Subject: Re: HELP! bring variables out of a subroutine?
Message-Id: <8vggf8$iah$1@nnrp1.deja.com>

What happens when I have multiple variables. Can I return all of those??

sub mysub
{
  my $str="Hello, World!";
  $addition= 5+7;
  return $str,$addition;
)

NEVERMIND ... I DID IT..AND IT WORKED. THANKS GUYS..


> In perl everything is rather different.
>
> sub mysub{
>   my $str="Hello, world!";
>   return $str;
> }


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


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

Date: Wed, 22 Nov 2000 10:20:38 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: how would you know the no of people accessing a perl file?
Message-Id: <Xns8FF46DDEBquuxi@194.203.134.135>

A million monkeys weren't enough! It took Erik van Roode 
<newsposter@cthulhu.demon.nl> on 15 Nov 2000 to produce 
<8uud1e$i1c$1@internal-news.uu.net>:

>> how can you know the no. of people reading a particular page?
>> or the no. of visitors in your site at a particular moment?

1. Define "reading" (as in "eyeball parsing" or "downloading")
2. Post to comp.infosystems.www.servers.(unix|windows|misc)
   I'd set f'ups but you didn't say what server/platform

You could try parsing the server's access log and consider a page being 
"read" if it was downloaded at most x seconds ago AND another page 
wasn't requested in the meantime (and these heuristics will fail 
miserably when AOLers start flocking to your site).
-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
In God we trust, everybody else please enter the password:


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

Date: Wed, 22 Nov 2000 12:03:48 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: I am sorry for posting this so many times!
Message-Id: <Xns8FF476D51quuxi@194.203.134.135>

A million monkeys weren't enough! It took Kent Perrier
<kperrier@blkbox.com> on 21 Nov 2000 to produce
<C08D24C101E3CB9C.E0E1EED19E3C3B34.6065F3DE1229FFFF@lp.airnews.net>: 

>"Johan M. Ditmar" <johan.ditmar@telia.com> writes:
>
>> Hi all,
>> 
>> I apologize for posting this message so many times. I don´t think
>> it´s my fault, it must have something to do with the newsgroup
>> server at my work or outlook. I did not do it to get more
>> attention. 
>
>Get a better news reader.
>

Judging from Tad McClellan's comment, Johan seems to be using Outlook 
Express. Upgrade to XNews:
http://xnews.3dnews.net/

-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
In God we trust, everybody else please enter the password:


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

Date: Wed, 22 Nov 2000 11:48:19 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: Most easy way to get IP from a local NIC by device name (eth0,eth1...)
Message-Id: <8vgbq2$epf$1@nnrp1.deja.com>

In article <slrn91ls6v.r2.mgjv@verbruggen.comdyn.com.au>,
  mgjv@tradingpost.com.au wrote:
> On Tue, 21 Nov 2000 17:27:02 GMT,
> mexicanmeatballs@my-deja.com <mexicanmeatballs@my-deja.com> wrote:
>> If you have multiple adapters (Hence multiple addresses) you can get
>> the address of the interface for a specific network by supplying a
>> host address for that network (not necessarily an actual host) in
>> place of the '27.0.0.1'.
> But how do you know that that is eth1 or eth0? I think the question
> was to find the IP address that are tied to a specific interface.
> I took that to mean that given nothing else but the name of the
> interface, find its IP address. In other words, you don't know any
> network or host addresses. That's what you're trying to find out.

 Yes, I was making the assumption that you knew the network
address that your ethernet ports are on, and that they have
different network adresses.

 I don't have anything against the netstat or ifconfig methods
other than they require a fork, and that this is an option if
you know the network address of the interface and don't want to
fork around.

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


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


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

Date: Wed, 22 Nov 2000 22:47:24 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: need some help with regex
Message-Id: <slrn91ncic.imr.mgjv@martien.heliotrope.home>

On Wed, 22 Nov 2000 11:14:00 +0100,
	Michael Guenther <MiGuenther@lucent.com> wrote:
> 
> metamp@my-deja.com wrote in message <8vff64$pjb$1@nnrp1.deja.com>...
>>I'm using CGI.pm and trying to check the if the textfield on the form
>>does not contain ilegal character
>>
> 
>>if ($query->param('texfield_name') != /[^a-zA-Z]/)
>>{
>>print "result a no ilegal characters";
>>}else{
>>      print "result b ilegal character detected";
>>     }
> 
> 
> This one not not working ....
> try
> 
>  if (not($query->param('texfield_name') = /[^a-zA-Z]/) )
>                                           ^^

This one is also not working.  At least, it will not do what you think
it does. And unless that method can be used as an lvalue, it's even an
error. If it can be used as an lvalue, the result is most likely not
what you want.

if ($query->param('texfield_name') !~ /[^a-zA-Z]/)
{
}

> and change the misspellings

Why? I think they're quite charming. At least they don't introduce
double 'not' where that may be confusing.

> the syntax ! for not usually not work with pattern matching.

Yes, it does work fine. But you do have to bind the regex to something,
and that's what the =~ and !~ operators are for.

> I don't know why, but it is always the same.

They do work. You must be doing something wrong, besides the above.

> Maybe someone else can tell us why "!" and "not" are not the same in that
> case
> ( maybe somthing with the binding of the pattern match  .........    don't
> know)

You use brackets around the whole thing above. In that case, not and !
are the same. If you don't bracket things, it depends on the precedence
of operators. ! binds tighter than =~ and !~, and maybe that is what
you're referring to. But you don't need to use it. That's why =~ and !~
both exist.

Read the perlop documentation, please. The operator precedence table is
a good place to start.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.   | you come to the end; then stop.
NSW, Australia                  | 


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

Date: Wed, 22 Nov 2000 22:37:08 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: OT:Re: Eurodate mysteries
Message-Id: <slrn91nbv4.imr.mgjv@martien.heliotrope.home>

On Wed, 22 Nov 2000 10:31:26 GMT,
	coluche@my-deja.com <coluche@my-deja.com> wrote:

>                                          I'm sure there are more
> deserving causes to spill blood upon, like from which end should one
> break a boiled egg.

I hope you're not suggesting that one should break the blunt end first.
it's obvious that that's wrong.


Martien
-- 
Martien Verbruggen              | Since light travels faster than
Interactive Media Division      | sound, isn't that why some people
Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
NSW, Australia                  | speak?


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

Date: Wed, 22 Nov 2000 12:45:16 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: OT:Re: Eurodate mysteries
Message-Id: <1eki3bn.1jgqq3p88wqmaN%tony@svanstrom.com>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:

> On Wed, 22 Nov 2000 10:31:26 GMT,
>       coluche@my-deja.com <coluche@my-deja.com> wrote:
> 
> >                                          I'm sure there are more
> > deserving causes to spill blood upon, like from which end should one
> > break a boiled egg.
> 
> I hope you're not suggesting that one should break the blunt end first.
> it's obvious that that's wrong.

The question isn't that simple, to answer it we'd need to know not only
what kind of egg it is but also how long it's been cooked, what state
the egg is in as well as what the egg will be used for.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Wed, 22 Nov 2000 11:54:23 +0000
From: Nuno Goncalves <nuno@fccn.pt>
Subject: passing as argument ...
Message-Id: <Pine.BSF.4.21.0011221153450.28099-100000@atlas.rccn.net>

Hi everybody !!!

Does someone know how to write i script that executes an "su user" ??

What i want to achive is writing a script (perl / shel / C program /
whatever) that executes a system call like "su user". But that system 
call blocks waiting for a password.
How can i write a script (with argv for example)
that does not block ???

thanks in advance.

Nuno



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

Date: 22 Nov 2000 12:13:21 +0000
From: nobull@mail.com
Subject: Re: passing as argument ...
Message-Id: <u94s108ase.fsf@wcl-l.bham.ac.uk>

Nuno Goncalves <nuno@fccn.pt> writes:

> Hi everybody !!!
> 
> Does someone know how to write i script that executes an "su user" ??
> 
> What i want to achive is writing a script (perl / shel / C program /
> whatever) that executes a system call like "su user". But that system 
> call blocks waiting for a password.

You could use Expect.pm to drive su but that would be fighting the
system.  Much better to write your own SUID wrapper program.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 22 Nov 2000 10:44:28 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: Perl Illiterate
Message-Id: <Xns8FF4656D5quuxi@194.203.134.135>

Matt Miller <repentandspamnomoremillerdg@mindspring.com> wrote:
> What is perl?

It's a metaphor for value or goodness, cf the Bible:

Don't throw your Perl to swines, lest th
Bible: memory error
core dumped

-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
In God we trust, everybody else please enter the password:


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

Date: Wed, 22 Nov 2000 12:50:08 +0100
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Perl question no on form results
Message-Id: <ZpOS5.1640$tw1.97267@news000.worldonline.dk>

Liam wrote:

> This script is used as a CGI script, but the question I have is for
> the perl end.
> The value of the variables returned is set up in the following format
> 
> $FORM{$name} = $value
> 
> 
> e.g.:
> 
> print "$Form{'FirstName'}\n";
> #would return whatever the user entered for the first name blank
> 
> I have several variables returned that are named 'Sub..' and are
> followed by 2 digits.  What I want is to identify any name that is
> 'Sub..' followed by 2 numbers.
> 
> I was trying to use:
> 
> if ($FORM{$name} ne $FORM{'sub(.{2})') {
> #run command
> }
> 
> I obviously have something wrong.
> 
> Can anyone lend a hand?
> 
> Any and all help is much appreciated.
> 
> LK
> 
> 

Use a regexp. Read your perl documentation, for regesps
$ perldoc perlre

Supposing that you want to test $FORM{$name} for beeing Sub<number><number>:

if ($FORM{$name} =~ m/^Sub\d\d$/) {
  # A match!
  &$FORM{$name}; # critiqueless run that, not clever!
}

Before running a sub which was selected by user input, you'd want to tjeck 
if it's valid!

my %validsubs = (
   Sub11 => 1,
   Sub45 => 1
   #...
);

if ($FORM{$name} =~ m/^Sub\d\d$/) {
  # A match!
  &$FORM{$name} if $validsubs{$FORM{$name}}; # only run if known
}

Frankly,
The usage of $FORM{$name} indicates that you are using oldish perl4 style 
CGI programs, which is silly considering the power of the CGI module!
Look up the CGI module in oyur docs
$ perldoc CGI
to get started!

-anders



-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]



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

Date: Wed, 22 Nov 2000 13:52:36 GMT
From: jkipp@mbna.com
Subject: Problem with simple del file script
Message-Id: <8vgj31$kal$1@nnrp1.deja.com>

I am trying to go through a directory and delete files that are older
than 30 days. Here is what I have, it will print the files, no problem,
but will not delete. Thanks for any suggestion
Jim
------
$path='h:\dbm\mediacreate';

opendir (WDIR, "$path") or die "Can't open $path: $!";

while ($file= readdir WDIR) {
	next if $file=~/^\./;
        $age= -M "$path/$file";

	if ($age > 30) {
            # print "$file\n"; # this works
             `del $file` # this does not
	      # unlink $file #this does not
		}
    }




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


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

Date: Wed, 22 Nov 2000 08:58:13 -0500
From: "_Thomas" <webmaster@860.org>
Subject: Re: Reg Exp Learning?
Message-Id: <xkQS5.53108$KI6.11642061@typhoon.snet.net>

>
> Although I think this is good advice, I would *not* recommend the
> following article:
>
> >   How Regexes Work:
> >      http://www.plover.com/~mjd/perl/Regex/
>
> because although it desribes *a* way that regexes *could* work, it
> does not actually describe the way they work in Perl.  Perl uses a
> different method entirely from the method described in the article.
>
> I should probably put a big disclaimer on the article.  Sorry for any
> confusion this has caused.  When I teach the regex class at the Perl
> conference, I talk about how the machine really does work, but I've
> never written it up as an article.  Sorry!

Ohh, no thats ok.  I was looking both for how they work in perl and in
general.  So anything is more than what I have now ( or had yesterday ..
:) ).

_Thomas







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

Date: Wed, 22 Nov 2000 11:10:49 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: rounding with "printf %f"
Message-Id: <G4FB21.Gu2@news.muni.cz>

On Wed, 22 Nov 2000 11:06:12 +0100, Felix Drüke <fd@orga.com> wrote:
> 
> The "printf %.0f" command doesn't give the result that I
> expect:
> 
> $ perl -e 'printf "%.0f\n",6.5'
> 6
> $ perl -e 'printf "%.0f\n",6.501'
> 7
> $
> 
> I expect 6.5 also to be rounded to 7. Why doesn't perl do this?
> Is there another way for rounding, which gives me the result
> that I expect?

http://x51.deja.com/=dnc/[ST_rn=ps]/viewthread.xp?AN=576973532&search=thread&svcclass=dnyr&ST=PS&CONTEXT=974891325.1155661844&HIT_CONTEXT=974891325.1155661844&HIT_NUM=43&recnum=%3c388c80e4.9407445@News.CIS.DFN.DE%3e%231/1&group=comp.lang.perl.misc&frpage=viewthread.xp&back=clarinet

A veeeeery long thread about "Surprising rounding results"

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Wed, 22 Nov 2000 23:05:40 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: rounding with "printf %f"
Message-Id: <slrn91ndkk.imr.mgjv@martien.heliotrope.home>

On Wed, 22 Nov 2000 11:06:12 +0100,
	Felix Drüke <fd@orga.com> wrote:
> 
> The "printf %.0f" command doesn't give the result that I
> expect:
> 
> $ perl -e 'printf "%.0f\n",6.5'
> 6
> $ perl -e 'printf "%.0f\n",6.501'
> 7
> $

Rounding is not always done up. In many places rounding is implemented
as round to nearest even, to prevent bias if many of the things you
round are exactly half. The old rule that we all learned when we were
very young (5 gets rounded up) is not really in use in many places
anymore.

Then there's also the issue that not all floats can be represented
exactly internally. I don't think you'll see that with 6.5, but print
out the 6.501 with a large precision, and discover how perl sees that
number internally.

Also read the perlnumber documentation, perl FAQ 4, (the question about
'does perl have a round()), and an enormous thread on rounding that ran
on this group a little while ago (or was it comp.lang.c?).

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | The gene pool could use a little
Commercial Dynamics Pty. Ltd.   | chlorine.
NSW, Australia                  | 


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

Date: Wed, 22 Nov 2000 12:16:41 GMT
From: sander@veenhoven.com (Sander van Gennip)
Subject: Re: rounding with "printf %f"
Message-Id: <3a1eb91a.15390951@news.xs4all.nl>

On Wed, 22 Nov 2000 11:06:12 +0100, Felix Drüke wrote:

>Hi,
>
>The "printf %.0f" command doesn't give the result that I
>expect:
>
>$ perl -e 'printf "%.0f\n",6.5'
>6
>$ perl -e 'printf "%.0f\n",6.501'
>7
>$
>
>I expect 6.5 also to be rounded to 7. Why doesn't perl do this?
>Is there another way for rounding, which gives me the result
>that I expect?
>
>Felix

Strange, both statements print '7' for me (I use v5.6.0 built for
MSWin32-x86-multi-thread). Maybe you can solve it by using:
$rounded = int($value + 0.5)

greetings,
Sander



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

Date: Wed, 22 Nov 2000 11:28:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: rounding with "printf %f"
Message-Id: <aoan1to28imiqcs9up09ae6b4grudp74v3@4ax.com>

Felix Drüke wrote:

>The "printf %.0f" command doesn't give the result that I
>expect:
>
>$ perl -e 'printf "%.0f\n",6.5'
>6
>$ perl -e 'printf "%.0f\n",6.501'
>7
>$
>
>I expect 6.5 also to be rounded to 7. Why doesn't perl do this?

Because you're exactly halfway between 6 and 7. There IS NO NEAREST
value. So, Perl does the common thing: rounding towards the neartest
even number.

This occasionally annoys the heck out of me, too. But there are "good
excuses" for this, especially the "multiple rounding" effect that I saw
mentioned once. Don't ask me for proof, but if you round a floating
point number to, say, 10 decimals, and then to 2, there allegedly is
less chance of rounding "the wrong way" for the second rounding. n.b.
results of calculations are virtually *always* rounded, because there is
no such thing as infinite precision.

But you don't have to believe *me*. Here's the Usenet post I got this
info from.

	<http://x54.deja.com/[ST_rn=ps]/getdoc.xp?AN=683438226>

See the rest of that thread (click on the link ">> Thread" at the top of
that page) for a discussion.

>Is there another way for rounding, which gives me the result
>that I expect?

For positive numbers: add 0.5, and take int.

	print int(6.5 + 0.5);

For negative numbers, int truncates "the wrong way", towards zero. So
instead, you have to subtract 0.5, instead of adding.

-- 
	Bart.


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

Date: 22 Nov 2000 12:02:29 +0000
From: nobull@mail.com
Subject: Re: running a script as root
Message-Id: <u966lg8bai.fsf@wcl-l.bham.ac.uk>

Alex Hart <news@#nospam#althepal.com> writes:

> Is it possible to allow anyone to run a particular script as root?

Yes.  See perlsec manpage for details.

> Specifically, say I want to allow visitors to my website to create an
> account for themselves. If I have a perl script which can create an
> account, can I allow them to run this script as root without allowing
> them any other privleges?

So long as there are no security holes in your programming.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 22 Nov 2000 23:13:49 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: running a script as root
Message-Id: <slrn91ne3t.imr.mgjv@martien.heliotrope.home>

On Wed, 22 Nov 2000 10:43:56 GMT,
	Alex Hart <news@#nospam#althepal.com> wrote:
> Is it possible to allow anyone to run a particular script as root?

Yes. But what does this have to do with Perl? Find out about sudo or
maybe about the setuid possibilities on unices.

> Specifically, say I want to allow visitors to my website to create an
> account for themselves. If I have a perl script which can create an
> account, can I allow them to run this script as root without allowing
> them any other privleges?

Bad, bad, bad, bad, bad, bad, bad idea. Do not do it.

I keep telling people this: If you have to ASK how to do this, then do
not even consider attempting it. Pay someone to do it for you. There is
too much that can go wrong. if you doubt that what I am saying is true,
then you should not even have the root password for your system.

Anything that runs as root, and that accepts user input needs to be
dealt with with the utmost care, wisdom, knowledge and paranoia. Writing
anything setuid root that is non-trivial takes me about 10 times as long
as anything that is a normal program. And I believe that I at least have
a reasonable idea of the issues involved. I normally take the easy way
out, and design a more complex solution that doesn't involve setuid
bits.

And now I will give you a loaded gun. Read the perlsec documentation,
and your system's manual pages on how to create setuid programs.

Now it's your job to figure out how much it is worth to you to not have
an open door in your system.

Martien
-- 
Martien Verbruggen              | My friend has a baby. I'm writing
Interactive Media Division      | down all the noises the baby makes so
Commercial Dynamics Pty. Ltd.   | later I can ask him what he meant -
NSW, Australia                  | Steven Wright


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

Date: Wed, 22 Nov 2000 12:55:56 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: sybperl CTlib character set
Message-Id: <3A1BB44C.76B2FEE6@mssys.com>

Ken Chesak wrote:
> How do I make a character set selection using sybperl CTlib?
I don't know, but..

> Current connection string:
Well, you're calling a function/method to establish a connection.


>  $::dbh  = new Sybase::CTlib $::DBUSER, $::DBPWD, $::ltcSERVER, undef,
>                  { CON_PROPS => { CS_HOSTNAME => 'beaver',
>                                   CS_SYB_CHARSET => 'iso_1' }};
> 
> Error:
> 
> Ambiguous use of CS_HOSTNAME => resolved to "CS_HOSTNAME" => at a.pl line
> 680.
> Ambiguous use of CS_SYB_CHARSET => resolved to "CS_SYB_CHARSET" => at a.pl
> line
You adoped the example given in the sybperl documentation, right?!

I think they got a little messed up with their use of "constants". So I
think they wanted to use CON_PROPS literaly and it may be more clearly
written as 'CON_PROPS'.
But I think with CS_HOSTNAME or CS_SYB_CHARSET they try to reference
constants which are implemented via subroutine-calls. So by writing 
   { CON_PROPS => {
         CS_HOSTNAME()    => 'beaver',
         CS_SYB_CHARSET() => 'iso_1',
      }
   }
the "Ambiguous use of..."-messages disappear.

It is however possible that the Sybase::CTlib::new method itself is able
to "dereference" these constants given as hash keys, so you _may_ get
your desired result by writing
   { CON_PROPS => {
         'CS_HOSTNAME'    => 'beaver',
         'CS_SYB_CHARSET' => 'iso_1',
      }
   }

I don't know which one of these (if any) will lead to the desired
behavior, I don't even know if CS_SYB_CHARSET is the constant you're
looking for, because I don't have a Sybase-DB at hand.

hth

Cheers
	Wolfgang


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

Date: Wed, 22 Nov 2000 13:54:27 GMT
From: David Waters <davidwaters@bigfoot.com>
Subject: trouble blessing object
Message-Id: <8vgj6g$kc0$1@nnrp1.deja.com>

I'm creating a class which uses the DBI module
and some of my own functionality.

I'd like to make $dbh only available to DBI and
a subroutine of my choosing.

############################
package myClass;

sub new {
 ...
}

sub connect {
my ($self,@args) = @_;
my $dbh = DBI->connect($args[0],$args[1],$args[2]);
return $dbh;
}
###############################

so if I do,
my $dbi = myClass->new;
my $dbh = $dbi->connect(...);
$dbh->disconnect;

this all works fine.

I've added the subroutine 'hello' which
I'd like $dbh to be only able to access.
so I tried changing the 'connect' routine and encapsulating
'hello' in a new package as follows.

sub connect {
 ....
bless $dbh, "NewClass";
}

package NewClass;
sub hello {
print "hello\n";
}

$dbh can access the 'hello' subroutine but it is now not
able to access DBI subroutines.

How do I make it available to both?

Thanks.


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


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

Date: 22 Nov 2000 12:37:05 +0000
From: nobull@mail.com
Subject: Re: uploading files over web
Message-Id: <u93dgk89ou.fsf@wcl-l.bham.ac.uk>

"Troy Rasiah" <troyr@vicnet.net.au> writes:

> Hi there...
>     I have a simple file uploading html/cgi page that uploads files to a
> server. My problem is that I want a progress bar or even dots going across
> the screen as the file uploads. My HTML only comes on the screen once the
> file has finished uploading.
> 
> Can anyone help me?

The first simple solution to the progress bar not tracking HTTP
uploads is to say use an HTTP client that lacks the bug in question.

As for having your HTTP response start to be sent before the whole
HTTP request has been received I don't think this is possible.  If you
want to pursue this further try a group where low-level HTTP stuff is
discussed.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 22 Nov 2000 11:04:18 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: using exec cgi in a perl program
Message-Id: <Xns8FF47EF28quuxi@194.203.134.135>

A million monkeys weren't enough! It took u0107@cheerful.com on 20
Nov 2000 to produce <8vc853$4d5$1@nnrp1.deja.com>: 

>Hello,
>
>The use of "exec cgi" command in an html file requires the renaming
>of the file with a "shtml" extension.
>

<OT>
No, it doesn't, but it's a good idea to do it.
Assuming Apache, the default configuration file says

AddHandler server-parsed .shtml

You can change that to .html but then *ALL* .html files will be 
searched for SSI. This places an extra burden on the server. If only 
 .shtml files go through server-parsed, then Apache can serve the static 
 .html files much faster.
</OT>

[snip html-javascript-SSI question]
The question you asked was not about how to do something in Perl. 
It was about passing information between Javascript and SSI. You'd get 
more information from comp.infosystems.www.authoring.(cgi|html) and/or 
comp.lang.javascript

-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
In God we trust, everybody else please enter the password:


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

Date: Wed, 22 Nov 2000 11:56:54 -0800
From: "Paul Clough" <cloughie@dcs.shef.ac.uk>
Subject: Using exists with hashes
Message-Id: <8vgc27$nvl$1@bignews.shef.ac.uk>

Can anyone tell me how I can use the exists hash function but with a fuzzy
match? Rather than matching the expr exactly, I would like to be able to
match with a given degree of similarity? Is it possible to change the exists
function to do this?

Many thanks or any help.

Paul.


--
----------------------------------------------------------------------------
---------------------
Paul Clough

Natural Language Processing Group,
Department of Computer Science,
University of Sheffield,
119 Regent Court,
211 Portobello Street,
SHEFFIELD,
S1 4DP.

http://www.dcs.shef.ac.uk/~cloughie/index.html
----------------------------------------------------------------------------
----------------------




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

Date: Wed, 22 Nov 2000 12:51:42 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Using exists with hashes
Message-Id: <yjPS5.8121$XX6.1276476@typhoon.southeast.rr.com>

Paul Clough <cloughie@dcs.shef.ac.uk> wrote in message
news:8vgc27$nvl$1@bignews.shef.ac.uk...
> Can anyone tell me how I can use the exists hash function but with a fuzzy
> match? Rather than matching the expr exactly, I would like to be able to
> match with a given degree of similarity? Is it possible to change the
exists
> function to do this?
>
> Many thanks or any help.
>
> Paul.

You could iteratively compare each key against a regular expression (or
whatever pattern-matching tool you like):

KEY:
foreach (keys %hash) {
    /pattern/ && do {
        # do stuff with $hash{$_}
        last KEY;  # or next KEY, if you want to match more than one
    };
}

hth,
p




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

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


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