in reply to Re^4: Entity statistics
in thread Entity statistics
The scalar variable $tally is different to an array variable @tally. Single members of the array are called with a dollar sign followed by a square bracket, but they are still elements of the array @tally. So, you need to declare the array:
my @tally;
> How could I get rid of "(?^:" and ")"?
One possibility is to use a regex:
for my $i (0 .. $#regexes) { my $regex = $regexes[$i]; $regex =~ s/^\(\?\^://; $regex =~ s/\)$//; print "$regex:\t$tally[$i]\n"; }
> Would it be possible to save this output to a file?
The easiest way is to use redirection in your shell, it should work even in MSWin.
perl script.pl > output.txt
If you want to write to a file from within Perl, open a file for writing and print to it:
open my $out, '>', 'output.txt' or die $!; for my $i (0 .. $#regexes) { my $regex = $regexes[$i]; $regex =~ s/^\(\?\^://; $regex =~ s/\)$//; print {$out} "$regex:\t$tally[$i]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Entity statistics
by LexPl (Beadle) on Nov 12, 2024 at 16:50 UTC | |
by choroba (Cardinal) on Nov 12, 2024 at 16:55 UTC |