Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: (crazyinsomniac) Re: Excluding words with more than three a

by Anonymous Monk
on Dec 20, 2001 at 22:17 UTC ( [id://133550]=note: print w/replies, xml ) Need Help??


in reply to (crazyinsomniac) Re: Excluding words with more than three a
in thread Excluding words with more than three a

Hi crazyinsomniac,

As my second language, I am sorry if my poor English mislead you to such funny exegesis of my post, and though I found some good points in it, other points were really dead wrong. Anyway, since some advises you offered seemed to me as good ones, I stand corrected and I would try to make a better move on future questions. So thanks for bring them.

Also, you wondered about my perl skills. I am aware that they are not strong -- I'm only starting with perl and no, my question wasn't a homework assignment, as I am not taking perl lessons --, but they are not so weak as to couldn't write a "Hello world" program, as you unfortunately guessed. Here is a code snippet, the one I wrote to find out how many times a letter appears in the names of the days (please read my other replies to know more about the target problem). It runs fine under MacPerl, so if you like to check it out, you may need to change it a bit (I guess only the first line).

#!perl -w use strict; my %semanal; while (<DATA>) { chomp; foreach my $letra (split //) { $semanal{$letra}++; } } foreach my $pal (sort keys %semanal) { print "$pal\t$semanal{$pal}\n"; } __DATA__ lunes martes miercoles jueves viernes sabado domingo output: a 3 b 1 c 1 d 2 e 8 g 1 i 3 j 1 l 2 m 3 n 3 o 4 r 3 s 6 t 1 u 2 v 2
Thank you.

Best regards,
Richard

Replies are listed 'Best First'.
Re: Re: (crazyinsomniac) Re: Excluding words with more than three a
by crazyinsomniac (Prior) on Dec 21, 2001 at 04:10 UTC
    Hey, I'm glad I was wrong (well, on some points). That's pretty good actually (as knowledge of m// and y// escaped me for a long time when I started learning perl) and that is how I would've approached it about two years ago. In terms of efficiency, and this is without any benchmarks of this particular problem, but from previous knowledge, your best bet would be to use y// aka tr//.

     
    ___crazyinsomniac_______________________________________
    Disclaimer: Don't blame. It came from inside the void

    perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://133550]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-25 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found