Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > Intro Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 24th, 2006, 07:53 AM
Registered User
 
Join Date: Dec 2006
Location: Atlantic Beach, Florida, USA.
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;
#auto2.pl
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?

Thanks,

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

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.

Kees.
Reply With Quote
  #3 (permalink)  
Old January 26th, 2007, 12:57 PM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.