[9654] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3248 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 24 18:07:33 1998

Date: Fri, 24 Jul 98 15:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 24 Jul 1998     Volume: 8 Number: 3248

Today's topics:
    Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos <TerryLCora@worldnet.att.net>
    Re: ...experienced Perl programmers rarely use eof... (Jordan Henderson)
    Re: ...experienced Perl programmers rarely use eof... <jdporter@min.net>
        Authentication---I want more <sponge@iav.com>
    Re: changing default shell for system() (Andrew M. Langmead)
    Re: changing default shell for system() <dagon@halcyon.com>
    Re: Changing to home directory <Eric.Zylberstejn@wanadoo.com>
    Re: confused with list of hashes. (Patrick Timmins)
    Re: Correction: Problem with escaped octal chars > 177 <jpowers@cs.oberlin.edu>
    Re: Gif Image Questions (I R A Aggie)
    Re: GUI avaible for the Perl debugger (UNIX only) <Eric.Zylberstejn@wanadoo.com>
    Re: Hash tree problems. (M.J.T. Guy)
    Re: How to delete files from perl (Gabor)
    Re: Is there a better way to do this? (M.J.T. Guy)
    Re: is there a isNumber($aString) function? (Abigail)
    Re: local %ENV buggy with open (M.J.T. Guy)
    Re: parsing question (Tad McClellan)
        Rounding (Ollie Cook)
    Re: Rounding (Craig Berry)
    Re: two "should-be" FAQ's re:arrays <tchrist@mox.perl.com>
        Using system sprintf instead of perl built-in (Joshua Burgin)
    Re: Using system sprintf instead of perl built-in (Joshua Burgin)
        web hosting <pjw7@ukc.ac.uk>
    Re: Why can't I "require" a file? merzky@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 24 Jul 1998 17:56:38 -0400
From: "Terry Cora" <TerryLCora@worldnet.att.net>
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <6pavuc$924@bgtnsc03.worldnet.att.net>

>Brigitt wrote:
>I think you got me wrong and I made a
>mistake in referencing my post.

>I was not questioning the MiniFAQ post of Mathan Torkington
>because perl books from O'Reilly are mentioned, not at all.


Copied from mini-FAQ Post.
*9. The latest version of the "Camel Book" ("Programming Perl"),
*updated for version 5.003, is available from your bookstore or from
*http://www.ora.com/
-end copy-

This is a link to O'Reilly's web site and the "Camel Book" is a Perl Book
published by O'Reilly.  So I believe you are incorrect.

BTW
I have nothing to do whatsoever with the site or mail list I referenced in
my first reply other than being a subscriber.  I will not make 1 cent from
that post. I do not know the listmaster and she does not know me.

I simply took an opportunity to let other newbies (like myself) know that
there is a cheaper place to get the recommended book on-line while looking
at many other titles not available from O'Riely, and support what I consider
a terrific free perl information rescource (the cgi-list).

The mini-FAQ, posted by a defacto employee of O'Reily, promotes 1 book by
O'Reily, but apparantly you don't consider this a sneaky form of spam.
Actually, I would not either, if it was done intentionally it would actually
be a highly targeted, and effective marketing ploy.

