in reply to Re: Comments trouble
in thread Comments trouble

I am writing the code in BBEDIT, a text editor, and then running it from the command line as an argument to the perl executable. All of my scripts run fine if I don't have any comments before, or in, the code.

an example:
%sushi = ( inari => "tofu", maguro => "tuna", ika => "squid", tamago => "omelet", sake => "salmon"); @english = values(%sushi); @japanese = keys(%sushi); foreach (@english) { ($japanese,$english) = each(%sushi); print ("$english => $japanese\n"); }
runs just fine, but if I add the line:

# script to swap keys and values in a hash

to the beginning, no go. The first thing I tried, thinking it was an end of line problem, was adding a semicolon to the end of my comment lines, but still no change. If I put that same comment line, no semicolon, at the end of the script, it runs just fine.

I am using Perl 5.6.0, which is what this machine came with.

Replies are listed 'Best First'.
Re: Re: Comments Trouble
by castaway (Parson) on Dec 29, 2003 at 08:28 UTC
    Sorry, not much experience on MAC OSX, I cant see how this could be happening..

    Just wanted to tell you you can reverse a hash quite easily using 'reverse' (since a hash in list context is just a list containing key,value,key,value etc.. so:

    %reversedsushi = reverse(%sushi);
    ;)

    C.

      DOH!!! oh my god.

      I'm quite sure our instructor is loving the torturous paths all of his students are taking to get such simple things done.

      many thanks!