DEV Community

Discussion on: Write a simple but impactful script

Collapse
 
littlefox profile image
Mara Sophie Grosch (LittleFox)

Hacky Perl/sh oneliner

perl -e '@v=("0000".."9999"); %x; print map { do { $i=int(rand(@v)); } while($x{$i}); $x{$i}=1; $v[$i] . "\n"} @v;' > hacked_pins.txt

Generates a list of pins (@v) and then selects a random entry for every entry in the list (hacky use of map). %x is used to mark which entries already have been returned.