perl.scripts...Re: hash values are printed in reverse order by Riehm Stephen- September 23, 2005 That&39;s pretty easy to answer: hashes aren&39;t sorted!If you want them sorted, you either have to use foreach $key ( sort keys %hash )Or if they are to be kept in the order in which they were defined (ie:chronological), you need to keep the keys in a separate array for sortingpurposes: foreach $key ( key_list ) print "$key: $hash$keyn" if exists $hash$key; See man perldata or perldsc for more information than you ever wanted toknow.SteveOn 22.09.2005...http://www.nntp.perl.org/group/perl.scripts/2005/09/msg426.html hash values are printed in reverse order by neelay thaker- September 23, 2005 Hi,when I parse a list of comma separated IP addresses, put them into an arrayand then transfer the elements of the array into a hash, the hash elementsget printed in reverse order as compared to the array and the input. Thefollowing code and output will make this problem clear.The code snipet is this-$arrsize = ipaddr;for( $ctr = 0 ; $ctr < $arrsize ; $ctr++ )$ip_intf_hash $ipaddr$ctr = "";print $ipaddr$ctr;print " : ";print "n";print "You entered the...http://www.nntp.perl.org/group/perl.scripts/2005/09/msg425.html Re: execution of shell commands in Perl Scripts by Riehm Stephen- September 9, 2005 try:grep_results = qx grep &39;abc&39; . ;$grep_status = $;system is only really usefull for starting programs which then do their ownthing. If you want the output, use qx!Cheers,SteveOn 08.09.2005 23:42 Uhr, "neelay thaker" wrote:> Hi,> I&39;m trying to use the output of a grep command in a shell script.> If I do-> $cmd = "grep &39;abc&39; .";> $status = system $cmd;> Then $status always turns out to be 0, even if I use invalid arguments with> grep.>.http://www.nntp.perl.org/group/perl.scripts/2005/09/msg424.html Re: execution of shell commands in Perl Scripts by Jonas B . Nielsen- September 9, 2005 Hello,If you want to catch the output of a command, use:$data = qx$cmdThe status you where getting back when calling system indicated success of your execution with 0.The return value of 0 is true for shell (mostly), it is platform dependent I suppose, so you have to turn you Perl logic around.Often see Perl scripts end with exit(0); for communication with the shell executing the perl script in question.jonasbnOn 89-2005, at 23.42, neelay thaker wrote:> Hi,> I&39;m trying to use the...http://www.nntp.perl.org/group/perl.scripts/2005/09/msg423.html execution of shell commands in Perl Scripts by neelay thaker- September 9, 2005 Hi,I&39;m trying to use the output of a grep command in a shell script.If I do-$cmd = "grep &39;abc&39; .";$status = system $cmd;Then $status always turns out to be 0, even if I use invalid arguments with grep.If the result of grep is not empty, I want to perform some action and if it is empty, I want to do something else.How can I get the output of grep into a string variable in the Perl scriptAny help will be highly appreciated.Thanks.Neelay.http://www.nntp.perl.org/group/perl.scripts/2005/09/msg422.html |