in reply to Comments trouble

Please give short examples of a script that runs, and a script that doesn't, together with how you are running the script (as executable, calling it as a parameter to the perl binary, somehow else? Using a self-build perl or one that came with the system?

C.

Replies are listed 'Best First'.
Re: Comments Trouble
by ctp (Beadle) on Dec 29, 2003 at 01:01 UTC
    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.
      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!
Re: Re: Comments trouble
by ctp (Beadle) on Dec 29, 2003 at 01:03 UTC
    BTW - when I posted the original query I was signed in, but it posted as anonymous. I'm actually CTP, not anonymous :)