Wrox Programmer Forums
Intro Programming What is a loop? Which language is best for beginners? What is "object oreinted?" All those types of questions and more are welcome here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Intro Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 24th, 2006, 07:53 AM
Registered User
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to philrobeson
Default Help with learning perl

I'm doing a program out of a book teaching me perl (I'm new to programming). The program is this:

#!/usr/bin/perl -w
use strict;
use warnings;
$a = "A9"; print ++$a, "\n";
$a = "bz"; print ++$a, "\n";
$a = "Zz"; print ++$a, "\n";
$a = "z9"; print ++$a, "\n";
$a = "9z"; print ++$a, "\n";

It works fine, but I really do not understand why the last line prints as "10" when, following the logic in the book and the previous lines, my thought would be it would print "0a". Can someone please explain this to me?


Reply With Quote
  #2 (permalink)  
Old January 18th, 2007, 04:39 PM
Registered User
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Phil,

I also struggled with this one. After having googled "perl 9z 10", I found the solution: perl finds a 9, and thats the number it increments; so in this case it does not regard the whole string.
It's probably more clear if you try
   $a = "8z"; print ++$a, "\n";

Good luck with your Perl course.

Reply With Quote
  #3 (permalink)  
Old January 26th, 2007, 12:57 PM
Friend of Wrox
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts

BTW, you don't need the -w in your perl string if you're doing
use warnings;
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
E-learning dineshv Flash (all versions) 1 January 4th, 2007 01:35 AM
learning Perl and running script on WinXP Pro IIS crmpicco Perl 4 December 1st, 2006 12:53 PM
Learning C# Jael C# 1 October 19th, 2005 07:54 PM
E-Learning dineshv Flash (all versions) 1 April 1st, 2005 03:12 PM
i am learning kuehhc Beginning PHP 4 March 29th, 2004 04:33 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.