Tag Archives: TMP

Letter Frequency Decryption Program in Perl

By jvr42

Hello,

I am learning Perl, and I am trying to to the Letter Frequency Decryption Program from page (I could not post the url) :

I had found how to count the frequency of each letter, but I am missing the other parts of the program:


#!/usr/bin/perl

use strict;
use warnings;

# read in the contents of the file
my $contents;
open(TMP, "<$ARGV[0]") or die ("Failed to open $ARGV[0]: $!");
{
local($/) = undef;
$contents = ;
}
close(TMP);

# split the contents around each character
my @bits = split(//, $contents);

# build the hash of each character with it's respective count
my %counts = map {
# use lc($_) to make the search case-insensitive
my $foo = $_;

# filter out newlines
$_ ne "n" ?
($foo => scalar grep {$_ eq $foo} @bits) :
() } @bits;

# reverse sort (highest first) the hash values and print
foreach(sort {$counts{$a} $counts{$b}} keys %counts) {
print "$_: $counts{$_}n";
}


Any help? :confused:

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Review: DropIt organizes your Downloads folder

DropIt is a free, open-source utility that processes collections of files according to rules you define. For example, you can set it loose at your Downloads folder, and telling it to sort all of the JPG and PNG files into an images subfolder, but only if they’re larger than 30KB (so you don’t have to save small images). It would then take all the ZIP files and put them in another folder, and delete all of the TMP files. In other words, you just configure a bunch of rules, and DropIt does the rest.

You can use DropIt by dragging and dropping files onto its desktop overlay (hence the name), or have DropIt sit in the background and constantly monitor one or more folders for any changes. Once you have a solid set of rules, that latter option offers a distraction-free way to get rid of file clutter, but only after you make some tweaks to the way DropIt works. By default, DropIt shows a progress bar whenever it’s processing files, and also prompts you when it stumbles upon a file it doesn’t know what to do with.

DropIt’s interface for configuring rules is simple to use, if a bit basic.

These behaviors make sense when you manually trigger DropIt, but when you have it running in the background, they can be maddening (imagine seeing a progress bar streak across your desktop every 60 seconds, 15 minutes, or however long the automatic scanning interval you set is). Fortunately, both of these features can be disabled in DropIt’s Options dialog.

For DropIt to be useful, you have to spend time carefully configuring it for your own use. After all, only you know how you like your files to be organized. But with time, it can become a useful file management assistant, sorting and removing needless files in ways that make sense to you.

To read this article in full or to leave a comment, please click here

Source: FULL ARTICLE at PCWorld