[18859] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1027 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 31 09:10:38 2001

Date: Thu, 31 May 2001 06:10:21 -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: <991314621-v10-i1027@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 31 May 2001     Volume: 10 Number: 1027

Today's topics:
        Reading from strings... (Chaos)
    Re: Reading from strings... <bart.lateur@skynet.be>
    Re: Rounding <ron@savage.net.au>
    Re: Rounding (Anno Siegel)
    Re: Rounding <flavell@mail.cern.ch>
    Re: shell command gnari@my-deja.com
    Re: shell command gnari@my-deja.com
    Re: shell command <Rene.Scheibe@gmx.net>
        some < problems ... <cuissart@pharmacie.unicaen.fr>
    Re: Statistics for comp.lang.perl.misc (Helgi Briem)
    Re: Substitution on .htm files (felan)
    Re: Substitution on .htm files (Bernard El-Hagin)
    Re: Substitution on .htm files (felan)
    Re: Substitution on .htm files (Bernard El-Hagin)
    Re: Variablen durch Formular <07950232225@one2one.net>
    Re: Variablen durch Formular <linux@edvnet.ch>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 31 May 2001 08:15:10 GMT
From: mordor@fly.srk.fer.hr (Chaos)
Subject: Reading from strings...
Message-Id: <slrn9hbvcd.jmn.mordor@fly.srk.fer.hr>

Is there a module or a feature in Perl that would allow me to use scalars
as files? Basically, I want something like this:

my $scalar = "this is my\nstring that I\nwant to read as a file\n";
some_call (FH, "<$scalar");
while(<FH>) { print "$_"; }

What do I put instead of some_call?

The thing is that I have a module that takes a filename. I already have a
file in memory and it seems ridicolous that I must first write the data to
temporary file and read it from disk. I want to rewrite the module so that it
takes a filehandle instead of filename. Then it wouldn't matter whether that
filehandle refers to some string, file on disk, etc..



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

Date: Thu, 31 May 2001 08:38:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Reading from strings...
Message-Id: <km0chtgkf8v2mfbma8b315ha7i19o099e8@4ax.com>

Chaos wrote:

>Is there a module or a feature in Perl that would allow me to use scalars
>as files? Basically, I want something like this:
>
>my $scalar = "this is my\nstring that I\nwant to read as a file\n";
>some_call (FH, "<$scalar");
>while(<FH>) { print "$_"; }
>
>What do I put instead of some_call?

See IO::String on CPAN.

-- 
	Bart.


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

Date: Thu, 31 May 2001 20:45:44 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Rounding
Message-Id: <OroR6.3240$Yr1.147296@ozemail.com.au>

Dave

