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

Re: [PBML] print<

Expand Messages
  • Etienne Marcotte
    I tryed some different things let s say I have sub print{ my $foo = $_[0]; my $bar = $_[1]; print
    Message 1 of 3 , Nov 1, 2001
      I tryed some different things

      let's say I have

      sub print{
      my $foo = $_[0];
      my $bar = $_[1];
      print<<END;
      some text
      $foo
      some more text
      $bar
      END
      }

      If i send 2 variable argument to the function it's fine.
      If I send only one and explicitly declare $bar = "baz"; it works
      If I use my $bar = ($_[1] ne "") ? $_[1] : "baz"; it doesn't work (well it
      works but there is still the warning)

      The thing is that the second argument sent to the sub is optionnal...
      I think I'll have to live with some warnings...

      Etienne

      Richard Taylor wrote:

      > Don't ask me why it happens. But check that your whole entire block,
      > including the print tags are left aligned. I was toying with this for a
      > while and this was the one thing that seemed to magically work (most of the
      > time?)
      >
      > Richard
      >
      > ----- Original Message -----
      > From: "Etienne Marcotte" <emarcott@...>
      > To: <perl-beginner@yahoogroups.com>
      > Sent: Wednesday, October 31, 2001 6:49 AM
      > Subject: [PBML] print<<END; = Use of uninitialized value
      >
      > > When I put warnings on and have a block of printed text with
      > >
      > > print<<END;
      > > or print<<"END";
      > >
      > > it gives me a warning "Use of uninitalized value at (filename)
      > > (linenumber)
      > >
      > > Any clue how to get rid of this?
      > >
      > > Etienne
      > >
      > >
      > >
      > >
      > >
      > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      > >
      > >
      > >
      >
      >
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Damien Carbery
      ... No way. Here is a way to avoid warnings: sub print( $;$ ) # The $:$ is optional - it s like a prototype. { my $foo = shift; my $bar = shift; $bar =
      Message 2 of 3 , Nov 1, 2001
        > I think I'll have to live with some warnings...
        No way.

        Here is a way to avoid warnings:

        sub print( $;$ ) # The '$:$' is optional - it's like a prototype.
        {
        my $foo = shift;
        my $bar = shift;
        $bar = "baz" if ( ! defined $bar );
        ....
        }

        --- In perl-beginner@y..., "Etienne Marcotte" <emarcott@i...> wrote:
        > I tryed some different things
        >
        > let's say I have
        >
        > sub print{
        > my $foo = $_[0];
        > my $bar = $_[1];
        > print<<END;
        > some text
        > $foo
        > some more text
        > $bar
        > END
        > }
        >
        > If i send 2 variable argument to the function it's fine.
        > If I send only one and explicitly declare $bar = "baz"; it works
        > If I use my $bar = ($_[1] ne "") ? $_[1] : "baz"; it doesn't work
        (well it
        > works but there is still the warning)
        >
        > The thing is that the second argument sent to the sub is
        optionnal...
        > I think I'll have to live with some warnings...
        >
        > Etienne
        >
        > Richard Taylor wrote:
        >
        > > Don't ask me why it happens. But check that your whole entire
        block,
        > > including the print tags are left aligned. I was toying with
        this for a
        > > while and this was the one thing that seemed to magically work
        (most of the
        > > time?)
        > >
        > > Richard
        > >
        > > ----- Original Message -----
        > > From: "Etienne Marcotte" <emarcott@i...>
        > > To: <perl-beginner@y...>
        > > Sent: Wednesday, October 31, 2001 6:49 AM
        > > Subject: [PBML] print<<END; = Use of uninitialized value
        > >
        > > > When I put warnings on and have a block of printed text with
        > > >
        > > > print<<END;
        > > > or print<<"END";
        > > >
        > > > it gives me a warning "Use of uninitalized value at (filename)
        > > > (linenumber)
        > > >
        > > > Any clue how to get rid of this?
        > > >
        > > > Etienne
      Your message has been successfully submitted and would be delivered to recipients shortly.