Thank you for the review, I'm learning and didn't know about this way of using hashes :-)

---
Vincent Lequertier
s...@riseup.net

Le 2015-05-06 11:09, Shlomi Fish a écrit :
Hi Vincent,

On Wed, 06 May 2015 10:07:41 +0200
Vincent Lequertier <s...@riseup.net> wrote:

It's a bit ugly, but here is one way to do it :


Your code encourages many bad practices. Some notes are:

#!/usr/bin/perl

no "use strict;"/"use warnings;":

http://perl-begin.org/tutorials/bad-elements/#no-strict-and-warnings

my @array = ('1900-0', '1900-1', 'NULL', 'NULL', '1900-2', '1900-4',
'1902-5', '1902-6', '1902-7', '1902-8');
my $num1900 = 'EARFCN=1900, PCID=';
my $num1902 = 'EARFCN=1902, PCID=';

That's varvarname:

http://perl-begin.org/tutorials/bad-elements/#varvarname

for (@array) {

Iterating using "$_":

http://perl-begin.org/tutorials/bad-elements/#overuse_dollar_underscore

     # print $_ . "\n";
     $num1900 .= (split '-', $_)[1] . '&'
         if $_ =~ /1900/;
     $num1902 .= (split '-', $_)[1] . '&'
         if $_ =~ /1902/;

Duplicate code and you really should use a datastructure and less error prone
parsing.

}
$num1900 =~ s/\&$/;/;
$num1902 =~ s/\&$/;/;

"&" has no special meaning in regexes , so there is no reason to backslash it
(it doesn't hurt though).

print $num1900 . "\n";
print $num1902;

There should be a newline here too for good measure.

Regards,

        Shlomi Fish

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to