From owner-freebsd-questions Fri Aug 2 11:42:24 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E53637B400 for ; Fri, 2 Aug 2002 11:42:21 -0700 (PDT) Received: from mail.liwing.de (mail.liwing.de [213.70.188.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD51843E97 for ; Fri, 2 Aug 2002 11:42:20 -0700 (PDT) (envelope-from rehsack@liwing.de) Received: (qmail 83788 invoked from network); 2 Aug 2002 18:50:47 -0000 Received: from stingray.liwing.de (HELO liwing.de) ([213.70.188.164]) (envelope-sender ) by mail.liwing.de (qmail-ldap-1.03) with SMTP for ; 2 Aug 2002 18:50:47 -0000 Message-ID: <3D4AD2C6.BDC95345@liwing.de> Date: Fri, 02 Aug 2002 20:43:18 +0200 From: Jens Rehsack Organization: LiWing IT-Services X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Fernando Costa de Almeida Cc: freebsd-questions@freebsd.org Subject: Re: Little Question References: <00a901c23a4b$a627a750$1a0e6bc0@Presto> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Fernando Costa de Almeida wrote: > > I know that this question is more related to perl than FreeBSD, but.... > Anyone knowns how can I count the number of bytes in STDIN in perl... > > Like: > > cat /kernel | ./checksize.pl > > and the script says: > > File has 50000 bytes.. > > Thanks in advance... > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message Example 1: #!/usr/bin/perl @lines = <>; print "File has 50000 bytes..\n"; Example 2: #!/usr/bin/perl $count = 0; @lines = <>; foreach(@lines) { $count += length( $_ ); } print "count: $count\n"; bash-2.05a$ ./test1.pl Fax: +49 - 3 45 - 5 17 05 92 http://www.liwing.de/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message