Your script cannot compile as you posted/pasted it. In the fifth line, you are missing a closing parenthesis:

$value = int(rand(100 ) +1);

Also, without knowing the mud environment you use, the seventh line is really quoted weird. I'm sure that the unbalanced quotes there are an error too:

&tellRoom($objects[$me]{"location:},$me,$objects[$me]{"name"} "rolled +$value."); # ^ Quote missing? # ^ Quote missing? or ^ Comma +missing?

Please consider whether your target environment really tells you compilation errors and how you can find out about them if not.

If your target environment silently swallows errors, consider developing for a different target environment or consider testing your code on a local Perl installation. You will have to fake some stuff like tellRoom then, but that's actually not too hard:

#!/usr/bin/perl -w use strict; my @objects = (); my $me = 1; $objects[$me] = { name = 'merrie' }; sub tellRoom { my ($room,$user,@msg) = @_; print "In $room: @msg\n"; }; sub hello { my ($me,) = @_; tellRoom("Here",$me,"$objects[$me]{name} says 'hello'." ); }; hello();

But you should learn much about Perl's syntax. Counter to your expectations, whitespace is important to Perl, for example, it makes little sense in Perl to write subdice100 and to expect Perl to know that you meant sub dice100. Get a good book on Perl (via http://books.perl.org) and/or read the Perl syntax description (perlsyn).


In reply to Re: Adding script to this base script? by Corion
in thread Adding script to this base script? by merrie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.