Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: What do I use to release a module to CPAN for the first time?

by ikegami (Patriarch)
on Oct 11, 2020 at 05:06 UTC ( [id://11122683]=note: print w/replies, xml ) Need Help??


in reply to What do I use to release a module to CPAN for the first time?

Tip:

$opt->{'encoding'} ? $opt->{'encoding'} : 'utf-8'
is more idiomatically/simply written as
$opt->{encoding} || 'utf-8'

Tip:

if ( length($line) > 0 || $opt->{'empty'} && $opt->{'empty'} eq 'fill' + ) { $final_line = $prefix . $line . $suffix; } elsif ( $opt->{'empty'} && $opt->{'empty'} eq 'blank' ) { $final_line = ''; } elsif ( $opt->{'empty'} && $opt->{'empty'} eq 'undefined' ) { $final_line = undef; } else { next; }
could be simplified to
my $empty = $opt->{empty} || ''; ... if ( length($line) || $empty eq 'fill' ) { $final_line = $prefix . $line . $suffix; } elsif ( $empty eq 'blank' ) { $final_line = ''; } elsif ( $empty eq 'undefined' ) { $final_line = undef; } else { next; }

But I'd personally setup some variables beforehand.

my $empty = $opt->{empty} || ''; my $trim_empty = !$empty; my $keep_empty = $empty eq 'fill'; my $empty_replacement = $empty eq 'blank' ? '' : undef; ... if ( length($line) || $keep_empty ) { push @array, $prefix . $line . $suffix; } elsif ( !$trim_empty ) { push @array, $empty_replacement; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11122683]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found