[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

list context in assignment ?



[jimc@harpo bleadperl]$ ./perl -de 1

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):    1
                                                                                               

   DB<1> @a=1,2;
                                                                                              

   DB<2> p $a[1]
                                                                                              

   DB<3> p $]
5.011000
                                                                                              

    DB<4>


Vs this

     DB<7> @a=(1,2);

     DB<8> p $a[1] 
2

     DB<9>


What surprises me is that the ()s are necessary.

I thought assignments were list context by default,
and surely both sides are lists ?




[jimc@harpo bleadperl]$ ./perl -V
Summary of my perl5 (revision 5 version 11 subversion 0 patch 33601) 
configuration:
  Platform:
    osname=linux, osvers=2.6.24.3-50.fc8, archname=i686-linux-thread-multi
    uname='linux harpo.jimc.earth 2.6.24.3-50.fc8 #1 smp thu mar 20 
14:47:10 edt 2008 i686 i686 i386 gnulinux '
    config_args='-des -Dusedevel -DDEBUGGING=both -Dusethreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING 
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING 
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include 
-I/usr/include/gdbm'
    ccversion='', gccversion='4.1.2 20070925 (Red Hat 4.1.2-33)', 
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_TRACK_MEMPOOL USE_ITHREADS USE_LARGE_FILES
                        USE_PERLIO USE_REENTRANT_API
  Locally applied patches:
    DEVEL
  Built under linux
  Compiled at Sep 30 2008 20:42:25
  @INC:
    /usr/local/lib/perl5/5.11.0/i686-linux-thread-multi
    /usr/local/lib/perl5/5.11.0
    /usr/local/lib/perl5/site_perl/5.11.0/i686-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.11.0
    /usr/local/lib/perl5/site_perl
    .
[jimc@harpo bleadperl]$


Follow-Ups from:
chromatic <chromatic@wgz.org>
Moritz Lenz <moritz@casella.verplant.org>
Ricardo SIGNES <perl.p5p@rjbs.manxome.org>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]