On Nov 17, Sherri said:

>#!/usr/bin/perl -w
>#This program replaces cm398p with cm498p
>use strict;
>@Classes = ("cm140", "cm325", "cm398p");
>subreplace
>{
>use $ref -> [X] = "cm498p"
>}
>replace (/@Classes);
>print @Classes;

Ok.  First, you're missing a space between 'sub' and 'replace'.  Second,
you're using 'use' in a very wrong way.  Third, you never defined $ref.
Fourth, what is X?  Fifth, you have /@Classes instead of \@Classes.

Oh, and since you're using strict, @Classes must be declared with 'my'.

Here's what I think your code was supposed to be:

  #!/usr/bin/perl -w

  use strict;

  my @Classes = ("cm140", "cm325", "cm398p");

  sub replace {
    my $ref = $_[0];
    $ref->[2] = "cm498p";
  }

  replace(\@Classes);
  print @Classes;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to