Loading ...
Sorry, an error occurred while loading the content.

Re: Sub problem

Expand Messages
  • Damien Carbery
    sub comma { my $OutputFileName = shift; print In comma function: $OutputFileName n ; } Call with: comma( $outfilename ); You don t need the & before comma
    Message 1 of 2 , Apr 2, 2001
    • 0 Attachment
      sub comma
      {
      my $OutputFileName = shift;

      print "In comma function: $OutputFileName\n";
      }

      Call with:
      comma( $outfilename );

      You don't need the '&' before 'comma' unless you are using an old
      version of Perl.

      --- In perl-beginner@y..., sxj0779@a... wrote:
      > How i can pass a scalar variable to a subroutine.
      >
      > print "Input file name:";
      > chomp($infilename = <stdin>);
      > print "Output file name:";
      > chomp($outfilename = <stdin>);
      > open (IN, $infilename) || die "cannot open $infilename for reading:
      > $!";
      > open (OUT, ">$outfilename") || die "cannot create $outfilename: $!";
      > ..............
      > more code
      >
      > &comma(i want to pass $outputfilename to sub comma);
      >
      > sub comma{
      >
      >
      > }
    Your message has been successfully submitted and would be delivered to recipients shortly.