Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. N3wb1e

    Problem with adding variables

    Thanks for the link, that will definitely help. I am now having the same trouble as I did before... #!/usr/bin/perl $str = 12; $rec = { name => "Anonymous", age => 25, strmod => statmod($str), }; print $rec->{name}."\n"; print $rec->{strmod}."\n";##comes out to 1 $str = 14; print...
  2. N3wb1e

    Problem with adding variables

    Wow, I feel stupid. I tried using: $total = sub{$var + $var2} But was having trouble printing and referencing $total elsewhere in the program, and just realized I was making syntax errors. This is for a D&D style RPG I've been writing in my spare time. I have a large list of variables (around...
  3. N3wb1e

    Problem with adding variables

    I suppose I could take that approach... Do you know if there is any way I could do this with dereferencing? The following works: $number = 2; $something = /$number; print $$something; $number = 3; print $$something I can't seem to get it to work when $something is equal to two variables added.
  4. N3wb1e

    Problem with adding variables

    I'm very new to perl, and I'm having trouble with the following script: #!perl $firstnum = 3; $secondnum = 2; $total = $firstnum + $secondnum; print $total; ##comes out to 5 $firstnum = 6; print $total; ##comes out to 5 (I know why) - but I want to come out to 8 How do I write this so...

Part and Inventory Search

Back
Top