[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Emulating AS-like properties in Perl



On Wed, 24 May 2000 04:10:48 +0800, robinmcf@altern.org wrote:

>>I'd like to have something like properties from AppleScript in
>>(Mac)Perl, i.e. variable values that are saved across executions of a
>>script, preferably without having to use a preferences file.
>>How should I go about it?
>
>  look up 'constant' in Shuck :

Huh? As far as I can see this simply makes an assignment 
non-modifiable. What I want is

>>  variable values that are saved across executions of a script

On Wed, 24 May 2000 01:13:23 GMT, bart.lateur@skynet.be (Bart Lateur) wrote:
>You must be a bit confused.

I am sorry, but no, I am not. It seems, though, that it is you who is 
a bit confused :)

>AppleScript *is*®using a preference file.
>Only, the preference file is the script itself.

An AppleScript per definition is no preferences file.
And of course, I know that properties are saved within the script, as 
is stated in my original post.
What I try to avoid is, exactly, the use of a preferences file in 
Perl, if possible.

>An easy example, saving a simple hash into a tab delimited text file
>(warning: untested code):

[snip]

Thanks to you and the other posters for their contributions. I'll 
give them a try.

What I liked best so far, but obviously did not get thru to the list is:

At 17:47 Uhr +0100 23.05.2000, Lindsay Davies wrote:
>[snip]
>Take a look into tied hashes with DB_File. quick snippet...
>
>#--------
>
>use DB_File;
>
>my $cache_file = "cache.file";
>my (%cache, $new_conf_count);
>tie(%cache, 'DB_File', "cache.file", O_RDWR|O_CREAT, 0644, $DB_BTREE)
>	or die "Can't open cache file: $!\n";
>
># use the %cache hash as you would normally...
>
>untie %cache;
>
>#-------
>
>Be aware that there are issues using $DB_HASH on some systems, as you
>will end up with some -HUGE- data files, which is why I've use the
>$DB_BTREE above.


Does anybody have experiences with writing to the resources of a 
script file or a droplet? Or would this be considered as dangerous? 
Certainly it is not portable, but that is not what I am looking for.

__Peter Hartmann ________

mailto:hphartmann@justmail.de

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org