The Camel book is a great rescource.  The mini-FAQ is also.  I'm sure the
Perl Cookbook will be a great book.  I highly doubt Nathan had any alterior
motives in mind.  But some could argue that there is a conflict of interest
in including a link to O'Reily's web site (http://www.ora.com/) since Nathan
receives, or will be receiving, some funding from O'Riely.

Since I seem to be the only one who thinks this way, I will accept that I am
wrong and that I impropperly spammed this newsgroup with a useless and
offtopic post.  I really need to limit my postings to stupid questions.

>I don't see how mentioning a publisher of a highly recommendable
>Perl book can be in any way considered as SPAM. The Llama, Camel
>and Panther books belong into a Perl programmer's library, it
>is IMHO normal and expectable that these books are mentioned in clpm.
>
>I was referring to your post ( Terry Cory), and was questioning
>the way you used clpm to announce a cheaper deal of the book
>at your own site, which is again linked to AMAZON for ordering purposes.

Again, it was not my site and I gain nothing (but indirect knowledge) from
anyone who visits it.

>
>You are earning commission for selling the book in question if they are
>ordered through the link on your site.

Nope.

>That is in my opinion a usage of clpm which is not acceptable,
>even if the money is used to support a mailing list concerned
>with Perl.


If it would have been true, you would have been correct.

>I just would like to make clear that any website owner who
>is an associate of AMAZON (or an associate of any other online
>bookseller) and who advertises *his* website to order a book
>from, is spamming, actually in this case it is SPAMMING FOR TWO,
>for himself and for the online bookseller he is an associate with.

>
>If I am the only one who thinks that way, I will not post
>any more complaints in that regard in the future.
>
>It is not that important to me, but from another thread and a post by
>Ted McClellan a couple of days ago, I got the impression
>that the distinction of who spams, Amazon or associates
>of Amazon is not realized. That is the reason I posted in reference
>to this subject.
>
>Birgitt Funk
>
>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

Date: 24 Jul 1998 15:09:07 -0500
From: jordan@Starbase.NeoSoft.COM (Jordan Henderson)
Subject: Re: ...experienced Perl programmers rarely use eof...
Message-Id: <6papl3$kpo$1@Starbase.NeoSoft.COM>


In article <35B8E1C4.8E4@min.net>, John Porter  <jdporter@min.net> wrote:
>Jordan Henderson wrote:
>> 
>> On p.161 of the Camel (2nd Ed.):
>>         ... In fact, experienced Perl programmers rarely use eof,
>>         since the various input operators already behave quite
>>         nicely in while-loop conditionals.
>> 
>> [But,] For example, 
>>         while (<>) { last if /^<PRE>/; }
>>         if (eof) die "...";
>
>Um, well, the Camel didn't say experienced Perl programmers *never* use
>eof().  I guess you found one really good example of when it comes in
>handy.
>

I guess it's just EXTREMELY vaguely deprecated, eh?  :-)

Related to my style musings, I note that the venerable Randal Schwartz 
<merlyn@stonehenge.com> in article <8csojrm9z1.fsf@gadget.cscaper.com>
writes:

Randal> Jordan> Is there a better, clearer way to do this sort of thing?
Randal> 
Randal> I usually write something like this:
Randal> 
Randal> 	$found = 0;
Randal> 	while (<FILE>) {
Randal> 		$where = /<PRE>/../<\/PRE>/;
Randal> 		$found = 1, print if $where;
Randal> 		last if $where =~ /E/;
Randal> 	}
Randal> 	die "we didn't find it!" unless $found;

In which he uses die ... unless.  Is the idiomatic rule here is that it's
supposed to read like human language?  I agree that "unless $found die..."
sounds awkward.

>John Porter

-Jordan Henderson
jordan@neosoft.com


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

Date: Fri, 24 Jul 1998 21:07:26 GMT
From: John Porter <jdporter@min.net>
Subject: Re: ...experienced Perl programmers rarely use eof...
Message-Id: <35B8F918.640F@min.net>

Jordan Henderson wrote:
> 
> I guess it's just EXTREMELY vaguely deprecated, eh?  :-)

Depends on who's doing the deprecating.   
I don't deprecate it at all.
I just never use it!


> Randal Schwartz <merlyn@stonehenge.com> in article
> <8csojrm9z1.fsf@gadget.cscaper.com> writes:
> 
> Randal>         die "we didn't find it!" unless $found;
> 
> Is the idiomatic rule here is that it's
> supposed to read like human language?  I agree that "unless $found die..."
> sounds awkward.

More than how it sounds, is how you'd have to write it:

	unless ( $found ) { die "..." }

Then parens and braces are not optional.  
That's probably the main reason people go for

	die "..." unless $found;

Personally, I prefer

	$found or die "...";


-- 
John Porter


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

Date: Fri, 24 Jul 1998 07:25:26 -1000
From: "Neal Miyake" <sponge@iav.com>
Subject: Authentication---I want more
Message-Id: <6pag4u$31e@enews2.newsguy.com>

Hi, Newbie Neal here,

I'm trying to translate some web forms (and its associated perl scripting)
from an unix server to NT 4 Server w/SP3 running IIS4 and Perl for Win32,
ver 5.003.  I would like to have some standard userid/password
authentication on the front end of the forms, that previously used
".htaccess" files.  This authentication would be something outside of the
regular NT user permissions.  It doesn't have to be really secure or
fancy--just one userid and password per page.  I don't really want to use
ASP as the solution.

Help!  Please copy a reply to sponge@iav.com.  Thanks in advance.

Neal




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

Date: Fri, 24 Jul 1998 20:51:28 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: changing default shell for system()
Message-Id: <EwM9xs.MxJ@world.std.com>

Dan Nguyen <nguyend7@egr.msu.edu> writes:

>Alexandros Labrinidis <labrinid@cs.umd.edu> wrote:

>:  I'd like to change the shell that system() spawns to execute its
>: arguments. For some reason, although $ENV{'SHELL'} is tcsh, perl
>: sticks with sh for system(). Any ideas? 

>Well the reason Alex is this.  Bourne Shell (sh) is on every UNIX
>system.  That you can guarantee.  This like CShell and tcshel are
>optional.

Beyond preventing differences in the execution of the code between
different machines, (depending on which shells are installed) its also
important in preventing differences between different users on the
same machine. (It would be dificult to track down bugs where system
gave different results depending on the environment variables the user
had set.)

And then when you add to that the differences between the redirection
capabilities in csh and maybe the non-existant redirection fascilities
if some site makes the shell some custom menu system or something) you
can see why the C library specified that system always call /bin/sh
(and since perl borrowed system() from C, why it followed suit.)