You can't rely on Perl's 'printf' function without extreme care. According to the C language spec (yes, it's relevant), 'printf' can
round up or truncate depending on the magnitude of the number.

I didn't test Scott's sub, but I'm sure he's trying to avoid this problem.

Look carefully at the output of this (tested code):
-----><8-----
#!/perl/lib/perl

use strict;
use warnings;

# ---------------------------------------------------------------

sub check
{
 my($i) = @_;
 my($j) = sprintf("%.2f", $i);

 print "$i => $j. \n\n";

} # End of check.

# ---------------------------------------------------------------

for my $i (0.555, 1.555, 0.565, 1.565, 0.575, 1.575)
{
 check($i);
}
-----><8-----

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html
dave jerzycki <david_jerzycki@agilent.com> wrote in message news:3B153E39.F10395CC@agilent.com...
>
>  Is there any function or procedure within perl (5.0) to round?
>  I can seem to locate any.
>  I have two scalars I divide by to get a percentage.
>  The figure comes out to 3.62509923334717
>  I'd like it to be just 3.62
>  use integer of course screws things up.
>  I'm using the print function to print the data to a file, so I can't
> use any
>  formating as in printf.
>  Is there some other way around this?
>
>




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

Date: 31 May 2001 09:57:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Rounding
Message-Id: <9f54ij$12k$2@mamenchi.zrz.TU-Berlin.DE>

According to Ron Savage <ron@savage.net.au>:
> Dave
> 
> You can't rely on Perl's 'printf' function without extreme care.
> According to the C language spec (yes, it's relevant), 'printf' can
> round up or truncate depending on the magnitude of the number.

Can you substantiate that?  In particular, I have never heard of
printf vacillating between rounding and truncating depending
on magnitude.

[snip]

Anno


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

Date: Thu, 31 May 2001 12:52:58 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Rounding
Message-Id: <Pine.LNX.4.30.0105311247360.22163-100000@lxplus003.cern.ch>

On Thu, 31 May 2001, Ron Savage blurted out:

> You can't rely on Perl's 'printf' function

You surely can rely on it.  You can't rely on knowing what is meant by
"rounding", without consulting the relevant specification.  It might
not exactly accord with what you learned in school.

> without extreme care.

Looks like a repeat of the standard boneheaded megathread about
rounding.


Oh look, an upside-down fullquote.  Pity my newsreader doesn't have a
killfile recipe for those.



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

Date: 31 May 2001 09:02:52 GMT
From: gnari@my-deja.com
Subject: Re: shell command
Message-Id: <9f51bs$ocf$1@news.netmar.com>

In article <9f32k7$20jdq$1@ID-65612.news.dfncis.de>, Rene Scheibe
<Rene.Scheibe@gmx.net> writes:
>I have written a CGI-script with perl to
>put out some statistics which are read from
>a logfile which is generated by a program
>once a day.
>Now I want realtime statistics so I need to
>send my this proggy the signal USR1.
>I tried in the following in the perlscript:
>`killall -USR1 ipfm`
>eval("killall -USR1 ipfm")
>system("killall -USR1 ipfm")
>`su root killall -USR1 ipfm`
>....but nothing worked.

do you want to send a signal to a CGI script?
in that case, i think you you are confused about how CGI scripts
work. 

if you are talking about sending the signal to the logfile
generating program, would it not be better just to run it every
five minutes?

>
>killall needs root priviledges but I think apache
>don't let perlscripts run as root

it sounds like you think CGI scripts are some sort of daemons,
running in background all the time.

maybe you should explain better why you need a signal.

gnari


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 31 May 2001 09:00:49 GMT
From: gnari@my-deja.com
Subject: Re: shell command
Message-Id: <9f5181$obf$1@news.netmar.com>

In article <9f32k7$20jdq$1@ID-65612.news.dfncis.de>, Rene Scheibe
<Rene.Scheibe@gmx.net> writes:
>I have written a CGI-script with perl to
>put out some statistics which are read from
>a logfile which is generated by a program
>once a day.
>Now I want realtime statistics so I need to
>send my this proggy the signal USR1.
>I tried in the following in the perlscript:
>`killall -USR1 ipfm`
>eval("killall -USR1 ipfm")
>system("killall -USR1 ipfm")
>`su root killall -USR1 ipfm`
>....but nothing worked.

do you want to send a signal to a CGI script?
in that case, i think you you are confused about how CGI scripts
work. 

if you are talking about sending the signal to the logfile
generating program, would it not be better just to run it every
five minutes?

>
>killall needs root priviledges but I think apache
>don't let perlscripts run as root

it sounds like you think CGI scripts are some sort of daemons,
running in background all the time.

maybe you should explain better why you need a signal.

gnari


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Thu, 31 May 2001 12:11:44 +0200
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: Re: shell command
Message-Id: <9f55a7$2bhpj$1@ID-65612.news.dfncis.de>

I need to send SIGUSR1 to ipfm (a running daemon)
so that it dumps it statistics to a logfile which I then
read out with the cgi-script and print it in a table on a
website.
I don't need and want to dump every 5 minutes to a
logfile.




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

Date: Thu, 31 May 2001 14:22:02 +0200
From: Bertrand Cuissart <cuissart@pharmacie.unicaen.fr>
Subject: some < problems ...
Message-Id: <3B16376A.7F68EEFA@pharmacie.unicaen.fr>


	Hello,

 i am trying to write a Perl script under Windows. I encounter some
problems with the operator "<". I want to call an external program that
reads on the stdin and writes on stdout. I wrote this kind of line :
`mytool.exe < input.dat >output.res`;

But there's a problem with the < character.

	What am I doing wrong?

	Thanks,

		B. Cuissart


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

Date: Thu, 31 May 2001 11:28:01 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <3b162a22.96231634@news.isholf.is>

On Wed, 30 May 2001 09:04:10 -0700, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:

>Tad McClellan wrote:
> 
>> Looks to me like lots of folks helping me automatically reduce
>> the number of posts that are visible in clp.misc.

>> I appreciate all the help I can get in that endeavor  :-)

>It is annoyingly clear you view yourself as the sole
>proprietary of this newsgroup.
>
Better him than you.  I appreciate Tad's effort
to control this news group and provide help
and support for all those who come here with
on-topic questions.

Regards,
Helgi Briem


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

Date: Thu, 31 May 2001 07:22:46 GMT
From: felan_66@hotmail.com (felan)
Subject: Re: Substitution on .htm files
Message-Id: <3b15f0c7.71492842@news.uio.no>

On 30 May 2001 18:43:49 +0100, nobull@mail.com wrote:

<...>
>
>I have told you already that there is a Perl module to repeat a
>operation for each file in a directory.  If you have any difficulty
>understanding how to use it then please feel free to ask. 
<
<....>

yes, I have some difficulties, could you plz, explain it a little more
detaited for me please ?

tnx
felan_66@hotmail.com



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

Date: Thu, 31 May 2001 07:48:12 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Substitution on .htm files
Message-Id: <slrn9hbt5e.2s4.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 31 May 2001 07:22:46 GMT, felan <felan_66@hotmail.com> wrote:
>On 30 May 2001 18:43:49 +0100, nobull@mail.com wrote:
>
><...>
>>
>>I have told you already that there is a Perl module to repeat a
>>operation for each file in a directory.  If you have any difficulty
>>understanding how to use it then please feel free to ask. 
><
><....>
>
>yes, I have some difficulties, could you plz, explain it a little more
>detaited for me please ?

The module nobull alluded to is File::Find. Read the documentation for
it by issuing the command:

perldoc File::Find

It's very straightforward and you should have no problems with
understanding it. If you *do* have problems, post relevant code that
is giving you trouble and we'll help you with it.

Cheers,
Bernard
--
perl -le '$#="Just another Perl hacker,"; print print;'


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

Date: Thu, 31 May 2001 07:53:27 GMT
From: felan_66@hotmail.com (felan)
Subject: Re: Substitution on .htm files
Message-Id: <3b15f83c.73402065@news.uio.no>

On Thu, 31 May 2001 07:48:12 +0000 (UTC),
bernard.el-hagin@lido-tech.net (Bernard El-Hagin) wrote:

>On Thu, 31 May 2001 07:22:46 GMT, felan <felan_66@hotmail.com> wrote:
>>On 30 May 2001 18:43:49 +0100, nobull@mail.com wrote:
>>
>><...>
>>>
>>>I have told you already that there is a Perl module to repeat a
>>>operation for each file in a directory.  If you have any difficulty
>>>understanding how to use it then please feel free to ask. 
>><
>><....>
>>
>>yes, I have some difficulties, could you plz, explain it a little more
>>detaited for me please ?
>
>The module nobull alluded to is File::Find. Read the documentation for
>it by issuing the command:
>
>perldoc File::Find
>

tnx, this what I get when I try the command:

<...> /local/bin/perldoc File::Find 
/local/bin/perldoc: Command not found.



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

Date: Thu, 31 May 2001 07:56:00 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Substitution on .htm files
Message-Id: <slrn9hbtk4.2s4.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 31 May 2001 07:53:27 GMT, felan <felan_66@hotmail.com> wrote:
>On Thu, 31 May 2001 07:48:12 +0000 (UTC),
>bernard.el-hagin@lido-tech.net (Bernard El-Hagin) wrote:
>
>>On Thu, 31 May 2001 07:22:46 GMT, felan <felan_66@hotmail.com> wrote:
>>>On 30 May 2001 18:43:49 +0100, nobull@mail.com wrote:
>>>
>>><...>
>>>>
>>>>I have told you already that there is a Perl module to repeat a
>>>>operation for each file in a directory.  If you have any difficulty
>>>>understanding how to use it then please feel free to ask. 
>>><
>>><....>
>>>
>>>yes, I have some difficulties, could you plz, explain it a little more
>>>detaited for me please ?
>>
>>The module nobull alluded to is File::Find. Read the documentation for
>>it by issuing the command:
>>
>>perldoc File::Find
>>
>
>tnx, this what I get when I try the command:
>
><...> /local/bin/perldoc File::Find 
>/local/bin/perldoc: Command not found.

Then you've got a messed up installation of Perl. Go to search.cpan.org
and read the File::Find docs there.

Cheers,
Bernard
--
perl -le '$#="Just another Perl hacker,"; print print;'


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

Date: Thu, 31 May 2001 09:40:46 +0100
From: John Imrie <07950232225@one2one.net>
Subject: Re: Variablen durch Formular
Message-Id: <3B16038E.F0C28FD6@one2one.net>



Ludmilla Markowska wrote:

> Hallo,
> ich bastele gerade an einem Script, mit dem man über eine Website u.a neue
> Zonendateien für einen DNS-Server anlegen kann, das Script, das an der
> Consolo gut funktioniert sieht (stark gekürzt) so aus:
> #!/usr/bin/perl -w
> # adddom
> use CGI qw(:standart);
> use strict;
> # print("\n\nZONE DOMAIN anlegen\----------\n\n");
> #my $domain = domain;
> #print("DOMAIN: ");
> $domain = <STDIN>;
> chomp($domain);
> system <"touch $domain.hosts">;
> open ZONE, ">$domain.hosts" or
> die "I can't open zonendatei";
> print ZONE <<"EOH";
> zone \"$domain\" \{
> type master\;
> file \"\/var\/named\/$domain\"\;
> \}\;
> EOH
>
> das Formular dazu:
> ...
> <form action="/cgi-bin/addzone-cgi.pl">
> <p>Bitte geben Sie den Domainnamen ein:
> <input name="domain" size="50"></p>
> <input type="submit" value="Abschicken">
> </form>
> ...
> Problem, es gibt einen "Internal Server Error".
> Kann mir jemand sagen, was ich da falsch mache?
>
> danke für euere Hilfe
> ludmilla

