#!/usr/bin/perl
# The Missing Textutils, Ondrej Bojar, obo@cuni.cz
# http://www.cuni.cz/~obo/textutils
#
# 'width' returns the maximum number of characters in one line of stdin/args.
# Tabs are counted as 1 char!
#
# $Id: width,v 1.5 2009-08-17 11:08:29 bojar Exp $
#

use Getopt::Long;
use strict;

my $utf = 0;
GetOptions(
  "utf" => \$utf,
) or exit 1;

if ($utf) {
  binmode(STDIN, ":utf8");
  binmode(STDOUT, ":utf8");
  binmode(STDERR, ":utf8");
}

my $nl = 0;
my $max = -1;
my $maxnl = -1;
while (<>) {
  $nl++;
  chomp;
  if ($max < length($_)) {
    $max = length($_);
    $maxnl = $nl;
  }
}
print "$max\n";
print STDERR "The first longest line is: $maxnl\n";
