MacPerl-Digest Thursday, March 11 1999 Volume 01 : Number 008 Re: [MacPerl] as2p Re: [MacPerl] as2p [MacPerl] not following aliases Re: [MacPerl] not following aliases Re: [MacPerl] not following aliases [MacPerl] Icon files Re: [MacPerl] not following aliases [MacPerl] Off-topic: Use of the 'strict' pragma Re: [MacPerl] not following aliases Re: [MacPerl] Off-topic: Use of the 'strict' pragma [MacPerl] How do I find the day of the week from a given date (NOT today) Re: [MacPerl] How do I find the day of the week from a given date (NOT today) ---------------------------------------------------------------------- Date: Wed, 10 Mar 1999 11:07:23 -0500 (EST) From: rjk@linguist.dartmouth.edu (Ronald J. Kimball) Subject: Re: [MacPerl] as2p Chris Nandor wrote: > > Will make all perl scripts dropped on it into compiled AppleScripts. > # as2p :) Shouldn't it be p2as? *boggle* Ronald ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 11:12:12 -0500 From: Chris Nandor <pudge@pobox.com> Subject: Re: [MacPerl] as2p At 11.07 -0500 1999.03.10, Ronald J. Kimball wrote: >Chris Nandor wrote: >> > >> Will make all perl scripts dropped on it into compiled AppleScripts. > >> # as2p :) > > >Shouldn't it be p2as? *boggle* Doh! I had it that way before, too. Silly goose! That's what I get for writing it late at night. Expect more of these brainos from me in the next couple weeks. :D - -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 10:48:11 -0600 From: Dave Lorand <davel@src.uchicago.edu> Subject: [MacPerl] not following aliases Hi, I just joined the list. I've been using Perl extensively on UNIX for the past year or so, but am just getting into MacPerl. I'm having truble with my first real script. This script uses File::Find to generate a listing of files contained in a directory (recursively) along with all of the attributed it can figure out about them. Another script I wrote then compares two different listings to tell me what has changed. This is useful when administering a lab of macs with Assimilator or RevRdist, because it tells me exactly what an installer does. Anyway, when the script which uses File::Find encounters an alias to an AppleShare server in the "Recent Servers" folder of the Apple Menu Items Folder, it mounts the server and scans everything on it. I would like to detect when a file is an alias, get what information I can without following it, and prune the find. Here's a copy my &wanted: sub wanted { my (%info, $info, $finfo, $pathname); $pathname = $File::Find::name; $info{dir} = $File::Find::dir; $info{name} = $_; $info{dSize} = -s $pathname; $info = FSpGetCatInfo($pathname); $finfo = $info->ioFlFndrInfo; $info{rSize} = $info->ioFlRLgLen; $info{cDate} = $info->ioDrMdDat; $info{mDate} = $info->ioFlMdDat; $info{creator} = $finfo->fdCreator; $info{type} = $finfo->fdType; $::files{$pathname} = \%info; } Any suggestions on how to modify this to behave the way I want it to? Thanks in advance, Dave ____________________________________________________________ | Dave Lorand, Programmer/Analyst | davel@src.uchicago.edu | | Social Science Research Computing | 773-702-3792 | | University of Chicago | 773-702-2101 (fax) | +-----------------------------------+------------------------+ ---> finger davel@cicero.src.uchicago.edu for my PGP key <-- ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 12:06:57 -0500 From: Chris Nandor <pudge@pobox.com> Subject: Re: [MacPerl] not following aliases At 11.48 -0500 1999.03.10, Dave Lorand wrote: >Anyway, when the script which uses File::Find encounters an alias to an >AppleShare server in the "Recent Servers" folder of the Apple Menu Items >Folder, it mounts the server and scans everything on it. I would like to >detect when a file is an alias, get what information I can without >following it, and prune the find. Here's a copy my &wanted: The -l file test tells you if a file is an alias. Is that what you wanted? - -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 11:10:38 -0600 From: Dave Lorand <davel@src.uchicago.edu> Subject: Re: [MacPerl] not following aliases At 11:06 AM -0600 3/10/99, Chris Nandor wrote: >At 11.48 -0500 1999.03.10, Dave Lorand wrote: >>Anyway, when the script which uses File::Find encounters an alias to an >>AppleShare server in the "Recent Servers" folder of the Apple Menu Items >>Folder, it mounts the server and scans everything on it. I would like to >>detect when a file is an alias, get what information I can without >>following it, and prune the find. Here's a copy my &wanted: > >The -l file test tells you if a file is an alias. Is that what you wanted? That's half of it. My other question is, which of the toolbox calls I'm making will cause the alias to be followed? I'd like to get as much info as I can on aliases without actually following them. Here are those toolbox calls again: sub wanted { my (%info, $info, $finfo, $pathname); $pathname = $File::Find::name; $info{dir} = $File::Find::dir; $info{name} = $_; $info{dSize} = -s $pathname; $info = FSpGetCatInfo($pathname); $finfo = $info->ioFlFndrInfo; $info{rSize} = $info->ioFlRLgLen; $info{cDate} = $info->ioDrMdDat; $info{mDate} = $info->ioFlMdDat; $info{creator} = $finfo->fdCreator; $info{type} = $finfo->fdType; $::files{$pathname} = \%info; } Thanks, Dave ____________________________________________________________ | Dave Lorand, Programmer/Analyst | davel@src.uchicago.edu | | Social Science Research Computing | 773-702-3792 | | University of Chicago | 773-702-2101 (fax) | +-----------------------------------+------------------------+ ---> finger davel@cicero.src.uchicago.edu for my PGP key <-- ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 14:55:38 -0500 From: Chris Nandor <pudge@pobox.com> Subject: [MacPerl] Icon files We need to take a serious look at Icon files, I think. They are messing up things that I do now more than ever, as they get put there by the system automatically in Mac OS 8.5 (more info is kept in the files than just icon data). One prominent case where this problem is hitting is in File::Find. These files when found cause problems because you can't do tests on them without getting warnings or errors, because the filename has a newline in it. And with CPAN.pm, some directories are not getting deleted because it is not able to delete the Icon file, and so the directory is not empty. I don't know what to do, but it is a problem. - -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 16:36:29 -0500 From: Chris Nandor <pudge@pobox.com> Subject: Re: [MacPerl] not following aliases At 12.10 -0500 1999.03.10, Dave Lorand wrote: >That's half of it. My other question is, which of the toolbox calls I'm >making will cause the alias to be followed? I'd like to get as much info >as I can on aliases without actually following them. I think all of them will get info on the aliased-to file, not the alias itself. You can get some of the data you want with the lstat command. That will give you the size of the alias, anyway. Here is a way using File::stat: $size = -l $_ ? lstat($_)->size : stat($_)->size; I noticed that CatInfo will return data for an alias file instead of its target if the alias file is opened in ResEdit. I don't know of a way to exploit that here, though. - -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 99 14:24:28 -0800 From: Elton Hughes <ehughes@novapic.org> Subject: [MacPerl] Off-topic: Use of the 'strict' pragma Hello All, This is an off-topic post. For those who would like to continue the discussion, I recommend that we move this to macperl-anyperl. I have been charged with developing an in-house project management system. It will use a web-based front end and will use a MySQL database for storage. All of my previous Perl and MacPerl projects have been small and relatively unsophisticated. This one will be much different. In doing some research on DBI, the pod documentation recommended 'use strict;'. This was new to me. So I then turned to Programming Perl and started to read up on 'strict-Restrict Unsafe Constructs' (page 500 for those who are interested). It was very informative reading, but I still have a few questions. 1. Am I correct in assuming that the larger the project, the more likely strict is used? Or, in the real world do some programmers just ignore it? 2. Is strict, too strict? (This is hinted at, but I value your comments.) 3. Once development is complete, can you save some (loading|run)time by commenting out strict? 4. Should one 'use strict;' encompassing 'vars', refs', and 'subs'? When should a programmer get specific? 5. Is there anything else one should know about the strict pragma? This project has already given me an opportunity to grow my knowledge. That alone makes it worth it in my book! Thank you all for your time. I hope this start useful thread for those new to (Mac)Perl. Elton ====================================================================== Elton Hughes 505 W. Olive Ave. Suite 550 NOVA Private Industry Council Sunnyvale, CA 94086 http://www.novapic.org/ Phone: 408-730-7232 - ---------------------------------------------------------------------- ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 16:29:22 -0600 From: Dave Lorand <davel@src.uchicago.edu> Subject: Re: [MacPerl] not following aliases At 3:36 PM -0600 3/10/99, Chris Nandor wrote: >At 12.10 -0500 1999.03.10, Dave Lorand wrote: >>That's half of it. My other question is, which of the toolbox calls I'm >>making will cause the alias to be followed? I'd like to get as much info >>as I can on aliases without actually following them. > >I think all of them will get info on the aliased-to file, not the alias >itself. > >You can get some of the data you want with the lstat command. That will >give you the size of the alias, anyway. Here is a way using File::stat: > > $size = -l $_ ? lstat($_)->size : stat($_)->size; > >I noticed that CatInfo will return data for an alias file instead of its >target if the alias file is opened in ResEdit. I don't know of a way to >exploit that here, though. It looks like I've got a solution, for those of you who are curious. Most of those toolbox calls were gathering information which I didn't really need for aliases anyway. The listing I gather is used to figure out what has changed in a folder, but those data are about the target of an alias, not the alias itself. If the target of an alias changes, we wouldn't say that the alias itself has changed. The information which is useful for checking whether an alias has changed (IMHO) are its size and its target. It might also be useful to check type, creator, creation date, and modification date, but size and target will do for me. I used Chris' suggestion of -l for determining whether the file is an alias in te first place. If it is, I get its size with "lstat($pathname)->size" as Chris suggested above. I get its target using readlink, which was ported perfectly. That's all! Thanks, Chris. Dave P.S. I can make the final scripts available if people are interested in them. Let me know if you are. ____________________________________________________________ | Dave Lorand, Programmer/Analyst | davel@src.uchicago.edu | | Social Science Research Computing | 773-702-3792 | | University of Chicago | 773-702-2101 (fax) | +-----------------------------------+------------------------+ ---> finger davel@cicero.src.uchicago.edu for my PGP key <-- ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Wed, 10 Mar 1999 18:47:57 -0500 From: Chris Nandor <pudge@pobox.com> Subject: Re: [MacPerl] Off-topic: Use of the 'strict' pragma At 17.24 -0500 1999.03.10, Elton Hughes wrote: >This is an off-topic post. For those who would like to continue the >discussion, I recommend that we move this to macperl-anyperl. I think it is fine here, personally. >1. Am I correct in assuming that the larger the project, the more likely >strict is used? Or, in the real world do some programmers just ignore it? I think so. >2. Is strict, too strict? (This is hinted at, but I value your comments.) Sometimes. I will occasionally need to do things that require me to turn off strict. But you can do it: use strict; { no strict 'vars'; $x = 1; # ok print $x; # ok } print $x; # not ok >3. Once development is complete, can you save some (loading|run)time by >commenting out strict? Nah. >4. Should one 'use strict;' encompassing 'vars', refs', and 'subs'? When >should a programmer get specific? I leave strict on all the time unless I need to disable it, and then I disable something specifically. - -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Thu, 11 Mar 1999 13:05:40 +0100 From: "Lars G. Skjellerup" <stenone@silkeborg.bib.dk> Subject: [MacPerl] How do I find the day of the week from a given date (NOT today) Hi all I have a small problem (Yet again). How can I find the day of the week from a given date, which is not the date today. If it was the date now it is real easy. Are there some pearl functions other than localtime(),time() - that might be helpful ? Or do I have to construct my own ? - -- ************************************************************ * Lars G. Skjellerup * * Web designer/Programmer - Software Tester * * * * Silkeborg Bibliotek Phone: (+45) 86820233 ext. 380 * * Hostrupsgade 41 A Fax: (+45) 86802679 * * DK 8600 Silkeborg E-mail: stenone@silkeborg.bib.dk * * Denmark stenone@netscape.net * * stenone@hotmail.com * * stenone@yahoo.com * * stenone@forum.dk * * * * URL: http://www.silkeborg.bib.dk * ************************************************************ ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ Date: Thu, 11 Mar 1999 08:49:32 -0400 (AST) From: Arved Sandstrom <Arved_37@chebucto.ns.ca> Subject: Re: [MacPerl] How do I find the day of the week from a given date (NOT today) On Thu, 11 Mar 1999, Lars G. Skjellerup wrote: > I have a small problem (Yet again). How can I find the day of the week > from a given date, which is not the date today. If it was the date now > it is real easy. > > Are there some pearl functions other than localtime(),time() - that > might be helpful ? Or do I have to construct my own ? > There is always the monolithic, all-capable Date::Manip module. :-) I don't use it myself, so the following is a cobble, and parts may be round-about, but it works: #!perl -w use Date::Manip; $date=&ParseDateString("15 Mar 1999"); $unixdate = &UnixDate($date, "%m %d %y"); ($m, $d, $y) = split(/ /,$unixdate); $day=&Date_DayOfWeek($m,$d,$y); @daynames = ("","Mon","Tue","Wed","Thu","Fri","Sat","Sun"); print "Day = $daynames[$day]\n"; __END__ ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org ------------------------------ End of MacPerl-Digest V1 #8 *************************** ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to ==== macperl-digest-request@macperl.org