LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   perl is different in windows and linux..?? (http://www.linuxquestions.org/questions/programming-9/perl-is-different-in-windows-and-linux-780756/)

ashok.g 01-07-2010 11:49 PM

perl is different in windows and linux..??
 
I came across a strange observation while I am working with perl in windows( Windows Vista) and in LINUX( RHEL AS 4). My observation is this:
Code:

#!usr/bin/perl
@a="ASHOK";
print $a[0];

In windows the output is "A" and in LINUX its "ASHOK".
Do perl have separate delimiters in different operating systems?
Why this is happening?

Sergei Steshenko 01-08-2010 02:07 AM

Quote:

Originally Posted by ashok.g (Post 3818422)
I came across a strange observation while I am working with perl in windows( Windows Vista) and in LINUX( RHEL AS 4). My observation is this:
Code:

#!usr/bin/perl
@a="ASHOK";
print $a[0];

In windows the output is "A" and in LINUX its "ASHOK".
Do perl have separate delimiters in different operating systems?
Why this is happening?

I think because you forgot to add new line, i.e. write

Code:

print $a[0], "\n";
in your code.

If my suggestion works, think about IO buffering and how shell prompt interferes with output.

ghostdog74 01-08-2010 02:34 AM

its definitely not a problem of new lines. I have no problems whether its run on Windows or *nix. the answer is "ASHOK" for both platforms. My platform : WinXP, Perl version 5.10.

smeezekitty 01-08-2010 12:00 PM

Code:

C:\Users\XXXX>perl
#!usr/bin/perl
@a="ASHOK";
print $a[0];^Z
ASHOK
C:\Users\XXXX>



All times are GMT -5. The time now is 07:53 AM.