# -- perl --

#
# usage: source target string1 string2
#        look for string1 in source and replace it with string2, save the result into target
# eg   : ./replace.pl test.txt .pork <X_INCLUDES> /usr/X11R6/include
#

$Source = @ARGV[0]; 
$Target = @ARGV[1];
$Token = @ARGV[2];
$Replacement = @ARGV[3];

# add \ for every / so sed won't complain
# eg: /usr/X11R6 -> \/usr\/X11R6
$Replacement =~ s/\//\\\//g;

`sed -e 's/$Token/$Replacement/g' $Source > $Target`;
