Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broken "@{ [] }" parsing #1768

Closed
p5pRT opened this issue Apr 4, 2000 · 3 comments
Closed

broken "@{ [] }" parsing #1768

p5pRT opened this issue Apr 4, 2000 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 4, 2000

Migrated from rt.perl.org#3022 (status was 'resolved')

Searchable as RT3022$

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2000

From gbacon@itsc.uah.edu

Created by gbacon@ruby.itsc.uah.edu

The parser does not accept the following program​:

  [12​:25] ruby% cat -n try
  1 #! /usr/bin/perl -w
  2
  3 use strict;
  4
  5 my $num = 1;
  6 my $den = 3;
  7
  8 my @​array;
  9 push @​array, (100*$num/$den);
  10
  11 print "array​: (@​{ [ map sprintf("%.2f", $_), @​array ] })\n";
  [12​:25] ruby% perl -cw try
  syntax error at try line 11, at EOF
  Missing right curly or square bracket at try line 11, within string
  try had compilation errors.

A small change results in a different error​:

  [12​:26] ruby% cat -n try
  1 #! /usr/bin/perl -w
  2
  3 use strict;
  4
  5 my $num = 1;
  6 my $den = 3;
  7
  8 my @​array;
  9 push @​array, (100*$num/$den);
  10
  11 print "array​: (@​{ [ map { sprintf "%.2f", $_ } @​array ] })\n";
  [12​:26] ruby% perl -cw try
  Not enough arguments for sprintf at try line 11, at EOF
  Missing right curly or square bracket at try line 11, within string
  syntax error at try line 11, at EOF
  try had compilation errors.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.6.0:

Configured by gbacon at Thu Mar 23 11:26:18 CST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.5-15, archname=i686-linux
    uname='linux ruby.itsc.uah.edu 2.2.5-15 #1 mon apr 19 23:00:46 edt 1999 i686 unknown '
    config_args='-des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.1.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /usr/local/lib/perl5/5.6.0/i686-linux
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i686-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/gbacon
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/nmh/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/usr/local/jdk1.2/bin:/home/gbacon/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented May 1, 2003

From @iabyn

(just closing old perl bugs)

The orignal report was that

print "array​: (@​{ [ map sprintf("%.2f", $_), @​array ] })\n";

gave a syntax error.

This is because the inner quotes need escaping, ie

print "array​: (@​{ [ map sprintf(\"%.2f\", $_), @​array ] })\n";

Regards,

Dave M.

@p5pRT
Copy link
Author

p5pRT commented May 1, 2003

@iabyn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant