Bash Code to count characters:
#!/bin/bash
data=`cat datafile`
IFS=$'\n'
x=0
for i in $data
do
chars=`echo "$i" | wc -m`
temp+=$chars:$x"\n"
x=$((x+1))
done
echo -e $temp | sort -n -r
Perl Code to Translate back and fourth via freetranslation.com and
www::mechanize:
#!/usr/bin/perl
my $string;
foreach (@ARGV){
$string .= $_. " " ;
}
if ($string eq ""){
$string = <>;
}
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get("http://www.freetranslation.com");
$mech->submit_form(
with_fields => {
srctext => $string,
language => "English/French"
});
$data = $mech->content;
$data =~ m/dsttext".*?>(.*)</;
$transstring = $1;
print $1;
print "\n";
$mech->get("http://www.freetranslation.com");
$mech->submit_form(
with_fields => {
srctext => $transstring,
language => "French/English"
});
$data = $mech->content;
$data =~ m/dsttext".*?>(.*)</;
print $1;
print "\n";
Sample Makefile (from Duke
University):
#-----Macros---------------------------------
# for cs machines
#BASEDIR = /usr/project/courses/cps008/lib
# for acpub machines
BASEDIR = /afs/acpub.duke.edu/users8/ola/courses/lib
TLIB = $(BASEDIR)/libtapestry.a
INCLUDES = -I. -I$(BASEDIR)
# set up compiler and options
CXX = g++
CXXFLAGS = -g $(INCLUDES)
#-----Suffix Rules---------------------------
# set up C++ suffixes and relationship between .cc and .o files
.SUFFIXES: .cc
.cc.o:
-> $(CXX) $(CXXFLAGS) -c $<
.cc :
-> $(CXX) $(CXXFLAGS) $< -o $@ -lm $(TLIB) -lg++
#-----File Dependencies----------------------
SRC = application.cc menu.cc menuitem.cc pixmap.cc usepix.cc \
readcommand.cc quitcommand.cc filelister.cc templateapp.cc \
displaycommand.cc
OBJ = $(addsuffix .o, $(basename $(SRC)))
usepix: $(OBJ)
-> $(CXX) $(CXXFLAGS) -o $@ $(OBJ) -lm $(TLIB) -lg++
#-----Other stuff----------------------------
depend:
-> makedepend $(CXXFLAGS) -Y $(SRC)
clean:
-> rm -f $(OBJ)