[28433] in Perl-Users-Digest
Perl-Users Digest, Issue: 9797 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 14:05:41 2006
Date: Tue, 3 Oct 2006 11:05:06 -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 Tue, 3 Oct 2006 Volume: 10 Number: 9797
Today's topics:
Re: Help with Code <rvtol+news@isolution.nl>
Re: Help with Code <hjp-usenet2@hjp.at>
Re: Help with Code <mritty@gmail.com>
Re: How to delete temporary file after displaying in br <ynl@nsparks.net>
Re: How to delete temporary file after displaying in br <ynl@nsparks.net>
Re: How to delete temporary file after displaying in br <glex_no-spam@qwest-spam-no.invalid>
Re: How to delete temporary file after displaying in br xhoster@gmail.com
Re: How to delete temporary file after displaying in br <ynl@nsparks.net>
Re: How to delete temporary file after displaying in br <ynl@nsparks.net>
Re: How to delete temporary file after displaying in br <ynl@nsparks.net>
Re: How to make 2 dimensinal aray in Perl $mat(x,y)? anno4000@radom.zrz.tu-berlin.de
Re: Inline C and different platforms vladimir.giron@gmail.com
Re: My first socket question xhoster@gmail.com
Re: My first socket question <jgibson@mail.arc.nasa.gov>
Re: my vs our for class data anno4000@radom.zrz.tu-berlin.de
Re: my vs our for class data (reading news)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Oct 2006 17:18:10 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Help with Code
Message-Id: <efu613.19k.1@news.isolution.nl>
Paul Lalli schreef:
> Dr.Ruud:
>> Ian Wilson:
>>> \d matches "0", "1" ... "8" or "9"
>>
>> Last time I checked, \d matched 268 different characters. Dear
>> programmer, if you mean [0-9], then write [0-9].
>
> Er. Huh? I realize that \w will match not only 'a'..'z', 'A'..'Z',
> '0'..'9', and _, and that all the "international" letters such as
> and are included as well, depending on locale. But other than the
> ten characters Ian implied, what else does \d match?
>
> I did take a look at `perldoc perlreref`, which in turn referred me to
> `perldoc perllocale`, but I confess that I don't get it - I'm
> extremely nave when it comes to locales...
The following tries to promote Data::Alias as well:
#!/usr/bin/perl
# Id: unicount.pl
# Subject: show some Unicode statistics
use warnings ;
use strict ;
use Data::Alias ;
binmode STDOUT, ':utf8' ;
my @table =
# +--Name------+---qRegexp--------+-C-+-L-+-U-+
(
[ 'xdigit' , qr/[[:xdigit:]]/ , 0 , 0 , 0 ] ,
[ 'ascii' , qr/[[:ascii:]]/ , 0 , 0 , 0 ] ,
[ '\\d' , qr/\d/ , 0 , 0 , 0 ] ,
[ 'digit' , qr/[[:digit:]]/ , 0 , 0 , 0 ] ,
[ 'IsNumber' , qr/\p{IsNumber}/ , 0 , 0 , 0 ] ,
[ 'alpha' , qr/[[:alpha:]]/ , 0 , 0 , 0 ] ,
[ 'alnum' , qr/[[:alnum:]]/ , 0 , 0 , 0 ] ,
[ 'word' , qr/[[:word:]]/ , 0 , 0 , 0 ] ,
[ 'graph' , qr/[[:graph:]]/ , 0 , 0 , 0 ] ,
[ 'print' , qr/[[:print:]]/ , 0 , 0 , 0 ] ,
[ 'blank' , qr/[[:blank:]]/ , 0 , 0 , 0 ] ,
[ 'space' , qr/[[:space:]]/ , 0 , 0 , 0 ] ,
[ 'punct' , qr/[[:punct:]]/ , 0 , 0 , 0 ] ,
[ 'cntrl' , qr/[[:cntrl:]]/ , 0 , 0 , 0 ] ,
) ;
my @codepoints =
(
0x0000 .. 0xD7FF,
0xE000 .. 0xFDCF,
0xFDF0 .. 0xFFFD,
0x10000 .. 0x1FFFD,
0x20000 .. 0x2FFFD,
# 0x30000 .. 0x3FFFD, # etc.
) ;
for my $row ( @table )
{
alias my ($name, $qrx, $count, $lower, $upper) = @$row ;
printf "\n%s\n", $name ;
my $n = 0 ;
for ( @codepoints )
{
local $_ = chr ; # int-2-char conversion
$n++ ;
if ( /$qrx/ )
{
$count++ ;
$lower++ if / [[:lower:]] /x ;
$upper++ if / [[:upper:]] /x ;
}
}
my $show_lower_upper =
($lower || $upper)
? sprintf( ' (lower:%6d, upper:%6d)'
, $lower
, $upper
)
: '' ;
printf "%6d /%6d =%7.3f%%%s\n"
, $count
, $n
, 100 * $count / $n
, $show_lower_upper
}
print "\n" ;
__END__
Results (v5.8.6, i386-freebsd-64int)
xdigit
22 /194522 = 0.011% (lower: 6, upper: 6)
ascii
128 /194522 = 0.066% (lower: 26, upper: 26)
\d
268 /194522 = 0.138%
digit
268 /194522 = 0.138%
IsNumber
612 /194522 = 0.315%
alpha
91183 /194522 = 46.875% (lower: 1380, upper: 1160)
alnum
91451 /194522 = 47.013% (lower: 1380, upper: 1160)
word
91801 /194522 = 47.193% (lower: 1380, upper: 1160)
graph
102330 /194522 = 52.606% (lower: 1380, upper: 1160)
print
102349 /194522 = 52.616% (lower: 1380, upper: 1160)
blank
18 /194522 = 0.009%
space
24 /194522 = 0.012%
punct
374 /194522 = 0.192%
cntrl
6473 /194522 = 3.328%
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Tue, 3 Oct 2006 17:50:01 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Help with Code
Message-Id: <slrnei51l9.3hq.hjp-usenet2@yoyo.hjp.at>
On 2006-10-03 12:12, Paul Lalli <mritty@gmail.com> wrote:
> Dr.Ruud wrote:
>> Ian Wilson schreef:
>>
>> > \d matches "0", "1" ... "8" or "9"
>>
>> Last time I checked, \d matched 268 different characters. Dear
>> programmer, if you mean [0-9], then write [0-9].
>
> Er. Huh? I realize that \w will match not only 'a'..'z', 'A'..'Z',
> '0'..'9', and _, and that all the "international" letters such as á
> and Ñ are included as well, depending on locale. But other than the
> ten characters Ian implied, what else does \d match?
The digits in all the non-latin scripts. Try:
#!/usr/bin/perl
use warnings;
use strict;
use charnames qw();
for my $c (0x0000 .. 0xD7FF,
0xE000 .. 0xFDCF,
0xFDF0 .. 0xFFFD,
0x1_0000 .. 11_0000
) {
my $s = pack 'U', $c;
if ($s =~ /\d/) {
printf ("%5d %5x %s %s\n", $c, $c, $s, charnames::viacode($c));
}
}
On my system this prints 218 digits:
48 30 0 DIGIT ZERO
49 31 1 DIGIT ONE
50 32 2 DIGIT TWO
51 33 3 DIGIT THREE
52 34 4 DIGIT FOUR
53 35 5 DIGIT FIVE
54 36 6 DIGIT SIX
55 37 7 DIGIT SEVEN
56 38 8 DIGIT EIGHT
57 39 9 DIGIT NINE
1632 660 ٠ ARABIC-INDIC DIGIT ZERO
1633 661 ١ ARABIC-INDIC DIGIT ONE
1634 662 ٢ ARABIC-INDIC DIGIT TWO
1635 663 ٣ ARABIC-INDIC DIGIT THREE
1636 664 ٤ ARABIC-INDIC DIGIT FOUR
1637 665 ٥ ARABIC-INDIC DIGIT FIVE
1638 666 ٦ ARABIC-INDIC DIGIT SIX
1639 667 ٧ ARABIC-INDIC DIGIT SEVEN
1640 668 ٨ ARABIC-INDIC DIGIT EIGHT
1641 669 ٩ ARABIC-INDIC DIGIT NINE
1776 6f0 ۰ EXTENDED ARABIC-INDIC DIGIT ZERO
1777 6f1 ۱ EXTENDED ARABIC-INDIC DIGIT ONE
1778 6f2 ۲ EXTENDED ARABIC-INDIC DIGIT TWO
1779 6f3 ۳ EXTENDED ARABIC-INDIC DIGIT THREE
1780 6f4 ۴ EXTENDED ARABIC-INDIC DIGIT FOUR
1781 6f5 ۵ EXTENDED ARABIC-INDIC DIGIT FIVE
1782 6f6 ۶ EXTENDED ARABIC-INDIC DIGIT SIX
1783 6f7 ۷ EXTENDED ARABIC-INDIC DIGIT SEVEN
1784 6f8 ۸ EXTENDED ARABIC-INDIC DIGIT EIGHT
1785 6f9 ۹ EXTENDED ARABIC-INDIC DIGIT NINE
2406 966 ० DEVANAGARI DIGIT ZERO
2407 967 १ DEVANAGARI DIGIT ONE
2408 968 २ DEVANAGARI DIGIT TWO
2409 969 ३ DEVANAGARI DIGIT THREE
2410 96a ४ DEVANAGARI DIGIT FOUR
2411 96b ५ DEVANAGARI DIGIT FIVE
2412 96c ६ DEVANAGARI DIGIT SIX
2413 96d ७ DEVANAGARI DIGIT SEVEN
2414 96e ८ DEVANAGARI DIGIT EIGHT
2415 96f ९ DEVANAGARI DIGIT NINE
2534 9e6 ০ BENGALI DIGIT ZERO
2535 9e7 ১ BENGALI DIGIT ONE
2536 9e8 ২ BENGALI DIGIT TWO
2537 9e9 ৩ BENGALI DIGIT THREE
2538 9ea ৪ BENGALI DIGIT FOUR
2539 9eb ৫ BENGALI DIGIT FIVE
2540 9ec ৬ BENGALI DIGIT SIX
2541 9ed ৭ BENGALI DIGIT SEVEN
2542 9ee ৮ BENGALI DIGIT EIGHT
2543 9ef ৯ BENGALI DIGIT NINE
2662 a66 ੦ GURMUKHI DIGIT ZERO
2663 a67 ੧ GURMUKHI DIGIT ONE
2664 a68 ੨ GURMUKHI DIGIT TWO
2665 a69 ੩ GURMUKHI DIGIT THREE
2666 a6a ੪ GURMUKHI DIGIT FOUR
2667 a6b ੫ GURMUKHI DIGIT FIVE
2668 a6c ੬ GURMUKHI DIGIT SIX
2669 a6d ੭ GURMUKHI DIGIT SEVEN
2670 a6e ੮ GURMUKHI DIGIT EIGHT
2671 a6f ੯ GURMUKHI DIGIT NINE
2790 ae6 ૦ GUJARATI DIGIT ZERO
2791 ae7 ૧ GUJARATI DIGIT ONE
2792 ae8 ૨ GUJARATI DIGIT TWO
2793 ae9 ૩ GUJARATI DIGIT THREE
2794 aea ૪ GUJARATI DIGIT FOUR
2795 aeb ૫ GUJARATI DIGIT FIVE
2796 aec ૬ GUJARATI DIGIT SIX
2797 aed ૭ GUJARATI DIGIT SEVEN
2798 aee ૮ GUJARATI DIGIT EIGHT
2799 aef ૯ GUJARATI DIGIT NINE
2918 b66 ୦ ORIYA DIGIT ZERO
2919 b67 ୧ ORIYA DIGIT ONE
2920 b68 ୨ ORIYA DIGIT TWO
2921 b69 ୩ ORIYA DIGIT THREE
2922 b6a ୪ ORIYA DIGIT FOUR
2923 b6b ୫ ORIYA DIGIT FIVE
2924 b6c ୬ ORIYA DIGIT SIX
2925 b6d ୭ ORIYA DIGIT SEVEN
2926 b6e ୮ ORIYA DIGIT EIGHT
2927 b6f ୯ ORIYA DIGIT NINE
3047 be7 ௧ TAMIL DIGIT ONE
3048 be8 ௨ TAMIL DIGIT TWO
3049 be9 ௩ TAMIL DIGIT THREE
3050 bea ௪ TAMIL DIGIT FOUR
3051 beb ௫ TAMIL DIGIT FIVE
3052 bec ௬ TAMIL DIGIT SIX
3053 bed ௭ TAMIL DIGIT SEVEN
3054 bee ௮ TAMIL DIGIT EIGHT
3055 bef ௯ TAMIL DIGIT NINE
3174 c66 ౦ TELUGU DIGIT ZERO
3175 c67 ౧ TELUGU DIGIT ONE
3176 c68 ౨ TELUGU DIGIT TWO
3177 c69 ౩ TELUGU DIGIT THREE
3178 c6a ౪ TELUGU DIGIT FOUR
3179 c6b ౫ TELUGU DIGIT FIVE
3180 c6c ౬ TELUGU DIGIT SIX
3181 c6d ౭ TELUGU DIGIT SEVEN
3182 c6e ౮ TELUGU DIGIT EIGHT
3183 c6f ౯ TELUGU DIGIT NINE
3302 ce6 ೦ KANNADA DIGIT ZERO
3303 ce7 ೧ KANNADA DIGIT ONE
3304 ce8 ೨ KANNADA DIGIT TWO
3305 ce9 ೩ KANNADA DIGIT THREE
3306 cea ೪ KANNADA DIGIT FOUR
3307 ceb ೫ KANNADA DIGIT FIVE
3308 cec ೬ KANNADA DIGIT SIX
3309 ced ೭ KANNADA DIGIT SEVEN
3310 cee ೮ KANNADA DIGIT EIGHT
3311 cef ೯ KANNADA DIGIT NINE
3430 d66 ൦ MALAYALAM DIGIT ZERO
3431 d67 ൧ MALAYALAM DIGIT ONE
3432 d68 ൨ MALAYALAM DIGIT TWO
3433 d69 ൩ MALAYALAM DIGIT THREE
3434 d6a ൪ MALAYALAM DIGIT FOUR
3435 d6b ൫ MALAYALAM DIGIT FIVE
3436 d6c ൬ MALAYALAM DIGIT SIX
3437 d6d ൭ MALAYALAM DIGIT SEVEN
3438 d6e ൮ MALAYALAM DIGIT EIGHT
3439 d6f ൯ MALAYALAM DIGIT NINE
3664 e50 ๐ THAI DIGIT ZERO
3665 e51 ๑ THAI DIGIT ONE
3666 e52 ๒ THAI DIGIT TWO
3667 e53 ๓ THAI DIGIT THREE
3668 e54 ๔ THAI DIGIT FOUR
3669 e55 ๕ THAI DIGIT FIVE
3670 e56 ๖ THAI DIGIT SIX
3671 e57 ๗ THAI DIGIT SEVEN
3672 e58 ๘ THAI DIGIT EIGHT
3673 e59 ๙ THAI DIGIT NINE
3792 ed0 ໐ LAO DIGIT ZERO
3793 ed1 ໑ LAO DIGIT ONE
3794 ed2 ໒ LAO DIGIT TWO
3795 ed3 ໓ LAO DIGIT THREE
3796 ed4 ໔ LAO DIGIT FOUR
3797 ed5 ໕ LAO DIGIT FIVE
3798 ed6 ໖ LAO DIGIT SIX
3799 ed7 ໗ LAO DIGIT SEVEN
3800 ed8 ໘ LAO DIGIT EIGHT
3801 ed9 ໙ LAO DIGIT NINE
3872 f20 ༠ TIBETAN DIGIT ZERO
3873 f21 ༡ TIBETAN DIGIT ONE
3874 f22 ༢ TIBETAN DIGIT TWO
3875 f23 ༣ TIBETAN DIGIT THREE
3876 f24 ༤ TIBETAN DIGIT FOUR
3877 f25 ༥ TIBETAN DIGIT FIVE
3878 f26 ༦ TIBETAN DIGIT SIX
3879 f27 ༧ TIBETAN DIGIT SEVEN
3880 f28 ༨ TIBETAN DIGIT EIGHT
3881 f29 ༩ TIBETAN DIGIT NINE
4160 1040 ၀ MYANMAR DIGIT ZERO
4161 1041 ၁ MYANMAR DIGIT ONE
4162 1042 ၂ MYANMAR DIGIT TWO
4163 1043 ၃ MYANMAR DIGIT THREE
4164 1044 ၄ MYANMAR DIGIT FOUR
4165 1045 ၅ MYANMAR DIGIT FIVE
4166 1046 ၆ MYANMAR DIGIT SIX
4167 1047 ၇ MYANMAR DIGIT SEVEN
4168 1048 ၈ MYANMAR DIGIT EIGHT
4169 1049 ၉ MYANMAR DIGIT NINE
4969 1369 ፩ ETHIOPIC DIGIT ONE
4970 136a ፪ ETHIOPIC DIGIT TWO
4971 136b ፫ ETHIOPIC DIGIT THREE
4972 136c ፬ ETHIOPIC DIGIT FOUR
4973 136d ፭ ETHIOPIC DIGIT FIVE
4974 136e ፮ ETHIOPIC DIGIT SIX
4975 136f ፯ ETHIOPIC DIGIT SEVEN
4976 1370 ፰ ETHIOPIC DIGIT EIGHT
4977 1371 ፱ ETHIOPIC DIGIT NINE
6112 17e0 ០ KHMER DIGIT ZERO
6113 17e1 ១ KHMER DIGIT ONE
6114 17e2 ២ KHMER DIGIT TWO
6115 17e3 ៣ KHMER DIGIT THREE
6116 17e4 ៤ KHMER DIGIT FOUR
6117 17e5 ៥ KHMER DIGIT FIVE
6118 17e6 ៦ KHMER DIGIT SIX
6119 17e7 ៧ KHMER DIGIT SEVEN
6120 17e8 ៨ KHMER DIGIT EIGHT
6121 17e9 ៩ KHMER DIGIT NINE
6160 1810 ᠐ MONGOLIAN DIGIT ZERO
6161 1811 ᠑ MONGOLIAN DIGIT ONE
6162 1812 ᠒ MONGOLIAN DIGIT TWO
6163 1813 ᠓ MONGOLIAN DIGIT THREE
6164 1814 ᠔ MONGOLIAN DIGIT FOUR
6165 1815 ᠕ MONGOLIAN DIGIT FIVE
6166 1816 ᠖ MONGOLIAN DIGIT SIX
6167 1817 ᠗ MONGOLIAN DIGIT SEVEN
6168 1818 ᠘ MONGOLIAN DIGIT EIGHT
6169 1819 ᠙ MONGOLIAN DIGIT NINE
6470 1946 ᥆ LIMBU DIGIT ZERO
6471 1947 ᥇ LIMBU DIGIT ONE
6472 1948 ᥈ LIMBU DIGIT TWO
6473 1949 ᥉ LIMBU DIGIT THREE
6474 194a ᥊ LIMBU DIGIT FOUR
6475 194b ᥋ LIMBU DIGIT FIVE
6476 194c ᥌ LIMBU DIGIT SIX
6477 194d ᥍ LIMBU DIGIT SEVEN
6478 194e ᥎ LIMBU DIGIT EIGHT
6479 194f ᥏ LIMBU DIGIT NINE
65296 ff10 0 FULLWIDTH DIGIT ZERO
65297 ff11 1 FULLWIDTH DIGIT ONE
65298 ff12 2 FULLWIDTH DIGIT TWO
65299 ff13 3 FULLWIDTH DIGIT THREE
65300 ff14 4 FULLWIDTH DIGIT FOUR
65301 ff15 5 FULLWIDTH DIGIT FIVE
65302 ff16 6 FULLWIDTH DIGIT SIX
65303 ff17 7 FULLWIDTH DIGIT SEVEN
65304 ff18 8 FULLWIDTH DIGIT EIGHT
65305 ff19 9 FULLWIDTH DIGIT NINE
66720 104a0 𐒠 OSMANYA DIGIT ZERO
66721 104a1 𐒡 OSMANYA DIGIT ONE
66722 104a2 𐒢 OSMANYA DIGIT TWO
66723 104a3 𐒣 OSMANYA DIGIT THREE
66724 104a4 𐒤 OSMANYA DIGIT FOUR
66725 104a5 𐒥 OSMANYA DIGIT FIVE
66726 104a6 𐒦 OSMANYA DIGIT SIX
66727 104a7 𐒧 OSMANYA DIGIT SEVEN
66728 104a8 𐒨 OSMANYA DIGIT EIGHT
66729 104a9 𐒩 OSMANYA DIGIT NINE
hp
--
_ | Peter J. Holzer | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR | > ist?
| | | hjp@hjp.at | Was sonst wäre der Sinn des Erfindens?
__/ | http://www.hjp.at/ | -- P. Einstein u. V. Gringmuth in desd
------------------------------
Date: 3 Oct 2006 09:43:38 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Help with Code
Message-Id: <1159893818.057966.162600@e3g2000cwe.googlegroups.com>
Peter J. Holzer wrote:
> On 2006-10-03 12:12, Paul Lalli <mritty@gmail.com> wrote:
> > Dr.Ruud wrote:
> >> Ian Wilson schreef:
> >>
> >> > \d matches "0", "1" ... "8" or "9"
> >>
> >> Last time I checked, \d matched 268 different characters. Dear
> >> programmer, if you mean [0-9], then write [0-9].
> >
> > Er. Huh? I realize that \w will match not only 'a'..'z', 'A'..'Z',
> > '0'..'9', and _, and that all the "international" letters such as =E1
> > and =D1 are included as well, depending on locale. But other than the
> > ten characters Ian implied, what else does \d match?
>
> The digits in all the non-latin scripts. Try:
It absolutely never even occurred to me that other characters would be
considered digits. Like I said, I'm depressingly un-informed about
locales and internationalization. Thanks for the information.
Paul Lalli
------------------------------
Date: Tue, 3 Oct 2006 17:05:44 +0200
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <MPG.1f8c9ab4369fa23b9898da@news.tiscali.fr>
In article <nuo4i21a1b2bqogc337ifem3ng68c6hsbm@4ax.com>,
bik.mido@tiscalinet.it says...
> >#!/usr/bin/perl
> >use CGI::Carp qw/fatalsToBrowser/;
>
> As a side note, you know that this will have to go away in
> "production", don't you?
Of course : I use this line during all dev stage until final touch. And,
better, all final CGI uses tainted mode.
> ".$imgurl." ?
> ^
> ^
>
> >print "<html><head></head><body>".$imghtm."</body></html>";
> >#... now I need to unlink this $imgpath ...
> >exit 0;
> >
> You don't print() the image, but its url which will make the browser
> issue another request. If you unlink() the image at this point it may
> not be available when the request is done.
I've effectively realised that it's the difficulty reading the Bart
reply too ; thanks Michele. Well, so it sounds it lets 3 solutions : 1)
cronjob, but complicate the install on some hosted sites 2) <img>
requesting to a separate cgi returning the image data, but the problem
seems to be the url limitation (unless POST of a form autosubmitted) 3)
unlink really later in the script.
>
>
> Michele
>
------------------------------
Date: Tue, 3 Oct 2006 17:11:45 +0200
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <MPG.1f8c9c1f778a86069898db@news.tiscali.fr>
In article <1159881510.761411.243360@e3g2000cwe.googlegroups.com>,
bart@nijlen.com says...
> Or use a frame/iframe to display the image and automatically submit the
> form.
>
Hmmm, thanks Bart, nut not really happy to go through iframe :-(
> Or you could use GET with another encryption algorithm that guarantees
> a URL that is short enough.
>
What for example ?
> Or let the main program sleep for 30 seconds or so and then perform the
> unlink before quitting.
>
>
Well, maybe the easier : I've just to found where is the best place...
Humm, maybe an idea : I could write down name of temporary image in a
log, then delete the one produced by previous session at the beginning
of every new one.
------------------------------
Date: Tue, 03 Oct 2006 10:45:28 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <4522850c$0$25781$815e3792@news.qwest.net>
Yohan N Leder wrote:
> I've effectively realised that it's the difficulty reading the Bart
> reply too ; thanks Michele. Well, so it sounds it lets 3 solutions : 1)
> cronjob, but complicate the install on some hosted sites 2) <img>
> requesting to a separate cgi returning the image data, but the problem
> seems to be the url limitation (unless POST of a form autosubmitted) 3)
> unlink really later in the script.
Also, you could fork a process that sleep for X seconds, then unlink
the file, or look at using 'at' or 'batch', if you're on a *nix platform.
------------------------------
Date: 03 Oct 2006 16:48:10 GMT
From: xhoster@gmail.com
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <20061003124940.458$Qw@newsreader.com>
Yohan N Leder <ynl@nsparks.net> wrote:
> In article <nuo4i21a1b2bqogc337ifem3ng68c6hsbm@4ax.com>,
> bik.mido@tiscalinet.it says...
> > >#!/usr/bin/perl
> > >use CGI::Carp qw/fatalsToBrowser/;
> >
> > As a side note, you know that this will have to go away in
> > "production", don't you?
>
> Of course : I use this line during all dev stage until final touch. And,
> better, all final CGI uses tainted mode.
I don't really see why it will have to go away anyway, taint or no.
>
> > ".$imgurl." ?
> > ^
> > ^
> >
> > >print "<html><head></head><body>".$imghtm."</body></html>";
> > >#... now I need to unlink this $imgpath ...
> > >exit 0;
> > >
> > You don't print() the image, but its url which will make the browser
> > issue another request. If you unlink() the image at this point it may
> > not be available when the request is done.
>
> I've effectively realised that it's the difficulty reading the Bart
> reply too ; thanks Michele. Well, so it sounds it lets 3 solutions : 1)
> cronjob, but complicate the install on some hosted sites
You could just make the cgi script, once it is done, close all it's file
handles and fork and exit, then have the child go on to do whatever the
cron job would do. That way everything stays as part of one script, and
you don't need to mess around with cronjob. If you don't want the clean up
to be run too often (i.e. not once per "hit"), you could check a file.
if ( -M 'log/cleanup' > 1/24 ) { #
fork and exit;
open STDERR, ">>log/cleanup';
close STDOUT;
#.....whatever the cron job would do
warn "Done cleaning up"
}
This has a race condition that will (rarely) allow more than one clean-up
to run at the same time. If that is not okay, then do something else.
> 2) <img>
> requesting to a separate cgi returning the image data, but the problem
> seems to be the url limitation (unless POST of a form autosubmitted)
I really like this method if you know the data will be small. Also, for
some browsers you don't even need to do the extra server round trip for
each image. Google this group on "exploder_render" for info.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 3 Oct 2006 18:58:43 +0200
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <MPG.1f8cb52a7c1efa289898dc@news.tiscali.fr>
In article <4522850c$0$25781$815e3792@news.qwest.net>, glex_no-
spam@qwest-spam-no.invalid says...
> Also, you could fork a process that sleep for X seconds, then unlink
> the file, or look at using 'at' or 'batch', if you're on a *nix platform.
>
Yes, unlink through fork was an idea, but Bart told me it was not a good
idea... So, I didn't gone deeper towards this direction... And more
knowing this script will run under Fedora, Windows and FreeBSD and, at
least, some Perl releases crashe using under Win32.
------------------------------
Date: Tue, 3 Oct 2006 19:07:45 +0200
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <MPG.1f8cb74e60c8ff3a9898dd@news.tiscali.fr>
In article <20061003124940.458$Qw@newsreader.com>, xhoster@gmail.com
says...
>
> > [quoted text muted]
> > 2) <img>
> > requesting to a separate cgi returning the image data, but the problem
> > seems to be the url limitation (unless POST of a form autosubmitted)
>
> I really like this method if you know the data will be small. Also, for
> some browsers you don't even need to do the extra server round trip for
> each image. Google this group on "exploder_render" for info.
>
Yep, it sounds nice unless limitation. So, I think I'll go toward two
solutions : a 1st one I'll reserve for small images, passing image data
through GET as said here ; and a snd one passing the image file path,
then the cgi called will delete the file itself after sending toward
browser.
Also, about fork : as replied to J.G., I would be agree of it was not so
problematic under Win32 (some Perl crash on fork under Win).
------------------------------
Date: Tue, 3 Oct 2006 19:11:05 +0200
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <MPG.1f8cb80fad3248c9898de@news.tiscali.fr>
In article <20061003124940.458$Qw@newsreader.com>, xhoster@gmail.com
says...
> Google this group on "exploder_render" for info.
>
Forgotten to thank you for this link
------------------------------
Date: 3 Oct 2006 16:11:47 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How to make 2 dimensinal aray in Perl $mat(x,y)?
Message-Id: <4ofge3Fe43rvU1@news.dfncis.de>
Ala Qumsieh <noreply@invalid.net> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de wrote:
>
> > Knowing how the arrow notation relates to the general de-referencing
> > syntax isn't entirely useless.
>
> I never said it was useless.
Superfluous, the same as "useless in this context".
> But you made it sound like it's more correct
> than dropping the arrow, which I disagree with. TMTOWTDI, and all of the
> ways are equally correct.
I'm not saying that one is more correct than the other, but depending
on context one can be more appropriate than the other. In particular,
I tend to relegate the "short" syntax without the arrow to cases where
the structure is conceptually a multi-dimensional array. In general
data structures I write the arrow. I see that the case in point was
in fact a two-dimensional array. Still, showing only the short syntax
is misleading.
> People don't need to know the internals of Perl to use it, just like people
> don't need to know the internals of combustion engines to drive cars.
The difference between $x[ $i] and $x->[ $i] is hardly arcane. You
*must* know it to deal with references successfully.
> > The answer I was replying to was way too pat. I gave an extra complete
> > one in contrast. Neither did I intend to confuse anyone, nor to show off
> > (what, really?).
>
> and I didn't intend to offend. But imagine what the OP, who's obviously a
> Perl newbie, would think after reading that $mat[$x][$y] is better written
> as $mat[$x]->[$y], which is better written as ${ $mat[ $x] }[ $y].
>
> My point is that an answer should be on the same level as the question
> itself. If you want to give more information, then you should at least
> point to docs that go into more depth about the subject.
I admit that I hardly thought of the OP of the thread when I wrote
the posting. I responded to the reply which I found lacking. That's
the well-known phenomenon of thread drift. Every Usenaut (where is
Alan Flavell, BTW?) must cope with that.
Anno
------------------------------
Date: 3 Oct 2006 09:58:39 -0700
From: vladimir.giron@gmail.com
Subject: Re: Inline C and different platforms
Message-Id: <1159894719.576197.300870@i3g2000cwc.googlegroups.com>
Thank you very much all of you, I really appreciate your help. Now I
have more ideas about what to do.
Vladimir
------------------------------
Date: 03 Oct 2006 17:13:19 GMT
From: xhoster@gmail.com
Subject: Re: My first socket question
Message-Id: <20061003131450.125$dp@newsreader.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On 02 Oct 2006 02:33:01 GMT, xhoster@gmail.com wrote:
>
> >> while (1) {
> >> $cnt++;
> >> $val=rand; # these are the important calculations!!
> >> next unless $sel->can_read(0.2);
> >
> >Why the 0.2? If the main task is $cnt++ and $val=rand, then it should
> >be spending most of it's time there and not waiting for someone to make
> >a connection that quite likely will not come within any given 0.2
> >anyway.
>
> No really good reason but utter ignorance. In my ignorance I thought
> the call may block if I don't timeout.
Ah, I see I should have explained that better. You would want to
"can_read(0)". You would *not* want to "can_read(undef)". They do very
different things. The first simply checks if anything is immediately
readable, and immediately returns either the readable ones or empty (i.e.
the timeout is as close to zero as your processor speed allows you to get).
The other blocks without a time limit until at least one becomes readable,
i.e. with an effectively infinite time limit.
> Indeed can_read()'s
> documentation mentions that possibility in connection with
> "registered" handles. But I'm not really sure if I know what that
> means. No, I'm sure: I *don't* know.
If there is at least one handle in the select, and you call can_read
with no argument or with undef, then it will block up to forever waiting
for one of those handles to become readable. As a special case, if the
select is empty (there is no handle in it in the first place), it will
return immediately, because it knows that it will not be possible for a
nonexistent handle to ever become readable.
> BTW: the "real" application is not that computation intensive, and
> actually has a sleep(1) in the main cycle.
Oh. I had assumed you were doing a long running computation that you
occasionally wanted to interrogate about its progress. But in your case,
it may make sense to use the timeout on the select rather than the a
sleep(1) in the main cycle--Without knowing more about the objective it is
hard to say which would be better, but you probably don't need *both* a
non-zero time-out and a sleep.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 03 Oct 2006 10:44:14 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: My first socket question
Message-Id: <031020061044146449%jgibson@mail.arc.nasa.gov>
In article <90k4i2pq1m52lhs72n6pcukc9f3f6sbovs@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> On Mon, 02 Oct 2006 10:02:07 -0700, Jim Gibson
> <jgibson@mail.arc.nasa.gov> wrote:
>
>
> So, all in all, is it better to time out or not? IIUC your answer is
> affirmative, whereas xhoster's one is negative. Since you both are
> much more knowledgeable than I am... I'm quite lost. (Although I must
> say that what I got thus far is fine for me now, but I want to learn
> more for the future.)
The criteria for deciding the timeout value for can_read is whether or
not your program is CPU-bound and whether it is more important to
respond to clients quickly or to keep the CPU busy doing processing. If
you want to do as much processing as possible between client requests,
then use a timeout value of zero so can_read returns immediately. This
is called "polling". You need to arrange it so that your program calls
can_read frequently enough not to starve clients. If you don't need
maximum utilization of the CPU for processing, then you can use a
non-zero timeout for can_read to increase responsiveness and throttle
down your use of the CPU.
>
> So, again, all in all you recommend doing so, don't you? Are there two
> schools of thought in this respect?
I don't know of any two schools of thought on this subject. Usually
there is just "thought" and "little or no thought". :) (I am of course
NOT referring to Xho with this statement. I defer to his greater
knowledge about many things Perl and otherwise.)
The select statement was invented to avoid two problems in servicing
asynchronous events from multiple sources: "blocking" and "polling".
You don't want to block on a single event, such as I/O, while other
events might occur instead. You also do not want to have your program
do nothing but polling multiple sources (non-blocking I/O) one after
another, wasting CPU cycles that could be better spent doing something
else. Hence, the advent of the select statement, which allows you to
block on multiple I/O sources and sinks until one of them is ready for
I/O, allowing other processes or threads to do useful work.
Another approach to a CPU-bound process that wants to service clients
quickly is to use multiple processes or threads. One process/thread
does the CPU-bound calculations, while the other blocks waiting for
clients. You would then need to set up some sort of data-sharing
mechanism between these two processes/threads (p/t) so that the
client-servicing p/t can provide the clients with the results of the
calculation p/t.
Good luck.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 3 Oct 2006 15:51:16 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: my vs our for class data
Message-Id: <4off7kFdk3nsU1@news.dfncis.de>
Ralph Moritz <rmoritz@quantm.invalid.co.za> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de writes:
>
> > Ralph Moritz <rmoritz@quantm.invalid.co.za> wrote in comp.lang.perl.misc:
> [snip]
> >> The reason I'm asking is
> >> that I'm eval'ing a Perl script to obtain the value of $data.
> >
> > I'm not sure what that means, but if it involves accessing the package
> > variables directly you're breaking encapsulation.
>
> Sorry if this wasn't well explained. Say I'm getting the value of
> $data by eval'ing a file, using the eval_file() sub defined below:
>
> { package Foo;
> our $data;
>
> sub eval_file {
> my $file = shift;
> open(my $fh, $file);
> my $code = join('', <$fh>);
> eval $code or die $@;
> }
> }
The built-in function do( $file) does what your eval_file( $file) does.
You can use that instead.
> It seems I have to declare $data as a package variable (if I want to
> use it as a class variable). Or is there a better way?
What do you call a class variable?
In my view, the code that deals with a class variable must be right
there in the class definition. A variable that is accessed from code
other than that (not to mention from code that is chosen at run time)
simply doesn't fit the term "class variable".
Perl isn't fascist about its OO model, you can use variables that don't
follow the rules if you have reasons to do so. Calling them class
variables is misleading.
That said, I believe you can do what you want with real class variables.
Untested:
{ package Foo;
{ # bare block to isolate $data
my $data;
sub data {
$data = shift if @_;
$data;
}
# other code that accesses $data directly
}
sub eval_file { do shift }
}
Now the code in whatever file you subject to ->eval_file would have to
set $data going through the accessor: Foo->data( $some_string). Likewise,
code that reads $data would have to use $x = Foo->data to do so. That's
what class variables are about.
If you can't or won't change the code that is eval_file()d, you can
isolate the package variable to eval_file (keeping everything else
as above):
sub eval_file {
our $data;
do shift;
Foo->data( $data);
}
The package variable $Foo::data is still accessible from everywhere,
but outside of eval_file its value is stored safely in a lexical
class variable, so it doesn't matter.
Anno
------------------------------
Date: Tue, 03 Oct 2006 16:04:29 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: my vs our for class data
Message-Id: <hSvUg.2603$Lv3.2329@newsread1.news.pas.earthlink.net>
On 10/03/2006 06:52 AM, Ralph Moritz wrote:
> anno4000@radom.zrz.tu-berlin.de writes:
>
>> Ralph Moritz <rmoritz@quantm.invalid.co.za> wrote in comp.lang.perl.misc:
> [snip]
>>> The reason I'm asking is
>>> that I'm eval'ing a Perl script to obtain the value of $data.
>> I'm not sure what that means, but if it involves accessing the package
>> variables directly you're breaking encapsulation.
>
> Sorry if this wasn't well explained. Say I'm getting the value of
> $data by eval'ing a file, using the eval_file() sub defined below:
>
> { package Foo;
> our $data;
>
> sub eval_file {
> my $file = shift;
> open(my $fh, $file);
> my $code = join('', <$fh>);
> eval $code or die $@;
> }
> }
>
> It seems I have to declare $data as a package variable (if I want to
> use it as a class variable). Or is there a better way?
>
For you, as a beginner, using a package variable is the best way.
--
Posting Guidelines for comp.lang.perl.misc:
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 9797
***************************************