Learn PPI 2: exchange in condition
as what I posted before, I want to convert
if ( $a eq 'a' ) {
to
if ( 'a' eq $a ) {
PBP encourages it because it's less buggy.
I wrote another script today to fulfill the above request.
http://fayland.googlecode.com/svn/trunk/script/learn_ppi/02ExchangeCondition.pl
things like
I know it's not perfect. it's just a start.
hmm, I'm thinking about packaging the two scripts into modules then uploading to CPAN.
but I can't find a good name(or namespace) for them.
I'll try later.
Thanks and Enjoy!
if ( $a eq 'a' ) {
to
if ( 'a' eq $a ) {
PBP encourages it because it's less buggy.
I wrote another script today to fulfill the above request.
http://fayland.googlecode.com/svn/trunk/script/learn_ppi/02ExchangeCondition.pl
things like
my $a = "a";
my $b = "'b'";
my $c = 'c';
my $d = qq~d~;
if ( $a eq "a" ) {
print "1";
} elsif ( $b eq 'b') {
print "2";
} elsif ( $c ne qq~c~) {
print "3";
} elsif ( $c eq q~d~) {
print '4';
} else {
print '5';
}
if ( $a eq $b ) {
print '6';
}
if ( $c eq '$d' ) {
print 7;
}
if ( $a =~ /$b/ ) {
print 8;
}
if ( $a == '$b' or $c == '$d' ) {
print 9;
} will be converted intomy $a = "a";
my $b = "'b'";
my $c = 'c';
my $d = qq~d~;
if ( "a" eq $a ) {
print "1";
} elsif ( 'b' eq $b ) {
print "2";
} elsif ( $c ne qq~c~) {
print "3";
} elsif ( q~d~ eq $c ) {
print '4';
} else {
print '5';
}
if ( $a eq $b ) {
print '6';
}
if ( '$d' eq $c ) {
print 7;
}
if ( $a =~ /$b/ ) {
print 8;
}
if ( '$b' == $a or '$d' == $c ) {
print 9;
}I know it's not perfect. it's just a start.
hmm, I'm thinking about packaging the two scripts into modules then uploading to CPAN.
but I can't find a good name(or namespace) for them.
I'll try later.
Thanks and Enjoy!
Labels: PPI
2 Comments:
merely some nit-picking in your english (well, I could be wrong as well ;)):
"it's less bugs." => "it's less buggy."
"I wrote another script today for fulfill the above request." => "I wrote another script today to fulfill the above request"
"I'm thinking to package the two scripts into modules then upload to CPAN." => "I'm thinking about packaging the two scripts into modules and uploading to CPAN."
thanks. corrected. my poor English.
Post a Comment
Links to this post:
Create a Link
<< Home