Lunedì, 30 Dic 2002, alle 23:38 Europe/Rome, Wiggins d'Anconia ha scritto:
Adriano Allora wrote:hi to all,Easier is subjective, I know Perl already and while Awk may be related I wouldn't want to have to learn new syntax/language just to process some files, so Perl is easier *to me*. As far as speed, your friend could very well be right, but to what extent. If it takes your program .5 ms to parse a file with perl and .3 ms to parse it with AWK, then yes it is faster, but it isn't likely in most situations that it matters that much, sure in others it does. Ask your friend how he connects to a database in awk? Or about the OOP features of Awk. Or about the list of publicly available pre-written modules to handle all kinds of tasks in Awk. Awk is great at one thing, which is why it is fast at that thing, Perl is great at lots of stuff, but not as fast as any one product in its own particular ability. Why is an orange better than an apple?
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?
you're right. thanks.
Ok, I spent this time to complicate - or semplify - my script (because I noted a carachteristic of the input).2 - an unexplicable differenceI don't completely understand what your doing here. Can you give an example of the input and desired output?
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?
Now, we're close to the new year's eve and I cannot stop to mind this script (this evening, I suppose, I will stop - if I wanna spent a good party).
I don't like who look for a complete and correct script here, but I cannot solve my problem: this is my input-type:
Dante Alighieri
Cecco Angiolieri
Brunetto Latini
Eugenio Montale
Giacomo Leopardi
Niccolò Tommaseo
Guido Gozzano
(and so on...)
all I want in my output are two arrays: the first column of the input (all the first names) in the first array and the second column (all the surnames) in the second array.
I wrote the script that follows, but my script does not work for the @orig (more precisely, this script gives an empty array) and I don't undestand why.
#!/usr/bin/perl -w
use strict;
my $file_name = "cicci.txt";
my $new = "";
my $orig = "";
my @new = ();
my @orig = ();
open (INPUT, $file_name) or die "File not opnd cos $!";
while (<INPUT>)
{
m/ /;
$new[$.] = $`;
$orig[$.] = $´;
}
close (INPUT);
#these print lines are only to test the script
#I need the output in those two arrays
print @new;
print "\n";
print @orig;
print "\n";
____END____
someone sees where I mistake?
Thank and have a nice nite (in Italy we say: a good end and a good start)!
all'adr
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]