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

Re: [MacPerl] Generic Search Script



> Richard asked:
> 
>> Am I correct in believing that the only point of testing
>> for OS is to use the results to determine the proper path
>> separators?
>
> I use OS tests for things that are meant to be fairly
> portable, but maybe there's a Mac specific hook that I
> would like to have. For instance, I've got a number of
> scripts the mutate text files. The way they do this is
> that they read from one file, write to another, delete
> the first file, and rename the second file to the first.
> Pretty typical; but I add in the following lines to make
> the new file adopt the type and creator codes of the old
> file. The OS tests let my code run equally well on a unix
> box where there is no concept of these codes...
>
>> if ($^O =~ /MacOS/i) { ($creator,$type) = MacPerl::GetFileInfo($infnam); }
>> unlink $infnam;
>> rename($outfnam, $infnam);
>> if ($^O =~ /MacOS/i) { MacPerl::SetFileInfo($creator,$type, $infnam); }
>
>
> This is only one example, but there are a number of similar
> instances where I've got Mac specific code in scripts that
> run on unix systems...

I use Mac specific code in some scripts which extract information from a
(binary) file. On Un*x I they output to STDOUT, on the Mac they open a
window with the filename as the window title and output to the window. That
way I can easily compare different files. I use the following code

    use File::Basename;
    use Config;
    $f = $ARGV[0];
    open(FILE, "$f") || die "could not open file $f";
    if ( $Config{'osname'} =~ /^macos/i ) {
        # output to a new window
        $basename = fileparse($f);
        open(STDOUT,">Dev:Console:$basename header");
    } # if

--
Rene' Laterveer
latervee@ccc.it


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch