[28224] in Perl-Users-Digest
Perl-Users Digest, Issue: 9588 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 10 14:05:36 2006
Date: Thu, 10 Aug 2006 11:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 10 Aug 2006 Volume: 10 Number: 9588
Today's topics:
Re: 50+ bits of arithmetic in a 32-bit bag <uri@stemsystems.com>
Re: 50+ bits of arithmetic in a 32-bit bag <nospam-abuse@ilyaz.org>
Re: @_ deprecated? <john@castleamber.com>
Re: Control characters - regex to match/lose these? <justin.0607@purestblue.com>
Re: convert structured strings to possibly deep hash of <uri@stemsystems.com>
Re: How to send command line options into test scripts? <yusufm@gmail.com>
Re: Is there arithmetic sequence represents? <tzz@lifelogs.com>
Re: LWP seems to hang <glex_no-spam@qwest-spam-no.invalid>
Re: LWP seems to hang <john@castleamber.com>
Re: match 2D patterns with perl <john@castleamber.com>
My code only works for 1st line in a file..need your he <Shani718@gmail.com>
Re: My code only works for 1st line in a file..need you <mritty@gmail.com>
Re: My code only works for 1st line in a file..need you <Shani718@gmail.com>
Re: My code only works for 1st line in a file..need you <mritty@gmail.com>
Re: POST data truncated in a cgi application <tzz@lifelogs.com>
Re: regex and utf8 characters (german umlauts) <tzz@lifelogs.com>
Re: Sorting integers in perl <bik.mido@tiscalinet.it>
Re: Sorting integers in perl <tzz@lifelogs.com>
win32::printer and text formatting <diavolo-verde@libero.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Aug 2006 11:29:02 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: 50+ bits of arithmetic in a 32-bit bag
Message-Id: <x7u04k38zl.fsf@mail.sysarch.com>
>>>>> "m" == mailbox <mailbox@cpacker.org> writes:
m> xhoster@gmail.com wrote:
>> On my machine, your test also passes for 55, but a more rigorous test
>> does not:
>>
>> $ perl -le '$foo=55; print((2**$foo+30)-(2**$foo+25))'
>> 8
>>
>> I'm pretty sure that 5 != 8, so 55 bits is right out. On my machine, 52 is
>> high as I would go.
>>
>> $ perl -le '$foo=52; foreach (1..1e7) { my $y =
>> ((2**$foo+$_+1)-(2**$foo+$_));
>> die $_ unless $y == 1}'
m> Thanks for that improvement! It behaves the same on our machine as on
m> yours. Fortunately, 52 bits is still plenty of magnitude for our
m> purposes.
it would be hard to use a cpu today that doesn't use ieee float formats
(any perl vax users around? :). so that mantissa size for double floats
(64 bits) will be the same for almost any common box today.
and this one liner also shows the transition from integers to float:
perl -le "print '2**', \$_, ': ', 2**\$_, ' - 1 = ', 2**\$_ - 1 for 47 .. 52"
notice that the -1 stops working after 49 bits so that is the largest
integer you can store in a double. note that this is a decimal issue so
even if the mantissa is 53 bits, you can't operate with a 1 (decimal)
because it takes 4 bits to hold a decimal digit. this is why this shows
49 usable (in decimal) integer bits but the ieee format has 53 bits in
the mantissa.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 10 Aug 2006 17:32:47 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: 50+ bits of arithmetic in a 32-bit bag
Message-Id: <ebfqjv$21k8$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Uri Guttman
<uri@stemsystems.com>], who wrote in article <x7u04k38zl.fsf@mail.sysarch.com>:
> perl -le "print '2**', \$_, ': ', 2**\$_, ' - 1 = ', 2**\$_ - 1 for 47 .. 52"
Converting to version which has a better chance to work in the shells' maze:
perl -le 'print q(2**), $_, q(: ), 2**$_, q( - 1 = ), 2**$_ - 1 for 47 .. 52'
2**47: 140737488355328 - 1 = 140737488355327
2**48: 281474976710656 - 1 = 281474976710655
2**49: 562949953421312 - 1 = 562949953421311
2**50: 1.12589990684262e+15 - 1 = 1.12589990684262e+15
2**51: 2.25179981368525e+15 - 1 = 2.25179981368525e+15
2**52: 4.5035996273705e+15 - 1 = 4.5035996273705e+15
> notice that the -1 stops working after 49 bits so that is the largest
> integer you can store in a double.
Nope. 53 bits is OK.
> note that this is a decimal issue so even if the mantissa is 53
> bits, you can't operate with a 1 (decimal) because it takes 4 bits
> to hold a decimal digit.
Nope, this is just a buggy Perl's convertion to string.
perl -le 'print q(2**), $_, q(: ), sprintf(q(%.0f), 2**$_), q( - 1 = ), sprintf(q(%.f), 2**$_ - 1) for 47 .. 55'
2**47: 140737488355328 - 1 = 140737488355327
2**48: 281474976710656 - 1 = 281474976710655
2**49: 562949953421312 - 1 = 562949953421311
2**50: 1125899906842624 - 1 = 1125899906842623
2**51: 2251799813685248 - 1 = 2251799813685247
2**52: 4503599627370496 - 1 = 4503599627370495
2**53: 9007199254740992 - 1 = 9007199254740991
2**54: 18014398509481984 - 1 = 18014398509481984
2**55: 36028797018963968 - 1 = 36028797018963968
Hope this helps,
Ilya
------------------------------
Date: 10 Aug 2006 16:23:45 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: @_ deprecated?
Message-Id: <Xns981B73EAD381Ccastleamber@130.133.1.4>
anno4000@radom.zrz.tu-berlin.de wrote:
> John Bokma <john@castleamber.com> wrote in comp.lang.perl.misc:
>> my @data = split /\s+/, $line; # not sure about the
> I'd prefer to use significant names instead of the data array
For the record, me too. I couldn't be bothered though to look the names up
(SSH into a GNU/Linux box etc.). Should have written this, though.
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: Thu, 10 Aug 2006 17:39:00 -0000
From: Justin C <justin.0607@purestblue.com>
Subject: Re: Control characters - regex to match/lose these?
Message-Id: <slrnedmrpc.45u.justin.0607@moonlight.purestblue.com>
On 2006-08-09, Ben Morrow <benmorrow@tiscali.co.uk> wrote:
>
> Quoth justin.news@purestblue.com:
>> On 2006-08-08, Dr.Ruud <rvtol+news@isolution.nl> wrote:
>> > Justin C schreef:
>> >> Dr.Ruud:
>> >
[snip] (apologies if the quoting goes awry)
>> > Concentrate on the "clustering, not capturing".
>> >
>> > You can just as well do it step by step:
>> >
>> > s/\e[=9]//g ;
>>
>> Why [=9]? I've read, and re-read, this thread and tried to understand
>> what you and Ben are trying to explain to me (I'm really not stupid,
>> honest), but I can't see, given the examples I gave in the OP, why the
>> [=9].
>
> Dr.Ruud is assuming that what you are in fact trying to do is remove HP
> PCL escape sequences. 'ESC 9' and 'ESC =' are valid sequences, in
> addition to the 'ESC ( s 1 S'-type sequence you mentioned.
Ah, PCL escape sequences. That was a correct assumption, it's just that
having none in any of the output I have here I wasn't expecting to see
someone trying to match sequences I hadn't mentioned (but I should have
been, Dr Ruud having pointed me at some good sources of info for those,
and also mentioning I might want to catch others too).
>
>> > s/\e[^@A-Z]*[@A-Z]//g ;
>> I also don't understand how the "clustering" use of ?: is enabling these
>> two lines to be made into one (it maybe that if I understand one part of
>> this the other falls into place). I'm not seeing what effect the ?: is
>> having, the one line without the ?: looks, to me, like it'd do the same
>> as the two.
>
> The (?:) (when corrected) is causing the RE to match 'escape, followed
> by (either a multi-char escape sequence or one of the single-char
> sequences'. It is necessary as without the grouping the | alternation
> would apply to the whole regex, and any '=' would be stripped. Compare
Thank you for clearing that up for me, I am now able to read, and
understand, that regex. I wasn't aware of the '=' being ignored in a
pattern match (though I'd probably escape it in most cases myself
anyway).
"Thank you" too to Dr Ruud for the solution - even though it's taken me
three days to understand it! :)
Justin.
--
Justin C, by the sea.
------------------------------
Date: Thu, 10 Aug 2006 11:15:49 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: convert structured strings to possibly deep hash of hashes
Message-Id: <x74pwk4o62.fsf@mail.sysarch.com>
>>>>> "a" == anno4000 <anno4000@radom.zrz.tu-berlin.de> writes:
a> Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
>> the issue of what to return for boolean is split. i currently prefer
>> plain return as in stem it is needed in message delivery to denote NO
>> VALUE returned as those methods are called in list context. return undef
>> is a legit return and will cause a return message sent back whereas
>> plain return won't.
a> I can see situations where that behavior would be useful, but I wouldn't
a> make it the standard. You wouldn't write
a> is_even {
a> my $n = shift;
a> return if $n % 2;
a> return 1;
a> }
a> would you?
it all depends on what false value you want to return. perl has multiple
falses as we know and they are subtly different in these
situations. many/most perl builtins return ''/0 (sv has both integer and
string) for false. some return undef (not sure if they return actual
undef or equivilent of plain return).
a> First, the question is clear for functions that return multiple values:
a> Returning empty is just the special case where the number of returned
a> values is 0. If an error situation must be distinguished from that
a> case, another solution must be sought.
that is the question. is the error return in-band or out of band? is
undef a legit 'normal' value to return or is an empty list desired in
when passing back no data?
a> So the question only applies to functions that normally return a single
a> scalar. In that case, returning empty should be reserved to signal
a> failure. Even if the correct value to return is undef, the function
a> should return that as a single value. The user can decide whether
a> the difference matters:
a> my $res = func( ...);
but that can't tell if that was a plain return or return undef which is
my point.
a> will set $res to undef in failure situations and when a legit undef
a> is returned. If the difference doesn't matter, that's all that's
a> needed. If the difference does matter, the simple device of
a> if ( my ( $res) = func( ...) ) {
a> # got a value, use it
a> } else {
a> # failure
a> }
a> brings it out.
not sure if that works the same as @res = func() which is what i do. i
know for sure if i get a real undef vs an empty list that way. an array
with undef in the first slot is true. i know a plain return will in a
list context will be false so that probably works too.
>> if you call something as in the map case above or in an arg list and do
>> a plain return you get an empty list which will be thrown away. so some
>> coders claim the sub should handle that and return a scalar value or a
>> real undef. i say the caller should force the scalar context ...
a> Again, I can see that this might useful behavior for a certain set
a> of functions, but in general a function that is supposed to return
a> a scalar should only fail to return a scalar if there is no scalar
a> to return, not if the scalar happens to be undefined.
it also comes down to whether you want the called to check for a special
case of an empty list or you want a real scalar to fill in a slot. you
can work around either way but i think having the called use scalar() to
force a scalar value is better as it is clearer you want that in the
slot. your code (which i use in stem to check for a real undef or any
value vs plain return is slightly more complex and subtle. the reader of
that code has to notice the () and also know that it will be false is a
plain return is done. i do it since i must know that result and it is in
only one key place and the plain return requirement is well documented
and enforced. you can go either way and i have argued this before. i
just prefer plain returns. and as a side point, i also encourage (so
does PBP) explicit returns in all subs (except in single expression subs
and such).
it is all about api design and who does what with the return values.
in any case this is a good topic to debate as it is not something
covered in the docs or books and it hopefully will ejimicate some perl
hackers about this.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 10 Aug 2006 10:43:28 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: Re: How to send command line options into test scripts?
Message-Id: <1155231808.138629.201620@i42g2000cwa.googlegroups.com>
> Then create stub scripts that supply the correct parameters.
But wouldn't the stub scripts have to still be called by runtests()?
The whole issue is how to call the test files from runtests(), and
still pass in parameters. Even if I have stub scripts how will I send
in the parameters to the stub scripts, because the pid being sent in
will survive over multiple tests.
------------------------------
Date: Thu, 10 Aug 2006 14:04:29 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Is there arithmetic sequence represents?
Message-Id: <g69mzacqxg2.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 9 Aug 2006, zhushenli@gmail.com wrote:
Tony Curtis wrote:
>> You could find a solution with a map...
>>
>> map {$_ * 2} (1 .. 6);
>>
> [snip]
> But it seems not intuitive like [2:2:12]. Anyhow, thanks!
Write your own function:
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
sub matlab_list
{
my $start = shift @_;
my $increment = shift @_;
my $end = shift @_;
my @ret;
while ($start <= $end)
{
push @ret, $start;
$start += $increment;
}
return @ret;
}
print "$_\n" foreach matlab_list(2, 2, 12);
prints:
2
4
6
8
10
12
------------------------------
Date: Thu, 10 Aug 2006 10:34:57 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: LWP seems to hang
Message-Id: <44db5241$0$34071$815e3792@news.qwest.net>
masmith27 wrote:
> $url = 'https://127.0.0.1:2381/webpage.php
my $url = 'https://127.0.0.1:2381/webpage.php';
That could have been a typo, which could possibly mean that you're
leaving out other code.
------------------------------
Date: 10 Aug 2006 16:28:25 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: LWP seems to hang
Message-Id: <Xns981B74B585DB1castleamber@130.133.1.4>
"masmith27" <mike.smith@amd.com> wrote:
> Hello,
> Thanks for the response. I have made the changes you suggested, but
> still no change. You have reminded me that I forgot to mention a couple
> things in my first post though. When I said the timeout has no response
> I meant that including the timeout statement does not change the script
> at all, changing the number inside has no change either, 15 was just
> the last value I had tried.
I suggested that "15" is not a number, but a string. I couldn't be
bothered to check if LWP is able to use is as a number, but I do recommend
not to quote numbers if you need it as a number.
You might want to try an actual number.
Another huge tip:
http://johnbokma.com/mexit/2006/04/11/how-to-reply.html
It's not finished (the debunking part that is), but I think the recipe is
easy to follow and very sound.
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: 10 Aug 2006 16:21:04 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: match 2D patterns with perl
Message-Id: <Xns981B7376B851Bcastleamber@130.133.1.4>
"FangQ" <fangqq@gmail.com> wrote:
> no, as I said, I want to match any rectangular structure, no matter
> what width/height and positions in the array.
Your writing was quite vague, to say the least. At first read you wanted
to have each rectangle to have rounded corners. Then I noticed that
the line below the rectangle:
0010000010000000
became:
0000000000000000
contradicting what I just had gathered from your message.
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: 10 Aug 2006 09:29:14 -0700
From: "Shan" <Shani718@gmail.com>
Subject: My code only works for 1st line in a file..need your help
Message-Id: <1155227353.903347.11320@p79g2000cwp.googlegroups.com>
My code works but only for the first line in a file. The file that is
being read contains urls.
for example
http://21stcmb.typepad.com
http://3banklawyers.typepad.com
I would appreciate your help getting my code to be fully functional.
Thank you
My code is below
---------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
my $record;
my $entry;
open (OUT,">results.txt") or die "err";
open (URLS, "urls1.txt");
while ($record = <URLS>) {
$entry=$record;
my $html = get("$entry")
or die "Could not get the information you wanted";
while ($html =~ m{<link rel="alternate"(.*?) />}g){
my $site_feed = $1;
my $string = $site_feed;
my $ATTRIBUTE = qr/type|title|href/;
my $INSIDE_QUOTES = qr/.*?/;
my @files = $string =~ m{(?:$ATTRIBUTE)="($INSIDE_QUOTES)"}g;
print "Found @files\n";
print OUT "$entry \, $files[0] \, $files[1] \, $files[2]\n";
}
}
close (URLS);
--------------------------------------------------------------------------------------------------------------------
------------------------------
Date: 10 Aug 2006 09:44:02 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: My code only works for 1st line in a file..need your help
Message-Id: <1155228242.780764.78750@m73g2000cwd.googlegroups.com>
Shan wrote:
> My code works but only for the first line in a file.
So how does it *not* work for the remainder? Can't get the URL? Can't
find any matches? Program freezes? Incorrect output? No output?
Crash? Infinite loop? Computer bursts into flames?
> The file that is being read contains urls.
> for example
>
> http://21stcmb.typepad.com
> http://3banklawyers.typepad.com
>
>
> I would appreciate your help getting my code to be fully functional.
> Thank you
>
> My code is below
> ---------------------------------------------------------------------------------------------------------------------------
> #!/usr/bin/perl -w
>
> use strict;
> use LWP::Simple;
> my $record;
> my $entry;
Declare your variables in the shortest scope possible.
> open (OUT,">results.txt") or die "err";
1) Use the three argument form of open
2) Use lexical filehandles, not global barewords
3) State *why* the open failed:
open my $OUT, '>', 'results.txt' or die "Error: $!";
> open (URLS, "urls1.txt");
Ditto.
> while ($record = <URLS>) {
> $entry=$record;
Uh. Why? You never use $record again. So why didn't you just do:
while (my $entry = <URLS>) {
?
> my $html = get("$entry")
I'm somewhat surprise this works, as I'd expect get() to be looking for
a URL that contains a newline. You should be chomping this variable
before using it.
Also, see: perldoc -q quoting
What's wrong with always quoting "$vars"?
> or die "Could not get the information you wanted";
> while ($html =~ m{<link rel="alternate"(.*?) />}g){
> my $site_feed = $1;
What do you have against indentation?
> my $string = $site_feed;
And again, you never use $site_feed again, so why the duplicate
variables?
> my $ATTRIBUTE = qr/type|title|href/;
> my $INSIDE_QUOTES = qr/.*?/;
> my @files = $string =~ m{(?:$ATTRIBUTE)="($INSIDE_QUOTES)"}g;
> print "Found @files\n";
Are you confident that each of the URLs you're fetching actually have
these attributes?
> print OUT "$entry \, $files[0] \, $files[1] \, $files[2]\n";
>
>
> }
> }
> close (URLS);
You still haven't told us what's going wrong, so I have no idea how to
help you.
Paul Lalli
------------------------------
Date: 10 Aug 2006 10:52:14 -0700
From: "Shan" <Shani718@gmail.com>
Subject: Re: My code only works for 1st line in a file..need your help
Message-Id: <1155232334.327493.287700@h48g2000cwc.googlegroups.com>
The follwing is the message i Get when the read file conatins more than
one url
%shttp://21stcmb.typepad.com
Could not get the information you wanted at getfeeds2.pl line 14,
<INFILE> line
1.
here is the new code (works with one url in the file)
-----------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
# Gets feeds
use strict;
use LWP::Simple;
open (OUT,">results.txt") or die "err";
open(INFILE,"< urls1.txt");
while (<INFILE>)
{
print("%s",$_);
my $html = get("$_")
or die "Could not get the information you wanted";
while ($html =~ m{<link rel="alternate"(.*?) />}g)
{
my $string = $1;
my $ATTRIBUTE = qr/type|title|href/;
my $INSIDE_QUOTES = qr/.*?/;
my @files = $string =~ m{(?:$ATTRIBUTE)="($INSIDE_QUOTES)"}g;
print "Found @files\n";
print OUT "$_ \, $files[0] \, $files[1] \, $files[2]\n";
}
}
------------------------------
Date: 10 Aug 2006 11:02:54 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: My code only works for 1st line in a file..need your help
Message-Id: <1155232973.937319.304740@q16g2000cwq.googlegroups.com>
Shan wrote:
> The follwing is the message i Get when the read file conatins more than
> one url
>
> %shttp://21stcmb.typepad.com
> Could not get the information you wanted at getfeeds2.pl line 14,
> <INFILE> line
> 1.
>
>
> here is the new code
...that completely ignores the suggestion I made. You are not chomping
the URL. My guess is that in your file that has only one URL, it does
not have a newline on the end.
> (works with one url in the file)
> -----------------------------------------------------------------------------------------------------
> #!/usr/bin/perl -w
> # Gets feeds
>
> use strict;
>
>
> use LWP::Simple;
>
> open (OUT,">results.txt") or die "err";
> open(INFILE,"< urls1.txt");
>
Why do you ask for people's advice if you're going to ignore it?
> while (<INFILE>)
> {
> print("%s",$_);
What do you think that %s is doing? print() is not printf()
> my $html = get("$_")
Make the adjustment I told you to make, twice now. See if it helps.
And follow the rest of the suggestions in my previous post.
Paul Lalli
------------------------------
Date: Thu, 10 Aug 2006 13:41:19 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: POST data truncated in a cgi application
Message-Id: <g69wt9gqyio.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 10 Aug 2006, timnels@gmail.com wrote:
> Ahh... sorry ... this problem (although it is ahrd to believe) seems to
> the the app on the Java phone (or the J2ME implementation). An i860
> phone works perfect for files over 8440, but has the error when I
> install it on the i850.
You may find it useful to learn about tcpdump, Ethereal, or any other
tools for your OS to look at the actual data going across the wire.
Often this is useful to ensure that the data you expect is actually
coming to you (as you saw here, that doesn't always happen).
Ted
------------------------------
Date: Thu, 10 Aug 2006 13:57:39 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: regex and utf8 characters (german umlauts)
Message-Id: <g69slk4qxrg.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 10 Aug 2006, ext-dirk.heinrichs@nokia.com wrote:
> the following little perl snippet
>
> perl -e '($string = "AAA ÄÄÄ BBB CCC DDD") =~ s/(\p{IsUpper}+)/\L\u\1\E/g;
> print $string . "\n"'
>
> gives this result:
>
> Aaa ÄÄÄ Bbb Ccc Ddd
>
> How do I turn those umlauts into "Äää" also? I tried adding "use utf8;", but
> that didn't help.
The utf8 pragma won't make a difference. Ä is ASCII code 196.
Try this:
perl -MPOSIX -e '$loc = setlocale( LC_ALL, "" ); print "$loc => ", lc(chr(196))'
en_US => Ä
perl -MPOSIX -e '$loc = setlocale( LC_ALL, "de_AT" ); print "$loc => ", lc(chr(196))'
=> Ä
(or whatever locale is appropriate for you)
I don't have the German locales installed here so I can't test it, but
it's supposed to work :) That's why the second line doesn't show
anything for $loc with my test.
Ted
------------------------------
Date: 10 Aug 2006 17:12:36 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Sorting integers in perl
Message-Id: <ssimd29ct25umj7pi2730irt1tnffu89n6@4ax.com>
On 10 Aug 2006 07:17:13 -0700, praveen.kantharajapura@gmail.com wrote:
>I have a file which contains characters as well as integers.
my @integers=get_integers_from_file('file');
Of course you still have to write the get_integers_from_file() sub:
how to do so depends on the actual format of the file, about which
afaict you did provide *no* detail.
>Now i should sort all the integers ??
If you don't know what to do, why should we?
>How to go about doing it.
And the sense of your claim is?
Anyway, if you want to know how to sort your integers once you have
them, then all you need is in
perldoc -f sort
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 10 Aug 2006 13:38:09 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Sorting integers in perl
Message-Id: <g691wrosd8e.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 10 Aug 2006, gkarpo@gmail.com wrote:
> sort() should do, but it defaults to sorting in string mode.
> You would need to switch to numeric mode: sort { $a <=> $b } @list
Small correction: this is not a mode per se. You're providing an
anonymous comparison function which happens to sort numbers in order.
The opposite order is done by swapping $a and $b, for example - there
is no mode to switch.
Ted
------------------------------
Date: 10 Aug 2006 10:12:27 -0700
From: "diavolo-verde@libero.it" <diavolo-verde@libero.it>
Subject: win32::printer and text formatting
Message-Id: <1155229947.755395.126210@75g2000cwc.googlegroups.com>
Hello,
I use Win32::printer for my prints. I print just simple text, i.e.
$rowHeight = $dc->Write($description, $x, $y);
$x += 45;
$rowHeight = $dc->Write($arrivalDate, $x, $y);
$x += 20;
$rowHeight = $dc->Write($price, $x, $y);
$y += $rowHeight;
I'd like to print the currency right formatted:
204,00
12,10
I didn't undersand very much the win32::printer manual on CPAN. Would
anyone give me an example how to do it?
Thanks,
Davide
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 9588
***************************************