Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: RFC: Data::Sync

by diotalevi (Canon)
on Sep 22, 2005 at 14:46 UTC ( #494148=note: print w/replies, xml ) Need Help??

in reply to RFC: Data::Sync

I skimmed your code and wanted to pick some nits with you. None are serious. The rest of your code was too sparse to skim and I couldn't read it.

If you plan to be backwards compatible with 5.005, you do not use warnings and you use vars instead of our(). If you are going to be 5.6+, you may use both. Doing only one is strange and it looks like you don't understand the reasons for doing things one way or the other.

use warnings; use vars qw($VERSION); $VERSION="0.02";

Your warning is technically correct but irrelevant. The order of keys() always matches the order of values(). Even in 5.8.x+ with key order randomization, this is true. This can be rewritten as two simple statements.

# DANGER! this initially used keys %$line, but order can't be guarante +ed. # my (@keys,@values); # for (keys %$line) # { # push @keys,$_; # push @values,$$line{$_} # } my @keys = keys %$line; my @values = map $$_, values %$line;

Instead of transforming a list of indexes into a list of "?" characters, its easier to just create that many "?" in one operation. Its faster and wastes less memory too. The parentheses are important. It means you get back a list of "?" instead of a string with many "????????" in it.

# map { "?" } (0..scalar @values-1) ( "?" ) x @values

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2020-05-26 17:24 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (150 votes). Check out past polls.