[17613] in Perl-Users-Digest
Perl-Users Digest, Issue: 5033 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 5 03:05:37 2000
Date: Tue, 5 Dec 2000 00:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976003510-v9-i5033@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 5 Dec 2000 Volume: 9 Number: 5033
Today's topics:
Re: Can anybody give me any suggestion (Ilya Zakharevich)
Re: Counting bits. (Tad McClellan)
Re: dynamic lvalues possible? (Tad McClellan)
Re: dynamic lvalues possible? (Garry Williams)
Re: forking a new process from a cgi w/perl <philipg@atl.mediaone.net>
form-to-mail not working properly <gmercille@videotron.ca>
Re: form-to-mail not working properly <Jodyman@usa.net>
Re: Help listing files in perl (Chris Fedde)
Re: How can I read a variable without evaluating it ? <joelnelson@home.com>
Re: How to trap a broken Pipe? <philipg@atl.mediaone.net>
Re: kill and security (suid) (Chris Fedde)
Re: NEWBIE: Help me make a module 'USE-able' on my web <clarityassoc@earthlink.net>
references, hashes & arrays <Jodyman@usa.net>
Re: references, hashes & arrays (Bernard El-Hagin)
Re: references, hashes & arrays <Jodyman@usa.net>
Re: references, hashes & arrays (Bernard El-Hagin)
Re: references, hashes & arrays <Jodyman@usa.net>
Re: references, hashes & arrays <Jodyman@usa.net>
submit a HTML file using a textarea within a form <Karsten@Hachmeister-Online.de>
Re: Using goto (Tramm Hudson)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Dec 2000 06:36:48 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Can anybody give me any suggestion
Message-Id: <90i2e0$73t$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Eric Bohlman
<ebohlman@omsdev.com>],
who wrote in article <90hmdj$hhl$3@bob.news.rcn.net>:
> > You should drop that last comma after the value assigned to key 'NM'.
>
> Nope. Trailing commas in lists get a special dispensation because using
> them can make code more maintainable
This is not entirely correct:
perl -wle 'open F,,, ">",,,,, "/tmp/bar",,, or die'
Name "main::F" used only once: possible typo at -e line 1.
Are you absolutely sure *this* makes your code more maintainable?
Extra-commas forgiveness leads to many obscure bugs, especially when
you create eval-strings.
Ilya
------------------------------
Date: Mon, 4 Dec 2000 23:59:51 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Counting bits.
Message-Id: <slrn92oti7.me5.tadmc@magna.metronet.com>
Linc Madison <lincmad001@telecom-digest.zzn.com> wrote:
>In article <e5rm2tkt122qs52aq5gl9isfnttua0htj1@4ax.com>, Bart Lateur
><bart.lateur@skynet.be> wrote:
>> Wolfgang Hielscher wrote:
>> > my $count = @{[$str =~ m/1/g]};
>> $count = () = $str =~ /1/g;
>
>Isn't it more efficient to say this instead?
>
> my $count = ($str =~ tr/1/1/);
------------------------------------
#!/usr/bin/perl -w
use Benchmark;
$str = '10101100';
timethese 1_000_000, {
m => q( my $count = () = $str =~ m/1/g ; ),
s => q( my $count = $str =~ s/1/1/g ; ),
sl => q( my $count = @{[ $str =~ m/1/g ]}; ),
tr => q( my $count = $str =~ tr/1// ; ),
};
------------------------------------
(partial) output:
Benchmark: timing 1000000 iterations of m, s, sl, tr...
m: 14 wallclock secs (13.44 usr + 0.00 sys = 13.44 CPU) @ 74404.76/s
s: 10 wallclock secs (10.11 usr + 0.00 sys = 10.11 CPU) @ 98911.97/s
sl: 17 wallclock secs (18.41 usr + 0.00 sys = 18.41 CPU) @ 54318.31/s
tr: 3 wallclock secs ( 2.11 usr + 0.00 sys = 2.11 CPU) @ 473933.65/s
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 4 Dec 2000 22:08:40 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: dynamic lvalues possible?
Message-Id: <slrn92on1o.me5.tadmc@magna.metronet.com>
[ Please put your comments *following* the quoted text that
you are commenting on.
]
ber1@my-deja.com <ber1@my-deja.com> wrote:
>Thanks for the advice and point in the right direction.
>I will change the -w to -T and use the hash as suggested.
^^^^^^
Noooo. Don't _change_ it to -T.
_Add_ a -T.
#!/usr/bin/perl -wT
You still want warnings too. Don't be shy, take all the help you can get.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Dec 2000 06:38:33 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: dynamic lvalues possible?
Message-Id: <J30X5.611$Xq5.29983@eagle.america.net>
On Tue, 05 Dec 2000 03:13:46 GMT, ber1@my-deja.com <ber1@my-deja.com> wrote:
>In article <90hedn$8b$1@charm.magnus.acs.ohio-state.edu>,
> ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
>Thanks for the advice and point in the right direction.
>I will change the -w to -T and use the hash as suggested.
I think Ilya meant to *add* taint-checking to the options (-wT) --
*not* replace -w with -T.
--
Garry Williams
------------------------------
Date: Tue, 05 Dec 2000 06:56:06 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: forking a new process from a cgi w/perl
Message-Id: <ak0X5.33128$88.5230222@typhoon.southeast.rr.com>
srame <srame@excite.no.spam.no.com> wrote in message
news:3A2BF676.F47B9390@excite.no.spam.no.com...
>
> Basically, I have a "Go" button. When the "Go" button is pressed, I
> would like some process to be executed as a child process and never to
> be heard from again - and I would like my cgi exit. So I have something
> like this happen after I press "Go".
>
> print start_html;
> print "before execution"
> system("nohup long_running_process &");
> print "after execution"
> print end_html;
> exit;
>
> The problem is, the browser will time out, because the cgi will not
> exit. It will do the stuff before the system call, and it will do the
> stuff after the system call - but the browser will continue to "load"
> until the long_running_process is complete. Any ideas?
You want to "daemonize" the program. To do this, use fork(), setsid() (or
maybe setpgrp(), depending on your OS), and then exec(). Here's an example:
use POSIX;
my $pid = fork;
die "can't fork: $!" unless defined $pid;
if ($pid == 0) {
# child
# dissociate from process group
if (POSIX::setsid == -1) {
die "can't setsid: $!";
}
# dissociate from controlling "terminal"
open STDOUT, ">/dev/null";
open STDIN, "/dev/null";
# replace current program with /bin/sleep
exec '/bin/sleep 30';
die "can't exec: $!";
}
print "Content-type: text/plain\n\n";
print "Parent exiting...\n";
If you do a 'ps -ef' (or your system's equivalent) right after you run the
cgi, you'll see 'sleep 30' running.
hth,
p
------------------------------
Date: Tue, 05 Dec 2000 00:16:20 -0500
From: Mercille <gmercille@videotron.ca>
Subject: form-to-mail not working properly
Message-Id: <3A2C7A23.A947F4@videotron.ca>
I have been making this form-to-mail script and something just doesn't
work and I just can't figure out what. Could someone please tell me if
you know what is wrong.
Here is the source (the comments are in French, sorry about that)
*************************************************
#!/usr/local/bin/perl
print "Content-type:text/html\n\n" ;
$mailprog = '/usr/bin/sendmail' ;
# On commence par determiner si le programme a ete appele correctement
# avec la methode POST
if($ENV{'REQUEST_METHOD'} ne "POST")
{
&posterror;
}
# Pour lire ce qui est envoye par le formulaire a travers le STDIN
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# On separe chaque elements (avec le caractere &)
@pairs = split(/&/, $buffer) ;
foreach $pair (@pairs) {
# On separe le nom de variable de sa valeur
($name, $value) = split(/=/, $pair) ;
# On remplace les + par des espaces
$value =~ tr/+/ /;
# On remplace les caracteres speciaux hexadecimaux par le vrai caractere
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# On place le tout dans une hashtable nommee $FORM
$FORM{$name} = $value;
}
# On ouvre le programme de courrier
open (MAIL, "|/usr/bin/sendmail -t");
# On envoie les informations recueillies
$recipient = 'fmercille@videotron.ca';
print MAIL "To: fmercille\@videotron.ca\n";
print MAIL "Subject: INSCRIPTION POUR LA SEMAINE INFORMATIQUE\n\n";
foreach $key (keys %FORM) {
print MAIL "$key = $FORM{$key}\n";
}
close (MAIL) ;
# Il faut maintenant afficher une nouvelle page HTML pour remercier
# l'utilisateur d'avoir utilise le formulaire
# On envoie une page en francais ou en anglais selon la langue du
# formulaire original
if($ENV{'HTTP_REFERER'} eq
"http://www.ceginfo.polymtl.ca/semaineinfo/inscription.html" or
$ENV{'HTTP_REFERER'} eq
"http://ceginfo.polymtl.ca/semaineinfo/inscription.html")
{
print <<ENDofHTML;
<html>
<head>
<title>Merci de votre inscription</title>
</head>
<body text="#99FF99" background="background02.jpg">
<center><font size=+4>Merci de votre inscription</font></center>
<p>
<font size=+1>
Vous recevrez un message de confirmation par courriel à l'adresse
$FORM{'courriel'} lors du prochain jour ouvrable.
</font>
</body>
</html>
ENDofHTML
}
else
{
print <<END_HTML;
<html>
<head>
<title>Thank you for subscribing</title>
</head>
<body text="#99FF99" background="background02.jpg">
<center><font size=+4>Thank you for subscribing</font></center>
<p>
<font size=+1>
You will soon receive a confirmation email at $FORM{'courriel'} in the
next business day.
</font>
</body>
</html>
END_HTML
}
# La sous-routine posterror lorsque la methode n'est pas POST
sub posterror {
print <<ENDERROR;
<html>
<head>
<title>ERREUR D'APPEL DE PROGRAMME</title>
</head>
<body>
<h1>
VOUS DEVEZ UTILISER LA METHODE POST VERS CE PROGRAMME
<p>
YOU MUST POST TO THIS PROGRAM
</h1>
</body>
</html>
ENDERROR
exit;
}
*************************************************
A big part of the code has been copied/pasted from a tutorial I found at
http://www.cgi101.com
When I submit the form, I get the "thank you" page, but I never receive
an email with the stuff that was in the form.
#!/usr/local/bin/perl and $mailprog = '/usr/bin/sendmail' ; are the
correct paths for the programs.
What's strange to me is that a simple test script like the following
works fine:
*************************************************
#!/usr/local/bin/perl
%fortesting = ( fred => "fredstuff",
beth => "bethstuff",
john => "johnstuff" ) ;
open (MAIL, "|/usr/bin/sendmail -t");
print MAIL "To: fmercille@videotron.ca\n";
print MAIL "Subject: Test\n\n;
print MAIL "Test\n";
foreach $i(keys %fortesting) {
print MAIL "$i = $fortesting{$i}\n";
}
close (MAIL) ;
*************************************************
When I execute this test script, I receive the email with the correct
stuff in it. But as soon as I try to print a html page in the same
script, the email is not sent. Please help. Thanks a lot
Frederic Mercille
------------------------------
Date: Tue, 5 Dec 2000 02:30:42 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: form-to-mail not working properly
Message-Id: <90i5ge$q0i$1@plonk.apk.net>
Mercille wrote in message <3A2C7A23.A947F4@videotron.ca>...
>$recipient = 'fmercille@videotron.ca';
You must escape @ like you did below: fmercille\@videotron.ca
>print MAIL "To: fmercille\@videotron.ca\n";
>What's strange to me is that a simple test script like the following
>works fine:
>
>*************************************************
>#!/usr/local/bin/perl
>
>%fortesting = ( fred => "fredstuff",
> beth => "bethstuff",
> john => "johnstuff" ) ;
>
>open (MAIL, "|/usr/bin/sendmail -t");
open (MAIL,"|/usr/lib/sendmail -t -n -oi") || die "there was a problem with
the call to sendmail: $!\n";
>
>print MAIL "To: fmercille@videotron.ca\n";
This should not have worked, you must escape the @ using \@
>print MAIL "Subject: Test\n\n;
>print MAIL "Test\n";
>
>foreach $i(keys %fortesting) {
> print MAIL "$i = $fortesting{$i}\n";
>}
>
>close (MAIL) ;
Should use: close(MAIL) or die "Can't close Mail: $!\n";
Hope this helped.
Jody
------------------------------
Date: Tue, 05 Dec 2000 05:06:16 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Help listing files in perl
Message-Id: <cJ_W5.56$T3.170845184@news.frii.net>
In article <90hrcl$9m3$1@nnrp1.deja.com>, <punksk8er@home.com> wrote:
>I'm kinda new to perl and I'm kinda lost on how to make a list of files
>in a directory.
>
>Can someone be kind enough to show me?
>Thank you.
>
Read about opendir in the perlfunc manual page.
Good Luck
chris
--
This space intentionally left blank
------------------------------
Date: Tue, 05 Dec 2000 06:57:17 GMT
From: Joel Nelson <joelnelson@home.com>
Subject: Re: How can I read a variable without evaluating it ?
Message-Id: <3A2C91A7.1D31AD60@home.com>
Marcelo Montagna wrote:
> Hello everyone,
>
> I have a hash like
>
> MyHash = (
> FirstName => $FORM{fname},
> Email => $FORM{email}
> );
>
> Now, I'd like to know what value is assigned to each key, without
> evaluating it, I mean, something that will return exactely
> "$FORM{email}" (Dollar sign, letter "F",...etc) as a string and not its
> value.
>
> I'm sure it must be possible, but after hours searching the net, I
> couldn't find a way to do it.
How about:
MyHash = (
FirstName => '$FORM{fname}',
Email => '$FORM{email}'
);
Note the quotes! Of course if you want to use $FORM{fname} later you will
have to 'eval' it like:
my $fname = eval ( $MyHash{FirstName} );
or something like that. Hope that gets you on the right track!!
Joel
------------------------------
Date: Tue, 05 Dec 2000 06:33:03 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: How to trap a broken Pipe?
Message-Id: <z_%W5.33126$88.5217951@typhoon.southeast.rr.com>
Jimmy <someone@compugenx.com> wrote in message
news:90h3fs$81i$1@bob.news.rcn.net...
> How do you trap a broken pipe error? For instance the following function
> reads until an \n is found, however if the client in this case is a
browser,
> and it does not send the \n, but instead hits the stop button , the server
> dies with Broken Pipe error.
>
> Anyone know how to properly trap a broken pip error?
>
> eval {
> if( !( print_errs( $got = Net::SSLeay::ssl_read_all($ssl)))){
> if ( $got ne ''){
> Net::SSLeay::ssl_write_all($ssl, $got) or die "$$: ssl write
> failed";
> print "$got\n";
> }
> }
> } || print "ERRORZ\n"; #I never get here due to an untrapable broken pipe
> error
$SIG{'PIPE'} = 'IGNORE';
or
$SIG{'PIPE'} = \&sigpipe_handler;
hth,
p
------------------------------
Date: Tue, 05 Dec 2000 06:00:56 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: kill and security (suid)
Message-Id: <sw%W5.59$T3.170584064@news.frii.net>
In article <87k89ftryb.fsf@nujoma.perrins>,
Andrew J. Perrin <aperrin@demog.berkeley.edu> wrote:
>
>kill('TERM',$_) foreach (split(/\s+/,$pppds));
>
>or:
>
>system("/bin/kill $_") foreach (split(/\s+/,$pppds));
>
>where $pppds contains a chomp()ed, space-separated list of pppd
>processes (of course, usually just one).
>
>No errors are returned, the system just exits quietly. One minor clue
>is that kill() does NOT succeed; if I use:
> kill 'TERM', $_ and print "Killed $_\n";
>
>I get no output. However, if I just print it:
>
>print "Killing $_\n";
>kill 'TERM', $_;
>
>it does print, and I manually issue a /bin/kill -TERM <pid>
>immediately thereafter it works fine.
>
Use one of the following:
kill TERM, $_; # no quotes
kill 15, $_; # numeric argument
or
system('/bin/kill', '-TERM', $_); # called with proper switch
good luck.
chris
BTW
--
This space intentionally left blank
------------------------------
Date: Tue, 05 Dec 2000 06:48:07 GMT
From: "Alan Mailer" <clarityassoc@earthlink.net>
Subject: Re: NEWBIE: Help me make a module 'USE-able' on my web site STEP-BY-STEP???
Message-Id: <Hc0X5.47355$nh5.3452162@newsread1.prod.itd.earthlink.net>
Thanks so much dtbaker. Just the sort of step-by-step response I was hoping
for. Thanks for being so thorough... and so patient!
<dtbaker_dejanews@my-deja.com> wrote in message
news:90gqcj$e0k$1@nnrp1.deja.com...
> In article <I8QW5.45250$nh5.3258849@newsread1.prod.itd.earthlink.net>,
> "Alan Mailer" <clarityassoc@earthlink.net> wrote:
> > A week or so ago I posted the following message:
> > > >Please excuse the complete naivete of this question but: since I
> may be
> > > >deploying my perl scrips on a Unix based web server...
> ----------------------
>
> *most* modules can be installed with the CPAN tool that takes most of
> the headache out of download and install. There are a few that you have
> to do all the unpacking and "making" yourself. You can always give it a
> shot with CPAN first. You should go read the FAQs at www.cpan.org, but
> here is a little cheat-sheet to help get going:
>
> for modules than can be installed with CPAN, its an easy way to go....
> better than the manual process of unpacking and making usually.
>
> - first, telnet to your host.
> - enter interactive mode:
>
> $ perl -MCPAN -e shell
>
> - to get a help menu
>
> cpan> h
>
> - to check configuration, use:
>
> cpan> o conf
>
> - typically, the only one you may want to set to make local non-root
> installs easy is to set a config var:
>
> cpan> o makepl_arg PREFIX=/home/<yourdomain>/usr
> cpan> o commit
>
> - then you can do installs as simply as:
>
> cpan> install Image::Size
>
> - then you'll have to add lines in your source to "find" your local
> installs. the path to the lib should be where the *.pm can be found.
> something like:
>
> use lib "/home/<yourdomain>/usr/lib/perl5/site_perl/5.005" ;
> use my::module ;
>
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
------------------------------
Date: Mon, 4 Dec 2000 21:59:37 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: references, hashes & arrays
Message-Id: <90i49q$pib$1@plonk.apk.net>
I receive the following error in my error log:
Bad name after unit' at report.pl line 65.
The code:
%unit = (
akrn => "Akron Ward",
alli => "Alliance Ward",
ashl => "Ashland Branch",
can1 => "Canton Ward",
can2 => "Canton II Ward",
medi => "Medina Ward",
newp => "New Philadelphia Ward",
root => "Rootstown Ward",
stow => "Stow Branch",
tall => "Tallmadge Ward",
wads => "Wadsworth Branch",
woos => "Wooster Ward",
);
print "Form Request from $unit{'$in{'unit'}'} for
$in{'month'}/$in{'year'}<br>\n";
This should reference the hash unit correct?
$in{'unit'} = "akrn" at this point, shouldn't $unit{'$in{'unit'}'} render
the results: Akron Ward?
Any help would be appreciated. I'm lost.
Jody
------------------------------
Date: Tue, 5 Dec 2000 07:43:18 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: references, hashes & arrays
Message-Id: <slrn92p72f.9v.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 4 Dec 2000 21:59:37 -0500, Jody Fedor <Jodyman@usa.net> wrote:
>I receive the following error in my error log:
>
>Bad name after unit' at report.pl line 65.
>
>The code:
>
>%unit = (
>akrn => "Akron Ward",
>alli => "Alliance Ward",
>ashl => "Ashland Branch",
>can1 => "Canton Ward",
>can2 => "Canton II Ward",
>medi => "Medina Ward",
>newp => "New Philadelphia Ward",
>root => "Rootstown Ward",
>stow => "Stow Branch",
>tall => "Tallmadge Ward",
>wads => "Wadsworth Branch",
>woos => "Wooster Ward",
>);
>
>print "Form Request from $unit{'$in{'unit'}'} for
>$in{'month'}/$in{'year'}<br>\n";
>
>This should reference the hash unit correct?
>
>$in{'unit'} = "akrn" at this point, shouldn't $unit{'$in{'unit'}'} render
>the results: Akron Ward?
This:
$unit{'$in{'unit'}'}
means that you want to access the element of hash %unit which has the
key - "a literal dollar sign, an i, an n, a literal opening curly,
etc." Try getting rid of those outermost 's like so:
$unit{$in{'unit'}}
and, if $in{'unit'} really is akrn you'll get the result you wanted.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: Tue, 5 Dec 2000 02:45:44 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: references, hashes & arrays
Message-Id: <90i6d1$qd3$1@plonk.apk.net>
Jody Fedor wrote in message <90i49q$pib$1@plonk.apk.net>...
>I receive the following error in my error log:
>
>Bad name after unit' at report.pl line 65.
>
>The code:
>
>$in{'unit'}="akrn";
>$in{'month'}="12";
>$in{'year'}="2000";
>
>%unit = (
>akrn => "Akron Ward",
>alli => "Alliance Ward",
>ashl => "Ashland Branch",
>can1 => "Canton Ward",
>can2 => "Canton II Ward",
>medi => "Medina Ward",
>newp => "New Philadelphia Ward",
>root => "Rootstown Ward",
>stow => "Stow Branch",
>tall => "Tallmadge Ward",
>wads => "Wadsworth Branch",
>woos => "Wooster Ward",
>);
>
>print "Form Request from $unit{'$in{'unit'}'} for
$in{'month'}/$in{'year'}<br>\n";
OK, so I'm brain dead. $unit{$in{'unit'}} worked fine. Why does it work?
What actually does the ' ' do around the key?
>
>This should reference the hash unit correct?
>
>$in{'unit'} = "akrn" at this point, shouldn't $unit{'$in{'unit'}'} render
>the results: Akron Ward?
>
>Any help would be appreciated. I'm lost.
>
>Jody
>
>
------------------------------
Date: Tue, 5 Dec 2000 07:48:43 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: references, hashes & arrays
Message-Id: <slrn92p7ck.9v.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 5 Dec 2000 02:45:44 -0500, Jody Fedor <Jodyman@usa.net> wrote:
[snip]
>OK, so I'm brain dead. $unit{$in{'unit'}} worked fine. Why does it work?
>What actually does the ' ' do around the key?
It tells the interpreter to interpret (sic!) what's between the 's as a
literal string - no extrapolation. So if you have a variable $a = 5 and
you do:
print '$a'
you won't get "5" as the output, you'll get "$a" - a literal dollar sign
followed by the letter a.
This is all explained in perldoc perlop.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: Tue, 5 Dec 2000 02:53:23 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: references, hashes & arrays
Message-Id: <90i6qu$qjk$1@plonk.apk.net>
Bernard El-Hagin wrote in message ...
> Try getting rid of those outermost 's like so:
>
>$unit{$in{'unit'}}
>
>and, if $in{'unit'} really is akrn you'll get the result you wanted.
It was that problem exactly Bernard. Thanks for the help.
Jody
PS - Still don't understand why you use the ' marks when accessing a hash
but
not if you are using a hash of a hash i.e.
%in = (
unit => "akrn",
month => "12",
year => "2000",
);
%unit = (
akrn => "Akron Ward",
);
you would use: print $unit{'akrn'} to get: Akron Ward
if $in{'unit'} = akrn why wouldn't you use: $unit{'$in{'unit'}'} ???
What are the tick marks actually doing in this sense?
Jody
------------------------------
Date: Tue, 5 Dec 2000 02:55:18 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: references, hashes & arrays
Message-Id: <90i6uh$qjo$1@plonk.apk.net>
Bernard El-Hagin wrote in message ...
>This is all explained in perldoc perlop.
Thanks, I'll read up on this.
Jody
------------------------------
Date: Mon, 04 Dec 2000 17:10:47 +1100
From: Karsten Hachmeister <Karsten@Hachmeister-Online.de>
Subject: submit a HTML file using a textarea within a form
Message-Id: <3A2B3567.4BB69B03@Hachmeister-Online.de>
Hello,
I have a problem to submit a HTML file with a form.
I have a form which uses a textarea element. With this textarea element
I want to edit a HTML file which contains several HTML-comments (<!--
Foo Bar -->).
After the submit of the form the text between the comments and the
comments itself are gone.
When I use only one '-' (<!- Foo Bar ->) the text is ok.
I use apache 1.3.11 and perl 5.00503
--
Karsten
_______________________________________________________________________
Email: mailto:Karsten@Hachmeister-Online.de
Homepage: http://www.Hachmeister-Online.de
------------------------------
Date: 5 Dec 2000 05:45:11 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Using goto
Message-Id: <90hvd7$8v1$1@sloth.swcp.com>
Keywords: troll, troll, troll
Abigail <abigail@foad.org> wrote:
!! On Fri, 01 Dec 2000 08:00:52 GMT, Shawn Smith
[snip]
!! ++ Also, to justify removing the goto's I must show that it will improve
!! ++ the efficiency of the scripts. I can't just say hey these are not
!! ++ cool. The goto's are (so far, I have only read 3 of a dozen scripts)
!! ++ being used when an error occurs. Thus, only on rare occasions do the
!! ++ goto's get used.
!!
!! If gotos are only used on rare occasions, they can't have much influence
!! on efficiency, can they? To increase the performance, one focusses on
!! the bottlenecks, on one some error handling code that isn't called often.
How about infrequent use of $', $& and $`? If they only used rarely in
a program, they can't have much influence on efficiency, can they?
For those other than Abigail, who already knows this, see perldoc perlvar
or the documentation on sawampersand:
http://search.cpan.org/doc/ANDK/Devel-SawAmpersand-0.20/README
Modern perl's may better localize this problem.
Tramm
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
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 5033
**************************************