Newbie to perl scripting. I am trying to read a file and append some test to it. my code works fine on windows but behaves very differently on Linux.

use strict; sub main{ my $configFile="/home/testuser/perl/config.properties"; #my $configFile="C:/Projects/perl/win_config.properties"; my $rootLoc ="NA"; if(-e $configFile){ # Open file to read if(open(DATAP, "<$configFile")){ # iterate through index file. while(<DATAP>){ my @splitLine = split('=', $_); if($splitLine[0] eq "rootLoc"){ chomp $splitLine[1]; $rootLoc = $splitLine[1]; } } #close data file. close( DATAP ); } } else{ print "***Config file does not exist***\n"; } print "\$rootLoc -> $rootLoc \n"; if(!($rootLoc eq "NA")){ my $srcDirectory = $rootLoc . "src/*"; my $srcWorkDir = $rootLoc . "work/"; my $procDir = $rootLoc."processed/"; my $errDir = $rootLoc."error/"; print "$srcDirectory\n"; print "$srcWorkDir\n"; print "$procDir\n"; print "$errDir\n"; } } main();

Output on windows:

$rootLoc -> C:/Projects/perl/output/ C:/Projects/perl/output/src/* C:/Projects/perl/output/work/ C:/Projects/perl/output/processed/ C:/Projects/perl/output/error/
but out put on Linux:
rootLoc -> /home/testuser/perl/ src/*/testuser/perl/ work//testuser/perl/ processed/user/perl/ error/testuser/perl/
What am i doing wrong...
expected output on Linux:
/home/testuser/perl/src/* /home/testuser/perl/work/ /home/testuser/perl/processed/ /home/testuser/perl/error/


In reply to Script behaving differently on Linux vs windows by venu2016

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.