Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: RFC: Data::Sync

by diotalevi (Canon)
on Sep 22, 2005 at 14:46 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-18 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found