in reply to Re: Platform Dependence observed in Perl - Hash keys have different format
in thread Platform Dependence observed in Perl - Hash keys have different format

Thanks for the response.

Could you please throw some light on why same code for defining a hash would yield hash key as only Key on one system and as "Key" on another? What could be possibly wrong with the code? I have added the subroutine in my post which actually defines the hash %pinList. On this hash I observed unexpected key format on different machine. Am I defining the hash incorrectly?

  • Comment on Re^2: Platform Dependence observed in Perl - Hash keys have different format

Replies are listed 'Best First'.
Re^3: Platform Dependence observed in Perl - Hash keys have different format
by Corion (Patriarch) on Mar 03, 2017 at 09:26 UTC

    Without seeing your input data, this is hard to tell. Your code seems to do some wonky CSV parsing here:

    my @pinWords = (); if($line =~ m/.*?,.*?,.*/){ @pinWords = split(',',$line); } elsif($line =~ m/.*?;.*?;.*/){ @pinWords = split(';',$line); }

    and then you write that value directly into the hash:

    ... $pin =~ s/^\s*|\s*$//g; #To remove all leading and t +railing blanks ... $pinList{$pin} = [$pinMaxSDV,$pinMinSDV];

    So my guess is that sometimes your CSV input data has double quotes around the pin and sometimes it does not.

    See Text::CSV_XS for CSV parsing.

      Sorry for my delayed response again.

      The issue was only because of soffice putting string without double quotes in my system and putting with double quotes on another system. So my csv file looked like below:

      On my(first) machine:

      key,value

      On Second Machine

      "key","value"

      Hi huck, I am not sure how to check what you mentioned. Sorry as I am not familiar with accessing values from modules. I tried below code and it gave error as mentioned.

      use strict; use warnings; print "\nUseqq = " . Data::Dumper::Useqq . "\n";\ print "\nQuotekeys = " . Data::Dumper::Quotekeys . "\n"; use Data::Dumper qw(Dumper);

      The error with above code: Useless use of single ref constructor in void context at test_dumper.pl line 6. Bareword "Data::Dumper::Useqq" not allowed while "strict subs" in use at test_dumper.pl line 5. Bareword "Data::Dumper::Quotekeys" not allowed while "strict subs" in use at test_dumper.pl line 6. Execution of test_dumper.pl aborted due to compilation errors.

        hi rkabhi

        sitecustomize.pl is a special perl file that MAY be run before any other code (even BEGIN blocks). If it will be used is determined via compile time switches for the perl executable (-Dusesitecustomize).

        If enabled it would be found at "$Config{sitelib}/sitecustomize.pl". The following code displays the settings.

        use strict; use warnings; use Config; print 'Version :'.$]."\n"; my $versionstr=`perl -v`; my $header='perl -v :'; for my $line (split ("\n",$versionstr)) { print $header.$line."\n";; $header=' :'; } print 'sitelib :'.$Config{sitelib}."\n"; print 'sitelibexp :'.$Config{sitelibexp}."\n"; print 'usesitecustomize:'.($Config{usesitecustomize}?$Config{usesitecu +stomize}:'')."\n";
        on my windows box
        Version :5.020001 perl -v : :This is perl 5, version 20, subversion 1 (v5.20.1) bu +ilt for MSWin32-x86-multi-thread-64int :(with 1 registered patch, see perl -V for more detail +) : :Copyright 1987-2014, Larry Wall : :Binary build 2000 [298557] provided by ActiveState ht +tp://www.ActiveState.com :Built Oct 15 2014 22:10:49 : :Perl may be copied only under the terms of either the + Artistic License or the :GNU General Public License, which may be found in the + Perl 5 source kit. : :Complete documentation for Perl, including FAQ lists, + should be found on :this system using "man perl" or "perldoc perl". If y +ou have access to the :Internet, point your browser at http://www.perl.org/, + the Perl Home Page. sitelib :C:\Perl\site\lib sitelibexp :C:\Perl\site\lib usesitecustomize:define
        on my lubuntu 14.04.5
        Version :5.018002 perl -v : :This is perl 5, version 18, subversion 2 (v5.18.2) bu +ilt for i686-linux-gnu-thread-multi-64int :(with 44 registered patches, see perl -V for more det +ail) : :Copyright 1987-2013, Larry Wall : :Perl may be copied only under the terms of either the + Artistic License or the :GNU General Public License, which may be found in the + Perl 5 source kit. : :Complete documentation for Perl, including FAQ lists, + should be found on :this system using "man perl" or "perldoc perl". If y +ou have access to the :Internet, point your browser at http://www.perl.org/, + the Perl Home Page. sitelib :/usr/local/share/perl/5.18.2 sitelibexp :/usr/local/share/perl/5.18.2 usesitecustomize:
        on my lxle 12.04.5
        Version :5.014002 perl -v : :This is perl 5, version 14, subversion 2 (v5.14.2) bu +ilt for i686-linux-gnu-thread-multi-64int :(with 60 registered patches, see perl -V for more det +ail) : :Copyright 1987-2011, Larry Wall : :Perl may be copied only under the terms of either the + Artistic License or the :GNU General Public License, which may be found in the + Perl 5 source kit. : :Complete documentation for Perl, including FAQ lists, + should be found on :this system using "man perl" or "perldoc perl". If y +ou have access to the :Internet, point your browser at http://www.perl.org/, + the Perl Home Page. sitelib :/usr/local/share/perl/5.14.2 sitelibexp :/usr/local/share/perl/5.14.2 usesitecustomize:
        So activestate enabled it while the ubuntu variants didnt.

        it was Eily that first mentioned the use of these two global variables at Re: Platform Dependence observed in Perl - Hash keys have different format. All i did was to test to see that setting them in sitecustomize.pl (run before "use Data::Dumper;" was seen in the main perl program) would work.

        Being main symbol table variables they are like other variables and need the $ to be used as Eily's examples showed. so the code to test them would be

        print "\nUseqq = " . $Data::Dumper::Useqq . "\n";\ print "\nQuotekeys = " . $Data::Dumper::Quotekeys . "\n";