in reply to Re^11: Perl vs C
in thread Perl vs C

So write some code that modifies a "list". What would that be?

We're still waiting for you to show it's possible.

Some authors say that @xyz is a list and that xyz is an array variable that defines a list.

So far, I've only seen you, and that's the problem.

What's wrong with saying that @xyz is a list?

It's very confusing. It leads to contradictory statements. If we went by your definition, all of the following statements are true depending on whether you are talking about (foo,bar) or @foo.

[What's wrong with saying] that xyz in the context of @ is a list?

Now you want to redefine "context" too! What do you have against being understood.

[What's wrong with saying] that (@xyz >1) is a list in a scalar context?

You wouldn't be talking about Perl. In Perl, lists evaluate to their last element in scalar context.

print(scalar( ( 'a', 'b', 'c' ) )); # c

However, @xyz does not.

@xyz = ( 'a', 'b', 'c' ); print(scalar( @xyz )); # 3

Replies are listed 'Best First'.
Re^13: Perl vs C
by Marshall (Canon) on Mar 16, 2009 at 17:02 UTC
    Well,
    @xyz = ( 'a', 'b', 'c' ); print scalar (@xyz); #prints 3
    is what I would have expected, the number of things in @xyz.
    print(scalar( ( 'a', 'b', 'c' ) )); # c
    Is different that I would have expected.
    I will have to think more about how this occurs!
    But I will say that compared with scalar(@xyz) which happens very often, this is rare albeit interesting.
        Thanks! Great tips!

        I would say that after a quick glance, glob() is a very bad idea. I've been in "glob hell" a few times and this is a very bad place to be! Even amongst *NIX platforms there are variances and when I started doing code for WinX platforms, this became even nastier! I don't if there is a FAQ about this, but the portable way is to open a dir, read it, use grep to get what you want. Glob() is easy, but not portable.