8 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# this emulates #! processing on NIH machines.
# (remove #! line above if indigestible)
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
# process any FOO=bar switches
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator
while (<>) {
($Fld1) = split(' ', $_, 9999);
&hello($Fld1);
}
sub hello {
local($X) = @_;
print 'hello ' . $X . ', how are you';
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
BEGIN {
Dup_sg = "";
Frei_sg = "";
Min_ig = 99999999;
Max_ig = 0;
LastFileDup_sg = "";
}
function PrintDup (From_iv, To_iv, File1_sv, File2_sv)
{
Dup_sg = Dup_sg sprintf ("Doppelt: %5d..%-5d %-10s %s\n%-34s%s\n", From_iv, To_iv, "(" To_iv - From_iv + 1 " Stk)",
File1_sv, "", File2_sv);
LastFileDup_sg = "";
}
function PrintFrei (From_iv, To_iv)
{
Frei_sg = Frei_sg sprintf ("Frei: %5d..%-5d %-10s\n", From_iv, To_iv, "(" To_iv - From_iv + 1 " Stk)");
}
END {
FreiFrom_ii = FreiTo_ii = 0;
From_ii = To_ii = Min_ig;
LastFile_si = "";
for (I_ii = Min_ig; I_ii <= Max_ig; I_ii++)
{
if ( LastFileDup_sg != "")
{
PrintDup(From_ii, To_ii, LastFileDup_sg, LastFile_si);
From_ii = I_ii;
}
else
{
if (LastFileDup_sg != "")
PrintDup(From_ii, To_ii, LastFileDup_sg, LastFile_si);
From_ii = To_ii = I_ii;
}
if ( FreiFrom_ii != 0)
PrintFrei(FreiFrom_ii, FreiTo_ii);
}
printf ("%s", Dup_sg);
printf ("%s", Frei_sg);
}
QuoteThe left parenthesis in a function call is required to immediately fol-
low the function name, without any intervening white space. This is to
avoid a syntactic ambiguity with the concatenation operator. This
restriction does not apply to the built-in functions listed above.
QuoteFunctions in AWK are defined as follows:
function name(parameter list) { statements }
8 Einträge, 1 Seite |