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

[MacPerl] Re: Variables into MacPerl Ask



At 4:57 PM -0700 8/19/99, Nicholas G. Thornton wrote:
>Just finished reading the pod about "." for contatinating strings before
>reading Charles' message ;) Just about getting the hang of this. Below is the
>most recent version of my script.

>Ant suggestions on opimising? BTW, is there a
>string equivilent to "=="?

Yes: eq

>################################

I'm not sure that putting any lines above the #! line is a good idea.

>#!perl -w
>
>print "\n","###############","\n",@ARGV,"\n";
>print join "/", reverse MacPerl::GetFileInfo(@ARGV);
>print "\n","###############","\n";

I'm not sure why you're separating

   print "\n","###############","\n";

rather than typing

   print "\n###############\n";

>        if ($type le "TEXT" and $type ge "TEXT") {
          if ($type eq 'TEXT') {

Aside from getting rid of the superfluous operations (what Perl book
are you using?  MPPE has a pretty complete rundown on operators...),
you might want to consider using double quotes _only_ when something
in the quoted string will be expanded.  Single quotes tell the reader
that "no magic is happening here", a useful hint...

   &mime_print;

This is more idiomatically put as

   mime_print();

(which I prefer) or (for the ters among us):

   mime_print;

You might also want to consider handing $text in as a parameter.
It isn't needed here, but in a larger app, this might help to
keep things clearer...

...
>        }
>        if ($type le "ttro" and $type ge "ttro") {
...
>        }
>        if ($type le "GIFf" and $type ge "GIFf") {
...

Some folks would complain about the fact that you are performing
superfluous tests here.  That is, if a test succeeds, why test
other possibilities that cannot succeed?  Thus, put a return at
the end of each block:

...
>        }
>        if ($type le "ttro" and $type ge "ttro") {
...
            return;
>        }
>        if ($type le "GIFf" and $type ge "GIFf") {
...

-r
--
Rich Morin:          rdm@cfcl.com, +1 650-873-7841, http://www.ptf.com/~rdm
Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com
MacPerl: http://www.macperl.com,       http://www.ptf.com/ptf/products/MPPE
MkLinux: http://www.mklinux.apple.com, http://www.ptf.com/ptf/products/MKLP

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