-- 
Andrew Langmead


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

Date: 24 Jul 1998 14:27:50 -0700
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: changing default shell for system()
Message-Id: <6pau8m$rqc$1@halcyon.com>

Alexandros Labrinidis arranged electrons in a pattern like this:
> I'd like to change the shell that system() spawns to execute its
>arguments.  For some reason, although $ENV{'SHELL'} is tcsh, perl
>sticks with sh for system(). Any ideas? 

Why would you want to do this?  You want it to behave differently based
on the preferred shell of the person who runs it?

If you're doing something complicated that requires tcsh, then call it
directly:
  system('/bin/tcsh', '-c', $tcsh_command);
This way it won't matter what the user has done to $ENV{'SHELL'}.  If
you're trying to make a shell escape to the user's preferred shell, then
do so with:
  system($ENV{'SHELL'}, '-');
You may want to add some sanity-checking (and taint removal) to this as
well, as $ENV{SHELL} might be compromised.

Good luck!
--
Mark Rafn    dagon@halcyon.com    <http://www.halcyon.com/dagon/>   !G


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

Date: Fri, 24 Jul 1998 22:33:49 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: Kevin Slanicky <slanicky@students.uiuc.edu>
Subject: Re: Changing to home directory
Message-Id: <35B8EFAD.1AED2772@wanadoo.com>

Hello,

Kevin Slanicky wrote:
> 
> I'm needing to change to the home directory of wherever the script is
> running
> and am having some serious problems.
> [...]

How about :

chdir $ENV{HOME};


	Eric.pl


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

Date: Fri, 24 Jul 1998 20:55:26 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: confused with list of hashes.
Message-Id: <6pasbv$o0m$1@nnrp1.dejanews.com>

In article <35B8BAD2.558BD36E@sig.net>,
  Alexander Bibighaus <alexb@sig.net> wrote:
