$x{$y} inside double quotes in print problem 
Author Message
 $x{$y} inside double quotes in print problem

I got what I thought was the latest version of perl from devvax.jpl.nasa.gov
and when trying it with the script aub, found a problem that at least aub
hadn't had.  If the construct $x{$y} appears inside double quotes in a
print statement, there's a problem with \n being ignored, viz:

#!/bin/perl
$x = "HOME";
$y = "USER";
print "Home = $ENV{$x}\n";
print "User = $ENV{$y}\n";

prints

Home = /home/pjsUser = pjs

followed by the shell prompt on the same line.


rather confused by the fact that the patchlevel.h in the perl.4.0
directory contained "19", and that there were only 19 patches in the
patches directory, but since "perl -v" prints

This is perl, version 4.0

$RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
Patch level: 33

I figured they were out of date.  I expect I'm making some elementary
error, being a perl novice, would someone point it out to me please?

(I have a workaround, by modifying the script to use printf instead
of print.)

--
This is news.  This is your       |    Peter Scott, NASA/JPL/Caltech



Sat, 23 Sep 1995 07:35:33 GMT  
 $x{$y} inside double quotes in print problem

Quote:

> #!/bin/perl
> $x = "HOME";
> $y = "USER";
> print "Home = $ENV{$x}\n";
> print "User = $ENV{$y}\n";

> prints

> Home = /home/pjsUser = pjs

Turned out that this must be a bug in patchlevel 33 (whoever
puts these things on devvax.jpl.nasa.gov, take note), and that
33 was in between stable levels 19 and 35.  Current patch level
is 36 and that works ok.

BTW, I thought it was odd that SunOS 4.1.x wasn't included in
the list of known systems.  The closest was SunOS 4.0.1 and 4.0.2,
so I used the latter and decided not to use -DFPUTS_BOTCH as
recommended, since I figured it had to have been fixed between
4.0.2 and 4.1.2, which I'm running.


--
This is news.  This is your       |    Peter Scott, NASA/JPL/Caltech



Sun, 24 Sep 1995 00:47:06 GMT  
 $x{$y} inside double quotes in print problem


[...]
|> BTW, I thought it was odd that SunOS 4.1.x wasn't included in
|> the list of known systems.  The closest was SunOS 4.0.1 and 4.0.2,
|> so I used the latter and decided not to use -DFPUTS_BOTCH as
|> recommended, since I figured it had to have been fixed between
|> 4.0.2 and 4.1.2, which I'm running.

You can't really say SunOS 4.1.x as 4.1.1 is the old BSD type and
4.1.{2,3} are more pre-releases of SunOS 5.0 which is an SVR4 type.

--

Michael Salmon

#include        <standard.disclaimer>
#include        <witty.saying>
#include        <fancy.pseudo.graphics>

Ericsson Telecom AB
Stockholm



Sun, 24 Sep 1995 14:56:48 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Comma delimited fields with line returns inside a double quote

2. Comma delimited fields with line returns inside a double quote

3. expanding variable inside double quotes

4. print + double quotes around object

5. Dereference in double quotes for a print

6. replace single quote to double quote with an example

7. replace single quote to double quote

8. changing a single quote string to a double quote string

9. performance penalty: bareword, single quoting, double quoting

10. replace single quote to double quote with an example

11. Converting single quoted string to double quoted string

12. quotes & double quotes in perl CGI

 

 
Powered by phpBB® Forum Software