Hello Monks! I've just started learning perl yesterday so this is probably newbie question. I'm trying to run the following basic code on Cygwin but it gives me errors.

#!C:\strawberry\perl\bin\perl use strict; use warnings; print "Array Sample \n" my @arrayone = ("String :","Hello","Number :",555); print "$arrayone[0] $arrayone[1]\n"; print "$arrayone[2] $arrayone[3] \n";

This is the error I get

syntax error at testarray.pl line 7, near "my " Global symbol "@arrayone" requires explicit package name at testarray. +pl line 7. Global symbol "@arrayone" requires explicit package name at testarray. +pl line 8. Global symbol "@arrayone" requires explicit package name at testarray. +pl line 8. Global symbol "@arrayone" requires explicit package name at testarray. +pl line 9. Global symbol "@arrayone" requires explicit package name at testarray. +pl line 9. Execution of testarray.pl aborted due to compilation errors.

This works perfectly on my friend's Ubuntu but don't know why am I getting this error on Cygwin.

Ubuntu Virtual OS is very very slow on my Windows 7 so had to go with Cygwin.

Please guide me through if this isn't correct section to post ! Thank you!


In reply to Simple perl Code runs on Ubuntu but gives errors on Cygwin by Krishna05

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.