[23102] in Perl-Users-Digest
Perl-Users Digest, Issue: 5323 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 6 11:05:54 2003
Date: Wed, 6 Aug 2003 08:05:09 -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 Wed, 6 Aug 2003 Volume: 10 Number: 5323
Today's topics:
CGI and browser cahce <SaschaMoe@web.de>
Re: CGI and browser cahce <NOSPAM@bigpond.com>
Re: CGI and browser cahce <flavell@mail.cern.ch>
Re: CGI and browser cahce <flavell@mail.cern.ch>
Re: CGI and browser cahce <jurgenex@hotmail.com>
Re: Convert UFT-8 to unicode? <bart.lateur@pandora.be>
Re: Convert UFT-8 to unicode? <flavell@mail.cern.ch>
Re: Convert UFT-8 to unicode? <flavell@mail.cern.ch>
Re: Convert UTF-8 to unicode? <njh@despammed.com>
Re: extract from html <simon@unisolve.com.au>
Re: extract from html (Tad McClellan)
Re: extract from html <michael.korte@materna.de>
Re: extract from html (Lydia Shawn)
Re: extract from html (Lydia Shawn)
Re: extract from html (Tad McClellan)
Re: Final "Flocking" Script (Tad McClellan)
Re: Final "Flocking" Script <grazz@pobox.com>
Problems with flock() <Rene.Scheibe@Stud.TU-Ilmenau.de>
Re: Problems with flock() <flavell@mail.cern.ch>
Re: Problems with flock() (Tad McClellan)
Re: Renaming Files inside a GZ Zip File <me@privacy.net>
Re: Renaming Files inside a GZ Zip File <mikeflan@earthlink.net>
Re: Renaming Files inside a GZ Zip File (hymie!)
Re: Trying to select range for Excel chart <Graham.T.Wood@oracle.com>
Re: Why, oh why have I read "Perl 6 essentials"??? <uri@stemsystems.com>
XML DB Xindice -> use with perl <a@viot.de>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Aug 2003 13:43:55 +0200
From: =?ISO-8859-1?Q?Sascha_M=F6llering?= <SaschaMoe@web.de>
Subject: CGI and browser cahce
Message-Id: <bgqpkv$mkv$04$1@news.t-online.com>
Hi,
I've a problem: I don't want the browser to cache websites, because I
wrote a shop with authentification and after having logged out, it is
possible to see the old sites using the back button of the browser. I
tried the following (my header.cgi-file), but it does not work:
print "Content-type: text/html\n\n";
print <<EOF;
<html>
<head>
<META http-equiv="Cache-Control" content="no-cache">
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Expires" content="-1">
<link rel="stylesheet" type="text/css" href="/css/main.css">
</head>
<body>
<table width="78%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="78%" align="left">
EOF
Any ideas?
Thank you,
Sascha
------------------------------
Date: Wed, 6 Aug 2003 22:11:19 +1000
From: "Gregory Toomey" <NOSPAM@bigpond.com>
Subject: Re: CGI and browser cahce
Message-Id: <bgqr9b$rj6nh$1@ID-202028.news.uni-berlin.de>
"Sascha Möllering" <SaschaMoe@web.de> wrote in message
news:bgqpkv$mkv$04$1@news.t-online.com...
> Hi,
>
> I've a problem: I don't want the browser to cache websites, because I
> wrote a shop with authentification and after having logged out, it is
> possible to see the old sites using the back button of the browser. I
> tried the following (my header.cgi-file), but it does not work:
Your Perl question is answered in
http://www.htmlgoodies.com/beyond/nocache.html
gtoomey
------------------------------
Date: Wed, 6 Aug 2003 14:24:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI and browser cahce
Message-Id: <Pine.LNX.4.53.0308061420440.2123@lxplus091.cern.ch>
On Wed, Aug 6, Gregory Toomey inscribed on the eternal scroll:
> > wrote a shop with authentification and after having logged out, it is
> > possible to see the old sites using the back button of the browser. I
> > tried the following (my header.cgi-file), but it does not work:
>
> Your Perl question
I didn't see a Perl question - did you, or was that sarcasm?
> is answered in
> http://www.htmlgoodies.com/beyond/nocache.html
I'm not sure whether you're deliberately punishing the questioner by
citing a sub-quality answer to the off-topic question, but as soon as
I saw the page recommending to write syntactically invalid HTML in
order to compensate for bug(s) in a certain browser-like operating
system component, I left.
------------------------------
Date: Wed, 6 Aug 2003 15:09:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI and browser cahce
Message-Id: <Pine.LNX.4.53.0308061454270.2123@lxplus091.cern.ch>
On Wed, Aug 6, Sascha Möllering inscribed on the eternal scroll:
> I've a problem:
You have several! I think I'm going to start reading
de.comp.lang.perl.cgi _before_ considering to answer any question seen
here. Has it suddenly become infectious to post the same question
(modulo the language) separately to both, without mentioning the fact?
I am by no means the only person around here who reads German! At
least it was vaguely on-topic there, which it really isn't here.
good luck.
------------------------------
Date: Wed, 06 Aug 2003 13:31:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: CGI and browser cahce
Message-Id: <dr7Ya.21875$td7.19286@nwrddc01.gnilink.net>
Sascha Möllering wrote:
> I've a problem: I don't want the browser to cache websites, because I
> wrote a shop with authentification and after having logged out, it is
> possible to see the old sites using the back button of the browser. I
> tried the following (my header.cgi-file), but it does not work:
>
> print "[print text snipped]";
> print <<EOF;
[print text snipped]
> EOF
On a first glimpse your Perl code looks fine (well, it's hardly possible to
mess up two simple print statements anyway). You need to provide more
details:
- What do you expect Perl to print
- What does Perl actually print on your computer
Without this information we cannot know why the Perl code does not do what
you expect it to do.
jue
------------------------------
Date: Wed, 06 Aug 2003 08:03:23 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Convert UFT-8 to unicode?
Message-Id: <vqc1jv4afalf1hsrc7uuc9m8brcaj1iroe@4ax.com>
Andreas Schmidt wrote:
>my CGI script receives UTF-8 strings, like "0xE2 0x82 0xAC" for the Euro
>symbol.
I assume you mean the UTF-8 looks like "\xE2\x82\xAC"?
>However, the unicode for this symbol is 0x20AC.
>
>How can I convert from UTF-8 to Unicode?
>
>
>I'd like to do sth like:
>
>if( $str =~ m/\x{20AC}/ ){
> print "used euro";
>}
>
>but first, I have to convert "0xE2 0x82 0xAC" to Unicode, of course...
If you're sure the string contains valid UTF-8, all you have to do is
enable the UTF-8 flag of the string. If you're using Perl 5.8.0 or
above, you have the Encode module at your displosal. See the last
section in its POD, "The UTF-8 flag" and "Messing with Perl's
Internals". You'll see the function _utf8_on($scalar) mentioned there.
<http://www.perldoc.com/perl5.8.0/lib/Encode.html>
If you're using a Perl 5.6.x, you can emulate that function using pack()
(most likely it will work for 5.8.x, too):
$utf8 = pack "U0a*", $bytes;
$utf8 will contain a string with exactly the same bytes as $bytes, but
having the UTF-8 flag on.
--
Bart.
------------------------------
Date: Wed, 6 Aug 2003 11:30:52 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Convert UFT-8 to unicode?
Message-Id: <Pine.LNX.4.53.0308061103180.2123@lxplus091.cern.ch>
On Wed, Aug 6, Andreas Schmidt inscribed on the eternal scroll:
> my CGI script receives UTF-8 strings, like "0xE2 0x82 0xAC" for the Euro
> symbol.
Then it would be best to use at least Perl 5.8.0 ...
> However, the unicode for this symbol is 0x20AC.
"Unicode" is an abstract concept - an identification of particular
characters with particular integer numbers ("code points" in the
Unicode character set). In order to actually _use_ those abtract
Unicode characters, it's necessary to have a way of representing them.
utf-8 is one particular way of representing them (and it just happens
to be Perl's own internal representation of Unicode, although you
don't need to know that in order to use it). You writing 0x20AC (or
as the Unicode folks would write it, U+20AC) are just other ways of
giving a concrete representation to the abstract characters. None of
them is "Unicode" per se: all of them are representations of Unicode.
> How can I convert from UTF-8 to Unicode?
utf-8 already _is_ (a representation of) Unicode.
> I'd like to do sth like:
>
> if( $str =~ m/\x{20AC}/ ){
Yup, that's another way of representing Unicode: it's Perl's way of
writing a "wide character" in source code.
Perhaps you could be a bit more precise about how this script
"receives" Unicode characters. Is it reading them directly from a
file (then it's easy in 5.8.0, you just open the file with :utf8), or
is it that you've decoded some HTML form submission data, and got
yourself a string of bytes which contains some utf-8 representations
of characters?
If it's the latter, and you really have to handle this yourself by
hand (it appears that recent versions of CGI.pm handle it for you, but
I have to admit to not trying that myself yet), then I think you want
pack() with a template of U0, as others have said.
> but first, I have to convert "0xE2 0x82 0xAC" to Unicode, of course...
Sort-of; but I'd still recommend taking a bit of time out to study
relevant parts of
http://www.perldoc.com/perl5.8.0/pod/perluniintro.html and then
http://www.perldoc.com/perl5.8.0/pod/perlunicode.html
to get a firmer understanding of what's going on, and how it's meant
to be used.
------------------------------
Date: Wed, 6 Aug 2003 13:55:44 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Convert UFT-8 to unicode?
Message-Id: <Pine.LNX.4.53.0308061352190.2123@lxplus091.cern.ch>
On Wed, Aug 6, Alan J. Flavell inscribed on the eternal scroll:
> On Wed, Aug 6, Andreas Schmidt inscribed on the eternal scroll:
>
> > How can I convert from UTF-8 to Unicode?
>
> utf-8 already _is_ (a representation of) Unicode.
I'm glad to see now that you got much the same answer to this point
when you posted the same question to the German-language Perl group.
But it's not nice to post the same question in several places without
informing the respective participants that you are doing that. It
leads to pointless duplication of effort by people who were trying to
help you.
------------------------------
Date: Wed, 06 Aug 2003 15:12:28 +0100
From: Nigel Horne <njh@despammed.com>
Subject: Re: Convert UTF-8 to unicode?
Message-Id: <bgr2cc$9nl$1$8302bc10@news.demon.co.uk>
I have been sent a file in UTF format, that is a file with UTF characters.
If I cat(1) the file I correctly see the Japanese characters. How do I
display the same characters in Perl? An "od -x" of the file looks like
this:
0000000 a4e6 e79c a2b4
-Nigel
------------------------------
Date: Wed, 06 Aug 2003 14:57:16 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: extract from html
Message-Id: <bgq1u1$25f6$1@otis.netspace.net.au>
Hello Peter,
> how can i extract the number between text1 and text2 in input.html
> only the first time it occurs ignoring the rest?
> preferably input.html would be a URL that stops downloading once a
> match has occured, that would save a lot of bandwidth..
> i guess html::parser would provide an option to work with a file while
> it's downloading (?)
>
> example
> ----
>
> input.html:
>
> bla..
> text1 555 text2
> bla
> bla
> text1 6000 text2
> bla
> EOF
>
>
> output.txt
> 555
Assuming you mean 'text1' and 'text2' are html tags, then the following
example, (which is straight out of the HTML::Parser documentation), will
do it for you. This example prints out the title text of a html page if
you supply the page as a filename on the command line, so just change
the word "title" to the tag name you require:
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Parser ();
sub start_handler
{
return if shift ne "title";
my $self = shift;
$self->handler(text => sub { print shift }, "dtext");
$self->handler(end => sub { shift->eof if shift eq "title"; },
"tagname,self");
}
my $p = HTML::Parser->new(api_version => 3);
$p->handler( start => \&start_handler, "tagname,self");
$p->parse_file(shift || die) || die $!;
print "\n";
------------------------------
Date: Tue, 5 Aug 2003 23:59:58 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extract from html
Message-Id: <slrnbj12qe.fu2.tadmc@magna.augustmail.com>
[ comp.lang.perl is not a Newsgroup. Removed ]
Lydia Shawn <apfeloma@hotmail.com> wrote:
> Subject: extract from html
Your post is not about extracting from HTML at all, so that
seems a strange choice of Subject...
> how can i extract the number between text1 and text2 in input.html
> only the first time it occurs ignoring the rest?
> input.html:
>
> bla..
> text1 555 text2
> bla
> bla
> text1 6000 text2
> bla
> EOF
No HTML there!
If you read it all into a scalar, then you can just do this pattern
match on the scalar:
/text1 (.*?) text2/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 6 Aug 2003 09:54:20 +0200
From: "Michael Korte" <michael.korte@materna.de>
Subject: Re: extract from html
Message-Id: <bgqc7c$uln$1@pentheus.materna.de>
"Lydia Shawn" <apfeloma@hotmail.com> schrieb im Newsbeitrag
news:1240b4dc.0308051647.685dde59@posting.google.com...
> hi,
> how can i extract the number between text1 and text2 in input.html
> only the first time it occurs ignoring the rest?
This problem I would solve by using a Hash. You can just put a unique key
into it, while finding the same term
it will be overwritten, or you can ask the hash if the term already exist
# $term is taken from your text - inbeetween text1 / text2
if( exists $myHash{$term})
{
# ignore
}else
{
$myHash{$term} = $value;
}
The Rest of your question : I don´t know ... sorry
> thanks for your help,
> peter
no prob...but what is your real name ?
"Lydia Shawn" or Peter :-)
HTH
greets Michael
------------------------------
Date: 6 Aug 2003 03:17:51 -0700
From: apfeloma@hotmail.com (Lydia Shawn)
Subject: Re: extract from html
Message-Id: <1240b4dc.0308060217.4a171485@posting.google.com>
> Your post is not about extracting from HTML at all, so that
> seems a strange choice of Subject...
>
>>
> No HTML there!
>
> If you read it all into a scalar, then you can just do this pattern
> match on the scalar:
>
> /text1 (.*?) text2/
yes there is no html in my example,
my question is more about the function of html::parser working with a
file and matching things as the file is coming in, and stopping after
the first match has occured.. to prevent needless downloading. how can
i do that?
thanks a lot,
peter
------------------------------
Date: 6 Aug 2003 03:24:32 -0700
From: apfeloma@hotmail.com (Lydia Shawn)
Subject: Re: extract from html
Message-Id: <1240b4dc.0308060224.69ac6d1f@posting.google.com>
>
> Assuming you mean 'text1' and 'text2' are html tags, then the following
> example, (which is straight out of the HTML::Parser documentation), will
> do it for you. This example prints out the title text of a html page if
> you supply the page as a filename on the command line, so just change
> the word "title" to the tag name you require:
>
>
thanks simon,
but the text1/text2 is actual text that occur within <TD> tags which
are all over the document...
the reason i would like to use html::parser to do the job is its
feature, at least the way i understand it, to start matching things
before the whole file is read in. then, after the match, it should
stop in order to save bandwidth,
thaks again,
peter
------------------------------
Date: Wed, 6 Aug 2003 08:54:15 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extract from html
Message-Id: <slrnbj2247.h7u.tadmc@magna.augustmail.com>
Lydia Shawn <apfeloma@hotmail.com> wrote:
>> Your post is not about extracting from HTML at all, so that
>> seems a strange choice of Subject...
> yes there is no html in my example,
> my question is more about the function of html::parser working with a
> file and matching things as the file is coming in, and stopping after
> the first match has occured.. to prevent needless downloading.
Then your Subject is not related to the content of the article.
The Subject should be related to the content of the article.
Subject: how to stop downloading when match succeeds
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 5 Aug 2003 23:51:20 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Final "Flocking" Script
Message-Id: <slrnbj12a8.fu2.tadmc@magna.augustmail.com>
Chas Friedman <friedman@math.utexas.edu> wrote:
> You wrote:
Who is "you"?
Please provide a proper attribution when you quote someone.
>>Thanx you to everyone who has been helping with my flocking issue.
>>open (FH, "<data.txt") or die "Can't open file: $!";
>>flock (FH, LOCK_EX) or die "Can't lock file: $!";
> I always worried about having the open and lock statements separate. I had
> the idea (possibly wrong) that there could be some time lag between
> execution of the 2 statements, and the file could change during that time.
Eh?
The very purspose of doing file locking in the first place is
because of such a "time lag", most commonly called a
"race condition".
So your idea is perfectly right. (so far)
> I usually do something like:
>
> .............
> use Fcntl ':flock'; # import LOCK_* constants
> use Fcntl ':DEFAULT';
> use POSIX;
> sub lock {
> flock F, LOCK_EX;
> # and, in case someone appended <-----
> # while we were waiting... <------ (This is from perl docs.)
> seek F, 0, 2; #<-----------
> }
>
> sub unlock {
> flock F, LOCK_UN;
> }
Uh oh, if this gets called, then you have _introduced_ a race,
exactly the opposite of what you're trying to do.
If you're worried about the open/flock timing why not worry
about the unlock/close timing as well?
seek()ing can overcome the former, but the later is a problem.
Do not unlock the file, just close() it. close() will unlock
it in a way that _is_ atomic.
> if (sysopen(F,$file, O_WRONLY)){
> lock();}
> .............
>
> That way, the open and lock is "atomic".
No they're not.
Why do you think that they are atomic in your code?
Your process could _still_ do the open() and lose its time slice
before doing the flock().
In fact, it makes the time for the race to bite you _longer_ due
to the overhead of calling a subroutine.
You made it a little worse, but that's OK since you're seek()ing anyway.
> I wonder if this is actually
> necessary.
If "this" means your code above, then no, it is not necessary.
> The perl docs show some examples where the open and lock are
> in separate statements, so I thought that should be OK.
Putting them in the same statement will not affect the possibility
of a race either.
> But I once did
> some tests of locking in which I appended, say, 100 times to a file with
> a script using open and lock separately and then in a single statement, and
> it seemed to make some difference
Must have been a statistical anomaly.
> - there were occasionally some errors
> when the open and lock were in separate statements. However, this could have
> been for some other reason...
Like the race between the unlock and the close. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Aug 2003 06:50:01 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Final "Flocking" Script
Message-Id: <ty1Ya.12243$W%3.2868@nwrdny01.gnilink.net>
Chas Friedman <friedman@math.utexas.edu> wrote:
> I always worried about having the open and lock statements separate.
> I usually do something like:
>
> sub lock {
> flock F, LOCK_EX;
> # and, in case someone appended <-----
> # while we were waiting... <------ (This is from perl docs.)
> seek F, 0, 2; #<-----------
> }
>
> That way, the open and lock is "atomic". I wonder if this is
> actually necessary.
The problem would occur when another process writes to the
file between the append-open() and the flock(). This could
invalidate your seek pointer -- i.e. you're prepared to write
at the end of the file, and the end of the file *moves* so
you end up writing in the wrong place.
This only applies to appending, though, and the FAQ suggests
that it only applies to Windows. Maybe somebody can list some
OS or filesystem versions where it's actually a problem?
Either Way: it doesn't affect our OP. His race condition is
even simpler.
Here's some code to spawn a number of processes, each of which
will increment a "counter" in a text file. The parent process
waits for the kids to finish and compares the number in the
file with the expected (if we didn't know better) result.
[ error-checking omitted ]
% cat -n race.pl
1 my ($procs, $loops) = @ARGV;
2 my $file = 'counter.race';
3
4 system qq{ echo 0 > $file };
5
6 for (1..$procs) {
7 next if fork;
8 for (1..$loops) {
9 open FH, '<', $file;
10 flock(FH, LOCK_EX);
11 my $count = <FH>;
12 close FH;
13
14 open FH, '>', $file;
15 flock(FH, LOCK_EX);
16 print FH $count+1, "\n";
17 close FH;
18 }
19 exit;
20 }
21
22 1 until wait == -1;
23 printf "%d/%s", $procs * $loops, qx{ cat $file };
% race.pl 2 10
20/20
% race.pl 5 100
500/332
% race.pl 10 1000
10000/1384
The most obvious problem occurs when another process comes
along while we're between lines 15 and 16. Since we've truncated
the file but not yet locked it, the other process will see the
empty file. This has the effect of resetting the counter...
So the entire read-calculate-write sequence must be protected
by flock(). There's an example in the FAQ
% perldoc -q "I still don't get locking"
That shows you how to do that with a read/write open(). You
could also lock a second file (a "semaphore" file) instead of
locking the data file itself. The nice thing about that
approach is that you don't have to do the awkward seek() and
truncate() on the data file.
HTH
--
Steve
------------------------------
Date: Wed, 6 Aug 2003 15:03:27 +0200
From: "Rene Scheibe" <Rene.Scheibe@Stud.TU-Ilmenau.de>
Subject: Problems with flock()
Message-Id: <bgqubc$r5mop$1@ID-65612.news.uni-berlin.de>
Hi,
i have a problem with perls flock() or maybe
it's another thing - i'll explane.
i have a website with a form.
the perl-cgi-script which is executed on send
button increases a counter on the server at
startup and decreases it at exit. (so i can
setup max number of running instances.)
if a user waits till results of script are
displayed and makes its new requests always
after this everything is fine.
but if he makes many requests before the script
is finished the counter isnt correctly decreased.
i have no idea why this is like this.
maybe you can tell me or make another suggestion
for better instance counter implementation.
thanks...
...rene
here are the two used scripts (shortened):
### upload.cgi ###
#!/usr/bin/perl -w
require 'subs.pl';
init();
return_result();
finish();
### subs.pl ###
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $CACHING_TIME = 10;
my $PATH_INST_COUNT = 'INSTANCES';
my $PATH_RUN_COUNT = 'RUNS';
my $MAX_INST_COUNT = 3;
my $cgi;
sub init () {
$cgi = new CGI;
instance('inc');
}
sub instance ($) {
open FILE, "+>> $PATH_INST_COUNT";
flock FILE, 2; # wait for exclusive lock
seek FILE, 0, 0; # rewind to beginning
my $content = <FILE>; # get current content
if ($_[0] =~ /inc/) {
if ($content < $MAX_INST_COUNT) {
seek FILE, 0, 0;
truncate $PATH_INST_COUNT, 0;
$content += 1;
print FILE $content;
close FILE;
}
else { # max number of instances reached
close FILE;
exit;
}
}
if ($_[0] =~ /dec/) {
seek FILE, 0, 0;
truncate $PATH_INST_COUNT, 0;
$content -= 1;
print FILE $content;
close FILE;
}
}
sub return_result () {
print $cgi->header(-type => 'text/html');
print $cgi->start_html(-title => 'result');
print "done";
print $cgi->end_html;
}
sub finish() {
my $pid = fork;
if ($pid == 0) { # child procress
sleep $CACHING_TIME;
#...delete some files
}
else { # parent process
instance('dec');
}
}
1;
------------------------------
Date: Wed, 6 Aug 2003 15:27:06 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Problems with flock()
Message-Id: <Pine.LNX.4.53.0308061511460.2123@lxplus091.cern.ch>
On Wed, Aug 6, Rene Scheibe inscribed on the eternal scroll:
> i have a problem with perls flock()
As you indeed said on de.comp.lang.perl.cgi in
<bgqtri$r6j88$1@ID-65612.news.uni-berlin.de>
Are you comparing the answers against each other? Will we
get an end-of-semester report?
------------------------------
Date: Wed, 6 Aug 2003 09:32:38 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problems with flock()
Message-Id: <slrnbj24c6.h7u.tadmc@magna.augustmail.com>
Rene Scheibe <Rene.Scheibe@Stud.TU-Ilmenau.de> wrote:
> i have a website with a form.
You should enable taint checking when you have a website with a form.
perldoc perlsec
> instance('inc');
> sub instance ($) {
> open FILE, "+>> $PATH_INST_COUNT";
You should always, yes *always*, check the return value from open():
open FILE, "+>> $PATH_INST_COUNT" or
die "could not open '$PATH_INST_COUNT' $!"; # or s/die/croak/
> if ($_[0] =~ /inc/) {
So you _want_ this block to be entered when called like instance('inch') ?
If you want to test for equality, then use the operator that
tests for equality:
if ( $_[0] eq 'inc' ) {
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 6 Aug 2003 22:50:19 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Renaming Files inside a GZ Zip File
Message-Id: <bgqmej$rdhe0$1@ID-172104.news.uni-berlin.de>
"Mike Flannigan" <mikeflan@earthlink.net> wrote in message
news:3F2FDD4C.215EC41B@earthlink.net...
>
> On a Win2000 box I have hundreds of files named
> somethingXXX - ZZZZZ.tif.gz
> that are gz zip files that contain a single file named:
> otherfileYYY.tif
You are confused as to what a gzipped file is. It is not analogous to a zip
file that can contain one or more files. A gzipped file is simply a
compressed version of the file itself.
>
> I want to write a perl script that will rename the single tif
> file inside each gz file with the first portion of the gz file
> name. So all the "inside" files will be named
> somethingXXX.tif
>
> The gz file name will not be modified. (I could do that
> right now if I wanted to).
Then that's what you need to do. Easy!
------------------------------
Date: Wed, 06 Aug 2003 14:00:55 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Renaming Files inside a GZ Zip File
Message-Id: <3F310AA6.42D68895@earthlink.net>
Tintin wrote:
> You are confused as to what a gzipped file is. It is not analogous to a zip
> file that can contain one or more files. A gzipped file is simply a
> compressed version of the file itself.
>
> >
> > The gz file name will not be modified. (I could do that
> > right now if I wanted to).
>
> Then that's what you need to do. Easy!
Thanks for the info. I was confused about that.
Years ago I had already renamed the gz file names to what
I wanted, but the tiff files inside retained the same old name.
Each time I use one of these files I manually rename the
"unzipped" file to what I want. Now I am finally going to
"fix" the name of the tiff file in these zipped files, so I
don't have to rename them every time I use them. While I'm
at it, I'll probably abandon the gz format, and just use the
zip that I am so familiar with.
Luckily, the Perl idiom: TIMTOWTDI, applies outside of
Perl also. I already have the files "unzipped" using another
program. Now I'm in the process of writing a simple
rename script that uses a hash. I'm real new to this, so
I am struggling with this simple routine. But I will get it.
Then I'll use the other program to Zip them up again.
I may post my simple hash code under another heading
for comments.
I upgraded to Perl v5.8.0, but it didn't fix the PerlIO::gzip
module problem. Now it gives the error:
Can't locate loadable object for module PerlIO::gzip . . .
I'd still like to learn the Perl way to do this, but it's probably
going to be awhile before I finally figure it out.
Mike
------------------------------
Date: Wed, 06 Aug 2003 14:33:32 -0000
From: hymie@lactose.smart.net (hymie!)
Subject: Re: Renaming Files inside a GZ Zip File
Message-Id: <vj24ds8rpi3la4@corp.supernews.com>
In our last episode, the evil Dr. Lacto had captured our hero,
Mike Flannigan <mikeflan@earthlink.net>, who said:
>
>Tintin wrote:
>
>> You are confused as to what a gzipped file is. It is not analogous to a zip
>> file that can contain one or more files. A gzipped file is simply a
>> compressed version of the file itself.
>Years ago I had already renamed the gz file names to what
>I wanted, but the tiff files inside retained the same old name.
>Each time I use one of these files I manually rename the
>"unzipped" file to what I want.
I can't comment on what you may or may not have done "years ago", but you
are still confused.
GZip is a compression program. You have a file named whatever.tif . If
you compress the file, then whatever.tif is removed and replaced with
whatever.tif.gz . You don't specify what you mean by
>Each time I use one of these files
but if you uncompress whatever.tif.gz , then it is removed and replaced
by whatever.tif
The only place the filename is stored is in the filename.
>I'll probably abandon the gz format, and just use the
>zip that I am so familiar with.
That might be for the best. A tool is of no value unless you can use
it properly.
>I'd still like to learn the Perl way to do this, but it's probably
>going to be awhile before I finally figure it out.
Perl is not the best tool for every job.
hymie! http://www.smart.net/~hymowitz hymie@lactose.smart.net
===============================================================================
------------------------------
Date: Wed, 06 Aug 2003 13:37:29 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Trying to select range for Excel chart
Message-Id: <3F30F689.9E307414@oracle.com>
This is a multi-part message in MIME format.
--------------6ACA1FB34367523651D886F4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
hansioux wrote:
> Hi,
>
> This is probably not an "perl" question, but I am writting this in perl,
> so I gave it a shot.
>
> I have created a excel spreadsheet using the Win32::ole..
>
> I am trying to create a excel chart,
>
> but instead of charting column A all the way through column J
> I just want to chart column A and column J.
>
> $Range = $Sheet->Range("A1:J10")->Select(); only gives the whole thing.
try
$Range = $Sheet->Range("A:A,J:J")->Select();
This should select column A and column J rather than all columns between A
and J.
Hope this helps
Graham
--------------6ACA1FB34367523651D886F4
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------6ACA1FB34367523651D886F4--
------------------------------
Date: Wed, 06 Aug 2003 04:32:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why, oh why have I read "Perl 6 essentials"???
Message-Id: <x7ispbs8xr.fsf@mail.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> Uri Guttman <uri@stemsystems.com> wrote:
>>>>>>> "GS" == Garry Short <g4rry_sh0rt@zw4llet.com> writes:
>>
GS> Just on a casual note, because the more I read, the more impatient
GS> I get, are there any estimated timescales on when Perl6 will be
GS> available?
>> next christmas (for some definition of christmas).
TM> So then, that would be:
TM> any('christmas')
no, because that includes christmases past. (apologies to dickens :)
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: Wed, 6 Aug 2003 11:19:34 +0200
From: "Georg Daniel Vassilopulos" <a@viot.de>
Subject: XML DB Xindice -> use with perl
Message-Id: <bgqhb0$mi5$02$1@news.t-online.com>
Hello!
Does anyone have experience using The XML.apache.org Database Xindice from
perl applications?
Should I use the Corba API from perl?
What limitations in comparison to the java API should I expect?.
Any comments heavily welcome...
Greetings from Darmstadt/Germany
Georg
comp.lang.perl.misc.02321@viot.de
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5323
***************************************