[11249] in Perl-Users-Digest
Perl-Users Digest, Issue: 4849 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 8 21:07:16 1999
Date: Mon, 8 Feb 99 18:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Feb 1999 Volume: 8 Number: 4849
Today's topics:
Re: 8-bit input (or, "Perl attacks on non-English langu (Abigail)
execution order ( perl bug?) <karlsson@hwcae.honeywell.com>
Re: execution order ( perl bug?) (Alastair)
Re: execution order ( perl bug?) <uri@ibnets.com>
Re: File::Path rmtree and tainting (Marc Haber)
Help pegasusetc@my-dejanews.com
Re: how do I get a date in perl? (Abigail)
libwww for NT <Bill.Palmer@online.disney.com>
Re: locking files <mwatkins@promotion4free.com>
Re: Mnaip.pm Not Supported (Bill Moseley)
Re: My SQL <bruce.d@btinternet.com>
Re: NEWBIE Question about error checking string <bgibby@iinet.net.au>
Re: Parsing output from a program called within perl <bgibby@iinet.net.au>
Re: Parsing output from a program called within perl (Abigail)
Re: performance penalty: bareword, single quoting, doub (Sean McAfee)
Re: performance penalty: bareword, single quoting, doub <bmb@ginger.libs.uga.edu>
Re: Perl 'zine <jjarrett@ecpi.com>
Perl for QNX <ken@activecom.net>
Re: Program needs compactification (Abigail)
Re: Programming with Style dragnovich@my-dejanews.com
Rounding for Euro currency <ian@no-spam4site.co.uk>
Re: Rounding for Euro currency (Alan Barclay)
Re: String splitting. (Abigail)
Re: String splitting. (Craig Berry)
system call works in command line mode but not from web <bwlang@nospam.genome.wi.mit.edu>
Using modules, esp. with perlxs <olsondan@ohsu.edu>
Re: Using modules, esp. with perlxs <jcounts@voicenet.com>
Re: Viewing remote Perl script before executing (Craig Berry)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Feb 1999 00:35:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: 8-bit input (or, "Perl attacks on non-English language communities!")
Message-Id: <79nvsq$2kr$3@client2.news.psi.net>
Matt Curtin (cmcurtin@interhack.net) wrote on MCMLXXXVII September
MCMXCIII in <URL:news:xlxiudcizfn.fsf@gold.cis.ohio-state.edu>:
$$
$$
$$ Let's see ... what other (programming) languages might support this
$$ sort of thing? How about Lisp? XEmacs Lisp, at that?
$$
$$ (defun icrivez (m)
$$ "Icrivez un message."
$$ (message m))
$ function icrivez () {
> echo $1
> }
$ icrivez "Icrivez un message."
Icrivez un message.
$ `which $SHELL` --version
GNU bash, version 2.02.0(1)-release (sparc-sun-solaris2.6)
Copyright 1998 Free Software Foundation, Inc.
$
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
Date: Mon, 08 Feb 1999 17:05:54 -0700
From: Niclas Karlsson <karlsson@hwcae.honeywell.com>
Subject: execution order ( perl bug?)
Message-Id: <36BF7BE1.4C869F12@hwcae.honeywell.com>
--------------49E336FE6E8D3137731FD634
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I've noticed a weird behaviour of Perl5.004_04 on HP-UX
Ex, when I run this simple script:
#!/usr/local/bin/perl -w
print "The time and date is now: ";
system("date");
Perl spits out:
Mon Feb 8 17:01:58 MST 1999
The time and date is now:
Notice the order, it gives the appeareance that perl excuted, them in
the wrong order!
However if you had a newline like this:
print "The time and date is now: \n";
system("date");
then perl spits out:
The time and date is now:
Mon Feb 8 17:04:36 MST 1999
which is correct. or at least what you would expect.
Has anyone seen this before?
--
Niclas Karlsson, CAE Support Engineer Phone: (602) 436-3751
Honeywell -- Air Transport Systems Fax: (602) 436-6479
P.O. Box 21111, M/S AZ75-M25A1, Phoenix AZ 85036
Email: karlsson@hwcae.honeywell.com
--------------49E336FE6E8D3137731FD634
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
I've noticed a weird behaviour of Perl5.004_04 on HP-UX
<BR>Ex, when I run this simple script:
<BR>#!/usr/local/bin/perl -w
<BR>print "The time and date is now: ";
<BR>system("date");
<P>Perl spits out:
<BR>Mon Feb 8 17:01:58 MST 1999
<BR>The time and date is now:
<P>Notice the order, it gives the appeareance that perl excuted, them in
the wrong order!
<BR>However if you had a newline like this:
<BR>print "The time and date is now: \n";
<BR>system("date");
<P>then perl spits out:
<BR>The time and date is now:
<BR>Mon Feb 8 17:04:36 MST 1999
<P>which is correct. or at least what you would expect.
<BR>Has anyone seen this before?
<PRE>--
Niclas Karlsson, CAE Support Engineer Phone: (602) 436-3751
Honeywell -- Air Transport Systems Fax: (602) 436-6479
P.O. Box 21111, M/S AZ75-M25A1, Phoenix AZ 85036
Email: karlsson@hwcae.honeywell.com</PRE>
</HTML>
--------------49E336FE6E8D3137731FD634--
------------------------------
Date: Tue, 09 Feb 1999 00:24:33 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: execution order ( perl bug?)
Message-Id: <slrn7bv0jv.5c.alastair@calliope.demon.co.uk>
Niclas Karlsson <karlsson@hwcae.honeywell.com> wrote:
>
>--------------49E336FE6E8D3137731FD634
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
Weird.
>I've noticed a weird behaviour of Perl5.004_04 on HP-UX
>Ex, when I run this simple script:
>#!/usr/local/bin/perl -w
>print "The time and date is now: ";
>system("date");
>
>Perl spits out:
>Mon Feb 8 17:01:58 MST 1999
>The time and date is now:
If I saw this, I'd think 'buffering'. Particularly the C stdio library type.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: 08 Feb 1999 19:31:41 -0500
From: Uri Guttman <uri@ibnets.com>
To: Niclas Karlsson <karlsson@hwcae.honeywell.com>
Subject: Re: execution order ( perl bug?)
Message-Id: <391zk0e7te.fsf@ibnets.com>
>>>>> "NK" == Niclas Karlsson <karlsson@hwcae.honeywell.com> writes:
NK> Content-Transfer-Encoding: 7bit
please don't post with mime enabled. usenet is a text only medium.
don't raise the spectre of a perl bug unless you are very sure of what
you are seeing.
NK> print "The time and date is now: ";
NK> system("date");
do you understand the basics of output buffering in stdio? stdout is
normally line buffered and only when a newline is printed does the
buffer get flushed.
NK> Mon Feb 8 17:01:58 MST 1999
NK> The time and date is now:
in this case the system call to date executes and flushes its stdout buffer,
THEN perl exits and flushes its stdout buffer.
NK> Notice the order, it gives the appeareance that perl excuted, them in
NK> the wrong order!
no, the buffers were flushed in an order you didn't expect.
NK> However if you had a newline like this:
NK> print "The time and date is now: \n";
NK> system("date");
now the perl stdout get flushed before the system call of date is made
so the order looks correct.
NK> The time and date is now:
NK> Mon Feb 8 17:04:36 MST 1999
try setting $| to 1 before the print in the first version. you may be
pleasantly surprised at what you see.
NK> Content-Type: text/html; charset=us-ascii
even worse than posting mime is posting html. bad boy!!
hth,
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Tue, 09 Feb 1999 00:09:24 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: File::Path rmtree and tainting
Message-Id: <79nubl$ktu$1@nz31-priv.rz.uni-karlsruhe.de>
dturley@pobox.com wrote:
>I was trying out the rmtree2 example in the Perl Cookbook (section 9.8
>Removing a directory and its contents). Th example uses the rmtree() function
>from File::Path. When tainting is turned on I get an insecure error on unlink
>within file.pm. The only user input I send is the directory name, which I
>untaint. Since the directory name is untainted, shouldn't the file names
>derived from it be also? How can I this function when running with the -T
>flag?
I think this behavior of File::Path is broken.
Try this patch:
palandt:/usr/lib/perl5/File # diff Path.pm Path.pm.orig
93,96d92
< Patched by Marc.Haber@gmx.de to (probably) properly
< handle Taint checking. This is a quick hack that is
< not guaranteed to work.
<
156d151
< print "rmtree($root,$verbose,$safe)\n" if $verbose;
178,186c173
< # @files = map("$root/$_", grep $_!~/^\.{1,2}$/,@files);
< foreach ( @files ) { # un-taint @files
< if( /^\.{1,2}$/ ) {
< $_ = "";
< } else {
< /^(.*)$/;
< $_ = "$root/$1";
< }
< }
---
> @files = map("$root/$_", grep $_!~/^\.{1,2}$/,@files);
palandt:/usr/lib/perl5/File #
I don't have a single idea about the security implications of this
patch. I handed it in to the developer half a year ago and got
notified that probably the patch will make it into the next release.
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Tue, 09 Feb 1999 01:17:24 GMT
From: pegasusetc@my-dejanews.com
Subject: Help
Message-Id: <79o2ar$nh$1@nnrp1.dejanews.com>
Hello folks! I give up. I am not a programmer. I could spend a month
obsessing to figure it out, but would like to get things running on site
asap. We have a nonprofit site which is an interactive site for children for
Humane Education. I have tried to modify a guestbook from Matt's Archive only
to mess it up. Are any of you far more capable people interested in helping?
We could pay, though we have little $. If you love Animals you could donate -
though we realize this is perhaps something we need to pay for. And I don't
believe it means that much work. The site itself is
http://www.pegasusetc.com/bitz.html The guestbook is at
http://www.pegasusetc.com/guestbook/index.html The add a guest is at
http://www.pegasusetc.com/addguest.html The cgi script is at
http://www.pegasusetc.com/guestbook/guestbook.cgi I'm not sure that you can
access the last via browser but the rest explains what I'm trying to do -
what modifications I am trying to make. Thank you for your attention, diane
of The Sanctuary
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 9 Feb 1999 00:39:12 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how do I get a date in perl?
Message-Id: <79o03g$2kr$4@client2.news.psi.net>
Duc Le (bamboo@best.com) wrote on MCMLXXXVII September MCMXCIII in
<URL:news:36BE41A8.66878025@best.com>:
== Hi!
==
== I don't know if Perl has any function for date manipulation besides
== localtime(). I just want to do a simple task like getting the week date
== from any given day of the month. For example, given "02/12/1999", I
== would like to know what date of the week this day falls on.
==
CPAN. Look for Date:: and/or Time:: modules.
Abigail
--
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
------------------------------
Date: Mon, 08 Feb 1999 16:41:08 +0000
From: Bill Palmer <Bill.Palmer@online.disney.com>
Subject: libwww for NT
Message-Id: <36BF13A4.25CB@online.disney.com>
Does anyone know where a version of libwww for perl WIN32 on NT might be
found?
TIA - bill
------------------------------
Date: Mon, 8 Feb 1999 23:50:01 -0000
From: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: Re: locking files
Message-Id: <Ox0#737U#GA.123@nih2naae.prod2.compuserve.com>
Hey Dan,
Basically, once a file is locked no other process can open that file. This
is good for files which are written to alot. Think about it. If the script
is writing a few lines to a file, then all of a sudden another process comes
in and starts writing to the same file, it'll screw up the entire file.
Here's an example of file locking:
open (FILE, ">file.txt");
flock (FILE, LOCK_EX); seek (FILE, 0, 1);
( .. do something .. )
close (FILE);
Hope that helps,
Mike
dan wrote in message <36BF6086.18B25F2B@macdaddyusa.com>...
>can someone give me a quick rundown on what locking files is? thanks
>
>
------------------------------
Date: Mon, 8 Feb 1999 16:04:15 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Mnaip.pm Not Supported
Message-Id: <MPG.11291b5cad1083039896a8@nntp1.ba.best.com>
In article <79n0fd$5gk$1@camel18.mindspring.com>, winstons@mindspring.com
says...
> I am developing my first application in Perl and wish to use functions
> from the manip.pm module. However, this module is not loaded on the Apache
> server at charweb.org.
Of course you understand that you don't load perl modules on Web servers.
> In attempting to get the module to run from my
> cgi-bin I noticed that it refers to a bunch of Perl configuration files
> which I do not have access to. Is there a work around to this or am I at
> the mercy of the sysop?
http://www.CPAN.org/modules -- check the second link and it describes how
to install modules locally.
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: Tue, 9 Feb 1999 00:30:52 -0000
From: "Bruce Davidson" <bruce.d@btinternet.com>
Subject: Re: My SQL
Message-Id: <79nvfm$h57$1@plutonium.btinternet.com>
>DBD::ODBC or Win32::ODBC if you prefer
I'd prefer Win32::ODBC in order to read from an Access.mdb and then write
the found rows to a Mysql Database, all from the one perl script.
Could do with a steer on the perl syntax to write to mysql - not the sql
statements but the general idea.
------------------------------
Date: Tue, 9 Feb 1999 07:37:15 +0800
From: "Bradley J. Gibby" <bgibby@iinet.net.au>
Subject: Re: NEWBIE Question about error checking string
Message-Id: <79nsed$91$1@news.iinet.net.au>
Try this...
if ($FORM{'string1'} =~ /[0..5]/ || $FORM{'string1'} =~ / /) {
print "Content-type: text/html\n\n";
print "<html><head><title>Bad Entry</title></head>\n";
print "<body><h1>Bad Entry</h1><br>Some of the characters
you have entetred are invalid\n";
print " Please click back and\n";
print "try again.\n";
exit;
}
Hope it helps q:)
--
Bradley J. Gibby
http://www.iinet.net.au/~bgibby/index.html
------------------------------
Date: Tue, 9 Feb 1999 07:41:57 +0800
From: "Bradley J. Gibby" <bgibby@iinet.net.au>
Subject: Re: Parsing output from a program called within perl
Message-Id: <79nsn7$1ap$1@news.iinet.net.au>
Wouldn't you do it either:
1. system("dir > filename.txt");
>From there just open the file and do what you please, or,
2. open (DIR, "dir |");
>From there the output of the dir command is put into <STDIN>.
Hope this helps q:)
--
Bradley J. Gibby
http://www.iinet.net.au/~bgibby/index.html
kalikste@uiuc.edu wrote in message <79n0ub$49e$1@nnrp1.dejanews.com>...
>How can I parse input from a program called from system() as if it were
>comming from <STDIN>? I don't think it should matter, but I am on a win32
>system (NT).
>
>For example: I would like to treat the output from system (dir), as if I
was
>reading the output from a file. I can't pipe the information to a file
first
>without some hassles, becase there may be more than one instance on the
>script running at a time. Logically, it seems to me this should be
relaivly
>easy with perl. I thank you in advance for your input. I would appreciate
>replies via email.
>
>Thanks,
>jeff
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 9 Feb 1999 00:40:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing output from a program called within perl
Message-Id: <79o06j$2kr$5@client2.news.psi.net>
kalikste@uiuc.edu (kalikste@uiuc.edu) wrote on MCMLXXXVII September
MCMXCIII in <URL:news:79n0ub$49e$1@nnrp1.dejanews.com>:
<> How can I parse input from a program called from system() as if it were
<> comming from <STDIN>? I don't think it should matter, but I am on a win32
<> system (NT).
open PIPE, "command |" or die "Opening pipe failed: $!";
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Tue, 09 Feb 1999 00:04:52 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: performance penalty: bareword, single quoting, double quoting
Message-Id: <EYKv2.6171$Ge3.25517640@news.itd.umich.edu>
In article <79nrgl$qou$1@nnrp1.dejanews.com>, <mlehmann@prismnet.com> wrote:
>I have been wondering for a while if I should use barewords for the keys in
>hashes. I started off using:
> $hash{'key_value'}
>because I thought it was the least amount of work for perl to determine what I
>want.
>Because perl interpolates double quoted strings I avoided using:
> $hash{"key value"}
>Using that logic I figured that perl has to look through some table containing
>the method/function names to determine if a bareword is an executable.
ITYM "function". Yes, but only once, at compile time. Observe:
perl -le 'sub foo { print "testing" } foo' # this prints "testing"
perl -le 'eval q/sub foo { print "testing" }/; foo' # this prints nothing
>However, many perl developers write aesthetically pleasing readable code using
>the barewords. I prefer barewords. Is there a noticable performance hit for
>barewords? Is there any performance hit at all?
Not that I can tell. There is another problem, though: if you run your
script with the -w switch (recommended), you'll get a warning about
lower-case barewords. So, use upper-case, or begin your barewords with an
underscore. Personally, I spring for the single quotes when I want
constant, lower-case hash keys.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Mon, 8 Feb 1999 19:40:41 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: performance penalty: bareword, single quoting, double quoting
Message-Id: <Pine.A41.4.02.9902081916590.13514-100000@ginger.libs.uga.edu>
On Tue, 9 Feb 1999, Sean McAfee wrote:
> In article <79nrgl$qou$1@nnrp1.dejanews.com>, <mlehmann@prismnet.com> wrote:
> >However, many perl developers write aesthetically pleasing readable code using
> >the barewords. I prefer barewords. Is there a noticable performance hit for
> >barewords? Is there any performance hit at all?
>
> Not that I can tell. There is another problem, though: if you run your
> script with the -w switch (recommended), you'll get a warning about
> lower-case barewords. So, use upper-case, or begin your barewords with an
> underscore. Personally, I spring for the single quotes when I want
> constant, lower-case hash keys.
Perl (perl, that is) is fast. Computers are fast. They just got faster
in the time it took me to type this. Don't worry about it. Choose a
style that helps *you* figure out what you wrote last week. If you
really want to know, use Benchmark, but IMHO you'd be wasting your time.
Of course that's never stopped me ...
I like barewords in those places where perl doesn't complain about
them. Actually, -w doesn't complain about lower-case barewords. It only
complains about Perl reserved words, to wit:
1 #!/usr/local/bin/perl -w
2 use strict;
3
4 my %h = ();
5 $h{DESTROY} = 1;
6 $h{x} = 1;
7
8 ### Output:
9 ### Ambiguous use of {DESTROY} resolved to {"DESTROY"}
10 ### at /export/home/bmb/bin/qt line 5.
11 ### Ambiguous use of {x} resolved to {"x"}
12 ### at /export/home/bmb/bin/qt line 6.
(Please note, perl did the right thing.) In those cases where you have
to, just put those keys in quotes, i.e., $h{'DESTROY'}, $h{'x'}.
Cheers!
-Brad
------------------------------
Date: Mon, 08 Feb 1999 18:57:16 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Re: Perl 'zine
Message-Id: <36BF79DB.42524299@ecpi.com>
This sounds like fun. When do we start?
John
Marquis de Carvdawg wrote:
> Just throwing this out to everyone...
>
> I really enjoy TPJ...when it comes out. I get digests from
> the ActiveState listservers, and I read the groups.
>
> Is there any desire for a monthly 'zine along the lines of TPJ?
> I was thinking that it could start out online, and then possibly
> go to soft-cover in the future. I would be glad to not only
> subscribe to such a thing, but also contribute...
>
> I am asking this b/c I have added a 'Perl Corner' to an e-letter
> that I edit, and it's been a real hit with newbies and more experienced
> Perl programmers, as well...
>
> Carv
------------------------------
Date: Mon, 8 Feb 1999 19:54:15 -0500
From: "Ken Pritchard" <ken@activecom.net>
Subject: Perl for QNX
Message-Id: <79o11f$8qa$1@saturn.activecom.net>
Has Perl ever been ported to QNX?
------------------------------
Date: 9 Feb 1999 00:26:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Program needs compactification
Message-Id: <79nvbe$2kr$2@client2.news.psi.net>
Uri Guttman (uri@home.sysarch.com) wrote on MCMLXXXVII September MCMXCIII
in <URL:news:x74soxqyoh.fsf@home.sysarch.com>:
'' >>>>> "A" == Abigail <abigail@fnx.com> writes:
''
'' A> perl -pale '@F{@F}=@F}for(keys%F){'
''
'' abby,
''
'' this is the second time (i know of) you resorted to using the -p
'' internal implementation to hack a tiny solution. it is obscure, elegant,
'' and inscrutable (even though i understand it). i think it violates some
'' (which?) rules of fair play in perl hackery as it takes advantage of
'' knowing how -p and -n are implemented. according to the docs that is
'' what virtually happens, but you know it actually is wrapped in that
'' source so the }{ stuff will work.
I don't know much about the Perl internals. I very seldom look at one
of its C-files.
But I do read The Perl Journal.
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: Tue, 09 Feb 1999 00:44:54 GMT
From: dragnovich@my-dejanews.com
Subject: Re: Programming with Style
Message-Id: <79o0e3$v2c$1@nnrp1.dejanews.com>
I think is easy to understand how to program with style to make more efficient
perl programs!... I make some practices and in the 80% it helps to make better
PERL programs. Im not a perl guru! even I dont know much of perl! but I know
techniques that helps me in programming on C, JavaScripts, Perl, Basic...
1) Ones you get a free time, take a look of you OLD perl programs.. read them
and try to think a better way to do the same thing! I can bet you, that if
you see some of your first programs, and you will say "HOW DID I DONE THIS
PROGRAM!! HO MY GOOD!!! WAS I DRUG INFLUENCED??" 2) Try to program like if
you are teaching to an other person! This help to quit many programming
vices.. Just One command by line! remember the enters are free 3) Buy a good
book! Yes there are many of them! And if you cant find it on the bookstore,
go to http://www.amazon.com this guys GETS ANY BOOK IN THE WORLD for you!
with a very aceptable price.. I Order a book in french that is sold in just
in France ... AND I LIVE IN MEXICO! and they give me it in just 25 days
So there are my ways to make a good programming ...
See ya!!
------------------------
Juan Carlos Lopez
QDesigns President & CEO
http://www.qdesigns.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 09 Feb 1999 00:49:07 GMT
From: "Ian Wilkinson" <ian@no-spam4site.co.uk>
Subject: Rounding for Euro currency
Message-Id: <01be53c5$e4de7700$LocalHost@quibhrgm>
Hi there.
I'm converting GBP sterling to Euros, multiplying by a 4-decimal place exchange
rate. The answer has to be rounded to the nearest 1/20th Euro, ie to the
nearest 0.05.
So: 9.2244 becomes 9.20, while 9.2245 becomes 9.25. At least, I think that's
what the rounding rule implies.
Is there a neat way of doing this without using a load of if's and modulus
stuff, please?
Thanks very much.
--
Ian Wilkinson
s/no-spam//i
------------------------------
Date: 9 Feb 1999 01:15:47 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Rounding for Euro currency
Message-Id: <918522936.105828@elaine.drink.com>
In article <01be53c5$e4de7700$LocalHost@quibhrgm>,
Ian Wilkinson <ian@no-spam4site.co.uk> wrote:
>Hi there.
>
>I'm converting GBP sterling to Euros, multiplying by a 4-decimal place exchange
>rate. The answer has to be rounded to the nearest 1/20th Euro, ie to the
>nearest 0.05.
Multiply by 20, round to the nearest integer as normal, then divide
by 20.
$new=sprintf("%9.0d",$old*20)/20;
------------------------------
Date: 9 Feb 1999 00:45:02 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: String splitting.
Message-Id: <79o0ee$2kr$6@client2.news.psi.net>
om7@cyberdude.com (om7@cyberdude.com) wrote on MCMLXXXVII September
MCMXCIII in <URL:news:79n4kd$7dm$1@nnrp1.dejanews.com>:
^^ I've got a string, something like $string = abcd.efg, say. Can someone remind
^^ me how I would get the part of of the string before the full stop.
^^
split
substr/index
s///
m//
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
------------------------------
Date: Tue, 09 Feb 1999 01:23:44 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: String splitting.
Message-Id: <A6Mv2.117$iI1.462@newsfeed.slurp.net>
om7@cyberdude.com wrote:
: I've got a string, something like $string = abcd.efg, say. Can someone
: remind me how I would get the part of of the string before the full stop.
As usual, TMTOWTDOI, but:
($part) = $string =~ /(.*?)\./;
or
$part = (split /\./, $string, 2)[0];
The first version leaves $part undefined if there's no . in $string; the
second version sets $part to the entire value of $string instead. Again,
there are dozens of related ways to attack this; these are just the first
two that sprang to mind.
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "The hills were burning, and the wind was raging; and the
clock struck midnight in the Garden of Allah."
------------------------------
Date: Mon, 08 Feb 1999 18:41:22 -0500
From: "Bradley W. Langhorst" <bwlang@nospam.genome.wi.mit.edu>
Subject: system call works in command line mode but not from web
Message-Id: <36BF7621.8E7B0342@nospam.genome.wi.mit.edu>
i have the following system call
$tmp1 = $TmpDir . "in.lp";
$tmp2 = $TmpDir . "lp.out";
print "<br>\ndollar! is : " . $! ."\n";
$tmp = system
("/net/speedo/local5/cvar_files/SRC/LP_SOLVE/lp_solve_2.3/lp_solve <
$tmp1 > $tmp2");
print "<br>System call to lp_solve returned: " . $tmp .
"<br>\ndollar! is : " . $! ."<br>\n";
$tmp is 1 (system call failed)but $! does not change from "Operation
would block" between before and after the system call
this works fine if i run my script
and supply parameters to it from the command line.
However it creates the $tmp2 (the output file)
but puts no data into it when i run it from the web.
yes lp_solve is world executable
and yes the user "web" has write access to the $TmpDir listed
any hints?
thanks
brad
bwlang@nospam.genome.wi.mit.edu
------------------------------
Date: Mon, 08 Feb 1999 16:49:21 -0800
From: Daniel Olson <olsondan@ohsu.edu>
Subject: Using modules, esp. with perlxs
Message-Id: <36BF8611.3D4C@ohsu.edu>
I have been using perlxs to make C functions available to my perl
script. Everything went along fine, with a little nudging from some list
members. Once I got my 'test.pl' file working, I was ecsatic. But the
line at the top of it concerned me:
"# Before `make install' is performed this script should be runnable
with
# `make test'. After `make install' it should work as `perl test.pl'"
I wasn't sure I wanted to install the module into the global perl
system, but it was the only way I could get my script to access the
module. Only after this step did 'require Mytest::module' work.
My basic question is, How can I make my modules available without doing
this install? This module is only useful to this particular script.
(Yes, I know this sounds short-sighted.) But I don't feel comfortable
cluttering up my perl installation (actually, the department server's
perl installation) with small modules that are not of general use.
A grander question is, What exactly does this install do? What
modifications to files or directories does it perform?
--
**************************************************************
Dan Olson
"You are so mercifully free from the ravages of intelligence."
-- Supreme Evil, Time Bandits
**************************************************************
------------------------------
Date: Mon, 8 Feb 1999 20:38:22 -0500
From: "John Counts" <jcounts@voicenet.com>
Subject: Re: Using modules, esp. with perlxs
Message-Id: <79o40q$198$1@news1.fast.net>
This article (found on reference.perl.com) called Perl Module Mechanics
might clear up some of your questions
http://world.std.com/~swmcd/steven/perl/module_mechanics.html
Daniel Olson wrote in message <36BF8611.3D4C@ohsu.edu>...
------------------------------
Date: Tue, 09 Feb 1999 00:30:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Viewing remote Perl script before executing
Message-Id: <WkLv2.4$iI1.890@newsfeed.slurp.net>
brackett@pobox.com wrote:
[wrt viewing Perl CGI script source before running it]
: Oh, I thought there was a way to do it. For some reason I thought that
: was the one of the reasons why so many people always wanted to be able
: to compile Perl code (to make it less readable).
Some people may want it for that reason, but these people are either
(a) mistaken, or
(b) using early versions of Microsoft IIS.
A security bug in IIS once allowed you to append ::$DATA to a CGI URL and
get handed the source. Needless to say, this caused some consternation.
It's fun trying ::$DATA on random CGIs around the web; it quickly becomes
clear how many people have never heard the words 'patch' or 'upgrade'. :)
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "The hills were burning, and the wind was raging; and the
clock struck midnight in the Garden of Allah."
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4849
**************************************