At 01:33 PM 12/5/2006 -0800, $Bill Luebkert wrote:
>Sure you can. The unused/skipped cells will be undef which you
>can check for on the print.
undef is also a legal rvalue. Perl autoextends arrays with undef values.
So regardless, perl will consider those offsets to "exist". Say he had
lines w
Chris Wagner wrote:
> At 02:39 PM 12/5/2006 -0500, Joe Discenza wrote:
>
>>The tr/// operator counts all the occurrences of the translated
>>character(s) in $_ (the default), and then you just increment the @semis
>>array at the index of the number of semicolons found to indicate another
>>line w
At 02:39 PM 12/5/2006 -0500, Joe Discenza wrote:
>The tr/// operator counts all the occurrences of the translated
>character(s) in $_ (the default), and then you just increment the @semis
>array at the index of the number of semicolons found to indicate another
>line with that number of semicolons.
EwenMarshall wrote, on Tuesday, December 05, 2006 2:23 PM
: All I want to do is count the number of ;'s on each line of
: 15,000'ish lined text file. The first 3 lines look like
: (FINISH; is the end of 1 line):
:
: NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.0;
: 0.0;"AN
This:
cut here
while() {
$cnt=()=$_=~ /;/g;
$matches{$cnt}++;
}
print "found $_ ; in $matches{$_} line(s)\n"
foreach (sort {$b <=> $a } keys %matches);
__DATA__
NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO;
100.0;0.0;"ANALOGUE CARD #100 INPUT
> The match condition is number of ; in 1 line
Output:
found 14 ; in 1,232 lines
found 13 ; in 7,456 lines
found 12 ; in 2,321 lines
my %line_counts;
while (<>) {
my $semis = tr/;/;/;
if ( $semis ) {
$line_counts{$semis}++;
}
else {
warn("Bad data - no semis: $_");
}
All I want to do is count the number of ;'s on each line of 15,000'ish lined
text file. The first 3 lines look like (FINISH; is the end of 1 line):
NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.0;
0.0;"ANALOGUE CARD #100 INPUT NO 01";FLOAT;FINISH;
NEW ANALOGUE; A.PS.19.602;
We need some more information. What is the match condition and how do u
find the number of matches?
If ur just trying to record the number of "something" per line so that u can
go back and correlate the number to the line, then u can't use foreach. U
have to iterate over the array so u can get t
Hi Guys,
How do I count matches in each line of a foreach loop...
Use strict;
My ($line,@match_count);
My @data = ("ALM1;;\"Alarm 1\";;FINISH;", ";ALM2;;\"Alarm
2\";SCO;FINISH;");
Foreach $line (@data) {
My $number=0;
# Code to count ; in each line
Push @match_count, "$number";
}
Print "Outp
hi all,
haven't worked with this for a while - still, don't
remember getting this error message ever ...
The code I'm running is below:
use Win32::OLE;
use Win32::OLE::Const;
$db = "db1";
$srv = "mySrv";
$uid = "usr1";
$pwd = "usr1pwd";
#this is an OLEDB connection to a MS-SQL Database
$connSt
*
# Count a attachments*
*my* $AttachmentNb = $message->Attachments()->Count();
*# Create attachments filename list *
*my* $AttachmentsList;
*if*($AttachmentNb > 0){
*for* (*my* $i=1;$i <= $AttachmentNb;$i++){
*# Add attachment filename to the list *
$AttachmentsList .= $message->Attachments()->I
11 matches
Mail list logo