Side-by-Side
| Perl | Tcl |
#!/usr/local/bin/perl
#
# usage: Join source
# join non-blank lines in source and write to stdout
#
# 1/19/99
#
# grab first command-line argument in @ARGV: source file
$ARGV = shift;
# read source file line-by-line
# if a line is not blank, replace "newline" with a space
#
open(SPLITFILE, "$ARGV");
while ($line = <SPLITFILE>) {
if ($line ne "\n") {
chop($line);
print $line, " ";
} else {
print "\n\n";
}
}
print "\n";
close(SPLITFILE);
|
#!/usr/local/bin/tclsh
#
# usage: Join source
# join non-blank lines in source and write to stdout
#
# 1/20/99
#
# read source file ($argv) line-by-line
# if a line is not blank, replace "newline" with a space
#
set fileHandle [open $argv]
while {[gets $fileHandle line] != -1} {
if {$line != ""} {
puts -nonewline "$line "
} else {
puts "\n"
}
}
puts ""
close $fileHandle
|

Last modified: 3/17/99