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

Re: [MacPerl] several dumb questions



At 9:15 10/30/96, Mike Hammond wrote:
>One is not specific to MacPerl. This can be best explained with an example.
>Imagine I want to search through a file for the following strings:
>        abcx
>        adex
>        afgx
>        ahix
>The following does NOT seem to work:
>        /a[(bc)(de)(fg)(hi)]x/
>Is there an elegant way to do this?

Try:    /a(bc|de|fg|hi)x/

The [] brackets only look for single characters.  The | does an OR.

>The second question is specific to MacPerl I think. I simply want to find a
>way to return the particular mac's name. For example, my office mac is
>called something like "Mike's office Mac". How can I get MacPerl to find
>this and return it as a string?

The only way I know is with AppleScript from Perl.

$macName = &MacPerl::DoAppleScript('get machine name of (sharing information)');

This requires the "Sharing Information" dictionary in your System
Folder:Extensions:Scripting Additions folder.  It comes with AppleScript,
but might not be installed (it's part of the GTQ Library).

#================================================================
perl -e 'srand();if(rand>.5){$i=0;foreach(@ARGV){@$i=split(//);$z
[$i]=0;foreach(@$i){$s[$i][$z[$i]]=$_;$z[$i]++;}$i++;}foreach(@s)
{foreach(@$_) {print}print" ";$_++}}else{print(join(" ", @ARGV))}
print"\n"' McClellan Clan Motto: Think On

Chris Nandor                                       pudge@pcix.com
PGP Key 0xB76E72AD                    http://pudge.petersons.com/