Baz has asked for the wisdom of the Perl Monks concerning the following question:

I wish to print the value of param(0) inside quotes, so if param(0) stores 10 i want to print '10', the following code prints 'param(0)' which is fair enough but not what i want..
print("\'param(0)\'");
what should I be doing?

Replies are listed 'Best First'.
Re: print(
by jryan (Vicar) on Nov 16, 2001 at 04:00 UTC

    Param is a function, and function calls are not interpolated in double quotes like variables are (not until perl 6, anyways). You want to do this:

    print "'",param(0),"'";
(jeffa) Re: print(
by jeffa (Bishop) on Nov 16, 2001 at 03:58 UTC
    There are many ways to do this:
    print '"' . param(0) . '"'; print "'" . param(0) . "'"; my $form_value = param(0); print "'$form_value'"; print qq|'$form_value'|;
    Hope this helps ...

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)
    
Re: print(
by YuckFoo (Abbot) on Nov 16, 2001 at 03:59 UTC
    Make the return of param(0) a reference, then wrap it in ${}:

    YuckFoo

    print "${\param(0)}\n";

      If you're going to do it "inlined" like that I'd recommend putting it inside a derefed array ref.
      @{[scalar .... ]}
      As in:

      #!/usr/bin/perl -wT use strict; print "Yours: ${\localtime()}\n"; print "Mine: @{[scalar localtime() ]}\n"; __END__ =head1 OUTPUT Yours: 0 Mine: Thu Nov 15 18:27:10 2001

      -Blake