in reply to syntax error at labmonkey.pl line 1, at EOF

You need to fix $prefix = $allprefixes{$to} -- $allprefixes{$from}; A double negative sign is not valid in this statement.

I think you want a single minus sign for the exponent arithmetic. The final print needs some work as what it displays is misleading.

(You also need something like #!/usr/local/bin/perl as your first line.)

Replies are listed 'Best First'.
Re^2: syntax error at labmonkey.pl line 1, at EOF
by theredqueentheory (Initiate) on Mar 04, 2008 at 18:37 UTC
    Cool. I have downloaded the TextMate text editor and now it runs, must have been an AdobeGoLive problem. I have searched for the OS units program, but don't seem to have it installed. Could you kindly provide a link? I have searched online but have not found a place to download it.

      Eeww. Consider getting a real code editor (or learn a *NIX standard such as vim or emacs). XCode's builtin editor also would be a step up (presuming you have the OS X development tools installed).

      And as a comment to your original program, you might consider using the OS' units program which already has a fairly good knowledge of conversions rather than reinventing the wheel piecemeal yourself.

      $ units kilograms grams * 1000 / 0.001 $ units feet kilometers * 0.0003048 / 3280.8399

      (Those two lines are what you multiply the later by to get the former and what you divide the former by to get the later)

      Update: Duuur. Strike that, reverse it; as is noted below. Been so long since I've used it I forgot how it works. (At least I remembered it was there . . . :)

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

        Your parenthetical statement is backwards, methinks. ;-)

        If you have 1 kilogram, you "* 1000" to get grams. Similarly, you can "/ 0.001" to get grams (same as "* 1000")

        The exact nature of the two outputs is a bit convoluted - the man page goes in to a LOT more detail.

      I can run your script once I've added #!/usr/local/bin/perl as the first line (because I'm using Solaris).

      What exactly is the error you're getting?