[23435] in Perl-Users-Digest
Perl-Users Digest, Issue: 5652 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 13 14:06:28 2003
Date: Mon, 13 Oct 2003 11:05:07 -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 Mon, 13 Oct 2003 Volume: 10 Number: 5652
Today's topics:
Re: Archive::Zip use? <jwillmore@remove.adelphia.net>
Re: CGI.pm File Upload doesn't work (blocks) on my Serv <bjoern_p1@gmx.net>
Don't reinvent the wheel! <pkrupa@redwood.rsc.raytheon.com>
Re: Help: Install DBI-Oracle on cygwin with Perl 5.8.0 <jwillmore@remove.adelphia.net>
Re: How To activate command line history in debugger? (Peter Scott)
Re: multiline regex <mjj@isorauta.ntc.nokia.com>
Named Pipe Permissions Question <mooseshoes@gmx.net>
Re: Remembering part of last matched string (Chandramohan Neelakantan)
Sharing variables across scripts. <ddunham@redwood.taos.com>
Re: Sharing variables across scripts. <tassilo.parseval@rwth-aachen.de>
Re: string splitting question (Emily Baylor)
Re: string splitting question (Anno Siegel)
Re: Teach me how to fish, regexp (Anno Siegel)
Re: Teach me how to fish, regexp (Roy Johnson)
Uploading files (michela rossi)
uploading files <nospampleasethankyouta@somewhereinthebluenowhere.com>
Re: uploading files <nospampleasethankyouta@somewhereinthebluenowhere.com>
Re: Using map to assign var values from hash <tassilo.parseval@rwth-aachen.de>
Re: Wierdness with code to display file creation date <dave.nospam@ntlworld.com>
Re: Wierdness with code to display file creation date <tony_curtis32@_SPAMTRAP_yahoo.com>
Re: Wierdness with code to display file creation date (Anno Siegel)
Re: Wierdness with code to display file creation date <dave.nospam@ntlworld.com>
Writing a perl file comparison program (Kulvinder Mall)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Oct 2003 15:24:53 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Archive::Zip use?
Message-Id: <20031013112513.36c7743d.jwillmore@remove.adelphia.net>
On Sat, 11 Oct 2003 20:28:12 GMT
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
> With excellent help from this group I have been able to use the
> following code to change a zip file to a doc file with the same name
> as the zip file ...
>
> would now like to do the reverse of this in a slightly different way
> .. I have say 20 doc files in a folder which I would like to zip and
> name as doc1.zip, doc2.zip etc ... I am guessing that the code will
> not be too different from that below but would appreciate some help
> on which Archive::Zip method would be appropriate here...
<snip>
Have you consulted the documentation?
The command is -
perldoc Archive::Zip
-or-
http://search.cpan.org/~nedkonz/Archive-Zip-1.06/lib/Archive/Zip/FAQ.pod
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Putt's Law: Technology is dominated by two types of people:
Those who understand what they do not manage. Those who manage
what they do not understand.
------------------------------
Date: Mon, 13 Oct 2003 18:39:28 +0200
From: Bjoern <bjoern_p1@gmx.net>
Subject: Re: CGI.pm File Upload doesn't work (blocks) on my Server (but works on my Desktop)
Message-Id: <bmekcf$ls80i$1@ID-142197.news.uni-berlin.de>
news@roaima.freeserve.co.uk wrote:
> Bjoern <bjoern_p1@gmx.net> wrote:
>
>>What coud be wrong? I've checked that /temp can be written to by anyone,
>
>
> There is no /temp on a standard unix or gnu/linux distribution.
oops, true - but there is a /tmp, which is what I meant.
I'll try to create a simple script that reproduces my problem and that I
can post.
Bjoern
--
Let's not weep for their evil deeds,
but for their lack of imagination
(Nick Cave)
------------------------------
Date: Mon, 13 Oct 2003 17:10:35 +0000
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Don't reinvent the wheel!
Message-Id: <f0Bib.51$b77.35@dfw-service2.ext.raytheon.com>
perldoc -q permut
------------------------------
Date: Mon, 13 Oct 2003 15:18:13 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Help: Install DBI-Oracle on cygwin with Perl 5.8.0
Message-Id: <20031013111833.3fa5a0d2.jwillmore@remove.adelphia.net>
On Mon, 13 Oct 2003 07:15:00 -0400
"James Hull" <jameshull@comcast.net> wrote:
> I am new in the Perl world. So far I have installed cygwin and Perl
> 5.8.0 along with Perl DBI and DBD::Oracle modules. NowI am trying to
> install Perl Tk on my PC (Windows 2K). I have tried both Tk804.025
> and Tk804.025_beta2. However, both versions failed with following
> errors. It appeared that the command "perl Makefile.PL" ran
> successfully, but the "make" command failed. I also ran "perl -Mblib
> demos/widget". It was complaining it "Can't locate Tk/Event.pm in
> @INC" (See following enclosed error message).
>
> BTW, what is "@INC"?
>
<snip>
If you're trying to compile Tk and getting errors, you may want to try
version 804.024. Version 804.25 is still beta. If you continue to
have issues, you may far better posting to comp.lang.perl.tk - you
posted to evry other newsgroup but the one where you may find an
answer :-)
And change your subject line - the one you have is very mis-leading.
Your question relates to Tk, not DBD::Oracle. At least, that's what I
got out of your post.
The answer to your @INC question can be found by typing the command:
perldoc perlvar
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"He flung himself on his horse and rode madly off in all
<directions"
------------------------------
Date: Mon, 13 Oct 2003 17:14:04 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: How To activate command line history in debugger?
Message-Id: <w3Bib.85005$6C4.17875@pd7tw1no>
I am not going to reply again on this thread unless you post with an address
that will accept email. I just wasted a bunch of time replying to your
posted address, reading the bounce, resending without the "-nospam", and
reading the bounce from that.
In article <bme5uf$h3h$01$1@news.t-online.com>,
Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de> writes:
>I got the tar file (http://www.cpan.org/authors/id/J/JS/JSTOWE/ is a
>http source I found) and everthing ran without any error.
>
>A simple test with a degbug session (perl -d)showed me unfortunaltely no
>success. It's still displaying the ESC-Sequence of Up-arrow.
>
>Could I check or do something else?
Maybe it's something wrong with your terminal settings. Write a small
application that uses Term::ReadKey and run it fom the same shell that
you're running the debugger to see if it works properly.
Also, see whether the debugger loaded the module properly. Do
perl -de 0
and type
x \%INC
Check that the output includes entries for ReadLine and ReadKey.
>If you would have a little bit of time ;=)
I do not.
> it would be a way for you to boot a Knoppix CD to see the effect live.
Hardly guaranteed, unless you know of other Knoppix users with the same
problem, in which case you should file a bug report.
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: Mon, 13 Oct 2003 13:32:30 GMT
From: Mike Jackson <mjj@isorauta.ntc.nokia.com>
Subject: Re: multiline regex
Message-Id: <OPxib.151$g4.1913@news2.nokia.com>
Anno Siegel wrote:
>
> You have nested parentheses to parse, so Text::Balanced will probably
> figure in the solution.
Hi,
That was all I asked and all I wanted to know, e.g. was there already
a module that could assist in this task, or was it purely a regex task.
Thanks for the tip :-) I'm sure that it will save me some time.
Thanks,
--
mike
------------------------------
Date: Mon, 13 Oct 2003 16:28:30 GMT
From: mooseshoes <mooseshoes@gmx.net>
Subject: Named Pipe Permissions Question
Message-Id: <OoAib.9873$nJ2.8765@newssvr29.news.prodigy.com>
All:
I want to use a named pipe to share information between processes and have
successfully achieved this in a test directory using two perl scripts.
The actual location for the code that creates the pipe and writes to it is
in a script that lives in my mod_perl scripts directory since it part of a
CGI routine.
The pipe gets created successfully in a directory (using "mknod") with user
priviledges but when the program attempts to write to the pipe, the
following error is generated (captured from "perl-error_log"):
<<<<<[Sun Oct 12 21:10:04 2003] [error] can't
write/home/myusername/mydirectoryname/AU_FIFO: Permission denied at
/var/www/perl/check_login.pl line 568.
The lines of code in check_login.pl are:
567 open(FIFO_WRITE, "> $FIFO") || die "can't write $FIFO: $!";
568 print FIFO_WRITE "$pref_concat\n";
I tried changing permissions on AU_FIFO to 755 but that didn't help. Same
error.
It appears to be a pure permissions issue, but I'm not sure what to try
next.
Your suggestions are appreciated.
TIA,
Moose
-----
Look for decreasing temperatures this winter with the likelihood of warmer
weather in the spring.
------------------------------
Date: 13 Oct 2003 08:27:32 -0700
From: knchandramohan@yahoo.com (Chandramohan Neelakantan)
Subject: Re: Remembering part of last matched string
Message-Id: <69d11688.0310130727.7e922d5c@posting.google.com>
> > -------------------------------------------------
>
> How about storing the values in a hash of hashes? This may be a start,
> assuming the output is in $_:
>
> my %rules = ();
>
> while (
> /(\d+(?:\.\d+)+) # Rule
> \s+
> ([\w\-\s]+[\w\-]) # Description
> \s+
> (\d+\.\d\s?x\s?\d+\.\d) # Dimensions
> \s+
> ([A-Z]*) # Devices
> \s+
> (\d,[A-Z]\d) # Fig
> \s+
> ([\w\-\s]+[\w\-]) # except NPN
> \s+
> (?=\d+(?:\.\d+)+|$) # next rule or end
> /gix
> )
>
> {
> $rules{ $1 } = {
> desc => $2,
> dim => $3,
> dev => $4,
> fig => $5,
> except => $6,
> };
> }
could you explain the line
(?=\d+(?:\.\d+)+|$) # next rule or end
please ?
CM
------------------------------
Date: Mon, 13 Oct 2003 16:31:40 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Sharing variables across scripts.
Message-Id: <MrAib.778$ru7.178@newssvr27.news.prodigy.com>
I have a set of about 5 or 6 scripts related to a single task. Rather
than have each one define all the variables they need in common, I want
to have them load a "header" file defining them.
Is this a good use of Exporter? When I read over the documentation, I'm
left with the idea that I'm overlooking an easier or better idea.
Something like...
<variables>
package LocalPackage;
[...]
use Exporter;
@EXPORT = qw($top_dir, $bin_dir, $process_user);
$top_dir="/path/to/data";
1;
<script>
use LocalPackage;
package LocalPackage;
[...]
chdir $topdir;
Is this worse than just defining the variables and 'require'ing the
file?
The scripts already exist, they're not OO, I'm not going to rewrite
them. I just want to make it easier to have the shared variables in one
file rather than independently defined in several places.
Thanks.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: 13 Oct 2003 17:18:58 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Sharing variables across scripts.
Message-Id: <bmemq2$ifd$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Darren Dunham:
> I have a set of about 5 or 6 scripts related to a single task. Rather
> than have each one define all the variables they need in common, I want
> to have them load a "header" file defining them.
>
> Is this a good use of Exporter? When I read over the documentation, I'm
> left with the idea that I'm overlooking an easier or better idea.
No, using the Exporter is fine here. require() or even do() could be
used as well, but they are not quite as flexible.
> Something like...
>
><variables>
> package LocalPackage;
> [...]
> use Exporter;
> @EXPORT = qw($top_dir, $bin_dir, $process_user);
> $top_dir="/path/to/data";
> 1;
Does that work at all? I was under the impression that your exporting
module needs to be derived from Exporter. Therefore:
package LocalPackage;
use base qw(Exporter);
@EXPORT = qw(...);
...
1;
><script>
> use LocalPackage;
> package LocalPackage;
> [...]
> chdir $topdir;
>
> Is this worse than just defining the variables and 'require'ing the
> file?
No, it isn't. It has the additional advantage that you have some nice
control over what is exported. For instance, you could import variables
on request only by putting them into @EXPORT_OK:
package LocalPackage;
use base qw(Exporter);
# none of those are now exported by default
@EXPORT_OK = qw($top_dir $bin_dir $process_user);
...
And in your scripts:
# only import the variables you need
use LocalPackage qw($top_dir $bin_dir);
A related note: You should be using strictures in your code:
use strict;
use LocalPackage;
use vars qw($top_dir $bin_dir $process_user);
This requires to pre-declare the global variables you are going to use,
either through 'use vars' or our() which is available ever since
Perl5.6.0.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 13 Oct 2003 07:25:14 -0700
From: sf_94133@yahoo.com (Emily Baylor)
Subject: Re: string splitting question
Message-Id: <a673227d.0310130625.1637b77c@posting.google.com>
"Kris Wempa" <calmincents(NO_SPAM)@yahoo.com> wrote in message news:<bm7093$r086@kcweb01.netnews.att.com>...
> "Emily Beylor" <sf_94133@yahoo.com> wrote in message
> news:bm6qse$1bo2@george.sabre.com...
> > I have a path string (/usr/local/bin/file.10102003) that I want to split
> > into a $path and $file section as well as a $date section.
> >
> > I'm able to get the $path and $file information (perhaps not very
> elegantly,
> > but still) as follows:
> >
> > while(/\//g) {
> > $position = pos();
> > }
> >
> > $getFile = substr($_, $position, length($_));
> > $getPath = substr($_, 0, $position);
> >
>
> This is a lot of unnecessary work. Assuming your full path filename is in
> $str , you can use this:
>
> if ($str =~ /\/([^\/]+)$/) {
> $filename = $1; # file is everything BETWEEN the first set of
> parentheses
> $dirname = $`; # dir is everything BEFORE the matched pattern
> }
>
> > I'm not sure how to get the $date information from the $file name. I've
> > tried with the following code, but it doesn't work:
> >
> > $_=$getFile;
> > @a = m/([\d]+)/g;
> > print "@a\n";
> >
> >
> > How do I get the date information out of vi.10102003 to a representation
> of
> > $date = 10/10/2003 ?
>
> Using the results stored in $filename, just do something like this:
>
> if ($filename =~ /(\d\d)(\d\d)(\d\d\d\d)/) {
> $date = "$1/$2/$3";
> }
>
> I'm sure there's simpler ways, but this comes to mind quickly.
Kris,
Thanks. It's funny how there are so many ways of doing perl.
EB
------------------------------
Date: 13 Oct 2003 14:34:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: string splitting question
Message-Id: <bmed59$sfq$2@mamenchi.zrz.TU-Berlin.DE>
Emily Baylor <sf_94133@yahoo.com> wrote in comp.lang.perl.misc:
[snip]
> Thanks. It's funny how there are so many ways of doing perl.
Hehe! Can you say TIMTOWTDI?
Anno
------------------------------
Date: 13 Oct 2003 14:49:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Teach me how to fish, regexp
Message-Id: <bmee1q$sfq$3@mamenchi.zrz.TU-Berlin.DE>
Tad McClellan <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Henry <henryn@zzzspacebbs.com> wrote:
> > HelgiBriem_1@hotmail.com wrote on 10/9/03 3:53 AM:
>
>
[ talking about Perl's std docs ]
>
> > Would you mind sharing a few bullet points about the keys to getting the
> > most out of perldoc?
>
>
> Never use it. (that isn't a joke)
>
> I don't.
>
> I use the std docs many times each day, but never through perldoc.
>
> I only use perldoc as a shorthand for pointing others to the
> relevant docs.
>
> I prefer to use vi and grep to read the raw *.pod files.
>
> Because it lets me do things that perldoc does not let me do.
I like perldoc for its ability to find docs in places I don't care to
remember. "view `perldoc -l <something>`" gives me both worlds.
Anno
------------------------------
Date: 13 Oct 2003 10:58:00 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Teach me how to fish, regexp
Message-Id: <3ee08638.0310130958.f491cd1@posting.google.com>
"David H. Adler" <dha@panix.com> wrote in message news:<slrnbobgln.7kb.dha@panix2.panix.com>...
> In article <3ee08638.0310090552.2821c3a4@posting.google.com>, Roy Johnson wrote:
> > That said, I should have had a caveat that features do change.
>
> That caveat is exactly what makes it a bad *reference*.
No, it's a fine reference for anything that isn't likely to change.
Very few things have changed to be backward-incompatible. Very few. So
if you look it up in the Camel, it's almost sure to work.
There might be new features you don't get informed about, but as a new
Perl programmer, it's unlikely that those details are what you're
looking for. If I need to know the arguments to split(), that's not
going to change. The Camel is a good *basic* reference.
If you want an alternative to looking everything up online, the Camel
is the way to go. If you don't, yay. Perldoc is always there for you.
------------------------------
Date: 13 Oct 2003 09:03:46 -0700
From: michela_rossi66@hotmail.com (michela rossi)
Subject: Uploading files
Message-Id: <1ed550fd.0310130803.651b68ff@posting.google.com>
Hi,
Wonder if anyone can help. I've got a Unix server inside our firewall
that contains a local version of a website. The live version of the
website resides on shared webspace elsewhere. We are frequently
updating the local website on behalf of a client, and so frequently
upload files using FTP.
My question is: does anyone know of a script we can run on the local
server that will automatically synchronise the live server with the
files on the local server i.e. will only update those files from the
local server that are out of date?
Please note that we cannot install any software on the live server.
Thanks for anyone's time,
Thanks, Michela.
------------------------------
Date: Mon, 13 Oct 2003 17:33:25 +0100
From: "D Borland" <nospampleasethankyouta@somewhereinthebluenowhere.com>
Subject: uploading files
Message-Id: <ktAib.559$yM1.838127@newsfep1-win.server.ntli.net>
Hi again folks,
I'm trying to get the script below to work. I've checked it's syntax and
perl says that it's ok, i cannot check the logs on the server as 1&1
webhosting don't seem to allow me that, as when i run the script i get a
server 500 error, with no info on why :( I've checked to see if the script
still managed to upload the file which it did... any ideas?
Thanks for your time.
__CODE__
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp 'fatalsToBrowser';
$CGI::POST_MAX = 1024 * 500;
my $query = new CGI;
my $filename = $query->param('image1');
my $fileToUpload = $query->upload('image1');
my $uploadDir = "$ENV{'DOCUMENT_ROOT'}/beta";
$filename =~ s/.*[\/\\](.*)/$1/;
open(NEWFILE, ">$uploadDir/$filename")
or die "Cannot create new file $uploadDir/$filename : $!\n";
binmode(NEWFILE);
while (<$fileToUpload>) {
print NEWFILE;
}
close(NEWFILE);
print $query->p("File uploaded");
__END__
------------------------------
Date: Mon, 13 Oct 2003 17:50:13 +0100
From: "D Borland" <nospampleasethankyouta@somewhereinthebluenowhere.com>
Subject: Re: uploading files
Message-Id: <9JAib.577$yM1.867177@newsfep1-win.server.ntli.net>
ooops! :)
Forgot to print the header first, guess i was just looking at it too long,
and just didn't see it until i sat back for a bit.
------------------------------
Date: 13 Oct 2003 17:08:28 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Using map to assign var values from hash
Message-Id: <bmem6c$hpe$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Anno Siegel:
> Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote in comp.lang.perl.misc:
>> Eric J. Roode (REMOVEsdnCAPS@comcast.net) wrote:
>> : Please do not post answers to questions unless you know what you're talking
>> : about.
>>
>> I think we can safely assume that he thought he knew what he was talking
>> about, so your advice wouldn't have made any difference.
>
> Wouldn't have, in the past. It may make a difference in the future.
But it's not required. People shouldn't deliberately state wrong things,
but then they shouldn't be forced to double-check that their given
advice is 100% correct either. Their mistake is going to be pointed out
to them which is a good way of learning. In my first year in this group
I learnt the most by being corrected.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 13 Oct 2003 14:07:52 +0100 (BST)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: Wierdness with code to display file creation date
Message-Id: <qnirfnivyyragyjbeyqpbz.hmpjp41.pminews@text.news.ntlworld.com>
On 13 Oct 2003 11:38:47 GMT, Anno Siegel wrote:
>Oh, and Unix doesn't keep a creation date for files. It is always
>the last-modified date you are working with.
>
I suppose that's why it's called ctime then :-)
From man stat on Solaris 8:
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last data modification */
time_t st_ctime; /* Time of last file status change */
Just what the hell *is* a file status change anyway? - it can't be a
write 'cos that changes last-modified. It always *seems* to match
create time when ever I bother to check.
Regards
Dave Saville
NB switch saville for nospam in address
------------------------------
Date: Mon, 13 Oct 2003 09:24:44 -0500
From: Tony Curtis <tony_curtis32@_SPAMTRAP_yahoo.com>
Subject: Re: Wierdness with code to display file creation date
Message-Id: <87ekxhjjv7.fsf@limey.hpcc.uh.edu>
>> On Mon, 13 Oct 2003 14:07:52 +0100 (BST),
>> "Dave Saville" <dave.nospam@ntlworld.com> said:
> On 13 Oct 2003 11:38:47 GMT, Anno Siegel wrote:
>> Oh, and Unix doesn't keep a creation date for files.
>> It is always the last-modified date you are working
>> with.
>>
> I suppose that's why it's called ctime then :-)
> time_t st_ctime; /* Time of last file status change */
c = change, like in the comment above
> Just what the hell *is* a file status change anyway? -
> it can't be a write 'cos that changes last-modified. It
> always *seems* to match create time when ever I bother
> to check.
ctime records inode (attribute, not content) changes. In
some cases, this will be the same as the date the file
came into existence, but not necessarily (and therefore
you should not rely on it).
The following code demonstrates this:
use Data::Dumper;
use File::stat;
unlink("somefile");
open(F, "> somefile"); # get a new "somefile"
$s = stat("somefile");
print Dumper($s); # inspect it, [acm]time all the same
sleep 3;
chmod 0755, "somefile"; # after 3 sec, change attributes
$s = stat("somefile");
print Dumper($s); # inspect again, note change in ctime
hth
t
------------------------------
Date: 13 Oct 2003 14:31:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Wierdness with code to display file creation date
Message-Id: <bmecvs$sfq$1@mamenchi.zrz.TU-Berlin.DE>
Dave Saville <dave.nospam@ntlworld.com> wrote in comp.lang.perl.misc:
> On 13 Oct 2003 11:38:47 GMT, Anno Siegel wrote:
>
> >Oh, and Unix doesn't keep a creation date for files. It is always
> >the last-modified date you are working with.
> >
>
> I suppose that's why it's called ctime then :-)
I don't know what the "c" stands for, but it's not "creation". Ctime is
probably the least frequently used of the three available timestamps.
> From man stat on Solaris 8:
> time_t st_atime; /* Time of last access */
> time_t st_mtime; /* Time of last data modification */
> time_t st_ctime; /* Time of last file status change */
>
> Just what the hell *is* a file status change anyway? - it can't be a
> write 'cos that changes last-modified. It always *seems* to match
> create time when ever I bother to check.
How do you know the creation time? Memory? Manual records.
The file status is what is kept in the inode of a file. It keeps track
of ownership, permissions, link count and other information associated
with the file that isn't data.
Ctime changes whenever the inode information of a file is updated. It changes
more frequently than mtime, because every write changes ctime also. Other
operations that change it are chmod, chown, link, mknod, rename, unlink,
and utimes.
Anno
------------------------------
Date: Mon, 13 Oct 2003 18:13:17 +0100 (BST)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: Wierdness with code to display file creation date
Message-Id: <qnirfnivyyragyjbeyqpbz.hmpv250.pminews@text.news.ntlworld.com>
On Mon, 13 Oct 2003 09:24:44 -0500, Tony Curtis wrote:
<snip>
>ctime records inode (attribute, not content) changes. In
>some cases, this will be the same as the date the file
>came into existence, but not necessarily (and therefore
>you should not rely on it).
>
>The following code demonstrates this:
>
<snipped>
$VAR1 = bless( [
0,
1048579,
33206,
1,
0,
0,
0,
0,
1066064996,
1066064996,
1066064996,
'',
''
], 'File::stat' );
$VAR1 = bless( [
0,
1048580,
33206,
1,
0,
0,
0,
0,
1066064996,
1066064996,
1066064996,
'',
''
], 'File::stat' );
Looks like you *might* rely on it on non-unix - this is perl 5.8 on
OS/2 Warp. And I am sure windows has accessed/modified/created. I
suspect the ports of the *nix type things that would change ctime don't
in these environments.
Regards
Dave Saville
NB switch saville for nospam in address
------------------------------
Date: 13 Oct 2003 09:50:18 -0700
From: kmall@lehman.com (Kulvinder Mall)
Subject: Writing a perl file comparison program
Message-Id: <29fa23df.0310130850.480210e0@posting.google.com>
Hi
I want to write perl utility to compare two text files.
The files will contain text in following format below.
I want to be able to compare the files and report on differences.
Rather than reinventing wheel can somebody throw me some pointers.
Cheers
Kulvinder
/* ----------------- GFSD_TWS_PREMIUM_FW ----------------- */
insert_job: GFSD_TWS_PREMIUM_FW job_type: f
box_name: GFSD_FEEDBOX
machine: njgfsprd1
#owner: gfsprd
permission: gx,gw
description: "Filewatcher for TWS PREMIUM ready file. Restart job
if it fails."
watch_file: $GFSROOT/ftp/SUPremium.txt
watch_interval: 60
alarm_if_fail: 1
profile: /home/gfsprd/profiles/gfs
/* ----------------- GFSD_TWS_PREMIUM_LOAD_BJ ----------------- */
insert_job: GFSD_TWS_PREMIUM_LOAD_BJ job_type: c
box_name: GFSD_FEEDBOX
command: $GFSROOT/bin/tws_premiums_load.csh
machine: njgfsprd1
#owner: gfsprd
permission: gx,gw
condition: s(GFSD_TWS_PREMIUM_FW)
description: "Loads TWS PREMIUM data. In event of failure please
see GFSD_Box for callout info."
std_out_file: /tmp/$AUTO_JOB_NAME.out
std_err_file: /tmp/$AUTO_JOB_NAME.err
alarm_if_fail: 1
profile: /home/gfsprd/profiles/gfs
------------------------------
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 5652
***************************************