venu2016 has asked for the wisdom of the Perl Monks concerning the following question:
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:
but out put on Linux:$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/
What am i doing wrong...rootLoc -> /home/testuser/perl/ src/*/testuser/perl/ work//testuser/perl/ processed/user/perl/ error/testuser/perl/
/home/testuser/perl/src/* /home/testuser/perl/work/ /home/testuser/perl/processed/ /home/testuser/perl/error/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script behaving differently on Linux vs windows
by Corion (Patriarch) on May 16, 2016 at 17:50 UTC | |
by venu2016 (Initiate) on May 16, 2016 at 19:20 UTC | |
|
Re: Script behaving differently on Linux vs windows
by choroba (Cardinal) on May 16, 2016 at 17:51 UTC | |
|
Re: Script behaving differently on Linux vs windows
by stevieb (Canon) on May 16, 2016 at 18:19 UTC |