[17016] in Perl-Users-Digest
Perl-Users Digest, Issue: 4428 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 25 21:10:23 2000
Date: Mon, 25 Sep 2000 18:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969930612-v9-i4428@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 25 Sep 2000 Volume: 9 Number: 4428
Today's topics:
Re: Simple one? How do I escape the '(" in a string? (William W. Arnold)
Simple substitution string of hash table name <glchy@email.com>
Re: Simple substitution string of hash table name <lr@hpl.hp.com>
Re: Simple substitution string of hash table name <ren.maddox@tivoli.com>
Re: Simple substitution string of hash table name (Richard J. Rauenzahn)
Re: Simple substitution string of hash table name <tim@ipac.caltech.edu>
West Chester, PA 19380 Perl Users Group? <nospam@david-steuber.com>
Re: West Chester, PA 19380 Perl Users Group? (Logan Shaw)
When to use \ ? <webscot@uswestmail.net>
Re: When to use \ ? <gene@allsysinc.com>
Re: When to use \ ? <jeff@vpservices.com>
Re: When to use \ ? <lr@hpl.hp.com>
Re: When to use \ ? <stephenk@cc.gatech.edu>
Re: When to use \ ? <uri@sysarch.com>
Re: When to use \ ? <lr@hpl.hp.com>
Re: When to use \ ? <ren.maddox@tivoli.com>
Re: When to use \ ? (Abigail)
Re: When to use \ ? (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Sep 2000 22:57:43 GMT
From: warnold@herringbone.richmond.edu (William W. Arnold)
Subject: Re: Simple one? How do I escape the '(" in a string?
Message-Id: <8qol96$k29$1@herringbone.richmond.edu>
In article <slrn8sv9bj.lo9.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
| Arthur Darren Dunham (add@netcom.com) wrote on MMDLXXXII September
| MCMXCIII in <URL:news:8qo6ie$9h1$1@slb0.atl.mindspring.net>:
||| In article <slrn8so4if.5fq.abigail@alexandra.foad.org>,
||| Abigail <abigail@foad.org> wrote:
||| >..
||| >.. $ perl -w beta.pl
||| >.. print (...) interpreted as function at beta.pl line 92.
||| >
||| >That is a very annoying warning, and I don't see what good it does.
||| >It isn't that people aren't used to functions.
|||
||| #!/usr/local/bin/perl
||| print (STDOUT "( ");
||| print (STDOUT ") ");
[cut]
||| perl -w /tmp/test
||| print (...) interpreted as function at /tmp/test line 2.
||| print (...) interpreted as function at /tmp/test line 3.
||| ( ) [ { < ; !
|||
||| Hmm.. only the '(' or ')' lines have warnings. What's up with that?
| No idea. What's even stranger:
[cut many good tests of this happening]
| Time for perlbug.
Note that you can kill the warning by removing the space between the
print and the (
[~]% cat /tmp/test
#!/usr/local/bin/perl
print (STDOUT "( ");
print(STDOUT "( ");
print (STDOUT ") ");
print(STDOUT ") ");
[~]% perl -w /tmp/test
print (...) interpreted as function at /tmp/test line 2.
print (...) interpreted as function at /tmp/test line 4.
( ( ) )
--
-billy- warnold@erols.com warnold@richmond.edu
warnold@vipnet.org
------------------------------
Date: Mon, 25 Sep 2000 22:14:20 GMT
From: GC <glchy@email.com>
Subject: Simple substitution string of hash table name
Message-Id: <8qoin8$kpq$1@nnrp1.deja.com>
Hi,
it's a very simple substitution string of a hash table name but it
doesnt seem to work. I want to access a value in a hash table whose
name is made up by 2 $ vars. Let me explain thru an example.
%traffic_data1 = (
"name" => "road",
"db_table" => "cm_traffic"
);
Now:
$a = "traffic_data1";
$b = "{\'name\'}";
I want to get "road" i.e $traffic_data{'name'}, so i tried:
$x = $a.$b; #i.e $x is now traffic_data1{'name'}
$y = ${$x};
print "$y";
But nothing is printed. Anyone has the proper syntax for my prob?
Thanks...
GC
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 25 Sep 2000 16:08:30 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Simple substitution string of hash table name
Message-Id: <MPG.14397acd8dfcc2f398adc3@nntp.hpl.hp.com>
In article <8qoin8$kpq$1@nnrp1.deja.com> on Mon, 25 Sep 2000 22:14:20
GMT, GC <glchy@email.com> says...
> Hi,
>
> it's a very simple substitution string of a hash table name but it
> doesnt seem to work. I want to access a value in a hash table whose
> name is made up by 2 $ vars. Let me explain thru an example.
>
> %traffic_data1 = (
> "name" => "road",
> "db_table" => "cm_traffic"
> );
>
> Now:
> $a = "traffic_data1";
> $b = "{\'name\'}";
>
> I want to get "road" i.e $traffic_data{'name'}, so i tried:
>
> $x = $a.$b; #i.e $x is now traffic_data1{'name'}
> $y = ${$x};
> print "$y";
The quotes above are superfluous, slow, and misleading.
> But nothing is printed. Anyone has the proper syntax for my prob?
The proper syntax would be:
$x = eval $a . $b;
print $x;
But that wouldn't be the proper solution, which is not to use a variable
as the name of the hash, but to use it as a key in a higher-level hash:
%data = (
traffic_data1 => {
name => "road",
db_table => "cm_traffic",
}
...
);
Note the curly braces to form a reference to an anonymous hash. (Note
also the reliance on the auto-quoting capability of the 'fat comma'
operator =>.)
Then the datum in question is
$data{traffic_data1}{name}
If the names of the data hashes differ only by a small integer, you
might use an array instead of a hash to hold them.
$traffic_date[1]{name}
Read perldsc for more information.
> Thanks...
You're welcome.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Sep 2000 17:49:27 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Simple substitution string of hash table name
Message-Id: <m3r968rsso.fsf@dhcp11-177.support.tivoli.com>
GC <glchy@email.com> writes:
> Hi,
>
> it's a very simple substitution string of a hash table name but it
> doesnt seem to work. I want to access a value in a hash table whose
> name is made up by 2 $ vars. Let me explain thru an example.
>
> %traffic_data1 = (
> "name" => "road",
> "db_table" => "cm_traffic"
You can leave off quotes around single words before "=>". Syntactic
sugar.
> );
>
> Now:
> $a = "traffic_data1";
> $b = "{\'name\'}";
Single quotes aren't special in a double-quoted string, so you do not
need those backslashes. Also, single words in a hash lookup do not
need to be quoted.
> I want to get "road" i.e $traffic_data{'name'}, so i tried:
>
> $x = $a.$b; #i.e $x is now traffic_data1{'name'}
> $y = ${$x};
> print "$y";
These quotes force an unnecessary copy of $y.
> But nothing is printed. Anyone has the proper syntax for my prob?
First, don't do it this way if you can help it. Use real references
and/or an additional hash instead:
%stuff = (
traffic_data1 => { name => "road", db_table => "cm_traffic" }
);
$a = "traffic_data1";
$b = "name";
print $stuff{$a}{$b};
__END__
Now, assuming that you can't help it, the easiest thing is to leave
the braces off of $b (just as I did above) and then use:
print ${$a}{$b};
If you really need to have the braces on $b, use:
print eval "\$$a$b";
But again, don't do it that way!
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 25 Sep 2000 23:27:00 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Simple substitution string of hash table name
Message-Id: <969924419.392996@hpvablab.cup.hp.com>
GC <glchy@email.com> writes:
>Hi,
>
>it's a very simple substitution string of a hash table name but it
>doesnt seem to work. I want to access a value in a hash table whose
>name is made up by 2 $ vars. Let me explain thru an example.
>
>%traffic_data1 = (
> "name" => "road",
> "db_table" => "cm_traffic"
>);
This would be expressed with less work on your part as...
%traffic_data1 = qw( name road
db_table cm_traffic);
Although some may prefer the => visual cue.
>Now:
>$a = "traffic_data1";
>$b = "{\'name\'}";
Don't use the variable names $a and $b -- they're special. (see perldoc
-f sort).
Change above to $a = "\$traffic_data1" or ...
$a = qw($traffic_data1);
$b = qw({'name'});
>I want to get "road" i.e $traffic_data{'name'}, so i tried:
>
>$x = $a.$b; #i.e $x is now traffic_data1{'name'}
>$y = ${$x};
$y = eval $x;
>print "$y";
>
>But nothing is printed. Anyone has the proper syntax for my prob?
>Thanks...
Your symbolic reference isn't doing what you think it's doing.
"$traffic_data1{'name'}" isn't the name of a symbol in the symbol table.
%traffic_data1 is.
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Mon, 25 Sep 2000 17:34:47 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Simple substitution string of hash table name
Message-Id: <39CFEF27.16B2C9A@ipac.caltech.edu>
GC wrote:
>
> Hi,
>
> it's a very simple substitution string of a hash table name but it
> doesnt seem to work. I want to access a value in a hash table whose
> name is made up by 2 $ vars. Let me explain thru an example.
>
> %traffic_data1 = (
> "name" => "road",
> "db_table" => "cm_traffic"
> );
>
> Now:
> $a = "traffic_data1";
> $b = "{\'name\'}";
>
> I want to get "road" i.e $traffic_data{'name'}, so i tried:
>
> $x = $a.$b; #i.e $x is now traffic_data1{'name'}
> $y = ${$x};
> print "$y";
>
> But nothing is printed. Anyone has the proper syntax for my prob?
> Thanks...
a) This seems a tad dubious. Are you sure this is what you want?
b) Really sure?
c) Symbollic references (what you are grasping for) don't work that way, but
eval does:
$y = eval "\$$x";
die "Bad var name: $@" if $@;
d) Are you sure you wouldn't prefer something like:
$table_name = "traffic_data1";
$membr_name = "name";
%tables = (traffic_data1 => \%traffic_data1,
other_data => ... whatever ...);
$y = $tables{$table_name}{name};
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Tue, 26 Sep 2000 00:02:02 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: West Chester, PA 19380 Perl Users Group?
Message-Id: <m3wvg03ts9.fsf@solo.david-steuber.com>
Does anyone know of any Perl users groups in the West Chester PA area?
Zipcode 19380.
Or how to find such a group?
--
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member | general Internet web wannabe.
ICQ# 91465842 (Using Micq 0.4.6 under Linux)
It's time to be free: http://www.harrybrowne2000.org
------------------------------
Date: 25 Sep 2000 19:04:13 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: West Chester, PA 19380 Perl Users Group?
Message-Id: <8qop5t$4sh$1@provolone.cs.utexas.edu>
In article <m3wvg03ts9.fsf@solo.david-steuber.com>,
David Steuber <nospam@david-steuber.com> wrote:
>Does anyone know of any Perl users groups in the West Chester PA area?
>Zipcode 19380.
>
>Or how to find such a group?
Check http://www.pm.org/ .
- Logan
------------------------------
Date: Mon, 25 Sep 2000 15:39:52 -0700
From: "Webscot5" <webscot@uswestmail.net>
Subject: When to use \ ?
Message-Id: <JtQz5.215$7Q2.309685@news.uswest.net>
Hello,
I am new to Perl. I wish to post some form results on an HTML page after
submission of the form. I continue to get a 500 Error for Barewords when
writing statements like this one:
Bareword found where operator expected at order2.cgi line 264, near ""0"
cellpadding"
(Missing operator before cellpadding?)
syntax error at order2.cgi line 264, near ""0" cellpadding"
Bareword found where operator expected at order2.cgi line 264, near ""0"
width"
(Missing operator before width?)
I get the same error for either format of the statements below (with or
without the \).
--For the following partial statement--
print "<body bgcolor=\"#FFFFFF\">\n";
print "<table border="0" cellspacing="0" cellpadding="0" width="100%">\n";
When do I know to add a \ in the above statement?
Such as here:
print "<body bgcolor=\"#FFFFFF\">\n";
print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
Or what else might be causing the error? Similar commands exist in the
script with no mention of a line error.
To whomever responds...thank you for your help.
Have a wonderful day!
Cordially,
Webscot
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For the finest in Colloidal Silver Generators &
pure & natural health products visit
Nature'sAlternatives.com at http://www.naturesalternatives.com
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------
Date: Mon, 25 Sep 2000 22:49:06 GMT
From: "Gene" <gene@allsysinc.com>
Subject: Re: When to use \ ?
Message-Id: <CDQz5.8171$864.510398@news.flash.net>
"Webscot5" <webscot@uswestmail.net> wrote in message
news:JtQz5.215$7Q2.309685@news.uswest.net...
> print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
One thing you forgot was to put a \ before the %. When it sees the %, it is
expecting to see a hash. You need to put the backslashes before anything
that might signify a variable of any sorts. That includes $, %, and @. And
possibly others that I'm forgetting at the moment.
Good Luck
------------------------------
Date: Mon, 25 Sep 2000 15:54:42 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: When to use \ ?
Message-Id: <39CFD7B2.99936E75@vpservices.com>
Webscot5 wrote:
>
> print "<body bgcolor=\"#FFFFFF\">\n";
> print "<table border="0" cellspacing="0" cellpadding="0" width="100%">\n";
>
> When do I know to add a \ in the above statement?
Never.
Use the qq() operator or here documents instead. For example this is a
"here document":
print <<END_OF_HTML;
<body bgcolor="$FFFFFF">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
END_OF_HTML
That way you do not need to worry about your double quotation marks or
your \ns either. Just make sure that the "END_OF_HTML" occurs on a line
by itself with no blank spaces on that line either before or after it.
--
Jeff
------------------------------
Date: Mon, 25 Sep 2000 15:59:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: When to use \ ?
Message-Id: <MPG.1439789879e9575b98adc2@nntp.hpl.hp.com>
In article <JtQz5.215$7Q2.309685@news.uswest.net> on Mon, 25 Sep 2000
15:39:52 -0700, Webscot5 <webscot@uswestmail.net> says...
...
> print "<body bgcolor=\"#FFFFFF\">\n";
> print "<table border="0" cellspacing="0" cellpadding="0" width="100%">\n";
>
> When do I know to add a \ in the above statement?
> Such as here:
>
> print "<body bgcolor=\"#FFFFFF\">\n";
> print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
>
> Or what else might be causing the error? Similar commands exist in the
> script with no mention of a line error.
You need to escape the character that would otherwise be interpreted as
terminating the string. Because that is such a pain, Perl offers you
the alternate-double-quoting operator qq, which can use any punctuation
character to delimit strings, or any pairs of brackets () {} [] <>.
So one way to write those statements would be:
print qq(<body bgcolor="#FFFFFF">\n);
print qq(<table border="0" cellspacing="0" width="100%">\n);
For more information about generalized quotes, see the section on
"Regexp Quote-Like Operators" in the perlop manpage.
Here's another way, using a here-document:
print <<HTML;
<body bgcolor="#FFFFFF">
<table border="0" cellspacing="0" width="100%">
HTML
Another way would be to replace the interior double-quotes by single-
quotes, but that is sidestepping the Perl issue by using an HTML
capability.
> To whomever responds...thank you for your help.
You're welcome.
> Have a wonderful day!
Welcome to Perl, and "Have the appropriate amount of fun!" (Larry Wall)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 25 Sep 2000 19:15:29 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: When to use \ ?
Message-Id: <39CFDC91.F4885BC5@cc.gatech.edu>
Webscot5 wrote:
> Hello,
>
> I am new to Perl. I wish to post some form results on an HTML page after
> submission of the form. I continue to get a 500 Error for Barewords when
> writing statements like this one:
>
> Bareword found where operator expected at order2.cgi line 264, near ""0"
> cellpadding"
> (Missing operator before cellpadding?)
> syntax error at order2.cgi line 264, near ""0" cellpadding"
> Bareword found where operator expected at order2.cgi line 264, near ""0"
> width"
> (Missing operator before width?)
>
> I get the same error for either format of the statements below (with or
> without the \).
>
> --For the following partial statement--
>
> print "<body bgcolor=\"#FFFFFF\">\n";
> print "<table border="0" cellspacing="0" cellpadding="0" width="100%">\n";
>
> When do I know to add a \ in the above statement?
> Such as here:
>
> print "<body bgcolor=\"#FFFFFF\">\n";
> print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
>
> Or what else might be causing the error? Similar commands exist in the
> script with no mention of a line error.
>
> To whomever responds...thank you for your help.
>
> Have a wonderful day!
>
A string delimited by double quotes ends at the first unescaped double quote.
Therefore, all double quotes inside a double-quote-delimited string should be
escaped. You have a few options here:
1) Escape all " $ and @
2) Use single quotes (if you are not interpolating values)
3) Use the qq operator (perldoc perlop) if you are interpolating
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Mon, 25 Sep 2000 23:18:12 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: When to use \ ?
Message-Id: <x7vgvk9i2z.fsf@home.sysarch.com>
>>>>> "G" == Gene <gene@allsysinc.com> writes:
G> "Webscot5" <webscot@uswestmail.net> wrote in message
G> news:JtQz5.215$7Q2.309685@news.uswest.net...
>> print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
G> One thing you forgot was to put a \ before the %. When it sees the
G> %, it is expecting to see a hash. You need to put the backslashes
G> before anything that might signify a variable of any sorts. That
G> includes $, %, and @. And possibly others that I'm forgetting at
G> the moment.
bzzzt. thanx for playing. better luck next time.
hashes do not interpolate.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 25 Sep 2000 16:10:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: When to use \ ?
Message-Id: <MPG.14397b554944acda98adc4@nntp.hpl.hp.com>
In article <CDQz5.8171$864.510398@news.flash.net> on Mon, 25 Sep 2000
22:49:06 GMT, Gene <gene@allsysinc.com> says...
>
> "Webscot5" <webscot@uswestmail.net> wrote in message
> news:JtQz5.215$7Q2.309685@news.uswest.net...
> > print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
>
> One thing you forgot was to put a \ before the %. When it sees the %, it is
> expecting to see a hash. You need to put the backslashes before anything
> that might signify a variable of any sorts. That includes $, %, and @. And
> possibly others that I'm forgetting at the moment.
You are wrong. Hashes are never interpolated. So the only characters
that need escaping within a double-quoted string (besides the string
terminator) are $ and @.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Sep 2000 17:54:56 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: When to use \ ?
Message-Id: <m3og1crsjj.fsf@dhcp11-177.support.tivoli.com>
"Gene" <gene@allsysinc.com> writes:
> "Webscot5" <webscot@uswestmail.net> wrote in message
> news:JtQz5.215$7Q2.309685@news.uswest.net...
> > print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
>
> One thing you forgot was to put a \ before the %. When it sees the %, it is
> expecting to see a hash. You need to put the backslashes before anything
> that might signify a variable of any sorts. That includes $, %, and @. And
> possibly others that I'm forgetting at the moment.
Actually, no. "%" is not special in a string (unless that string is a
format for printf or sprintf, but that doesn't really count). Only
"@" and "$" lead to variable interpolation in a string, not "%".
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 26 Sep 2000 00:11:33 GMT
From: abigail@foad.org (Abigail)
Subject: Re: When to use \ ?
Message-Id: <slrn8svqb8.lo9.abigail@alexandra.foad.org>
Webscot5 (webscot@uswestmail.net) wrote on MMDLXXXII September MCMXCIII
in <URL:news:JtQz5.215$7Q2.309685@news.uswest.net>:
%% Hello,
%%
%% I am new to Perl. I wish to post some form results on an HTML page after
%% submission of the form. I continue to get a 500 Error for Barewords when
%% writing statements like this one:
%%
%% Bareword found where operator expected at order2.cgi line 264, near ""0"
%% cellpadding"
%% (Missing operator before cellpadding?)
%% syntax error at order2.cgi line 264, near ""0" cellpadding"
%% Bareword found where operator expected at order2.cgi line 264, near ""0"
%% width"
%% (Missing operator before width?)
%%
%% I get the same error for either format of the statements below (with or
%% without the \).
%%
%% --For the following partial statement--
%%
%% print "<body bgcolor=\"#FFFFFF\">\n";
%% print "<table border="0" cellspacing="0" cellpadding="0" width="100%">\n";
^ this ends the string.
%% When do I know to add a \ in the above statement?
There are several ways to deal with it. The most obvious is the recognize
that HTML allows double *AND* single quotes. So, you write it as:
print "<table border='0' cellspacing='0' cellpadding='0' width='100%'>\n";
Or, you use different Perl quotes, with qq:
print qq [<table border="0" cellspacing="0" cellpadding="0" width="100%">\n];
Or you can use interpolation:
my $quote = '"';
print "<table border=${quote}0${quote} cellspacing=${quote}0${quote} " .
"cellpadding=${quote}0${quote} width=${quote}100%${quote}>\n";
Or you use join:
print join '"' => "<table border=", "0", "cellspacing=", "0",
"cellpadding=", "0", "width=", "100%", ">\n";
Or array interpolation:
my @chunks = ("<table border=", "0", "cellspacing=", "0",
"cellpadding=", "0", "width=", "100%", ">\n");
{local $" = '"'; print "@chunks"}
Or printf:
printf
"<table border=%s0%s cellspacing=%s0%s cellpadding=%s0%s width=%s100%%%s>\n",
'"' x 8;
Or you use backwacks:
print
"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
Pick something.
Abigail
--
END {print "Hacker\n"} # Two eagles nesting in
INIT {print "Perl " } # the branches of a banana
CHECK {print "another "} # tree. A flying eagle.
BEGIN {print "Just " }
------------------------------
Date: 26 Sep 2000 00:22:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: When to use \ ?
Message-Id: <slrn8svqvn.lo9.abigail@alexandra.foad.org>
Gene (gene@allsysinc.com) wrote on MMDLXXXII September MCMXCIII in
<URL:news:CDQz5.8171$864.510398@news.flash.net>:
;;
;; "Webscot5" <webscot@uswestmail.net> wrote in message
;; news:JtQz5.215$7Q2.309685@news.uswest.net...
;; > print "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n";
;;
;; One thing you forgot was to put a \ before the %. When it sees the %, it is
;; expecting to see a hash.
Bullshit.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4428
**************************************