Re: Perl trainer requests beginner help

2002-02-10 Thread Michael R. Wolf
[EMAIL PROTECTED] (Michael R. Wolf) writes: > I'd like a few volunteers to take a test that I've put > together for an "Introduction to Perl" class that I teach. > If you are a beginner or recent "graduate" of an intro > course and have a few minutes,

Re: is false self-evident? [was Re: Perl trainer requests beginner help]

2002-02-10 Thread Michael R. Wolf
e of reusable subroutines and methods. I often think, "How do I want to return false/failure? There's only 4 of 'em, which one makes most sense in this context? Now that I've figured out the false/failure mode, the true/success value is much easier". -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: is false self-evident? [was Re: Perl trainer requests beginner help]

2002-02-10 Thread Michael R. Wolf
[EMAIL PROTECTED] (John W. Krahn) writes: > "Michael R. Wolf" wrote: > > > > [EMAIL PROTECTED] (John W. Krahn) writes: > > > > > > Are you sure there are only three? :-) > > > > > > $ perl -le' > > > print qq(undef is

is false self-evident? [was Re: Perl trainer requests beginner help]

2002-02-02 Thread Michael R. Wolf
[EMAIL PROTECTED] (John W. Krahn) writes: > "Michael R. Wolf" wrote: > > [...] > > Any value that is not false is true. What 3 values indicate > > false? > > > Are you sure there are only three? :-) > > $ perl -le' > print qq(undef is

Re: Perl trainer requests beginner help

2002-02-02 Thread Michael R. Wolf
[EMAIL PROTECTED] (Peter Scott) writes: > At 01:15 AM 2/2/2002 -0500, Michael R. Wolf wrote: > > >I don't usually give quizes at the end of class, but a > >client of mine has requested it. (Required it in fact. No > >test, no payment!) > >[snip] > >

Re: Class data and initialization

2002-02-01 Thread Michael R. Wolf
ame of an internal member. Keep it balck-box like this sub size_of_internal_encapsulated_member { return scalar @arr; } Because this is a class method, it's not even necessary to pull off the $self parameter. The purpose of the method is just to encapsulate the implementation. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: one question to end the day on . . .

