Re: comma operator

Discussion in 'C Programming' started by Franken Sense, May 17, 2009.

  1. In Dread Ink, the Grave Hand of Uri Guttman Did Inscribe:

    >>>>>> "R" == RedGrittyBrick <> writes:

    >
    > R> Franken Sense wrote:


    [x-posted to clc]

    > >>
    > >> 100) A comma operator does not yield an lvalue.
    > >>
    > >> Is this also true in perl?

    >
    > C> perl -e "$x,$y = 42; print qq(x=$x, y=$y)"
    > R> x=, y=42
    >
    > there is no lvalue in that first statement. comma binds lower than = so
    > that was $x followed by $y = 42 which works. the problem is finding a
    > way to have a comma operator which binds tighter than =. using parens
    > won't work since that makes a list and it isn't a comma op anymore but a
    > list element separator.
    >
    > and finally WTF is franken sense asking dumb sidebar questions and
    > getting answers. he needs to focus on learning perl and not obscure side
    > issues like comma ops and lvalues (i bet he doesn't even know what the term
    > lvalue means)
    >
    > uri


    Uri Guttman responded to a post that I clearly marked as a mispost with a
    sentence that included the words "dumb ****" and seems to think the problem
    is that I get answers.

    I learn what a comma operator is when I look into it, which is now. I'm
    putting the finishing touches on a perl program that will stall now that
    I've told your snippy, presumptuous self to consult the F standard.

    I bet you don't know what F is. Tell you what, you change your modus
    operandi and give me advice about code as opposed to advise about life, and
    I'll move on.

    Why doesn't this compile:

    #!/usr/bin/perl
    # perl bb8.pl
    use warnings;
    use strict;


    my $filename3 = 'ot5.txt';
    open(my $hh, '<', $filename3) or
    die "cannot open $filename3 for reading: $!";

    # open output file
    my $filename2 = 'outfile16.txt';
    open(my $gh, '>', $filename2) or
    die "cannot open $filename2 for writing: $!";

    my %Scripts;
    my %comments;


    local $/="";

    while ( <$hh> )
    {
    my @s = split /\s+/, $_;
    my $verse = $s[0];
    my $counter = 0;

    if ($s[0] =~ m/^\d/)
    {
    my $verse = $s[0];
    my $script = join(' ', @s[1..$#s]);
    $Scripts{$verse} = $script;

    }
    else
    {
    $counter++;
    my $comment = join(' ', @s);
    $comments($counter) = $comment;
    print $_;
    }

    }


    # close input and output files

    close($hh) or die("Error closing $filename3: $!");
    close($gh) or die("Error closing $filename2: $!");


    C:\MinGW\source>perl bb8.pl
    Global symbol "$comments" requires explicit package name at bb8.pl line 39.
    syntax error at bb8.pl line 39, near "$comments("
    Execution of bb8.pl aborted due to compilation errors.

    C:\MinGW\source>
    --
    Frank

    During the Reagan Administration, Bob Dole was present at a ceremony that
    included each living ex-president. Looking at a tableau of Ford, Carter and
    Nixon, Dole said, 'There they are: Hear No Evil, See No Evil and Evil.'
    ~~ Al Franken,
     
    Franken Sense, May 17, 2009
    #1
    1. Advertising

  2. Franken Sense <> wrote in
    news:z1zk0i2r2zm1$.1v8oo1z1txoha$:

    >> and finally WTF is franken sense asking dumb sidebar questions and
    >> getting answers. he needs to focus on learning perl and not obscure
    >> side issues like comma ops and lvalues (i bet he doesn't even know
    >> what the term lvalue means)


    ....

    > Uri Guttman responded to a post that I clearly marked as a mispost
    > with a sentence that included the words "dumb ****" and seems to think
    > the problem is that I get answers.


    You might want to make thedailywtf.com your daily reading.

    Oh, and Uri never used the phrase "dumb f**k". You lied.

    Bye bye.

    Sinan

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://www.rehabitation.com/clpmisc/
     
    A. Sinan Unur, May 17, 2009
    #2
    1. Advertising

  3. Franken Sense

    Nathan Keel Guest

    Franken Sense wrote:

    > $comments($counter) = $comment;


    $comments{$counter} = $comment;
     
    Nathan Keel, May 18, 2009
    #3
    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. Paul Davis
    Replies:
    7
    Views:
    614
    Paul Davis
    Jul 17, 2003
  2. Derek
    Replies:
    6
    Views:
    381
    Old Wolf
    Apr 13, 2004
  3. Koster

    Yet another comma operator question

    Koster, Jan 16, 2004, in forum: C Programming
    Replies:
    7
    Views:
    386
    Old Wolf
    Jan 18, 2004
  4. Michael Scarlett

    the whys of the comma operator

    Michael Scarlett, Jun 10, 2004, in forum: C Programming
    Replies:
    8
    Views:
    326
    Michael Scarlett
    Jun 19, 2004
  5. G Patel

    comma operator and assignment operator

    G Patel, Feb 7, 2005, in forum: C Programming
    Replies:
    4
    Views:
    506
    Barry Schwarz
    Feb 8, 2005
Loading...

Share This Page