in reply to Re: Sort the hash array
in thread Sort the hash array
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sort the hash array
by haukex (Archbishop) on Jul 06, 2017 at 11:26 UTC | |
I am beginner to perl ,so if you could help to optimized my code with perform below step ... i will be great help if you can correct where ever in code,I'm missing basic perl syntax and line not relevant.. For a beginner, your code looks pretty good, and there are no syntax errors in it (including the commented out code). Are you having problems with it? If so, feel free use the resources of PerlMonks, e.g. Basic debugging checklist and How do I post a question effectively? Because the code depends on XML input and servers I don't have available to me, I can't run it, but from a quick read-through I have the following suggestions for improvements: | [reply] [d/l] [select] |
by snehit.ar (Beadle) on Jul 06, 2017 at 12:09 UTC | |
| [reply] [d/l] |
by haukex (Archbishop) on Jul 06, 2017 at 12:38 UTC | |
is there way i can use s/^\s+|\s+$//g only once for all the variables
Doesn't apply to $remedyqueue though, one way to make that a little bit more idiomatic might be:
Or, for Perl versions before 5.14: map { (my $x=$_->string_value)=~s/^\s+|\s+$//g; $x } if i use sprintf("%.0f h", $diff_hours); gives me err in sorting statement Argument "2158 h" isn't numeric You didn't implement the suggestion I showed, instead you're attempting to sort by the field event_age, which does contain strings like "2158 h", which are not plain numbers and therefore | [reply] [d/l] [select] |