For those of us who don't speek German I got this from the *fish
In such a way hello, I tinkers even at a Script, with which one can create
among other things new zone files for a DNS server over a Website, the Script,
that to the Consolo looks well functioned (strongly shortened):

#!/usr/bin/perl - w
# ADD cathedral
use cgi qw(:standart);
use strict;
# print("\n\nZONE DOMAIN anlegen\ \n\n ");
# my $$domain = domain;
# print("DOMAIN: ");
$$domain = < STDIN >;
chomp($domain);
system < "touch $$domain.hosts " >;
open ZONE, " > $$domain.hosts " or the " I can't open zone file ";
print ZONE < < " EOH ";
zone \"$domain \ " \ { type master \;
file\"\/var\/named\/$domain \ " \;
\ } \;
EOH

the form in addition: < form action="/cgi-bin/addzone cgi.pl " >
< p>Bitte inputs you to the Domainnamen: < inputs name="domain " size="50">
< input type="submit " value="Abschicken " >
< / form >

 ... Problem, it gives a " Internal to server error ".
Can someone say to me, what there false I make?
thanks for your assistance ludmill



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

Date: Thu, 31 May 2001 13:20:53 +0200
From: "Andreas Horvath" <linux@edvnet.ch>
Subject: Re: Variablen durch Formular
Message-Id: <991308284.496853@fuchs.cyberlink.ch>

Ludmilla Markowska <ludmilla.markowska@gmx.net> schrieb:

> Nur verstehe ich trotzdem nicht, warum man die Variable "domain" aus dem
> Formular nicht einfach so in das Script einsetzen kann?

weil das ein klitze kleines sicherheitsrisiko darstellt?

> Wäre nett wenn mir trotzdem jemand helfen könnte!

wenn du _unbedingt_ deinen kopf ueber gutes/sicheres design stellen
willst...

{
 no strict 'refs';
 ${"$_"} = join q, ,,param($_) for param();
}

/me lehnt jegliche haftung fuer die verwendung dieser zeile ab ;)

> gruss
> ludmilla

nd






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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1027
***************************************


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