Perl script for pricing content

A place where authors can exchange ideas or thoughts. Talk about what categories are hot and which ones are not.

Moderators: Celeste Stewart, Ed

Locked
thepaintguru
Posts: 21
Joined: Thu Apr 16, 2009 6:19 pm

Perl script for pricing content

Post by thepaintguru »

In case I'm not the only one running in a *nix environment, I thought I'd post this Perl script I use to price my content. For those of you who aren't programmers, it's just a little program that counts the words in a text file and calculates a price based on your target cost per word.

Anyway, here's the code:

Code: Select all

#!/usr/bin/perl

my $file = shift;
my $cpw = shift || 10;  #The number represents default price per word

@_ = split(/ /,`wc $file -w`);
my $count = $_[0];

my $fr = $count * $cpw; #You can change these:
my $un = $fr * 3/4;          #Price for unique content (Default: 3/4 fullrights)
my $us = $fr * 1/3;          #Price for use (Default 1/3 fullrights)

print "$count WORDS\n";
print "Fullrights: ".price($fr);
print "\t-> ".price($fr * .65)."\n";
print "Unique:     ".price($un);
print "\t-> ".price($un * .65)."\n";
print "Use:        ".price($us);
print "\t-> ".price($us * .65)."\n";
print "\n";

sub price {
	my $cents = shift;
	my $dollars = int($cents / 100);
	$cents = $cents % 100;
	return "\$$dollars.$cents";
}
If you don't know how to use it, don't try :).
Locked