2002-02-01 Thread Michael R. Wolf
1: open (INFILE, "report.txt" ; 2: while () { 3: $line =~ /\"(.+?)\"/ ; 4: $YourTextBetweenTheQuotes = $1 ; 5: # Do whatever you want 6: } 7: close (INFILE) Seems that a WinDOS file system insinuated itself on your Perl keywords -- Michael R. Wolf Al

Perl trainer requests beginner help

2002-02-01 Thread Michael R. Wolf
== | Regular Expressions | == Supply the repetition quantifier for these convenience quantifiers: *{___,___} +{___,___} ?{___,___} Briefly describe (less than 5 words) these flags /i /g /x /o /============\ |

Re: interesting JAPH, how does this work?

2002-01-10 Thread Michael R. Wolf
gt; print ++($foo = 'a0'); # prints 'a1' => print ++($foo = 'Az'); # prints 'Ba' => print ++($foo = 'zz'); # prints 'aaa' => => The autodecrement operator, however, is not magical. I guess by "within its range" imp

formatting is a tool [[was: help with Net::POP3]]

2002-01-09 Thread Michael R. Wolf
tter. I use all the tools I can get. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Inline file edit

2002-01-09 Thread Michael R. Wolf
[EMAIL PROTECTED] (Ronald Yacketta) writes: > This works great with one exception... the two values in the sed need to be > passed into the script... > > IE: > changedbsid.pl OLDSID NEWSID filename(s) > > could be ran against 1 or more files at a time. > > I havethis which works like a champ o

Re: Inline file edit

2002-01-09 Thread Michael R. Wolf
[EMAIL PROTECTED] (Michael R. Wolf) writes: > Other alternatives include > #! /usr/bin/perl -w -i > #! /usr/bin/perl -w -i .bak > $^I = undef; Oops! May have been misleading. Here's commentary on alternatives. $^I = ''; # in-place, but no backup $^I

Re: help with Net::POP3

2002-01-09 Thread Michael R. Wolf
ple loop, it's not a big deal. Start nesting the loops, doing a copule 'o conditionals, throw a few "my" variables in one block (but try to use 'em in another) and the value of well-formatted code becomes real important. -- Michael R. Wolf All mammals learn

Re: Inline file edit

2002-01-09 Thread Michael R. Wolf
EDIT The current value of the inplace-edit extension. Use undef to disable inplace editing -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: @$

2002-01-09 Thread Michael R. Wolf
ferences) into what's more comfortable (arrays). Do it often enough and you won't *need* the intermediate step any more (like me) though you'll have the freedom to *choose* either way (like me). -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: bash 'trap' equivalent ?

2002-01-09 Thread Michael R. Wolf
handler; If you merely "return" from the handler, the interrupt will get caught, handled, but *not* exit your program. Some times this is good behavior -- a C-c can do a "reset", for instance. Check out "stty -a" from the command line. C-c is probably mapped to INT

Re: pull line #1 from a file

2002-01-09 Thread Michael R. Wolf
his is in _list_ context. > my @line =; The original code was in _scalar_ context. > > my $line = ; -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Inline file edit

2002-01-09 Thread Michael R. Wolf
de wrong, you've messed it up for good. Keep backups. This is a very *powerful* statement. In the right hands it's very good, else it's very bad Something like this might work. perl -e s/_VALUETEST/_QAP2/g -i original.scr -- Michael R. Wolf All mammals learn by playing!

Re: SubRoutine Help

2002-01-07 Thread Michael R. Wolf
[EMAIL PROTECTED] (John W. Krahn) writes: > "Michael R. Wolf" wrote: [buggy code deleted ...] > $ perl -le' > @fred = qw(1 3 5 7 9); > sub total { > my $sum; > $sum += $_ foreach (@_); > } # undef from final foreach always returned!!

Re: SubRoutine Help

2002-01-06 Thread Michael R. Wolf
joy the learning exercise, Michael Answers below | | | V | | | V | | | V | | | V | | | V # Readable. sub total { my $sum; foreach my $num (@_) { $sum += $num; } return $

Re: Resume after die?

2002-01-06 Thread Michael R. Wolf
LB/Religion-1.04/Religion.pm -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: regexp to replace double with single quotes inside html tags

2002-01-06 Thread Michael R. Wolf
g to do a full-blown RE to get all the special cases would be like trying to herd cats. Don't try it but for the very simple cases. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: where to start ?

2002-01-06 Thread Michael R. Wolf
ead perldoc la, you must read perlfunc ti, no thanks I'll have a Coke that will loop us back to do.. do... do.. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

cmsg cancel

2002-01-06 Thread Michael R. Wolf
I am canceling my own article. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: call a windows application (.exe) via perl

2002-01-06 Thread Michael R. Wolf
[EMAIL PROTECTED] (Mb) writes: > I asking if there is any module to make some directives > like : runing a window appli, waiting it finish and get > the result of runing. $results = qx(whatever.exe args); $results = `whatever.exe args`; -- Michael R. Wolf All mammals learn b

Re: putback

2002-01-06 Thread Michael R. Wolf
a 1-level pushback, but it generalizes to as deep as you need. while (my $line = (pop @pushback || <>)) { ... push @pushback, $line if (your_conditions_may_vary); ... } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail:

Re: putback

2002-01-06 Thread Michael R. Wolf
a 1-level pushback, but it generalizes to as deep as you need. while (my $line = (pop @pushback || <>)) { ... push @pushback, $line if (your_conditions_may_vary); ... } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail:

Re: Print / overwrite line

2002-01-06 Thread Michael R. Wolf
ollowed by line-feed (what used to advance the paper), but without the line-feed, the characters already on the line remain. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: lexically scoped variables [was: use strict... and my auto-increment don't increase]

2002-01-06 Thread Michael R. Wolf
[EMAIL PROTECTED] (Jenda Krynicky) writes: > From: "Michael R. Wolf" <[EMAIL PROTECTED]> > > When dealing with "my", you can look at the line that > > declares it, then backup to the smallest enclosing brace. > > The variable belon

Re: lexically scoped variables [was: use strict... and my auto-increment don't increase]

2002-01-06 Thread Michael R. Wolf
[EMAIL PROTECTED] (Leon) writes: > and its happy&sad journey ends at the "the curly Heavenly > gates =>}". I like it! Appropriate for "eventualdeath" With a name like that you should get real sharp with scoping. -- Michael R. Wolf All mammals

lexically scoped variables [was: use strict... and my auto-increment don't increase]

2002-01-03 Thread Michael R. Wolf
$b++; > print "2nd while \$b = $b\n"; > }; > }; The outer one is a global variable: $main::b or $::b The inner one is a lexically scoped variable. When dealing with "my", you can look at the line that declares it, then backup to the smallest

Re: Squeezing a list

2002-01-03 Thread Michael R. Wolf
Joshua Colson <[EMAIL PROTECTED]> writes: > @NEWLIST = grep(!/^$/, @LIST); Is there a reason you're using UPPER CASE? It's not *wrong*, it's just more perl-ish style to use lower case. @newlist = grep(!/^$/, @list); And it lets your Shift key last longer.... :-) --

Re: find blank line

2002-01-02 Thread Michael R. Wolf
e). There are two solutions to your bug... # use $line while ( my $line = ) { next if ( $line =~ /^\s*$/ ); } # use $_ while ( ) { next if ( /^\s*$/ ); } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: use strict, How to 'globalised' variable within loops. (was => Re: Question!! number of line....)

2001-12-29 Thread Michael R. Wolf
n't use) is at a higher scope. Even though it's spelled the same, it's a different variable. Here's a good little example. It remembers the scalar between invocations, but doesn't allow it to be accessable outside the blocck that encloses the subroutine. { my $serial_num

Re: help on how to split a string

2001-12-29 Thread Michael R. Wolf
k your data carefully. You may be able to get away with this RE. Luck you if you can. If not, you have to use one of the CSV splitting modules. The first line works, the second one doesn't. "a", "bcd, efg, h", "c" a,"bcd, efg, h",c -- Michael R. W

Re: help on how to split a string

2001-12-29 Thread Michael R. Wolf
", "bcd, efg, h", "c"'; @words = parse_line(",", 0, $line); foreach (@words) { printf "%d. <%s>\n", $index++, $_; } Should print: 1. 2. 3. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Subject line suggestion for "newbies"

2001-12-29 Thread Michael R. Wolf
at you are missing, or at least know what direction it is. People like helping people that are helping themselves. Don't put up a post that reeks of "I'm helpless". We all started out at "ignorant" and are still there on some subject; "ignorant" merely m

reinventing "The Book" [ was: Good CS Literature

2001-12-29 Thread Michael R. Wolf
that I vaguely remember. I use it less now that I have the Perl CD, since it's searchable. But I still use the paper books, and would not substitute the CD for the paper. They complement each other very well. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Multiple Key,Value Pairs?

2001-12-28 Thread Michael R. Wolf
7;2'], 'kelty' => ['3'], 'biran' => ['4'] ); foreach $fn (keys %hash) { printf "key: '%s'\n\tvalue(s): [%s]\n", $fn, join ", " => @{$hash{$fn}}; } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Good CS Literature

2001-12-28 Thread Michael R. Wolf
ute broken software into broken software is something worth remembering. We call it playing with code, but it's really a code word for learning -- take a look at my signature file, and have fun. Computers have been a continual mental exercise, and larning adventure for me. Good luck on your ad

Re: Shift question...

2001-12-21 Thread Michael R. Wolf
lue. If ARRAY is omitted, the function shifts @ARGV (in the main program), or @_ (in subroutines). See also unshift, push, pop, and splice. The shift and unshift functions do the same thing to the left end of an array that pop and push do to the right end. -- Michael R. Wolf All mammals lea

Re: Counting the size of an array reference

2001-12-21 Thread Michael R. Wolf
a scalar context. $MyLen = @MyArray; or print "Length of array is: ", scalar(@MyArray) -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: split

2001-12-21 Thread Michael R. Wolf
t use Control-g as the delimiter. You can't do that here, however. I think the character must be printable. It's probably a moot point any way since it's only hard coded for the discussion. A real program would read it in a loop while(defined($line = <>)) { # whatever. } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: directing output

2001-12-21 Thread Michael R. Wolf
set. That backtick is way up in the corner -- I miss it a lot, and have to stop my normal touch-typing to get into hunt-peck mode. Who says emacs isn't modal -- I've got my home keys in touch-mode and the other keys in hunt-mode. :-) -- Michael R. Wolf All mammals learn by playing

Re: Regexp question...

2001-12-21 Thread Michael R. Wolf
art to me was the m//g in scalar context. The first time it was called (test 3) it returned qw(one two three). The second time it was called (on the same string) it started where it left off and returned qw(four five six) which is used to assign in a list context to the LHS. There being only on

Re: Deleting from a list

2001-12-21 Thread Michael R. Wolf
hat delete works on hashes, splice works on arrays. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: directing output

2001-12-21 Thread Michael R. Wolf
"John W. Krahn" <[EMAIL PROTECTED]> writes: > my $MBody = `who`; > my $MBody = qx(who); # same thing IMHO qx() is more readable. I often miss seeing the back-ticks, or see them as single-quotes during a code skim. -- Michael R. Wolf All mammals learn by playing!

Re: declarations within an if statement.

2001-12-19 Thread Michael R. Wolf
Help yourself and your readers out. Use some whitespace!!! Let form follow function. if (@ARGV == 2) { chdir $ARGV[0]; my $testfile = $ARGV[1]; } else { my $testfile = $ARGV[0]; } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-ma

Re: Print second set of keys in hash of hash...

2001-12-18 Thread Michael R. Wolf
"\n"; # Should be the same. print join("++" => $user_name, $attr_name, $attrs{$user_name}{$attr_name}; # difficult ), "\n"; } } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Should I trust Microsoft interface [was Re: Should I use Perl?]

2001-12-18 Thread Michael R. Wolf
ot;Open systems" is a *marketing* term to MS, not a *technical* term. [end rant] -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Last line of file...

2001-12-18 Thread Michael R. Wolf
n: Arrays are ordered. Diamond operator is ordered. Assigning diamond operator to array is ordered. Rely on it -- it's reliable. Code to it. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How can I send an HTML format email using send mail

2001-12-18 Thread Michael R. Wolf
Is there a html2text script that can be used to prevent the writer from creating 2 versions? This reeks of maintenance headaches. > --_=_NextPart > Content-Type: text/html; > charset="iso-8859-1" > > > > > HTML mail here > &

Re: Array Length.

2001-12-17 Thread Michael R. Wolf
ay; The scalar *is* necessary since print would otherwise provide a list context. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Array Length.

2001-12-17 Thread Michael R. Wolf
"Agustin Rivera" <[EMAIL PROTECTED]> writes: > print $#array; Off by one. That prints the last index, not the number of elements. print scalar @array If print isn't your use, try: $length = @array; $last_index = $#array; -- Michael R. Wolf All

Re: How can I send an HTML format email using send mail

2001-12-17 Thread Michael R. Wolf
Thanks for your compatability, Michael -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: summarizing a list of numbers?

2001-12-17 Thread Michael R. Wolf
ot a LIST. Therefore the following won't work. while ($f = shift sort {$a<=>$b} @list) { # Wront!!! } I can two-line it. @list = sort {$a<=>$b} @list; while ($f = shift @list) { } Can it be one-lined? -- Michael R. Wolf All mammals learn by playing! [EMAIL P

Re: summarizing a list of numbers?

2001-12-17 Thread Michael R. Wolf
mputer" languages, but (lately) they have more to do with how *we* think than how *computers* operate. I think they should be called "thinking languages" because they structure our thinking. Boole came up with such a structure long before it could be executed by cams, tubes, or silicon.

Re: Shift and "=>"

2001-12-17 Thread Michael R. Wolf
rs to wrangle up the argument I just presented but this little ditty is easy to remember. It's what I remember when I'm coding. I don't have time or gray matter to spare to remember precedence tables. Use the "word flavor" (i.e. "or") with words (like die): open HANDLE, "file" or die "why"; Use the "symbol flavor" (i.e. "||") with symbols (like "<", "<="): if ($x < 7 || $y <= 42 || $z > 99) It kinda' parallels another simple rule I have for use in comparison operators: Use the "word flavor" (i.e. "le") with words: if ("apple" le "bannana") Use the "symbol flavor" (i.e. "<=") with symbols (a stretch to mean "numbers") if (7 <= 42) And of course, with respect to parenthesis: when in doubt, whip 'em out. Extra parens never hurt. Missing ones often do. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: wildcards in perl

2001-12-17 Thread Michael R. Wolf
[EMAIL PROTECTED] writes: > > "Michael R. Wolf" <[EMAIL PROTECTED]> said: > > > Since <> is used so often in a while loop to mean the > > diamond operator, I prefer to spell out "glob" as follows. > > > > > > while (gl

Re: wildcards in perl

2001-12-16 Thread Michael R. Wolf
while (glob "sn.") { print "$_\n"; } Just a *preference*. They're both *right*. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: ascii,hex,decimal printout problem

2001-12-16 Thread Michael R. Wolf
operators. The doubles were introduced in a later version and have a much richer (super)set of operators than the single-character operators. I "parsed" the Perl [[:digit]] similarly. Now it makes sense. I can remove my "special case" rule -- it's cosistent with what

Re: Scalar Localtime

2001-12-15 Thread Michael R. Wolf
my @slice = (I don't remember); my ($hour, $minute, $second, $julian) = (time)[@slice] -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: ascii,hex,decimal printout problem

2001-12-15 Thread Michael R. Wolf
e 32..126 into zentara's printing program. Especially if it's to work in different locales. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

substr eq to string [was (incorrectly) Re: Summarizing tables]

2001-12-14 Thread Michael R. Wolf
ot;Running" (*with* the double quotes around it - *9* characters). -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Summarising tables

2001-12-14 Thread Michael R. Wolf
lus side. The minus side is that you don't have control over the open failure, so you have to be happy with the built-in version. This code is *different*, not *better* --- my %data; @ARGV = qw(/data/table1 /data/table2); while(<>) > my ( $time, $in, $out ) = split; >

Re: Regexp on variable

2001-12-13 Thread Michael R. Wolf
t. ($foo = "bar") =~ s/bar/goo/g; ($_ = "bar") =~ s/bar/goo/g; Better? I think not (therefore I am not?) Different, but not better. -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]