[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] macPerl: first steps!




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.

#!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)
{
 $InputNum= $1;
 $type    = $3;
 if ($type eq "C" or $type eq "c") {
 $celsius = $InputNum;
 $celsius = ($fahrenheit - 32) * 5 / 9;
 }  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???)




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