From nate at campin.net Wed Apr 5 16:38:16 2000 From: nate at campin.net (Nate) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Nate wrote - Hello again there JaxPM! A few weeks ago I modified the logcheck script (from www.psionic.com, the Abacus stuff) to analyze the logs from a central syslog loghost. I use a perl script to sort the logs by hostname, then the logcheck shell script parses each log in turn and mails a report. Why are you telling me this, you ask? Well, I have lots of duplicate log entries, things like postfix complaining that it can't connect to a certain mail server, etc. I certainly do want to see these messages, just not 50 times! I want to use perl to emulate the syslog feature that just tells you "Last message repeated 5 times", but not just when they are one after another. Even when the times are spread out, I could say it a couple ways way #1: Message "zeus PAM_pwdb[19196]: (su) session opened for user root by nate(uid=501)" reported at 14:22:33, 14:40:29, 14:55:21 way #2: Message "zeus PAM_pwdb[19196]: (su) session opened for user root by nate(uid=501)" reported 3 times. I'd like to use the first way. The ouput of logcheck is mailed to me every hour, and the messages average about 300 lines. With this feature I could reduce that drastically. I want ideas on the best way to implement this feature. My first thought is to create a hash for each hostname, with the hash values the log entries, but I can't use the time for a key, as many log messages have the same time. I have a feeling that I may need to look into using multidimensional hashes to implement this, but I'm not sure. That's where you guys come in ;) Thanks in advance for any advice you can lend... P.S. Bill, I didn't know that you have authored stuff on CPAN! I saw your work there the other day. You're the man. -- Nate Campi nate@campin.net my infosec favorites: www.campin.net Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From jproctor at oit.umass.edu Wed Apr 5 17:20:35 2000 From: jproctor at oit.umass.edu (j proctor) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er j proctor wrote - > I want to use perl to emulate the syslog feature that just tells you "Last > message repeated 5 times", but not just when they are one after > another. Even when the times are spread out, I could say it a couple ways > > way #1: Message "zeus PAM_pwdb[19196]: (su) session opened > for user root by nate(uid=501)" reported at 14:22:33, 14:40:29, 14:55:21 > > way #2: Message "zeus PAM_pwdb[19196]: (su) session opened for user root > by nate(uid=501)" reported 3 times. for each hostname, hash with the key as everything *but* the time, and append times to the values. That is, iterate over something like: $zeus{$event} .= ", $timestamp"; On successive(-ish) passes through the loop, you should see: $event $timestamp -------------------------------------------------- ---------- (su) session opened for user root by nate(uid=501) 14:22:33 (su) session opened for user root by nate(uid=501) 14:40:29 (su) session opened for user root by nate(uid=501) 14:55:21 At the end, s/^, // off all hash values before printing. It's quick-and-dirty, but for logs of the size you're talking about, it'll work just fine as long as the event entries are the same. If they're not (or if you're expecting a change in PID or something like that), then you can work out rules for what you want matched as the same class of event, and do a regex thang. :) Hope this helps. j Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From nate at campin.net Wed Apr 5 19:56:23 2000 From: nate at campin.net (Nate) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Nate wrote - On Wed, 5 Apr 2000, j proctor wrote: > On the jacksonville-pm-list; Jax.PM'er j proctor wrote - > for each hostname, hash with the key as everything *but* the time, and > append times to the values. That is, iterate over something like: > > $zeus{$event} .= ", $timestamp"; > > On successive(-ish) passes through the loop, you should see: > > $event $timestamp > -------------------------------------------------- ---------- > (su) session opened for user root by nate(uid=501) 14:22:33 > (su) session opened for user root by nate(uid=501) 14:40:29 > (su) session opened for user root by nate(uid=501) 14:55:21 > > At the end, s/^, // off all hash values before printing. So if I while (($key, $val) = (each @zeus)) { print "\"$key\" was reported at: $val\n"; } I'll see something like: "(su) session opened for user root by nate(uid=501)" was reported at 14:22:33, 14:22:33, 14:55:21 That's perfect (maybe without the quotes ;) > > It's quick-and-dirty, but for logs of the size you're talking about, it'll > work just fine as long as the event entries are the same. If they're not > (or if you're expecting a change in PID or something like that), then you > can work out rules for what you want matched as the same class of event, > and do a regex thang. :) The syslog file itself on the loghost reaches about 2 megs each day, but the reports are trimmed down quite a bit by logcheck before I would feed it into this perl script. Plus since it's run each hour it's not too much. Right now ony half our hosts are logging to the loghost, but once I implement this feature I'll send the logs from the rest. I just don't want to read all that mail until this is in place, as the postmaster alias already sends me about 2000 messages a day! Sheesh. Thanks J, Nate Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From bill at ASTRO.FCCJ.CC.FL.US Fri Apr 7 09:54:40 2000 From: bill at ASTRO.FCCJ.CC.FL.US (Bill Jones) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] Re: Wanted:mod_perl programers at well funded Boston B2B .com Linux house In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - No, thx, I am a little busy at the moment. I'll forward to the group. -Sneex- :] - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - > From: IngaParsons@aol.com > Date: Fri, 7 Apr 2000 05:15:03 EDT > To: bill@fccj.org > Subject: Wanted:mod_perl programers at well funded Boston B2B .com Linux house > > Any interest in a web development position with a really great Boston pre IPO > startup? They operate on a Unix platform and need senior and junior web > developers to script in Perl to develop applications. NOT shell script. In > short, must know how to write apps in perl on UNIX to Interface Apache > webserver. Perl DBI (delineation). Especially interested in Mod perl to > allow apache to executive obst. dbi perl code and db layer (SQL db layer) > e.g., "Linux Guru." C++ a Plus. Some Java script a plus. Do not need Java. > > > Please let me know whether you or someone you know is interested. > > Thanks! > > Inga > > Inga L. Parsons > President, HTH-BOSTON > tel: 781-581-2272 > fax: 781-581-2252 > IngaParsons@aol.com > Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From jproctor at oit.umass.edu Fri Apr 7 10:34:11 2000 From: jproctor at oit.umass.edu (j proctor) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] Re: Wanted:mod_perl programers at well funded Boston B2B .com Linux house In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er j proctor wrote - Wow. I got that job posting from Jax.pm before Boston or Hartford. They must really be desperate for someone who doesn't know how much programmers are worth around the Hub. :) (Well, that, or the other list admins just haven't passed it through yet). j Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From bill at fccj.org Fri Apr 7 17:54:07 2000 From: bill at fccj.org (Bill Jones) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - Did anyone see my log analyzer at CPAN? See - http://www.perl.com/CPAN-local/authors/id/S/SN/SNEEX/ -Sneex- :] - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From nate at campin.net Fri Apr 7 10:17:01 2000 From: nate at campin.net (Nate) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Nate wrote - Bill, I'll have to look at your log anayler. Perhaps you and the list can tell me how to fix this piece of my script: foreach $hash (%postfix, %mars, %jupiter, %szebra, %wwwsaigon, %sol, %mercury, %zeus ) { while(($key, $val)=(each $hash )){ $val =~ s/^, //; chomp $key; print "$val $key \n"; } } this gives me: $ perl -c test-sort.pl Type of arg 1 to each must be hash (not scalar deref) at test-sort.pl line 140, near "$hash )" test-sort.pl had compilation errors. How do I iterate over this list of hashes? -- Nate Campi nate@campin.net my infosec favorites: www.campin.net On Fri, 7 Apr 2000, Bill Jones wrote: > Date: Fri, 07 Apr 2000 18:54:07 -0400 > From: Bill Jones > To: Jax Perl Mongers > Subject: Re: [JaxPM] syslog analyzing > > On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - > > Did anyone see my log analyzer at CPAN? > > See - > > http://www.perl.com/CPAN-local/authors/id/S/SN/SNEEX/ > > -Sneex- :] > - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - > > > > Jax.PM Moderator's Note: > This message was posted to the Jacksonville Perl Monger's Group listserv. > The group manager can be reached at -- owner-jacksonville-pm-list@pm.org > to whom send all praises, complaints, or comments... > > Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From bill at fccj.org Fri Apr 7 20:20:37 2000 From: bill at fccj.org (Bill Jones) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - Perl Cookbook: 5.4. Traversing a Hash Problem You want to perform an action on each entry (i.e., each key-value pair) in a hash. Solution Use each with a while loop: while(($key, $value) = each(%HASH)) { # do something with $key and $value } Or use keys with a foreach loop, unless the hash is potentially very large: foreach $key (keys %HASH) { $value = $HASH{$key}; # do something with $key and $value } Discussion Here's a simple example, iterating through the %food_color hash from the introduction. # %food_color per the introduction while(($food, $color) = each(%food_color)) { print "$food is $color.\n"; } Banana is yellow. Apple is red. Carrot is orange. Lemon is yellow. foreach $food (keys %food_color) { my $color = $food_color{$food}; print "$food is $color.\n"; } Banana is yellow. Apple is red. Carrot is orange. Lemon is yellow. We didn't really need the $color variable in the foreach example because we only use it once. Instead, we could have just written: print "$food is $food_color{$food}.\n" Every time each is called on the same hash, it returns the "next" key-value pair. We say "next" because the pairs are returned in the order the underlying lookup structure imposes on them, and this order is almost never alphabetic or numeric. When each runs out of hash elements, it returns the empty list (), which tests false and terminates the while loop. The foreach example uses keys, which constructs an entire list containing every key from hash, before the loop even begins executing. The advantage to using each is that it gets the keys and values one pair at a time. If the hash contains many keys, not having to pre-construct a complete list of them can save substantial memory. The each function, however, doesn't let you control the order in which pairs are processed. Using foreach and keys to loop over the list lets you impose an order. For instance, if we wanted to print the food names in alphabetical order: foreach $food (sort keys %food_color) { print "$food is $food_color{$food}.\n"; } Apple is red. Banana is yellow. Carrot is orange. Lemon is yellow. This is a common use of foreach. We use keys to obtain a list of keys in the hash, and then we use foreach to iterate over them. The danger is that if the hash contains a large number of elements, the list returned by keys will use a lot of memory. The trade-off lies between memory use and the ability to process the entries in a particular order. We cover sorting in more detail in Recipe 5.9. Because keys, values, and each all use the same internal data structures, be careful about mixing calls to these functions or prematurely exiting an each loop. Each time you call keys or values, the current location for each is reset. This code loops forever, printing the first key returned by each: while ( ($k,$v) = each %food_color ) { print "Processing $k\n"; keys %food_color; # goes back to the start of %food_color } Modifying a hash while looping over it with each or foreach is, in general, fraught with danger. The each function can behave differently with tied and untied hashes when you add or delete keys from a hash. A foreach loops over a pre-generated list of keys, so once the loop starts, foreach can't know whether you've added or deleted keys. Keys added in the body of the loop aren't automatically appended to the list of keys to loop over, nor are keys deleted by the body of the loop deleted from this list. Example 5.1 reads a mailbox file and reports on the number of messages from each person. It uses the From: line to determine the sender. (It isn't smart in this respect, but we're showing hash manipulation, not mail-file processing.) Supply the mailbox filename as a command-line argument, or use "-" to indicate you're piping the mailbox to the program. Example 5.1: countfrom #!/usr/bin/perl # countfrom - count number of messages from each sender $filename = $ARGV[0] || "-"; open(FILE, "<$filename") or die "Can't open $filename : $!"; while() { if (/^From: (.*)/) { $from{$1}++ } } foreach $person (sort keys %from) { print "$person: $from{$person}\n"; } See Also The each and keys functions in perlfunc (1) and in Chapter 3 of Programming Perl; we talk about for and foreach in Recipe 4.5 - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - > From: Nate > Date: Fri, 7 Apr 2000 08:17:01 -0700 (PDT) > To: Bill Jones > Cc: Jax Perl Mongers > Subject: Re: [JaxPM] syslog analyzing > > On the jacksonville-pm-list; Jax.PM'er Nate wrote - > > How do I iterate over this list of hashes? Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From nate at campin.net Fri Apr 7 17:56:03 2000 From: nate at campin.net (Nate) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Nate wrote - Bill, Am I missing something? I don't see where it tells you how to use each on each of a _list_ of hashes. My code was like this pseudocode: foreach $hash (in list of %hases) while (($key, $val)=(each $hash)) { # do something to/with the hash that $hash references; } } I get errors about how the argument to each() must be a hash, not a scalar dereference. I want to iterate over a list of hashes so I don't have to cut and paste the same while loop for each hash. There must be a way to do this. -- Nate Campi nate@campin.net my infosec favorites: www.campin.net Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From jproctor at oit.umass.edu Sat Apr 8 08:03:56 2000 From: jproctor at oit.umass.edu (j proctor) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er j proctor wrote - > foreach $hash (%postfix, %mars, %jupiter, %szebra, %wwwsaigon, > %sol, %mercury, %zeus ) { > while(($key, $val)=(each $hash )){ > [...] > > Type of arg 1 to each must be hash (not scalar deref) at test-sort.pl line > 140, near "$hash )" > test-sort.pl had compilation errors. I think, because you're trying to assign a list of hashes in turn to a scalar, that foreach is actually giving you a reference to each hash instead. Since I'm pretty sure foreach %hash... won't work, what you need to do is tell the each that you're giving it a hash ref instead of an actual hash. Well, more precisely, to dereference it back to a hash. Try this: while(($key, $val)=(each %{$hash} )){ Caution: it's Saturday morning, and I neither drink coffee on Saturdays nor usually attempt to code before noon or so. :) j Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From jproctor at oit.umass.edu Sat Apr 8 08:10:07 2000 From: jproctor at oit.umass.edu (j proctor) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er j proctor wrote - > foreach $hash (%postfix, %mars, %jupiter, %szebra, %wwwsaigon, > %sol, %mercury, %zeus ) { > while(($key, $val)=(each $hash )){ > [...] > > Type of arg 1 to each must be hash (not scalar deref) at test-sort.pl line > 140, near "$hash )" P.S. When quoting code and error messages that have line numbers, it's often useful to actually put the line number in, too, so we don't get confused about *which* $hash (for instance) is causing the problem. :) Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From jacksonville-pm-list at happyfunball.pm.org Sat Apr 8 11:58:42 2000 From: jacksonville-pm-list at happyfunball.pm.org (Jax PM Moderator) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] unsubscribe jacksonville-pm-list neomancer@linuxmail.org In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Jax PM Moderator wrote - unsubscribe jacksonville-pm-list neomancer@linuxmail.org Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From bill at fccj.org Sat Apr 8 12:05:16 2000 From: bill at fccj.org (Bill Jones) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - No, I am missing something :) Try this code: # Note that this is NOT -w safe... my @hash = (%postfix, %mars, %jupiter, %szebra, %wwwsaigon, %sol, %mercury, %zeus); for $i (0 .. $#hash) { while(($key, $val)=(each %{ $hash[$i] } )){ $val =~ s/^, //; chomp $key; print "$val $key \n"; } } HTH, -Sneex- :] - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - > From: Nate > Date: Fri, 7 Apr 2000 15:56:03 -0700 (PDT) > To: Bill Jones > Cc: jacksonville-pm-list@happyfunball.pm.org > Subject: Re: [JaxPM] syslog analyzing > > On the jacksonville-pm-list; Jax.PM'er Nate wrote - > > Bill, > > Am I missing something? I don't see where it tells you how to use each on > each of a _list_ of hashes. Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From sml at zfx.com Mon Apr 10 17:37:55 2000 From: sml at zfx.com (Steve Lane) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] syslog analyzing References: Message-ID: <38F257C3.7D55@zfx.com> On the jacksonville-pm-list; Jax.PM'er Steve Lane wrote - j proctor wrote: > > On the jacksonville-pm-list; Jax.PM'er j proctor wrote - > > > foreach $hash (%postfix, %mars, %jupiter, %szebra, %wwwsaigon, > > %sol, %mercury, %zeus ) { > > while(($key, $val)=(each $hash )){ > > > [...] > > > > Type of arg 1 to each must be hash (not scalar deref) at test-sort.pl line > > 140, near "$hash )" > > test-sort.pl had compilation errors. > > I think, because you're trying to assign a list of hashes in turn to a > scalar, that foreach is actually giving you a reference to each hash > instead. Since I'm pretty sure foreach %hash... won't work, what you need > to do is tell the each that you're giving it a hash ref instead of an > actual hash. Well, more precisely, to dereference it back to a hash. > Try this: > > while(($key, $val)=(each %{$hash} )){ this is wrong. $hash is -not- a hash reference, it's a key or value from the hashes in the foreach () that got "smoothed out" to a plain list. that's basic perl: arrays and hashes inside a list lose their array- or hash-identity and all the values are merged into a single list. what you need to do is make sure that $hash is a hashref. you can do this is two ways: # backslash each hash foreach $hash (\%postfix, \%mars, \%jupiter, \%szebra, \%wwwsaigon, \%sol, \%mercury, \%zeus) { # backslash the entire list of hashes, which works because # backslashing a list is distributive foreach $hash (\(%postfix, %mars, %jupiter, %szebra, %wwwsaigon, %sol, %mercury, %zeus)) { P.S. the error "Type of arg 1 to each must be hash (not scalar deref)" may be confusing here. you get this error if you use each() on any scalar, not just references: $ perl -e '$a = 1; while (each $a) { }' Type of arg 1 to each must be hash (not scalar deref) at -e line 1, near "$a) " Execution of -e aborted due to compilation errors. $ perl -e '$a = {}; while (each $a) { }' Type of arg 1 to each must be hash (not scalar deref) at -e line 1, near "$a) " Execution of -e aborted due to compilation errors. the error would probably be improved if it said just "scalar" instead of "scalar deref" in appropriate situations, but i'm not excited enough about that to complain to P5P. -- Steve Lane Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From bill at fccj.org Sun Apr 30 11:48:28 2000 From: bill at fccj.org (Bill Jones) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] FW: Stupid questions ... ? In-Reply-To: Message-ID: On the jacksonville-pm-list; Jax.PM'er Bill Jones wrote - Hi All :] Let me spring this on you programmers (and NON-Programmers alike :) Pls forward your thoughts about this; I would be most interested. Thx! -Sneex- :] - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - ---------- > From: Bill Jones > Date: Sun, 30 Apr 2000 12:41:20 -0400 > Subject: Stupid questions ... ? > > (Or - Are there ANY stupid questions?!?) > > Hi, Would you consider this a stupid question? > > Someone asked me: > "How can I convert Letters to Numbers?" > > I said "Why would you want to?" > > They said "Can it be done?" > > I said: Yes ... > > $_ = "This converts Letters 2 Numbers."; > $_ =~ s/\G(\s*)(\S+\s*)/{ > foreach $chr ((split('',$2))) { > print $chr . ' is ' . (ord(uc($chr)) - 64) . "\n"; > } }/ge; > print; > > Here is the output: > T is 20 > h is 8 > i is 9 > s is 19 > is -32 > c is 3 > o is 15 > n is 14 > v is 22 > e is 5 > r is 18 > t is 20 > s is 19 > is -32 > L is 12 > e is 5 > t is 20 > t is 20 > e is 5 > r is 18 > s is 19 > is -32 > 2 is -14 > is -32 > N is 14 > u is 21 > m is 13 > b is 2 > e is 5 > r is 18 > s is 19 > . is -18 > > > But, again "Why?" > > What do you think about this? I think I am glad I am not alone -- > I cannot think of any good reason to convert letters to numbers... > > ??? > -Sneex- :] > - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments... From rrinker at exchange.fccj.org Sun Apr 30 12:09:31 2000 From: rrinker at exchange.fccj.org (RINKER, ROBERT E) Date: Thu Aug 5 00:02:34 2004 Subject: [JaxPM] RE: Stupid questions ... ? Message-ID: On the jacksonville-pm-list; Jax.PM'er "RINKER, ROBERT E" wrote - been there, done that. I call it ASCII, or EBCDIC, or even UNICODE. Bsides, when you talk about computer data, there are ONLY numbers (and only 2 of them at that!) -----Original Message----- From: Bill Jones To: rrinker@fccj.org; jtrifile@fccj.org Cc: jacksonville-pm-list@happyfunball.pm.org Sent: 4/30/00 12:48 PM Subject: FW: Stupid questions ... ? Hi All :] Let me spring this on you programmers (and NON-Programmers alike :) Pls forward your thoughts about this; I would be most interested. Thx! -Sneex- :] - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - ---------- > From: Bill Jones > Date: Sun, 30 Apr 2000 12:41:20 -0400 > Subject: Stupid questions ... ? > > (Or - Are there ANY stupid questions?!?) > > Hi, Would you consider this a stupid question? > > Someone asked me: > "How can I convert Letters to Numbers?" > > I said "Why would you want to?" > > They said "Can it be done?" > > I said: Yes ... > > $_ = "This converts Letters 2 Numbers."; > $_ =~ s/\G(\s*)(\S+\s*)/{ > foreach $chr ((split('',$2))) { > print $chr . ' is ' . (ord(uc($chr)) - 64) . "\n"; > } }/ge; > print; > > Here is the output: > T is 20 > h is 8 > i is 9 > s is 19 > is -32 > c is 3 > o is 15 > n is 14 > v is 22 > e is 5 > r is 18 > t is 20 > s is 19 > is -32 > L is 12 > e is 5 > t is 20 > t is 20 > e is 5 > r is 18 > s is 19 > is -32 > 2 is -14 > is -32 > N is 14 > u is 21 > m is 13 > b is 2 > e is 5 > r is 18 > s is 19 > . is -18 > > > But, again "Why?" > > What do you think about this? I think I am glad I am not alone -- > I cannot think of any good reason to convert letters to numbers... > > ??? > -Sneex- :] > - FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 - Jax.PM Moderator's Note: This message was posted to the Jacksonville Perl Monger's Group listserv. The group manager can be reached at -- owner-jacksonville-pm-list@pm.org to whom send all praises, complaints, or comments...