[18789] in Perl-Users-Digest
Perl-Users Digest, Issue: 957 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 22 09:05:40 2001
Date: Tue, 22 May 2001 06:05:10 -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: <990536709-v10-i957@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 22 May 2001 Volume: 10 Number: 957
Today's topics:
delete() from array <bart.lateur@skynet.be>
Re: delete() from array (Anno Siegel)
Re: garbage collection in perl <ilya@math.ohio-state.edu>
Re: Handling JPEGs without modules <pilsl_@goldfisch.at>
Re: HELP!!!! : HTTPd: malformed header Error <1@1.1>
Re: Help: using constants from inherited parent class (Anno Siegel)
Re: How to store data in the session with perl? <pilsl_@goldfisch.at>
Re: Module DB_File on NT <carvdawg@patriot.net>
Re: My senior project is "done" <c_clarkson@hotmail.com>
Re: Need help on formatting output <admin@the-piper.net>
Re: non repeating random numbers (Anno Siegel)
of the TWO perl-debugging books, which best? (David Combs)
Re: scientific notation (Anno Siegel)
Re: Slight problems with rounding. (Anno Siegel)
Re: Solaris help <thunderbear@bigfoot.com>
Re: Stringformation <peb@bms.umist.ac.uk>
Re: Stringformation <bart.lateur@skynet.be>
Re: Stringformation <flavell@mail.cern.ch>
Re: Stringformation <bart.lateur@skynet.be>
Re: Stringformation <Rene.Scheibe@gmx.net>
XML::Simple more than one root tag?? (Sascha)
Re: XML::Simple more than one root tag?? <thunderbear@bigfoot.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 May 2001 11:29:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: delete() from array
Message-Id: <57jkgtscln272jhdnmj6pkfh0gctfun7sf@4ax.com>
In recent perls (from 5.6 on, I believe), it is possible to remove items
from an array using delete(). However, it doesn't work as *I* expected.
What I did expect, is the same effect as when using splice(). However:
@ary = 1 .. 5;
@del = delete @ary[1,3];
$" = "+";
print "deleted: @del\n";
print "remains: @ary\n";
-->
Use of uninitialized value in join at test.pl line 6.
Use of uninitialized value in join at test.pl line 6.
deleted: 2+4
remains: 1++3++5
What gives? These array elements are not really deleted. They are
undef()fed. I would have expected the holes to have been closed.
The current behaviour hardly seems useful.
--
Bart.
------------------------------
Date: 22 May 2001 12:05:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: delete() from array
Message-Id: <9edkmk$q04$1@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> In recent perls (from 5.6 on, I believe), it is possible to remove items
> from an array using delete(). However, it doesn't work as *I* expected.
> What I did expect, is the same effect as when using splice(). However:
>
> @ary = 1 .. 5;
> @del = delete @ary[1,3];
> $" = "+";
> print "deleted: @del\n";
> print "remains: @ary\n";
> -->
> Use of uninitialized value in join at test.pl line 6.
> Use of uninitialized value in join at test.pl line 6.
> deleted: 2+4
> remains: 1++3++5
>
> What gives? These array elements are not really deleted. They are
> undef()fed. I would have expected the holes to have been closed.
>
> The current behaviour hardly seems useful.
Well, it's not the multi-splice one might have hoped for. It does
allow to remove multiple elements from an array at once (unlike undef,
which is a unary operator), and the state of a delete()d element
is slightly different from an undef()ed one: exists() returns
false for the former and true for the latter[1]. It is the same
state $ary[0] has after "my @ary; $ary[1] = 123;".
If delete happens at the end of an array, some shrinkage even
takes place: The array length goes down by one or more, depending
on whether there are more non-existent elements at the end of the
array.
Anno
[1] I'd speculate that undef puts pointers to PL_sv_undef in the
slot while delete leaves a NULL pointer there.
------------------------------
Date: 22 May 2001 04:35:41 GMT
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: garbage collection in perl
Message-Id: <9ecqat$ip5$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Joe Smith
<inwap@best.com>], who wrote in article <9ec6tt$2k7k$1@nntp1.ba.best.com>:
> >becomes
> >
> > my $var;
> > <nothing> if 0;
> >and
> >
> > my $var = 'some_initial_value';
>
> That interferes with the current, documented behavior: "A private
> variable's scope does not start until the statement _after_ its
> declaration."
What you discuss is a compile-time action of my(). No change in a
run-time action will influence the compile-time stuff.
Ilya
------------------------------
Date: Tue, 22 May 2001 14:49:56 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: Handling JPEGs without modules
Message-Id: <MPG.15747ee312b6c7179898b6@news.inode.at>
In article <9ec6cd$ffj$06$1@news.t-online.com>, ebo_mike-antispam-remove-
t@hottmail.com says...
>
> So this is a challenge... is nobody up to it?! I'm rather surprised to see
> that no-one else has encountered a similar problem. I wouldn't even say that
> my hoster sucks; they're competent and (usually) have great support, they
> just fall flat on this one issue.
>
If your ISP offers perl he need to install the basic modules or it sucks
;)
however: why not ftp the module-files to your host after proper compiling
them on your own machine and then include them using a command like
use lib "whatpathever"
peter
--
pilsl@
goldfisch.at
------------------------------
Date: Tue, 22 May 2001 13:01:06 GMT
From: G3CK0 <1@1.1>
Subject: Re: HELP!!!! : HTTPd: malformed header Error
Message-Id: <MPG.15739d004fc21a03989682@news-server.wi.rr.com>
Once the script runs and produces the form preview HTML page, if I look
at the code, it has:
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
I have looked over the script that produces the page and it IS printing
a content type.
Here is the script that produces the preview page:
sub prev {
$prv = "";
if ($S_NDWO_RD) {
$prv .= " <input type=\"hidden\" name=\"WRD\"
value=\"$S_NDWO_RD\">\n";
$prv .= " <input type=\"hidden\" name=\"WRD2\"
value=\"$S_NDWO_RD\">\n"; }
$prv .= " <input type=\"hidden\" name=\"shwprev\" value=\"1\">
\n";
for ($cnt = 0; $cnt < @forms; $cnt++) {
if ($nulls == 1 && $INS{$forms[$cnt]} eq "") {next;}
($do = $INS{$forms[$cnt]}) =~ s/\&/\&\;/g;
$do =~ s/chr(61)/\"\;/g;
$do =~ s/chr(139)/\<\;/g;
$do =~ s/chr(155)/\>\;/g;
$do =~ s/chr(169)/\&\#169\;/g;
$do =~ s/chr(174)/\&\#174\;/g;
$do =~ s/chr(153)/\&\#153\;/g;
$do =~ s/\cM\n/\n/g;
$do =~ s/(\n(\n+))/<p>/g;
$do =~ s/\r//g;
$do =~ s/ +/ /g;
$do =~ s/\n/<br>/g;
if ($forms[$cnt] =~ /^(return|mailto|WRD|GEN|db
$|frmName|opts|thnx)$/i) {$prv .= " <input type=\"hidden\" name=
\"$1\" value=\"$INS{$forms[$cnt]}\">\n";}
elsif ($forms[$cnt] =~ /(_H)$/) {$prv .= " <input
type=\"hidden\" name=\"$forms[$cnt]\" value=\"$do\">\n";}
elsif ($forms[$cnt] !~ /(^send$|^mailto$)/i) {&mke;}
}
if ($bigTtl) {$labels[$cnt] = "Total Value"; $do = "$total_prfx
$bigTtl"; $forms[$cnt] = "Total.Value"; $INS{$forms[$cnt]} =
"$total_prfx$bigTtl"; &mke;}
$nprv .= " <tr><td bgcolor=\"#F0F0F0\" width=\"20\">
</td>\n";
$nprv .= " <td align=\"right\" valign=\"top\" bgcolor=
\"#F0F0F0\" nowrap><font size=\"2\" face=\"arial,helvetica,geneva\"><b>
Form: </b></font></td>\n";
$nprv .= " <td align=\"left\" width=\"80%\" bgcolor=
\"#F0F0F0\"><font size=\"2\" face=\"arial,helvetica,geneva\">$INS
{'frmName'}";
$nprv .= " </font></td></tr>\n";
$prv = "$nprv$prv";
print "Content-type: text/html\n\n";
print <<EOT;
<html><head>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<title>Form Input Preview</title></head>
<body bgcolor="#CCCCCC" text="#000000" link="#0000FF" vlink="#
0000FF" alink="#FF0000">
<center><table border="0" cellspacing="0" cellpadding="2"><tr><td
align="center" bgcolor="#E2E2E2"><font
size="2" face="arial,helvetica,geneva" color="#0000cc">
<b>Preview Only</b>. Contents not posted until submitted
</font></td></tr></table></center>
<form method="POST" action="$cgi_url">
<center><table width="530" border="0" cellspacing="0"
cellpadding="1"><tr><td align="center" bgcolor="#666666"><table
width="100%" border="0" cellspacing="0" cellpadding="2"><tr>
<td align=center colspan=3 bgcolor="#454566"><font size="5"
color="#FFFFFF"><b>Confirmation Preview</b></font></td></tr>
<tr><td width="100%" colspan="3" align="center" bgcolor="#F0F0F0">
<input type="submit" name="send" value="SUBMIT details"></tr></tr>
<tr><td bgcolor="#F0F0F0" align="center" colspan="3"><font
face="arial,helvetica,geneva" size="2" color="#cc0000">Back
Arrow to make changes, click "Submit" to send.</font></td></tr>
$prv
<tr><td bgcolor="#F5F5F5" align="center" colspan="3"><font
face="arial,helvetica,geneva" size="2" color="#cc0000">Back Arrow to
make changes, click "Submit" to send.<FONT
color="#666666"><p align="center"><small>ennyForms v2.07
copyright</small>
</font></font></td></tr></font></td></tr></table></td></tr>
</table></center></form>
<HR width="200"></body></html>
EOT
# ALL COPYRIGHT and name notices must remain, visible and
unchanged as is
exit;
}
sub mke {
if ($forms[$cnt] =~ /Subscribe/) {
if ($INS{$forms[$cnt]} =~ /:1$/) {$do = "Yes";}
elsif ($INS{$forms[$cnt]} =~ /:0$/) {$do = "<b>UN-Subscribe
</b>";}
}
$prv .= " <tr><td bgcolor=\"#F0F0F0\" width=\"20\"> </td>
\n";
$prv .= " <td align=\"right\" valign=\"top\" bgcolor=\"#DFDFDF
\" nowrap><font size=\"2\" face=\"arial,helvetica,geneva\" color=\"#
0000cc\"><b>$labels[$cnt]: </b></font></td>\n";
$prv .= " <td align=\"left\" bgcolor=\"#EAEAEA\"><font size=
\"2\" face=\"arial,helvetica,geneva\"> $do</font></td></tr>\n";
$INS{$forms[$cnt]} =~ s/\"/'/g;
$prv .= " <input type=\"hidden\" name=\"$forms[$cnt]\" value=
\"$INS{$forms[$cnt]}\">\n";
}
1;
In article <3B09DFF4.F3763744@stomp.stomp.tokyo>,
godzilla@stomp.stomp.tokyo says...
> G3CK0 wrote:
>
> > Ok...what are some possible causes of this message? Could it be a
> > problem on my webhost's end? I didnt touch the code and I would assume
> > the author wouldnt distribute bad code. Any thoughts would be greatly
> > appreciated.
>
> A good approach would be to check to discover if
> your script is actually printing a content type,
> as I suggested previously.
>
> This is not too difficult; simply look for a
> content type print within your script.
>
> Godzilla!
>
------------------------------
Date: 22 May 2001 10:15:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help: using constants from inherited parent class
Message-Id: <9ede7j$kt4$1@mamenchi.zrz.TU-Berlin.DE>
According to Abigail <abigail@foad.org>:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCXX
> September MCMXCIII in <URL:news:9ead5q$92g$1@mamenchi.zrz.TU-Berlin.DE>:
> ## According to Abigail <abigail@foad.org>:
> ## > Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCXVIII
> ## > September MCMXCIII in <URL:news:9e5vhs$7fq$2@mamenchi.zrz.TU-Berlin.DE>:
> ## > %% According to Michael Ströck <michael@stroeck.com>:
> ## > %% >
> ## > %% > "Abigail" <abigail@foad.org> schrieb im Newsbeitrag
> ## > %% > news:slrn9gbe3f.anl.abigail@tsathoggua.rlyeh.net...
> ## > %% > >
> ## > %% > > I've never understood why. I've always learned that use of constants
> ## > %% > > was a good thing, and that duplication of data should be avoided.
> ## > %% > >
> ## > %% > > Doesn't the school of OO agree?
> ## > %% > <snip>
> ## > %% >
> ## > %% > I agree with Abigail. Can someone point out some disadvantages
> to that ?
> ## > %% > And don't say "It's not OOP" ;-)
> ## > %%
> ## > %% Using a constant and exporting its name into the user's name space
> ## > %% are different things. If you're going OO, a constant DIM in class
> ## > %% Vector is a class method and can be called as such:
> ## >
> ## > FUD.
> ## >
> ## > Almost anything that exports something either uses Exporter, or offers
> ## > its functionality. Exporter doesn't force *anything* in the users name
> ## > space.
> ##
> ## ...nor did I mention "forcing" anywhere. Exporting is transplantation
> ## of a symbol from one package to another, forced or by request. This
> ## is not the "done thing" in OO, and my point is just that you can
> ## access Perl constants with OO methods.
>
> *shrug* Of course you can. Heck, you can access OO methods using a tie
> mechanism, or by using overloaded <<.
>
> That's not the point.
Point, umm, taken... Though the proposal is concerned with accessing
non-OO constants via an OO access. It isn't entirely obvious that this
works (constants are prototyped (), after all), so I thought I'd mention
it.
> Even in an OO world, I'd like to use O_CREAT instead of Fcntl -> O_CREAT.
>
> Programmer convenience. Making 'Fcntl ->' mandatory adds *NOTHING*,
> just warm fuzzy feelings for OO pronents.
It does add inheritance, though that is convenient more for the module
author than its user.
> ##
> ## > Two additional chars make Exporter not export anything.
> ##
> ## The two characters "_OK"?
>
>
> Not under control of the requestor.
>
>
> The answer is:
>
> ()
Oh, those.
Anno
------------------------------
Date: Tue, 22 May 2001 12:53:07 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: How to store data in the session with perl?
Message-Id: <MPG.1574637eab3abce39898b5@news.inode.at>
In article <b245486b.0105220057.1bf27206@posting.google.com>,
yburtin@freesurf.fr says...
> Hi,
>
> In an html page with a perl script inside, I'd like to store a
> variable in the session in order to access it later in another page.
> How can I do that?
>
cookies, hidden-fields ...
peter
--
pilsl@
goldfisch.at
------------------------------
Date: Tue, 22 May 2001 06:28:04 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Module DB_File on NT
Message-Id: <3B0A3F34.BC11E05E@patriot.net>
> I've been working on a time sheet app, which thus far I have been developing
> on my linux station at work. thus far I have been using DB_File to handle my
> data. lately I tried this on my nt station after adding active state and
> realized DB_File is not loaded even though it says it is.
What does this mean? Does this mean that you've used 'ppm query db_file' and
the response shows that it was loaded?
According to the ActiveState help documentation:
"This module is not included with the standard ActivePerl distribution. It is
available as a separate download using PPM."
> I tried downloading
> DB_File from CPAN but then realized it had to be compliled. and I am
> clueless in C. anyone have ideas
Why not simply use PPM to install it? After all, that's what PPM is there
for...
------------------------------
Date: Tue, 22 May 2001 05:20:06 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: My senior project is "done"
Message-Id: <DA430A9E9CE2C476.6C67DF3C534F11D2.B216EF4F3E743102@lp.airnews.net>
Daniel Berger <djberg96@hotmail.com> wrote:
:
: "Cato" <not_a_pack_animal@yahoo.com> wrote in message
: > My senior project (comprised of a perl script and java applets) can be
: > found here:
: >
: > http://www.geocities.com/uhdseniorproject
: >
: > I got an A! And a BS in Computer Science cum laude with a 3.8+ major
: > GPA ...and...and...and...I am available for employment!
: >
: > Quell your enthusiasm....
:
: Some (hopefully) helpful suggestions...
:
: 1) use -w
: 2) use strict
: 3) use "my" for variables within subroutines unless you *really* want them
: to be global
: 4) work on your indentation and spacing (that could be HTML rendering, I
: suppose).
: 5) you spelled DEBUG wrong. Ok, just messing with ya
: 6) check for failure when doing "open()" or "close()". You never know...
: 7) I don't know for sure, but there's got to be a better way of doing this
: doozy:
:
: if(((index($urlcontent,$conf))> -1)||((index($urlcontent,$USeco))> -1)
: ||((index($urlcontent,$theEco))> -1)||((index($urlcontent,$consem))
> -1)
:
||((index($urlcontent,$oil))> -1)||((index($urlcontent,$perbarrel))> -1)
:
||((index($urlcontent,$recession))> -1)||((index($urlcontent,$alan))> -1)
: ||((index($urlcontent,$oureco))> -1)){ ... }
:
If the 'if' fails:
Line 253 executes:
#print "$poscount $negcount\n";
$poscount=0; $negcount=0;
} #end foreach URL
But, $poscount and $negcount get set to 0 if the 'if' succeeds, so
these aren't needed here.
How about:
next unless
(index $urlcontent, $conf) > -1
|| (index $urlcontent, $USeco) > -1
|| (index $urlcontent, $theEco) > -1
|| (index $urlcontent, $consem) > -1
|| (index $urlcontent, $oil) > -1
|| (index $urlcontent, $perbarrel) > -1
|| (index $urlcontent, $recession) > -1
|| (index $urlcontent, $alan) > -1
|| (index $urlcontent, $oureco) > -1;
Also in that same sub;
Line 231:
foreach $posword (@poswords)
{
while (($pos=index($urlcontent,$posword,$pos)) != -1)
{
$poscount++; $pos++;
}#end while loop to count a word
}
The word count routine will count 'strongest' twice. Once as
'strong' and again as 'strongest'.
And the word lists have some words listed twice.
HTH,
Charles K. Clarkson
------------------------------
Date: Tue, 22 May 2001 13:48:52 +0200
From: "Tom Klinger" <admin@the-piper.net>
Subject: Re: Need help on formatting output
Message-Id: <3b0a533c@news.i-one.at>
"Chris Stith" <mischief@velma.motion.net> wrote in message
news:tgjdcib5nhp571@corp.supernews.com...
> Ren Maddox <ren@tivoli.com> wrote:
> > On Mon, 21 May 2001, admin@the-piper.net wrote:
...
> > It's been a while since I had to do this, but IIRC, you can set $- to
> > 0 before calling write to force a new page.
>
> I believe you can set $= to the number of total lines on the page
> when at the top of the page, if you only do output with write().
>
> q{perldoc perlform} states that you can mix print()s and write()s,
> but you'll have to manage $- on your own.
>
> I think Ren's advice will work.
>
Yes it did, thank you both. I overlooked that on.
I've added now following line:
...
write PROGRAMS;
} # end foreach @programs
# here's the new line
if ( $- > 0 ) { print $^L,"\n"; $- = 0; }
close (PROGRAMS);
} # end if loop
...
And it worked fine. I also added at the beginning $%=0; so that on every
directory the counter will begin at 1.
> You must cede to me one of your bases, or I will crush you
> like a bug! Ooops... sorry. I was playing Alpha Centauri
> all day yesterday.
>
*LOL*
Thanks and greets, Tom
------------------------------
Date: 22 May 2001 11:03:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: non repeating random numbers
Message-Id: <9edh2v$ltf$1@mamenchi.zrz.TU-Berlin.DE>
According to Benjamin Goldberg <goldbb2@earthlink.net>:
[creating a set of unique random numbers]
> Encrypt a counter with a small block cipher. Obviously, since each
> input value encrypts to exactly one output value, we know that no output
> will appear more than once provided no input appears more than once.
> Since the counter will never be any value more than once, this
> requirement is satisfied. Of course, we need a small block cipher...
[code snipped]
Very well. You would however have to make sure that the cipher used
doesn't introduce unwanted non-random properties in the resulting
sequence, or rather, that it creates a sufficiently random sequence
out of the first few integers. It also makes the random sequence
predictable, which may be a problem.
Anno
------------------------------
Date: 22 May 2001 03:51:06 -0400
From: dkcombs@panix.com (David Combs)
Subject: of the TWO perl-debugging books, which best?
Message-Id: <9ed5pa$asb$1@panix3.panix.com>
There are TWO perl debugging books:
. "Debugging Perl" by Martin Brown (Osbourne/McGraw Hill)
. CSBOOK: Why, yes: "Perl Debugged," by Peter Scott and Ed Wright. Addison-Wesley, 2001.
I have not actually seen either one (eg, in a bookstore).
Which of the two is the best?
Are they both SO good, and SO different from each
other, that it's worthwhile to buy BOTH?
Thanks
David
------------------------------
Date: 22 May 2001 12:47:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: scientific notation
Message-Id: <9edn51$q04$3@mamenchi.zrz.TU-Berlin.DE>
According to Todd Bair <todd@ti.com>:
> Thanks Greg.
>
>
> Answer for reference:
Reference to what? When you reply to an article, trim the quoted
material to contain only what you are replying to and place your
reply below what you are referring to.
> print sprintf("%e",22534238432.3955);
>
> # 2.253424e+10
I suppose (it's hard to say) that you are complaining that Greg's
proposal doesn't do what you expect (it prints a decimal place more
than you want). Take a look at the documentation of sprintf to see
how you can modify this behavior.
Anno
[jeopardy quote snipped]
------------------------------
Date: 22 May 2001 12:29:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Slight problems with rounding.
Message-Id: <9edm3q$q04$2@mamenchi.zrz.TU-Berlin.DE>
According to Randal L. Schwartz <merlyn@stonehenge.com>:
> >>>>> "Nick" == Nick <nick@NOSPAM3db.co.uk> writes:
>
> Nick> I'm currently using the following code to produce a percentage
> Nick> of various values. It basically loads an unknown quantity of
> Nick> numbers (separated by #'s), adds them up to form a total and
> Nick> then, as a separate process, attempts to work out what
> Nick> percentage of the total each individual number represents. I'm
> Nick> trying to create a poll system. It mostly works okay, but I've
> Nick> noticed that certain results combinations produce percentages
> Nick> that do not add up to 100, and wondered if anyone could see the
> Nick> flaw in my "rounding" logic.
>
> Rounding frequently messes up totals. Haven't you ever seen "totals
> do not add up to 100% because of rounding" on polls before?
In fact, when percentages add up to 100% this is often a sign that
a less experienced statistician has found it necessary to doctor the
results to come out that way. Not a good sign.
[...]
Anno
------------------------------
Date: Tue, 22 May 2001 12:09:39 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Solaris help
Message-Id: <3B0A48F3.A8EED26E@bigfoot.com>
Per- Fredrik Pollnow wrote:
> BANNER=" `perl script` "
Try giving the full name of the perl executable.
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
Date: Tue, 22 May 2001 11:15:19 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Stringformation
Message-Id: <3B0A3C37.FB57DB10@bms.umist.ac.uk>
Rene Scheibe wrote:
>
> I have large numbers and for better reading
> want to print a dot every third digit.
> Anybody any suggestions?
how about having a look at the FAQ entry that was posted here just 8
hours ago?
***FAQ exert follows***
How can I output my numbers with commas added?
This one will do it for you:
sub commify {
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
$n = 23659019423.2331;
print "GOT: ", commify($n), "\n";
GOT: 23,659,019,423.2331
You can't just:
s/^([-+]?\d+)(\d{3})/$1,$2/g;
because you have to put the comma in and then recalculate your
position.
Alternatively, this commifies all numbers in a line regardless of
whether they have decimal portions, are preceded by + or -, or
whatever:
# from Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
sub commify {
my $input = shift;
$input = reverse $input;
$input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
return scalar reverse $input;
}
**end of FAQ**
HTH
Paul
------------------------------
Date: Tue, 22 May 2001 10:47:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Stringformation
Message-Id: <lsgkgtgtemk5dhkvb3u1reh8j4hpo8t31i@4ax.com>
Rene Scheibe wrote:
>I have large numbers and for better reading
>want to print a dot every third digit.
>Anybody any suggestions?
As Paul boardman already suggested: check the FAQ.
My only addition would be that, as you want a dot instead of a comma,
you're probably in one of those European countries where the meaning of
the comma and the dot are swapped.
Here's how I commonly do that:
... # preformat number
$number =~ tr/.,/,./;
So, first process a number in US style, and then, finally, swap commas
and dots.
--
Bart.
------------------------------
Date: Tue, 22 May 2001 13:16:17 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Stringformation
Message-Id: <Pine.LNX.4.30.0105221302320.7298-100000@lxplus003.cern.ch>
On Tue, 22 May 2001, Bart Lateur wrote:
> My only addition would be that, as you want a dot instead of a comma,
> you're probably in one of those European countries where the meaning of
> the comma and the dot are swapped.
[..]
> ... # preformat number
> $number =~ tr/.,/,./;
> So, first process a number in US style, and then, finally, swap commas
> and dots.
If C<use locale> is in effect, the character used for the decimal
point in formatted real numbers is affected by the LC_NUMERIC locale.
Is there any reason to avoid the use of locale? I'm not very familiar
with its use myself, and would be interested to know of any hidden
traps.
--
"Lynx entsorgt Designschrott aller Art gründlich und umweltfreundlich."
- Uwe Waldmann
------------------------------
Date: Tue, 22 May 2001 12:32:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Stringformation
Message-Id: <9jmkgts6do2cas2i01g5u6otdr5ovg0aib@4ax.com>
Alan J. Flavell wrote:
>> ... # preformat number
>> $number =~ tr/.,/,./;
>
>> So, first process a number in US style, and then, finally, swap commas
>> and dots.
>
> If C<use locale> is in effect, the character used for the decimal
> point in formatted real numbers is affected by the LC_NUMERIC locale.
>
>Is there any reason to avoid the use of locale?
The normal reasons, I suppose? I don't like giving up control to
something as unpredictable as "locale".
On my home system:
use locale;
$pi = 4 * atan2 1, 1;
print $pi;
-->
3.14159265358979
This is supposed to represent numbers, European style.
Furthermore: we have a web server in the US for a European audience.
"use locale;" will most likely not do the right thing, even if it is
doing what it is supposed to do.
--
Bart.
------------------------------
Date: Tue, 22 May 2001 14:52:37 +0200
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: Re: Stringformation
Message-Id: <9edncj$26h49$1@ID-65612.news.dfncis.de>
Can someone explain me this code a little bit, please.
> # from Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
> sub commify {
> my $input = shift;
> $input = reverse $input;
> $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
> return scalar reverse $input;
> }
------------------------------
Date: 22 May 2001 04:10:27 -0700
From: tgyeti@web.de (Sascha)
Subject: XML::Simple more than one root tag??
Message-Id: <c1a45ba7.0105220310.536a9ae0@posting.google.com>
Hello,
I have a problem to using the XML::Simple module.
I have a XML-String, which content a image of a XML-File such like
-------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<mail>
<from>USER 1</from>
<to>Absender</to>
<subject>test des subjects</subject>
</mail>
---------------------------------------------------------------------
That's not the Problem to convert this to a hash.
If the image have a syntax like ...
---------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<mail>
<from>USER 1</from>
<to>Absender</to>
<subject>test des subjects</subject>
</mail>
<ebene>
<test>ksdjkfjsa</test>
<bla>lksadjfljlksd</bla>
</ebene>
----------------------------------------------------------------------
... then i receive a error. This is the error:
---------------------------------------------------------------------
junk after document element at line 8, column 0, byte 177 at
/usr/lib/perl5/site_perl/5.6.0/i586-linux/XML/Parser.pm line 168
----------------------------------------------------------------------
I convert the xml with the following syntax:
----------------------------------------------------------------------
my $self = shift;
my $xmldatei = shift;
my @ebeneCheck;
my $element;
my $element_vorher;
my $xmlhash;
my $key;
my $value;
print "Inhalt von Variable der XML-Datei: \n", $xmldatei,
"\n";
$xmlhash = XMLin($xmldatei);
-------------------------------------------------------------------------
What's my mistake???
I have another problem.
If i convert the XML-File or String then I get the Hash back, but
without the root tag. I think the Tag "mail" and "ebene". You can see
it in my example in the top of these posting.
I hope that you can help me and my english is't so bad.
Bis dann, Ciao!
Sascha
------------------------------
Date: Tue, 22 May 2001 13:15:55 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: XML::Simple more than one root tag??
Message-Id: <3B0A587B.80883567@bigfoot.com>
Sascha wrote:
> If the image have a syntax like ...
> ---------------------------------------------------------------------
> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
>
> <mail>
> <from>USER 1</from>
> <to>Absender</to>
> <subject>test des subjects</subject>
> </mail>
> <ebene>
> <test>ksdjkfjsa</test>
> <bla>lksadjfljlksd</bla>
> </ebene>
> ----------------------------------------------------------------------
>
> ... then i receive a error. This is the error:
Naturally. This is not a valid XML file.
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
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 957
**************************************