>
>
> I was reading the more elaborate records cookbook trying to figure out
> how to create a list of
> records.
>
> for instance, my record fields would be
>
> Port,
> SessionID
> UserID
> Time
>
> Now, I seem to understand that I can create this record by using a hash
> such as
> (Please correct me if I am wrong)
>
> my(%rec) = (
>     Port => undef,
>     SessionId => undef,
>     UserID => undef,
>     Time => undef
> );
>
> Now, I am confused with the syntax in the example  I was reading:
>
> # reading from file
> # format: LEAD=fred FRIEND=barney
>  while ( <> ) {
>      $rec = {};                                                # ??
>      for $field ( split ) {
>          ($key, $value) = split /=/, $field;
>          $rec->{$key} = $value;                         # ???
>      }
>      push @LoH, $rec;                                     # ??
>  }
>
> Could someone explain this example for me and maybe how it would relate
> to what I am trying to do.
>
> thanks,
>
> alexander
>
>

What Tom C. is saying in his example (and it is Recipes for PDSC #3: Lists of
Hashes, not Recipes for PDSC #5: More Elaborate Structures) is that if you
have an input file with a data structure of (expanding on Tom's):

LEAD=fred FRIEND=barney WIFE=wilma
LEAD=ralph FRIEND=norton WIFE=alice
LEAD=bill FRIEND=monica WIFE=hillary
etc
etc

then:

while ( <> ) {
    $rec = {};
    for $field ( split ) {
        ($key, $value) = split /=/, $field;
        $rec->{$key} = $value;
    }
    push @LoH, $rec;
}

will load that data structure in to a list of hashes called @LoH.

Your data structure sounds more likely to be something suited to a hash of
hashes (keyed on a process id, perhaps?), so you should probably look at Tom's
Recipes for PDSC #4: Hashes of Hashes, which can be found at:

http://www.perl.com/CPAN-local/doc/FMTEYEWTK/pdsc/pdsc-4.html

Hope that helps.

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 24 Jul 1998 12:44:01 -0400
From: Joshua Powers <jpowers@cs.oberlin.edu>
To: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Correction: Problem with escaped octal chars > 177
Message-Id: <Pine.ULT.3.96.980724124129.4231Y-100000@occs.cs.oberlin.edu>

I can't reproduce this problem now.  I'm afraid that it was due an
oversight on my part.  Also, I was not aware that the perl debugger
iterates over a loop once before stopping at a breakpoint set at the
beginning of the loop, so I was confused by this.  It seems that this
happens on all loops (at least "for" loops - i haven't tried it on any
others).
 
But my main question is, should this work?  That is, should perl
understand escaped octal characters up to 377?  Does it just set the high
bit and then recognize it as a non-ascii, non-printable character when
reading it from a scalar?

Thanks for responding...

On Fri, 17 Jul 1998, Ronald J Kimball wrote:

> Joshua Powers <jpowers@cs.oberlin.edu> wrote:
> 
> > I have run into an interesting problem...
> 
> Please provide a brief code sample which demonstrates this behavior.
> 

-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-^-_-
		     Josh Powers - jpowers@cs.oberlin.edu
		      http://www.cs.oberlin.edu/~jpowers



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

Date: Tue, 21 Jul 1998 21:19:20 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Gif Image Questions
Message-Id: <fl_aggie-2107982119200001@aggie.coaps.fsu.edu>

In article <Pine.OSF.3.95.980721173359.32369D-100000@cda.mrs.umn.edu>,
James Harman <harmanjd@cda.mrs.umn.edu> wrote:

+ I would like to determine if a given gif is anitmated or not animated, and
+ also get the dimensions of the gif.  Does anybody know how to do this?

I can provide pointers to and hints about the dimensions:

# to get the latest version of wwwimage try either:
#    http://www.dcs.ed.ac.uk/home/ark/wwwimagesize
#    http://www.ugcs.caltech.edu/~werdna/gifsize/

My understanding is that the guts of this program has been incorporated
into a perl module. Which one? dunno. Probably "*ImageSize*" or the like.

As for animated or not, there is this one small clue. There are two
main gif standards, GIF87a and GIF89a. GIF87a is plain-jane gif. No
transparency, no animations, nothing. That is the domain of GIF89a.

'unpack' the first 5 bytes, and you can at least determine if animation
is a possibility. 

Have you considered looking at the documentation for the GIF standard 
that spells all this out in gory detail?

James


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

Date: Fri, 24 Jul 1998 23:22:03 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: Curt McKelvey <mckelvey@usacmckelve.eng.mc.xerox.com>
Subject: Re: GUI avaible for the Perl debugger (UNIX only)
Message-Id: <35B8FAFB.9343C4A@wanadoo.com>

Hello,

Curt McKelvey wrote:
> 
> [...]
> More information, screenshots, and the software for download are available at:
> http://members.tripod.com/~CurtMcKelvey/perldbgui/

I wish this page had a title, some label would appear in the bookmarks and I
would often visit it.

	Regards

		Eric.pl


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

Date: 24 Jul 1998 21:16:49 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Hash tree problems.
Message-Id: <6patk1$3g$1@pegasus.csx.cam.ac.uk>

In article <35B78F12.6123@min.net>, John Porter  <jdporter@min.net> wrote:
>Michael Bowler wrote:
>> 
>> Mark-Jason Dominus wrote:
>> >
>> > But I thought that `exists' was not supposed to trigger any sort of
>> > autovivification; if it does, that is certainly a bug.  I wonder what
>> > version of Perl Michael is using?
>> 
>> I am using 5.002.  I suppose that this is pretty old.  If this is a bug that
>> has been fixed in later releases I will push our sys admin to upgrade.
>
>I have 5.004_04, and it still does this.  
>As tchrist pointed out, we're stuck with it.
>It's not a bug, it's a feature. :-)

No.  It's universally acknowledged that autovivication in rvalue context
is a bug.    It's just that noone has worked out how to fix it without
excessive overhead and/or turning Perl's guts inside out.


Mike Guy


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

Date: 24 Jul 1998 21:21:31 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: How to delete files from perl
Message-Id: <slrn6rhup5.1qd.gabor@localhost.vmunix.com>

In comp.lang.perl.misc, Anandan Balaji <anandan_balaji@emicx.mentorg.com> wrote :
# To remove a file:
# 
# unlink   ( $filename );
# 
# To remove a directory
# 
# use File::Path;
# rmtree ( $dir_name );

To do both at the same time like rm -rf can, use File::Remove

# Neelam Saini wrote:
# 
# > Using perl on UNIX. How do I delete files from perl. I am creating the
# > file using open <filename>
# >
# > Thanks
# 
# 
# 
# 


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

Date: 24 Jul 1998 21:26:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Is there a better way to do this?
Message-Id: <6pau6a$8d$1@pegasus.csx.cam.ac.uk>

Richard Proctor  <Richard@waveney.demon.co.uk> wrote:
>In article <35B79D15.3ED2@min.net>, John Porter
><URL:mailto:jdporter@min.net> wrote:
>> Suggestion #2: 
>> 
>> >     $Warn=$^W;$^W=0;
>> >     $USPrice    = $1;
>> >     $OtherPrice = $2;
>> >     $OnePrice   = $3;
>> >     $^W=$Warn;
>> 
>> This would be much better as
>> 
>> 	{ local $^W;  # =undef, same effect as =0.
>> 	  $USPrice    = $1;
>> 	  $OtherPrice = $2;
>> 	  $OnePrice   = $3;
>> 	} # restore previous value of $^W.
>> 
>
>I had half considered doing it that way, I probably will.

What are you doing that for anyway?   What warning are you hoping to avoid?

(Hint: just copying an 'undef' doesn't generate a warning.)


Mike Guy


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

Date: 24 Jul 1998 21:18:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: is there a isNumber($aString) function?
Message-Id: <6patmb$o50$1@client3.news.psi.net>

Colin Kuskie (ckuskie@cadence.com) wrote on MDCCLXXXVII September
MCMXCIII in <URL: news:Pine.GSO.3.96.980723134713.19858K-100000@pdxmail.cadence.com>:
++ On 23 Jul 1998, Abigail wrote:

It *WOULD* be nice if you said in your email you posted a copy
to the newsgroup as well.

++ For some reason perl doesn't seem to like your anonymous hash.  When I
++ expand it out to a more clear syntax:

sub is_a_number {+{map {$_ => 1} 0 .. 0x7FFFFFFF} -> {+shift}}



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 24 Jul 1998 21:33:12 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: local %ENV buggy with open
Message-Id: <6pauio$d4$1@pegasus.csx.cam.ac.uk>

Michael Maraist  <maraism@sterlingdi.com> wrote:
>
>It would seem that this was a bug.. I have perl version 5.004_03
>installed as our production version, but also have version 5.004_66 for
>my own amusement.  I ran the above script on both, and it worked
>properly on 004_66.

perl5.004_03 was never a released version, as it had serious bugs.
Running it as a production system is distinctly unwise.    You would be
well advised to upgrade to perl5.004_04.


Mike Guy


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

Date: Fri, 24 Jul 1998 10:56:25 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: parsing question
Message-Id: <9raap6.gim.ln@localhost>

Martin (minich@globalnet.co.uk) wrote:

[ this followup did not include the code being discussed...'

  it was something like:      $data = "$something";
]


: >It's still superfluous.  Where did you get this strange notion?
: >Just do a few tests for yourself, if you don't believe me.

: It's not just semicolons 

   *This* is the "strange notion" refered to (I think).

   semicolons in scalar values matter not at all.

   You appear to think that perl will "look inside" $something.

   It won't, unless you tell it to.


: but if the data were all numerals then
: if ($data eq $para) would turn out false 

---------------
#!/usr/bin/perl -w

$something = '1234';

$data = "$something";
$para = '1234';

if ($data eq $para)
   {print "they are equal\n"}
else
   {print "they are not equal\n"}


if ($data == $para)
   {print "they are equal\n"}
else
   {print "they are not equal\n"}
---------------


: wouldn't it 

   I guess not  ;-)

   Both are reported as equal.

   Executes fine with or without the double quotes. 


   (of course   '1.0' and '1'   are == equal, but not eq equal  ;-)



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Jul 1998 21:09:21 GMT
From: oliver.cook@bigfoot.com (Ollie Cook)
Subject: Rounding
Message-Id: <35b8f7a9.1319427@news.ukonline.co.uk>

I've just written a Web Cart perl script for a client and I'm now
stuck at what seems the simplest part of the script. How can I round
the amount to pay to 2 dp? Current the value in the scalar is, say,
1839.12864 , due to complex VAT arithmetic. I'd like it to round to
1839.13. How can I achieve this?
Thanks
Ollie
----
Oliver COOK, Web Site Designer for
Premiere Web Designs - Http://Www.Premiere.Uk.Com/
+
Webmaster of The Audio-Visual Archive 
 * over 900 images and 700 sounds, free
 * Http://Www.Premiere.Uk.Com/ava/ 


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

Date: 24 Jul 1998 21:31:29 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Rounding
Message-Id: <6paufh$ab6$1@marina.cinenet.net>

Ollie Cook (oliver.cook@bigfoot.com) wrote:
: I've just written a Web Cart perl script for a client and I'm now
: stuck at what seems the simplest part of the script. How can I round
: the amount to pay to 2 dp? Current the value in the scalar is, say,
: 1839.12864 , due to complex VAT arithmetic. I'd like it to round to
: 1839.13. How can I achieve this?

It's impolite to ask a question on a newsgroup without reading at least
the past day or two's worth of messages first.  This very question has
been asked and answered twice in that time.  'perldoc -f printf' (or
sprintf).

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 24 Jul 1998 20:17:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: two "should-be" FAQ's re:arrays
Message-Id: <6paq5f$33q$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Steven Jackson N3VZL <steve@gnosis.slac.com> writes:
:1. How does one pass multiple arrays to functions while retaining their
:individuality? 

That's in perlsub.  And perlfaq7.

:2. Is there a $ variable for the "current key" in a for loop through an
:array? i.e.

Nope, use a real C-style for loop.

--tom
-- 
MS-DOS is CP/M on steroids, bigger bulkier and not much better.
Windows is MS-DOS with a bad copy of a Macintosh GUI.
NT is a Windows riddled with VMS.  


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

Date: 24 Jul 1998 19:56:45 GMT
From: joshua@purestuff.com (Joshua Burgin)
Subject: Using system sprintf instead of perl built-in
Message-Id: <slrn6rhpnt.sdh.joshua@nothing.izzy.com>

I'd like perl to use the system sprintf rather than the built-in perl
function.

I looked around in the perl source code but couldn't find an easy
solution.

The system sprintf allows for better localization, with gettext
(Locale::gettext). because the translated strings can have their parts
moved around, like so

sprintf(gettext("%1s is %2s", $var1, $var2));

The translater can actually say put in hints to move the first string into
the second position (%2s is %1s).

The perl sprintf doesn't allow these positioning hints.

Any ideas?

- Joshua
_________________________________________________________________________
Joshua M. Burgin          | The best things in life aren't things
joshua@purestuff.com      | http://www.purestuff.com


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

Date: 24 Jul 1998 20:07:44 GMT
From: joshua@purestuff.com (Joshua Burgin)
Subject: Re: Using system sprintf instead of perl built-in
Message-Id: <slrn6rhqcg.sun.joshua@nothing.izzy.com>

In <slrn6rhpnt.sdh.joshua@nothing.izzy.com>,
Joshua Burgin <joshua@purestuff.com> wrote:

> I'd like perl to use the system sprintf rather than the built-in perl
> function.
> 
> I looked around in the perl source code but couldn't find an easy
> solution.
> 
> The system sprintf allows for better localization, with gettext
> (Locale::gettext). because the translated strings can have their parts
> moved around, like so
> 
> sprintf(gettext("%1s is %2s", $var1, $var2));
> 
> The translater can actually say put in hints to move the first string into
> the second position (%2s is %1s).
> 
> The perl sprintf doesn't allow these positioning hints.

Here's the detailed info, from the sprintf/printf man page for DEC Unix.

    +  A % (percent sign).

       The printf() functions can handle a format string that enables the
       system to process elements of the parameter list in variable order.
       In such a case, the normal conversion character % (percent sign) is
       replaced by %digit$, where digit is a decimal number in the range
       from 1 to NL_ARGMAX. Conversion is then applied to the specified
       argument, rather than to the next unused argument.  This feature
       provides for the definition of format strings in an order
       appropriate to specific languages.  When variable ordering is used,
       the * (asterisk) specifi-cation for field width in precision is
       replaced by *digit$.  If the variable ordering feature is used, it
       must be specified for all conversions.

Basically what I'm asking is for a way to comment out the perl printf
function and force it to use the 'system' printf, and then compile perl
that way.

Joshua


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

Date: Fri, 24 Jul 1998 21:00:38 +0100
From: pjw7 <pjw7@ukc.ac.uk>
Subject: web hosting
Message-Id: <35B8E7E6.31B@ukc.ac.uk>

Can someone please tell me if there is a good free web hoster that
allows cgi scripts to be put on their server.  My current ISP (u-net)
only allows the use of their own cgi scripts which consists of a counter
and......well I think thats it.  Pretty sad eh.


Thanks



Peter


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

Date: Fri, 24 Jul 1998 20:04:33 GMT
From: merzky@my-dejanews.com
Subject: Re: Why can't I "require" a file?
Message-Id: <6papch$kf8$1@nnrp1.dejanews.com>

In article <901283176.20914.0.nnrp-07.9e9886e2@news.demon.co.uk>,
  "David Travis" <david@system-concepts.com> wrote:
> I'm running a Perl script on my ISP's Apache server and it won't let me
> "require" another file. It's not a permissions problem, since the program
> gets past a check to see if the file exists and is readable. Any
> suggestions?
>
> Here's the code fragment:
>
>     if (-e "$file" && -r "$file")
>       {
>       require "$file";
>       }

would be nice if you could show us the file you want to include.
The error probably is located there...

This message means, that perl found that file, parsed it, but could
not find a true statement at finally. Sometimes, a simle
1;
as last line helps, but no warranty for that.

Andre.

>
> The compiler fails at the require line and complains that $file
> "did not return a true value".
>
> david@system-concepts.com
>


--
Andre Merzky
pinocchio@earthling.net
http://pino.home.pages.de/

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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