<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1555" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Patty,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>A função system() não retorna nada. Se quiser
retorno, use </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>$count=`cat $file | wc -l`;</STRONG> <FONT
color=#008000># com crases</FONT></FONT></DIV>
<DIV><FONT face=Arial color=#008000 size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Como já foi dito, o comando cat mostra em
STDOUT o conteúdo de um ou mais arquivos (conCATenados). A contagem fica por
conta do comando wc (word count) que, com a opção -l conta as
linhas.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Apesar de eu não recomendar chamadas ao sistema, às
vezes são necessárias.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Vinicius</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=ptfzs@yahoo.com.br href="mailto:ptfzs@yahoo.com.br">Patty Silva</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=cascavel-pm@pm.org
href="mailto:cascavel-pm@pm.org">Cascavel Perl Mongers</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, June 23, 2006 4:23 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Cascavel-pm] Comando cat |
wc -l</DIV>
<DIV><BR></DIV><PRE><SPAN style="COLOR: rgb(128,0,0)"></SPAN>Ai.. esta +- assim:<BR></PRE>
<META content="Kate, the KDE Advanced Text Editor" name=Generator><PRE><SPAN style="COLOR: rgb(0,0,128)">open</SPAN> (File, <SPAN style="COLOR: rgb(0,128,0)"><B>"</B></SPAN><SPAN style="COLOR: rgb(128,0,0)"></SPAN><SPAN style="COLOR: rgb(128,0,0)">$file</SPAN><SPAN style="COLOR: rgb(0,128,0)"><B>"</B></SPAN>) <SPAN style="COLOR: rgb(0,128,0)"><B>or</B></SPAN> <SPAN style="COLOR: rgb(0,0,128)">die</SPAN> <SPAN style="COLOR: rgb(192,0,0)">$!<BR></SPAN><SPAN style="COLOR: rgb(128,0,0)"><BR>$count</SPAN>=<SPAN style="COLOR: rgb(0,0,128)">system</SPAN>(<SPAN style="COLOR: rgb(0,128,0)"><B>'</B></SPAN><SPAN style="COLOR: rgb(255,108,108)">cat $file | wc
-l</SPAN><SPAN style="COLOR: rgb(0,128,0)"><B>'</B></SPAN>);<BR><BR>// ESSE system imprime na tela.. e nao atrivbui a variavel..<BR>// Eu quero que conte antes de entrar no while<BR></PRE>
<META content="Kate, the KDE Advanced Text Editor" name=Generator><PRE><B>while</B> (<B>my</B> <SPAN style="COLOR: rgb(128,0,0)">$line</SPAN> = <File>)<BR>{<BR><BR>}<BR></PRE><BR><BR>oks??
Obrigada<BR><BR><B><I>Igor Sutton Lopes <<A
href="mailto:igor.sutton@gmail.com">igor.sutton@gmail.com</A>></I></B>
escreveu:
<BLOCKQUOTE class=replbq
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">Patty
Silva <PTFZS @yahoo.com.br="">writes:<BR><BR>Cadê seu código
inicial?<BR><BR>> Pessoal.. qual comando do perl substitui o cat (contar
quantas linhas<BR>> possui no arquivo). Eu preciso contar a quantidade de
linhas mas nao<BR>> pode ser contagem linha a linha.. pois preciso da
quantidade antes da<BR>> contagem linha linha acabar.. por isso pensei no
cat | wc -l<BR>><BR>>
Obrigada<BR>><BR>><BR>><BR>><BR>><BR>>
-------------------------------------------------------------------------------<BR>>
Yahoo! Search Música para ver e ouvir: You're Beautiful, do James<BR>>
Blunt<BR>> _______________________________________________ Cascavel-pm
mailing<BR>> list Cascavel-pm@pm.org<BR>>
http://mail.pm.org/mailman/listinfo/cascavel-pm<BR>_______________________________________________<BR>Cascavel-pm
mailing
list<BR>Cascavel-pm@pm.org<BR>http://mail.pm.org/mailman/listinfo/cascavel-pm<BR></PTFZS></BLOCKQUOTE><BR>
<P>
<HR SIZE=1>
Yahoo! Search<BR>Música para ver e ouvir: <A
href="http://us.rd.yahoo.com/mail/br/tagline/search/video/*http://br.search.yahoo.com/search/video?p=james+blunt&ei=UTF-8&cv=g&x=wrt&vm=r&fr=intl-mail-br-b">You're
Beautiful, do James Blunt</A>
<P>
<HR>
<P></P>_______________________________________________<BR>Cascavel-pm mailing
list<BR>Cascavel-pm@pm.org<BR>http://mail.pm.org/mailman/listinfo/cascavel-pm
<P>
<HR>
<P></P>No virus found in this incoming message.<BR>Checked by AVG Free
Edition.<BR>Version: 7.1.394 / Virus Database: 268.9.2/372 - Release Date:
21/6/2006<BR></BLOCKQUOTE></BODY></HTML>