Concatenation

Discussion in 'Perl Misc' started by Greg, Jul 27, 2003.

  1. Greg

    Greg Guest

    Can someone give me any insight into why

    my $s = undef() . '';

    executes without complaint in my Perl 5.6 installation. But

    my $s = '' . undef();

    emits

    "Use of uninitialized value in concatenation (.) or string"

    Seems to me that I'm using an uninitialized value in either case.

    Just curious.

    Any information appreciated.

    TIA.

    Greg
     
    Greg, Jul 27, 2003
    #1
    1. Advertising

  2. Greg <> wrote:

    > Can someone give me any insight into why



    It must have been a bug.


    > my $s = undef() . '';
    >
    > executes without complaint in my Perl 5.6 installation. But
    >
    > my $s = '' . undef();
    >
    > emits
    >
    > "Use of uninitialized value in concatenation (.) or string"
    >
    > Seems to me that I'm using an uninitialized value in either case.



    5.6.1 does that for me too.

    5.8.0 issues warnings for either one.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jul 27, 2003
    #2
    1. Advertising

  3. Also sprach Greg:

    > Can someone give me any insight into why
    >
    > my $s = undef() . '';
    >
    > executes without complaint in my Perl 5.6 installation. But
    >
    > my $s = '' . undef();
    >
    > emits
    >
    > "Use of uninitialized value in concatenation (.) or string"
    >
    > Seems to me that I'm using an uninitialized value in either case.


    Yes, in both cases it's uninitialized. But the former works because it is
    treated specially. There is no warning because it would make things like
    this clumsy:

    my $var;
    for (0 .. 50) {
    # in the first iteration this is:
    # $var = undef . something()
    $var .= something();
    }

    So it's really just a convenience thing that perl wont warn when you
    append something to an unitialized variable.

    Tassilo
    --
    $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
    pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
    $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
     
    Tassilo v. Parseval, Jul 27, 2003
    #3
  4. Greg

    Greg Guest

    "Tassilo v. Parseval" <> wrote in message news:<bg1g9j$cvh$-Aachen.DE>...
    > Also sprach Greg:
    >
    > > Can someone give me any insight into why
    > >
    > > my $s = undef() . '';
    > >
    > > executes without complaint in my Perl 5.6 installation. But
    > >
    > > my $s = '' . undef();
    > >
    > > emits
    > >
    > > "Use of uninitialized value in concatenation (.) or string"
    > >
    > > Seems to me that I'm using an uninitialized value in either case.

    >
    > Yes, in both cases it's uninitialized. But the former works because it is
    > treated specially. There is no warning because it would make things like
    > this clumsy:
    >
    > my $var;
    > for (0 .. 50) {
    > # in the first iteration this is:
    > # $var = undef . something()
    > $var .= something();
    > }
    >
    > So it's really just a convenience thing that perl wont warn when you
    > append something to an unitialized variable.
    >
    > Tassilo


    Thanks for the explanation. That makes sense after a fashion, though I
    wonder if the value of this convenience balances the cost of the
    difference in behavior in the two cases.

    I guess I'm still not comfortable with the level of 'help' that Perl
    gives one.

    Greg
     
    Greg, Jul 28, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ralf Hildebrandt

    type conversion and concatenation

    Ralf Hildebrandt, Jul 23, 2003, in forum: VHDL
    Replies:
    3
    Views:
    6,687
  2. walala
    Replies:
    3
    Views:
    4,809
    walala
    Sep 18, 2003
  3. bigdipper_gary
    Replies:
    1
    Views:
    930
    Mike Treseler
    Jan 5, 2004
  4. pandora

    vector concatenation

    pandora, Apr 3, 2004, in forum: VHDL
    Replies:
    8
    Views:
    21,826
    vipinlal
    Mar 26, 2010
  5. Chad

    generic concatenation

    Chad, Aug 25, 2004, in forum: VHDL
    Replies:
    4
    Views:
    671
Loading...

Share This Page