Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; my $use_file = "no"; # yes or no my $file = "convo.txt"; # the file to open if $use_file = 1 my $i=0; my $j=0; my $n = 0; my $n2=0; my @i; get(); my $name2; sub parse{ my @i = @_; if(@i){ my $name = $i[0]; $name =~ s/^(.*?):\s+.*/$1/; my @words; foreach(@i){ s/^(.*?):\s+(.*)/$1/; push @words,$2; if($name eq $_){ $n++; }else{ $name2 = $_; $n2++; } } foreach(@words){ $i++ foreach split/ /; $j++ foreach split//; } print "$i words total, $j total characters\n", "$name has $n IMs sent while $name2 has $n2 IMs sent. Ther +e were ", $n + $n2," IMs total"; }else{ print "YOU NEED TO PUT STUFF IN $file OR PUT IT BETWEEN THE PI +PES |BLAH|"; } } sub get{ if($use_file eq "yes"){ if(-e $file){ open(FH,$file) || die "$!"; @i = <FH>; close FH; }else{ open(FH,">$file") && die "The conversation file has been c +reated.\n Paste your conversation in $file and run the program agai +n."; close (FH); } }else{ @i=split/\n/,qq|hey: yo\nyo: hey|; #paste the convo between th +e pipes |convo here| make sure that it isn't # like | # convo here # | } parse(@i); }

In reply to Instant message parser. by damian1301

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-16 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found