[25460] in Perl-Users-Digest
Perl-Users Digest, Issue: 7705 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 28 14:05:40 2005
Date: Fri, 28 Jan 2005 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 28 Jan 2005 Volume: 10 Number: 7705
Today's topics:
Anonymous Hash <travisq@gmail.com>
Re: Anonymous Hash <mritty@gmail.com>
Re: Anonymous Hash <1usa@llenroc.ude.invalid>
Re: Anonymous Hash <matternc@comcast.net>
Re: Anonymous Hash <nobull@mail.com>
Re: Anonymous Hash <1usa@llenroc.ude.invalid>
Re: Global symbol "%Config" requires explicit package a <spamtrap@dot-app.org>
Re: I will pay for perl help <LilaDuncan@XSPAMhotmail.co.uk>
Re: Missing first line when reading in .csv file (Dackle)
Re: Missing first line when reading in .csv file <tadmc@augustmail.com>
Re: Missing first line when reading in .csv file (Anno Siegel)
Multiple POD docs from a single .pl file? <bernie@rev.net>
Re: Old tutorial - now corrected axel@white-eagle.co.uk
Re: Perl CGI and email <spamtrap@dot-app.org>
Re: Perl CGI and email <nobull@mail.com>
Re: Perl CGI and email <1usa@llenroc.ude.invalid>
Re: Perl error <tadmc@augustmail.com>
Re: Script dumps core....? Any suggestions... xhoster@gmail.com
Re: Script dumps core....? Any suggestions... (Anno Siegel)
Re: Starting Point for backup script <1usa@llenroc.ude.invalid>
Re: Starting Point for backup script <spamtrap@dot-app.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Jan 2005 06:30:55 -0800
From: "quartet" <travisq@gmail.com>
Subject: Anonymous Hash
Message-Id: <1106922655.678839.250080@z14g2000cwz.googlegroups.com>
I am using the following script to output the data structure below:
#!/usr/bin/perl -wT
use Data::Dumper;
use FindBin qw($Bin);
use XML::Simple;
use strict;
my ($data,$xml,$VAR1);
#$xml = new XML::Simple (KeyAttr=>'sku', forcearray=>'1');
$xml = new XML::Simple (forcearray=>'1');
$data = $xml->XMLin("$Bin/some.xml");
print Dumper($data);
print "\n";
output:
$VAR1 = {
'JOB' => [
{
'MAXRUNS' => '0',
'APPLICATION' => 'MANUGISTICST',
'MAXDAYS' => '0',
'MAR' => '1',
'TASKTYPE' => 'Job',
'FEB' => '1',
'NOV' => '1',
'INTERVAL' => '0M',
'DATACENTER' => 'EM61',
'CONFIRM' => '0',
'MAY' => '1',
'TIMETO' => '0105',
'OCT' => '1',
'QUANTITATIVE' => [
{
'QUANT' => '1',
'NAME' => 'SYSTEM'
},
{
'QUANT' => '1',
Can someone tell me why its neccessary to use '%$' for referncing the
hash, I want to access all the values in the anonymous hash.
------------------------------
Date: Fri, 28 Jan 2005 14:46:05 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Anonymous Hash
Message-Id: <NesKd.1$6i4.0@trndny02>
"quartet" <travisq@gmail.com> wrote in message
news:1106922655.678839.250080@z14g2000cwz.googlegroups.com...
> I am using the following script to output the data structure below:
>
> #!/usr/bin/perl -wT
>
> use Data::Dumper;
> use FindBin qw($Bin);
> use XML::Simple;
> use strict;
>
> my ($data,$xml,$VAR1);
> #$xml = new XML::Simple (KeyAttr=>'sku', forcearray=>'1');
> $xml = new XML::Simple (forcearray=>'1');
> $data = $xml->XMLin("$Bin/some.xml");
> print Dumper($data);
> print "\n";
<Dumper output of a hashref snipped>
> Can someone tell me why its neccessary to use '%$' for referncing the
> hash, I want to access all the values in the anonymous hash.
Because you don't have an anonymous hash. You have a reference to an
anonymous hash. $data is not a hash. It is a reference to a hash. In
order to get at the hash that $data references, you must dereference
$data. In perl, the way to dereference a reference is to precede it
with the character that represents the kind of variable. In this case,
'%' for hash.
$data ==> hash reference
%$data ==> hash that $data references
To access all the elements of the hash, you can do something similar to:
foreach (keys %$data){
print "Key $_ has value $data->{$_}\n";
}
(Note that '$data->{$_}' can just as effectively be written
'$$data{$_}'. The choice is yours, but I believe the arrow notation is
generally more well accepted).
Hope this helps,
Paul Lalli
------------------------------
Date: Fri, 28 Jan 2005 14:50:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Anonymous Hash
Message-Id: <Xns95EC6431CF54Easu1cornelledu@127.0.0.1>
"quartet" <travisq@gmail.com> wrote in news:1106922655.678839.250080
@z14g2000cwz.googlegroups.com:
> I am using the following script to output the data structure below:
I am not sure what all this code has to do with your question, so I am
snipping:
...
> my $xml = new XML::Simple (forcearray=>'1');
...
> Can someone tell me why its neccessary to use '%$' for referncing the
> hash, I want to access all the values in the anonymous hash.
XML::Simple returns a reference to a hash. You can _dereference elements
of the hash referred to by $xml by using the $xml->{JOBS} notation which
is basically syntatic sugar. It accomplish the same things as
%{ $xml }{JOBS}
in a visually more pleasing way.
For more information,
perldoc perlreftut
Sinan.
------------------------------
Date: Fri, 28 Jan 2005 11:39:07 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Anonymous Hash
Message-Id: <eqWdnagL2PIw92fcRVn-ow@comcast.com>
quartet wrote:
>
> Can someone tell me why its neccessary to use '%$' for referncing the
> hash, I want to access all the values in the anonymous hash.
Um, because that's how you dereference a reference to a hash. Whether
the reference was made by using an anonymous hash or a named hash is
irrelevant; that's how you dereference it.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Fri, 28 Jan 2005 17:06:57 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Anonymous Hash
Message-Id: <ctdr5i$9fg$1@sun3.bham.ac.uk>
A. Sinan Unur wrote:
> [...]the $xml->{JOBS} notation which
> is basically syntatic sugar. It accomplish the same things as
>
> %{ $xml }{JOBS}
You mean:
${ $xml }{JOBS}
or, since $xml is a simple variable not an expression, it doesn't need
to be wrapped in a block:
$$xml{JOBS}
> in a visually more pleasing way.
Yes I like the -> too.
------------------------------
Date: Fri, 28 Jan 2005 17:31:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Anonymous Hash
Message-Id: <Xns95EC7F6D54116asu1cornelledu@127.0.0.1>
Brian McCauley <nobull@mail.com> wrote in news:ctdr5i$9fg$1
@sun3.bham.ac.uk:
> A. Sinan Unur wrote:
>
>> [...]the $xml->{JOBS} notation which
>> is basically syntatic sugar. It accomplish the same things as
>>
>> %{ $xml }{JOBS}
>
> You mean:
>
> ${ $xml }{JOBS}
Yes, I did, thank you for catching that.
> or, since $xml is a simple variable not an expression, it doesn't need
> to be wrapped in a block:
>
> $$xml{JOBS}
Clearly, however, I wanted to illustrate _what_ that expression was
dereferencing. Didn't quite work as I had intended.
Sinan
------------------------------
Date: Fri, 28 Jan 2005 10:54:23 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Global symbol "%Config" requires explicit package at at C:/Perl/lib/Time/Local .pm line 27.
Message-Id: <ApydnSN_m6ys_WfcRVn-sg@adelphia.com>
Brian McCauley wrote:
> Sherm Pendley wrote:
>
>> Perl is case-sensitive, but the Windows file system is not.
>>
>> If you do a 'use config' on a system with a case-insensitive file system,
>> then Config.pm will load and parse just fine. But, then Perl will look
>> for config->import(), and obviously it won't find it. So no functions or
>> constants get imported from the module.
>
> True but this is not what is happening to the OP.
The example file names were reversed - he's trying to load Config.pm and
getting config.pm instead, not the other way 'round - but otherwise that's
exactly what is happening.
The point is that the Windows file system is not case sensitive, whereas
package names are. Whichever way you look at it, it's that impedance
mismatch which is the cause of the problem.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 28 Jan 2005 14:16:58 +0000
From: Lila Duncan <LilaDuncan@XSPAMhotmail.co.uk>
Subject: Re: I will pay for perl help
Message-Id: <c4hkv0l37h1vbk2lqdc51l0ti4a90duoci@4ax.com>
On 27 Jan 2005 21:37:44 -0800, ioneabu@yahoo.com wrote:
>
>Lila Duncan wrote:
>> Hi,
>> I'm a newbie. I think perl is great and I'm busy getting together
>> documentation and links so I can learn more about it.
>> I installed ActivePerl on my Win XP computer.
>> I recently wrote to the perl.beginners group about a problem I was
>having
>> but I got ignored. Maybe I wasn't advanced enough for them. :-)
>> My reasons for wanting to learn perl are practical and commercial.
>> I'd like to become a proficient buyer and seller on eBay.
>> I read David A Karp's book "ebay Hacks" in which he recommends the
>use of
>> perlscripts for automating eBay searches. The example files he gives
>don't
>> seem to be working for me at present.
>
>What happened when you tried his files that made you think that they
>did not work?
I get errors that I believe are related to the original file being
structured for use on a unix-like system.
The initial errors refer to not finding the path to a "search results"
text file.
I've tried a number of suggestions for delimiter and quote variations on
this pathname, to the extent that the script moves on 15 lines or so.
The next error seems to be referring once again to problems with the
earlier pathname.
>Look at http://search.cpan.org/ and type in the word 'ebay' and search
>for any relevent Perl modules. There are a few things that come up
>that could be exactly what you need.
Thanks I'd already downloaded one WWW-Search-Ebay module using PMM.
I followed the link you gave and see that there are a number of others
there. Also, much more detailed information on these and the one I already
have installed, so thanks very much for that.
> Even if you pay someone else to
>do the work, it might help to be as informed as possible about what
>needs to be done. It might be trivially easy, maybe even worth
>learning a little Perl. Good luck!
The book I was reading which introduced me to the idea of using Perl did
it in a way that kind of sneaked Perl up on me and pretended it was a piece
of cake. I might 've taken flight on seeing the errors and potential errors
coming over the horizon, had it not been for the realisation that Perl
could be a big help in more ways than making eBay searches easier and more
productive.
I'm currently finding and starting to read a lot of documentation. It
already looks like I'm in for the long haul.
Thanks for the encouragement.
--
Lila Duncan
------------------------------
Date: 28 Jan 2005 07:34:14 -0800
From: simon.dukes@gmail.com (Dackle)
Subject: Re: Missing first line when reading in .csv file
Message-Id: <51f6bb21.0501280734.1bb9d85@posting.google.com>
> without the while.
Thanks a lot, it works now. That's been bugging me for a long time.
------------------------------
Date: Fri, 28 Jan 2005 09:46:48 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Missing first line when reading in .csv file
Message-Id: <slrncvknj8.3lp.tadmc@magna.augustmail.com>
Dackle <simon.dukes@gmail.com> wrote:
> I'm having a recurring problem reading in .csv files. The first line
> in the file is always missing,
No it isn't.
Your code reads the first line and discards it without processing it.
> while (<SCORES>) {
That reads the 1st line into the $_ variable.
Your code never does anything with what is in the $_ variable.
> chomp;
> @x=<SCORES>;
This grabs ALL of the remaining lines, so the while() loop
will *always* execute exactly one time, it is an UNloop!
> $n=@x+0; # Number of games
One-character variable names really suck, have you been
programming for long?
> for $a (0..$n) {
> @c=split(",",@x[$a]);
You should always enable warnings when developing Perl code!
A pattern match should *look like* a pattern match.
Whitespace is not a scarce resource, feel free to use as much
of it as you like to make your code easier to read and maintain.
@c = split(/,/, $x[$a]);
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Jan 2005 18:18:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Missing first line when reading in .csv file
Message-Id: <ctdvls$eo6$1@mamenchi.zrz.TU-Berlin.DE>
<ioneabu@yahoo.com> wrote in comp.lang.perl.misc:
>
> Dackle wrote:
> > I'm having a recurring problem reading in .csv files. The first line
> > in the file is always missing, and so when the code below executes,
> > $dt[0] will contain the second line, $dt[1] the third, and so on.
> > Usually I get around this by manually opening the .csv file in
> notepad
> > and inserting "DUMMY" and a carriage return, then resaving. Then when
> > the code executes, DUMMY is skipped, and $dt[0] containes the first
> > line, $dt[1] the second etc., which is how I want it. In general,
> this
> > manual process works fine, but I'd rather skip it if possible. Has
> > anyone encountered this problem before or knows why it is happening?
> >
> > open SCORES, "C:/$filename.csv" or die "can't open file: $!";
> > while (<SCORES>) {
> > chomp;
> > @x=<SCORES>;
> > }
>
> hmm.. seems obvious enough...
>
> the first line you have already moved the file pointer down one line.
> It's as if you said: while ($_ = <SCORES>) { chomp $_ ...
> now you are starting at the second line and then...
> @x=<SCORES>; in scalar context, you have just sucked in the whole file
> into @x starting at the second line. All you had to do was:
>
> @x=<SCORES;
>
> without the while.
>
> > $n=@x+0; # Number of games
> > for $a (0..$n) {
> > @c=split(",",@x[$a]);
> > $dt[$a]=$c[0]; # Date
> > $vis[$a]=$c[3]; # Visitor
> > $hom[$a]=$c[6]; # Home
> > }
That fixes the particular misbehavior, but the program is still
unnecessarily roundabout.
Why read a file into an array, and then pass through it line by line
anyway? It doesn't make sense. The standard way in Perl to process
the lines of a file is a while loop (untested):
my $a = 0;
while ( <SCORES> ) {
chomp; # you forgot that, could bite some day
( $dt[ $a], $vis[ $a], $hom[ $a]) = ( split /,/)[ 0, 3, 6];
$a ++;
}
The index variable $a isn't really necessary, it is the length of the
arrays @dt etc. Here is one way to build them directly:
( $dt[ @dt], $vis[ @vis], $hom[ @hom]) = ( split /,/)[ 0, 3, 6] for
map { chomp; $_ } <DATA>;
Then again, as has been noted, this is really a job for one of the
csv modules.
Anno
------------------------------
Date: Fri, 28 Jan 2005 09:24:50 -0500
From: Bernard Cosell <bernie@rev.net>
Subject: Multiple POD docs from a single .pl file?
Message-Id: <lkhkv01m960d3fmh9teuvcsdseosv1f1r9@4ax.com>
I have a .pl file that would be well served to generate two POD files
[one in (1) and one in (3)]. Is there some way to do that?
/Bernie\
------------------------------
Date: Fri, 28 Jan 2005 14:22:49 GMT
From: axel@white-eagle.co.uk
Subject: Re: Old tutorial - now corrected
Message-Id: <ZUrKd.7700$B5.3378@fe1.news.blueyonder.co.uk>
Tad McClellan <tadmc@augustmail.com> wrote:
> You are not qualified to do what you are doing, please
> stop doing it.
> No code is *better* than bad code!
OT Chuckle.
Reading Robert Rankins *Knees Up Mother Earth* earlier this week
brought back fond memories of the old ICL 1900 computer series...in
which the Algol/Cobol/Fortran compilers would attempt to produce
some runnable code no matter how many errors were found in the
source.
O tempora, O mores.
Axel
------------------------------
Date: Fri, 28 Jan 2005 10:04:00 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl CGI and email
Message-Id: <GsednX1XGt_9yWfcRVn-sg@adelphia.com>
Sebastien wrote:
> If some guy programs a CGI script with PERL can he get my email
> address while I am browsing his web site by his/her CGI PERL script?
No. And not with Perl either. (What is this PERL you're talking about,
anyway?)
> I know that's not obvious question to answer.
Actually, it is.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 28 Jan 2005 17:17:14 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl CGI and email
Message-Id: <ctdroq$9ss$1@sun3.bham.ac.uk>
A. Sinan Unur wrote:
> dorey.sebastien@free.fr (Sebastien) wrote in
> news:a9cb8dbb.0501280452.5170ffb@posting.google.com:
>
>>If some guy programs a CGI script with PERL can he get my email
>>address while I am browsing his web site by his/her CGI PERL script?
>
> Your question has nothing to do with Perl.
>
> You can find the answer in the CGI FAQ list, section 3 to be specific:
>
> http://www.faqs.org/faqs/www/cgi-faq/preamble.html
While I know it's totally OT but for completeness I shall mention that
the HTTP protocol _does_ allow you to put your e-mail address in the
From: header of your HTTP requests. However the only web clients I've
ever heard of that do this are robots where this address is used to
inform the to the robot's owner if it's gone out of control.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.22
------------------------------
Date: Fri, 28 Jan 2005 17:45:35 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl CGI and email
Message-Id: <Xns95EC81D72CFBCasu1cornelledu@127.0.0.1>
Brian McCauley <nobull@mail.com> wrote in news:ctdroq$9ss$1
@sun3.bham.ac.uk:
> A. Sinan Unur wrote:
>> http://www.faqs.org/faqs/www/cgi-faq/preamble.html
>
> While I know it's totally OT but for completeness I shall mention that
> the HTTP protocol _does_ allow you to put your e-mail address in the
> From: header of your HTTP requests.
BTW, the CGI FAQ mentions that in
3.2 Can I get the email of visitors?
http://www.faqs.org/faqs/www/cgi-faq/section-40.html
I decided to link to the top level so that the OP could be motivated to
actually looking at all the information listed there.
Sinan.
------------------------------
Date: Fri, 28 Jan 2005 09:38:28 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl error
Message-Id: <slrncvkn3j.3lp.tadmc@magna.augustmail.com>
quartet <travisq@gmail.com> wrote:
> As a followup to Tad was saying,
If you quote some context, like everybody else does, then it
would have been clear from the start without this round-and-round.
Here is the context taken from my followup:
> appears that the function, "KeyAttr=>'sku'" was need
That is NOT a "function".
> I was meaning perl attribute,
No you weren't, "KeyAttr=>'sku'" is not a perl attribute, it
was a pair of arguments that you passed to the XML::Simple
constructor.
The "Attr" in "KeyAttr" refers to an *XML* attribute.
(but the module docs say it should be "keyattr")
> in
> correcting myself.
You have not done that yet...
Post one more time without quoting any context and your posts
will become eternally invisible.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Jan 2005 16:56:58 GMT
From: xhoster@gmail.com
Subject: Re: Script dumps core....? Any suggestions...
Message-Id: <20050128115658.503$Rv@newsreader.com>
"Gancy" <ganesh_tiwari@hotmail.com> wrote:
> Here is the snipet of the perl script, I have perl version v5.8.5 built
> for sun4-solaris. I have run this script on thousands of 'c','C++'
> headers and source files. Runs smoothly as my new ESTEEM car. But i
> have one surce file toke.c in my test case. soon this scripts hits this
> file at it dumps.
Is this feature still considered highly experimental in 5.8.5? I guess the
experiment failed in your case. Can you monitor memory usage and see if it
becomes exorbitant somehwere? Perhaps from excessive nesting of
paranthesis in the toke.c file?
I can't make it coredump with a simple test case below, but it doesn't
seem to give the right answer, either. It seems like it should always
matche the outermost set of parenthesis, but it doesn't:
(I should mention, I'm using 5.8.0)
my $re = qr{\((?:(?>[^()]+)|(??{$re}))*\)};
my $x='(j)';
foreach (1..10) {
print "Starting loop $_ $x\n";
print "matched $1\n" if $x=~/($re)/;
$x = "($x)";
};
__END__
Starting loop 1 (j)
matched (j)
Starting loop 2 ((j))
matched ((j))
Starting loop 3 (((j)))
matched ((j))
Starting loop 4 ((((j))))
matched ((j))
Starting loop 5 (((((j)))))
matched ((j))
Starting loop 6 ((((((j))))))
matched ((j))
Starting loop 7 (((((((j)))))))
matched ((j))
Starting loop 8 ((((((((j))))))))
matched ((j))
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 28 Jan 2005 18:32:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Script dumps core....? Any suggestions...
Message-Id: <cte0g1$eo6$2@mamenchi.zrz.TU-Berlin.DE>
<xhoster@gmail.com> wrote in comp.lang.perl.misc:
> "Gancy" <ganesh_tiwari@hotmail.com> wrote:
> > Here is the snipet of the perl script, I have perl version v5.8.5 built
> > for sun4-solaris. I have run this script on thousands of 'c','C++'
> > headers and source files. Runs smoothly as my new ESTEEM car. But i
> > have one surce file toke.c in my test case. soon this scripts hits this
> > file at it dumps.
>
> Is this feature still considered highly experimental in 5.8.5? I guess the
> experiment failed in your case. Can you monitor memory usage and see if it
> becomes exorbitant somehwere? Perhaps from excessive nesting of
> paranthesis in the toke.c file?
>
> I can't make it coredump with a simple test case below, but it doesn't
[...]
I have replied to this in the other thread the OP started about it. To
summarize: It does indeed segfault with toke.c from the perl source
(v5.8.6) as the input. The reason is simple: The recursive regex goes
into deep recursion. Perl doesn't warn about that, that's the bug, if
there is one. Otherwise, it's just that the regex is broken.
I am only slightly curious what bit of legal C in toke.c is throwing
it. The OP claims it ran fine with many other sources.
Anno
------------------------------
Date: Fri, 28 Jan 2005 14:53:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Starting Point for backup script
Message-Id: <Xns95EC64BE85436asu1cornelledu@127.0.0.1>
Larry <dontmewithme@got.it> wrote in news:dontmewithme-
76A548.14510428012005@twister1.tin.it:
> In article <14c7b35.0501280216.3ebba9be@posting.google.com>,
> daninbrum@hotmail.com (Dan Vesma) wrote:
>
> MacOS9 or X?
I don't know. Which one do you prefer? I have heard some people still
holding on to their MacOS9 machines. Some others prefer the cool look of
the new widgets in Mac OS X. Opinions vary. Me, I have never warmed up to
Macs, ever since I found out that I had to drag the floppy icon to the
trash to be able to get it out of the drive.
When posting, please provide some context so everyone else knows what you
are talking about.
Sinan
------------------------------
Date: Fri, 28 Jan 2005 10:38:10 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Starting Point for backup script
Message-Id: <7rKdndnKCaX5wWfcRVn-2A@adelphia.com>
Dan Vesma wrote:
> I am looking at the possibilities of creating a script that I can run
> on my Mac that will scour through the directory structure and copy any
> new MS Word Documents into a newly created folder on an External HDD.
...
> 1. Create destination directory for all found files
Easy. "perldoc -f mkdir". The user who runs your script will need to have
permission to create the directory. Don't forget to check to see if it's
already been created!
> 2. Find its way around the directory structure.
> 3. Filter so that it only looks at Word documents
Easy enough with File::Find. If you're using a recent Word and you've given
your documents extensions, you can simply use file names. If you're using
an old version of Word in Classic, and/or you're allergic to file name
extensions, you can use Mac::Carbon's GetFileInfo() function to get the
type and creator code.
> 4. Check date created
Don't you mean date last modified? That's normally what backups are based
on, and anyway I'm not certain if creation date is kept. Anyway - use
stat() (perldoc -f stat).
> 5. If date created is today, copy file to destination directory and
> move onto the next
Use File::Copy. Or, if you need to preserve metadata and resource forks, run
the '/Developer/Tools/CpMac' command-line tool.
> It sounds so simple, but I'm sure it can't be.
The concept is simple, but the devil is in the details, as the saying goes.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
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 7705
***************************************