in reply to Re^4: Problems around Param (CGI->param or CGI->multi_param instead of CGI->Vars )
in thread Problems around Param

#!perl use warnings; use strict; use CGI; open FH, '>','/tmp/hash.dat' or die "Can not open hash.dat : $!"; my $q = new CGI; for my $k ( sort $q->param ) { if ($k =~ /(.+)_drp$/){ print FH join'|', $q->param( $1 ),$q->param( $k )."\n"; } } close FH;
poj
  • Comment on Re^5: Problems around Param (CGI->param or CGI->multi_param instead of CGI->Vars )
  • Download Code

Replies are listed 'Best First'.
Re^6: Problems around Param (CGI->param or CGI->multi_param instead of CGI->Vars )
by sauravrout (Novice) on Aug 27, 2015 at 04:46 UTC
    Thanks poj. I am getting desired result. But the issue I am facing is the inputs are not coming in the order in which they are inserted to the hash. I know hash doesn't store values in order, but is there any way to achieve this ? Note: I don't have Tie::IxHash; installed on my system and I am not authorized to install this.

      I don't understand, are you saying that the order appearing in hash.dat is not the same as they appear on the html table ?

      Is there any pattern to the order you want them in ? For example the number before the underscore.

      poj
        Yes, actually we were doing a sort here
        for my $k ( sort $q->param )
        I removed the sort and I am getting in the desired order. But will it every time come in the same order that it was entered in the html table? Because I know hash doesn't save the values in the order that they were inserted. Correct me if I am wrong.