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

Re: [MacPerl] minor debugging



At 19.16 -0800 1999.11.11, Nicholas G. Thornton wrote:
>It's set by the MacPerl::Ask perhaps should it be...
>>$_[0] = MacPerl::Ask($orig.'     =>     TYPE/CREA ?');

First, $_ and $_[0] are unrelated.  Two entirely different things.

Second, why not use new variable names?

>as it stands it works for most cases of input (perhaps it just silently
>fails?). I've only had problems when using "alt" charecters (or "opt"
>charecters)

I see no possible way it could ever succeed, no matter what the input is.
$_[0] is guranteed to be undef in what you have presented.  In this code
below, it works with option characters.

Before I paste the code, I'll note that you have "#!perl-w" as your top
line, which doesn't work; you need a space in there, like "#!perl -w".
Second, @types was never defined (but it doesn't really matter, except that
it gives a warning).

Anyway, here is some working code.

$orig = join "/", reverse MacPerl::GetFileInfo($file);
$new  = MacPerl::Ask($orig.'     =>     TYPE/CREA ?');
if ($new =~ /^\/(....)$/) {
    $creator = $1;
    $orig =~ /^(....)/;
    $type = $1;
    MacPerl::SetFileInfo($creator, $type, $file);
} elsif ($new =~ /^(....)\/(....)$/) {
    ($type, $creator) = ($1, $2);
    MacPerl::SetFileInfo($creator, $type, $file);
} else {
     exit;
}

__END__

-- 
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