using a variable as the name for an array ex: @$var

Hello everyone,

I was wondering if anyone has ran into this problem before.

I'm passing a name to a function and then I want to create an array with that name.

something like:

sub fn {
$temp = @_[0];
@$temp[0] = "blah";
}

It doesn't want to let me do this, any advice, ideas, suggestions?

Thanks alot.

Isaac Vetter
Centre College

Comments

  • : Hello everyone,
    :
    : I was wondering if anyone has ran into this problem before.
    :
    : I'm passing a name to a function and then I want to create an array with that name.
    :
    : something like:
    :
    : sub fn {
    : $temp = @_[0];
    : @$temp[0] = "blah";
    : }
    :
    : It doesn't want to let me do this, any advice, ideas, suggestions?
    :
    : Thanks alot.
    :
    : Isaac Vetter
    : Centre College
    :

    Use an eval block
    -----------------------
    [RED]Heero Yuy
    Perl Board Moderator
    Perl Semi-Expert[/RED]

  • : Hello everyone,
    :
    : I was wondering if anyone has ran into this problem before.
    :
    : I'm passing a name to a function and then I want to create an array with that name.
    :
    : something like:
    :
    : sub fn {
    : $temp = @_[0];
    : @$temp[0] = "blah";
    : }
    :
    : It doesn't want to let me do this, any advice, ideas, suggestions?
    :
    : Thanks alot.
    :
    : Isaac Vetter
    : Centre College
    :
    I'm not familiar with have the '@' and '$' in front of the variable but that doesn't mean much. Make sure this is what you want to do. If not, and you are wanting to assign to the first element of an array, then this should be ok:
    $temp[0] = "whatever";

    $temp[0] and $temp are 2 different variables in Perl.

    X
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories