LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-05-2002, 10:16 AM   #1
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Rep: Reputation: 30
perl: question about postincrementing


from a perl tutorial i have been looking at i am puzzled why i get the results:

[chijtska@chijtska perl]$ perl operator.pl
Two $nums are 10 * 2 and adding one to $var makes Perl++
Two $nums are 20 and adding one to $var makes Perl

here of course are the lines of code:

$num=10;
print "Two \$nums are $num * 2 and adding one to \$var makes $var++\n";
print "Two \$nums are ", $num * 2," and adding one to \$var makes ",
$var++,"\n";

why did $var come out as Perl++ instead of Perm? Yes, I have read the section in the tutorial about it but it doesnt give a satisfactory answer...

thanks
 
Old 02-05-2002, 10:29 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
camelfudged

huh? the first one is printed as perl++ as ++ is just a text strign in that case... i don't follow what you mean..

nice to see a questions actually abuot programming on this forum for once...
 
Old 02-05-2002, 10:37 AM   #3
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Original Poster
Rep: Reputation: 30
the reason i ask is that when you designate $var++ (when $var="perl") youre supposed to get "perm", right?

sorry i wasnt clear
 
Old 02-05-2002, 10:38 AM   #4
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Original Poster
Rep: Reputation: 30
shoot!--- nevermind... i get it... $var was never given the value "perl"... ok i was making too big a deal out of it
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
a perl question thanhVic Programming 1 03-13-2005 02:45 AM
Hiding code in PERL, perl gui question randomx Programming 1 06-26-2004 03:22 PM
perl question eph Programming 4 04-04-2004 09:51 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Perl question isajera Programming 2 07-23-2001 02:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration