in reply to quick way to add value of a hash with same x, y, z?
Hello buchi2,
Regarding the part of your question And is it possible, to trim the blanks during reading automatically away, wihout the trim sub?.
Why you need to trim the string through a function and not onsite directly?
Sample of code:
#!/usr/bin/perl use strict; use warnings; use feature 'say'; sub trim { my ($str) = @_; $str =~ s/^\s+|\s+$//g; return $str; } my $test = ' sample '; say 'Before (trim):'; say $test; say trim($test); say 'Without (trim):'; say $test; $test =~ s/^\s+|\s+$//g; say $test; __END__ $ perl test.pl Before (trim): sample sample Without (trim): sample sample
Just do it as in the function without call the function, but the only reason to use the function is to avoid retyping over and over and over again the same code.
I do not have time now, to check the rest of the code but maybe later on I will find some time (hopefully).
Hope this helps, BR.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: quick way to add value of a hash with same x, y, z?
by buchi2 (Acolyte) on Aug 11, 2017 at 08:39 UTC |