On Tue, Apr 04, 2000 at 06:39:07PM +0200, Marek Stepanek wrote: } } Hello dear Perlers, } } } I know, that normally as a newbie on a mailing list, you have first to } lurk some } weeks, and than you have to meditate for a long while your first } question. But I am } so "hot" to learn more Perl, that I dare to bust in, hoping to find } someone, who } could help me in my first steps in MacPerl perhaps even privately, if } this group is } not adapted to such a beginner level. } } So here my Problem: in the BBEdit list, many times the book "Mastering } Regular } Expressions", from Jeffrey Friedl were recommended to learn Perl. Now I } am trying } to learn with the first examples from this book, but the scripts are not } working as } they are supposed to work. On pages > 38 I found this example to convert } Celsius to } Fahrenheit. Unfortunately, the script has a mistake in it. I hope you've copied it accurately here. Check O'Reilly's Web site, since they usually post errata there, and also the scripts from their books. The book is also pretty old, and no longer really covers modern Perl regex. But since MacPerl is also pretty old, that doesn't matter all that much. } } #!perl -w } print "Enter a temperature in Celsius (i.e. 32 F, 100F):\n"; } $celsius = <STDIN>; } chop ($celsius); } if ($input =~ m/^([-+]?[0-9]+(\.[0-9]*)?)\s*([CF]?)$/i) Note that this is the first time that $input appears, so it's empty. There's nothing for the regex to match against. } { } $InputNum= $1; } $type = $3; } if ($type eq "C" or $type eq "c") { $celsius = $InputNum; } $celsius = ($fahrenheit - 32) * 5 / 9; Why does it convert Farenheit to Celsius even if it's given a Celsius temperature? } } else { } $fahrenheit = $InputNum; } $celsius = ($fahrenheit - 32) * 5 / 9; } } } printf "%.2f C = %.2F\n.", $celsius, $fahrenheit; } } else { } print "expecting a number, so don't understand \"$input\".\n"; } } } } I get the following answer, but I do not understand anything of it. (I } think the } regex ($input =~ m/^([-+]?[0-9]+(\.[0-9]*)?)\s*([CF]?)$/i) is al right } like } that???) Change the two $input to $celsius. Then you'll get output. It won't exactly be right, though, unless you fix the other problems. } } } } } Enter a temperature in Celsius (i.e. 32 F, 100F): } + 34 C } # Use of uninitialized value, <STDIN> chunk 1. } File 'Macintosh HD:Programme:Programmetext:BBEdit 5.0:MacPerl } Support:Perl } Scripts:celsiustofahrnheit2.pl'; Line 5 } # Use of uninitialized value, <STDIN> chunk 1. } File 'Macintosh HD:Programme:Programmetext:BBEdit 5.0:MacPerl } Support:Perl } Scripts:celsiustofahrnheit2.pl'; Line 5 } expecting a number, so don't understand "". } } Could someone be so nice, and put me on the right way to conquer this } fascinating } new world of Perl scripting? } } Thank you in advance, about your help and your patience! } } Greetings from Paris, nice spring weather out here } } Marek } } -- } *************************************************** } } Podium International } } Marek Stepanek } 12, rue du Lys } F-77150 Lésigny } France } } Phone: ++33/1-60 02 05 07 } mstep@PodiumInternational.org } http://www.PodiumInternational.org } } the embassy for talented young musicians } } *************************************************** } } } # ===== Want to unsubscribe from this list? } # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org } } -- Paul Schinder schinder@pobox.com # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org