-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.pl
More file actions
41 lines (38 loc) · 796 Bytes
/
print.pl
File metadata and controls
41 lines (38 loc) · 796 Bytes
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
#!/usr/bin/perl -w
@printers=openPrintersFile("printers.txt");
foreach (@printers)
{
chomp;
$count = wordCount($_);
while ($count > 12) {
print "$_\n";
chop;
print "$_\n";
$count--
}
$current = $_."_p";
print "$current\n";
}
sub wordCount
{
$name = shift;
$count = 0;
@printerName = split(/\s*/, $name);
for ($i=0;$i <= $#printerName;$i++) {
$count++;
}
return $count;
#if ($count > 12) {
# print "Printer name: @printerName";
# print " count: $count\n";
# removeLastChar($count, @printerName);
#}
}
sub openPrintersFile
{
$PRINTERS=shift;
open(PRINTERS);
@printers=<PRINTERS>;
close(PRINTERS);
return @printers;
}