hi to all,
I'd like to know two things:

1 - Perl vs. AWK
I'm learning Perl to use it in text processing. Recently I start to argue with a friend of mine about the best language to process texts (clear them, or markup them, tokenize them or parse them), he says awk is better - quicker than perl, for example, and easier -.
I want to learn perl also for cging, but I'm curious about its skills with texts (my friend also forwarded me a mail of AWK mailing list in which someone who did a benchmark demonstrated the speed of awk...)
Someone want to tell me somethong about it?


2 - an unexplicable difference
I wrote two scripts in order to extract parts of text from a file and put these parts in two arrays.
The first one works very well, but the second one doesn't. Because of the scripts are identical in all but for the second regexp (but the regexp is not erroneous), I cannot undestand this difference.
Some advice?

THIS ONE WORKS:
#!/usr/bin/perl -w
my $file_name = "cicci.txt";
my $num = 0;
my $new = "";
open (INPUT, $file_name);
while (<INPUT>)
{
s/\s.+/\n/g;
foreach ($.)
{
m/\n/;
$new[$.] = $`;
}
}
close (INPUT);
print @new;
print "\n";

THIS ONE DOESN'T WORK:
#!/usr/bin/perl -w
my $file_name = "cicci.txt";
my $num = 0;
my $new = "";
open (INPUT, $file_name);
while (<INPUT>)
{
foreach (s/(\S|\S\S|\S\S\S)(  )//g)
# typing here "print;" I saw that the regexp works;
{
print;
m/\n/;
$new[$.] = $`;
}
}
close (INPUT);
print @new;
print "\n";

all'adr


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to