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

format problem in both 5.005.03 and 5.6.0 #1870

Closed
p5pRT opened this issue Apr 21, 2000 · 1 comment
Closed

format problem in both 5.005.03 and 5.6.0 #1870

p5pRT opened this issue Apr 21, 2000 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Apr 21, 2000

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

Searchable as RT3136$

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2000

From @Tux

As I wanted to replace symbolic references in an old perl5 script in
order to be able to anable 'use strict', I ran into a strange problem
with format.

In the old version, the variables where dynamically created and afterwards
used in a required script where the format was defined. Since the naming
of the variable was quite well suited for a re-write to an array of anonymous
hashes, that was chosen as an approach.

  while (<INPUT>) {
  chomp;
  my ($cat, $elem, $data) = split m/\s*\|\s*/, $_, 3;

  # The old way
  my $e = "e$cat$elem";
  $$e = $data;

  # The new way
  $e[$cat]{$elem} = $data;

  :
  }

Now look at using these kind of variables within formats​:

Script started on Fri Apr 21 16​:49​:45 2000
$ cat fmt-bug.pl
#!/usr/bin/perl -w

use strict;

use diagnostics;

my ($e010101, $e020202) = ("Value 1", "Value 2");
my @​e;

$e[1]{101} = $e010101;
$e[2]{202} = $e020202;

format OLD0 =
@​<<<<<<<<<< @​<<<<<<<<<<
$e010101, $e020202
.

format OLD1 =
@​<<<<<<<<<< @​<<<<<<<<<< @​<<<<<<<<<<<<<<<<<<<<<<<<<<<
$e010101, $e020202, "$e010101 $e020202"
.

format OLD2 =
@​<<<<<<<<<< @​<<<<<<<<<< @​<<<<<<<<<<<<<<<<<<<<<<<<<<<
$e010101, $e020202, uc ($e010101)
.

format NEW0 =
@​<<<<<<<<<< @​<<<<<<<<<<
$e[1]{101}, $e[2]{202}
.

format NEW1 =
@​<<<<<<<<<< @​<<<<<<<<<< @​<<<<<<<<<<<<<<<<<<<<<<<<<<<
$e[1]{101}, $e[2]{202}, "$e[1]{101} $e[2]{202}"
.

format NEW2 =
@​<<<<<<<<<< @​<<<<<<<<<< @​<<<<<<<<<<<<<<<<<<<<<<<<<<<
$e[1]{101}, $e[2]{202}, uc ($e[1]{101})
.
$ perl -c fmt-bug.pl
syntax error at fmt-bug.pl line 39, near "format NEW2 "
Missing right bracket at fmt-bug.pl line 42, at end of line
fmt-bug.pl had compilation errors (#1)
 
  (F) The final summary message when a perl -c fails.
 
Uncaught exception from user code​:
  fmt-bug.pl had compilation errors.
$ perl5.6.0 -c fmt-bug.pl
syntax error at fmt-bug.pl line 39, near "format NEW2 " (#1)
 
  (F) Probably means you had a syntax error. Common reasons include​:
 
  A keyword is misspelled.
  A semicolon is missing.
  A comma is missing.
  An opening or closing parenthesis is missing.
  An opening or closing brace is missing.
  A closing quote is missing.
 
  Often there will be another error message associated with the syntax
  error giving more information. (Sometimes it helps to turn on -w.)
  The error message itself often tells you where it was in the line when
  it decided to give up. Sometimes the actual error is several tokens
  before this, because Perl is good at understanding random input.
  Occasionally the line number may be misleading, and once in a blue moon
  the only way to figure out what's triggering the error is to call
  perl -c repeatedly, chopping away half the program each time to see
  if the error went away. Sort of the cybernetic version of S<20 questions>.
 
Missing right curly or square bracket at fmt-bug.pl line 42, at end of line (#2)
 
  (F) The lexer counted more opening curly or square brackets than
  closing ones. As a general rule, you'll find it's missing near the place
  you were last editing.
 
fmt-bug.pl had compilation errors (#3)
 
  (F) The final summary message when a perl -c fails.
 
Uncaught exception from user code​:
  fmt-bug.pl had compilation errors.
$ perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=hpux, osvers=11.00, archname=PA-RISC2.0
  uname='hp-ux d3 b.11.00 e 9000800 2015358431 8-user license '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc', optimize='+O2 +Onolimit', gccversion=
  cppflags='-DDEBUGGING -D_HPUX_SOURCE -Ae -I/pro/local/include'
  ccflags ='-DDEBUGGING -D_HPUX_SOURCE -Ae -I/pro/local/include'
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags =' -L/pro/local/lib'
  libpth=/pro/local/lib /lib/pa1.1 /lib /usr/lib /usr/ccs/lib
  libs=-lnsl -lnm -lndbm -lgdbm -ldld -lm -lc -lndir -lcrypt
  libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred '
  cccdlflags='+z', lddlflags='-b -L/pro/local/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING
  Built under hpux
  Compiled at Mar 16 2000 15​:14​:01
  @​INC​:
  /pro/lib/perl5/5.00503/PA-RISC2.0
  /pro/lib/perl5/5.00503
  /pro/lib/perl5/site_perl/5.005/PA-RISC2.0
  /pro/lib/perl5/site_perl/5.005
  .
$ perl5.6.0 -V
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​:
  Platform​:
  osname=hpux, osvers=11.00, archname=PA-RISC2.0
  uname='hp-ux l1 b.11.00 u 9000800 527706567 unlimited-user license '
  config_args='-ds'
  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 +Onolimit', gccversion=
  cppflags='-DDEBUGGING -Ae -D_HPUX_SOURCE -I/pro/local/include'
  ccflags =' -DDEBUGGING -Ae -D_HPUX_SOURCE -I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 '
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags ='-L/pro/local/lib -Wl,+vnocompatwarnings'
  libpth=/pro/local/lib /lib /usr/lib /usr/ccs/lib /usr/local/lib
  libs=-lnsl -lnm -lndbm -lgdbm -ldb -ldld -lm -lc -lndir -lcrypt -lsec
  libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred '
  cccdlflags='+z', lddlflags='-b +vnocompatwarnings -L/pro/local/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING USE_LARGE_FILES
  Built under hpux
  Compiled at Mar 29 2000 20​:34​:00
  @​INC​:
  /pro/lib/perl5/5.6.0/PA-RISC2.0
  /pro/lib/perl5/5.6.0
  /pro/lib/perl5/site_perl/5.6.0/PA-RISC2.0
  /pro/lib/perl5/site_perl/5.6.0
  /pro/lib/perl5/site_perl/5.005/PA-RISC2.0
  /pro/lib/perl5/site_perl/5.005
  /pro/lib/perl5/site_perl
  .
$

script done on Fri Apr 21 16​:50​:51 2000

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