[11568] in Perl-Users-Digest
Perl-Users Digest, Issue: 5167 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 18 15:17:28 1999
Date: Thu, 18 Mar 99 12:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 18 Mar 1999 Volume: 8 Number: 5167
Today's topics:
Re: Adding elements to hash (Tad McClellan)
Re: echo pwd <droby@copyright.com>
Re: find command problem <blundell@lts.sel.alcatel.de>
Re: find command problem (Ken Pizzini)
Re: find command problem <ilya_NO_JUNK_PLS_@napavlly.rose.hp.com>
Re: Get an image from a URL using LWP <jamesht@idt.net>
Re: gethostname() <spike_YYwhiteYY@YYdellYY.com>
How to get DOCUMENT_URI variable <hallvard@npk.no>
incrementation with undef results in definition. jon@amxstudios.com
Re: Is this "perlish" <jglascoe@giss.nasa.gov>
Re: Is this "perlish" <cw@dwc.ch>
Re: Mac Newbie: droplet question (Rory Campbell Lange)
Macperl NEWBIE filename question (Rory Campbell Lange)
Mysterious Perl Bug <cart@dansie.net>
Re: Mysterious Perl Bug <aghaeim@genesis.co.nz>
not my server! <b-olsen@post8.tele.dk>
Perl 4 to Perl 5 Question <aweiss@csdi.qualcomm.com>
Perl Excel OLE dstanky@my-dejanews.com
Perl/Daemon wweng@ei.org
Promblems in compiling <mharris@webserver.iie.org>
Re: Regular Expression Help <jglascoe@giss.nasa.gov>
Re: Removing white space. <jglascoe@giss.nasa.gov>
Re: Removing white space. <cw@dwc.ch>
Re: Sending a Unique Image Height From HTML to CGI? <jamesht@idt.net>
Re: sendmail won't run on www ? <mlc@glink.net.hk>
Re: Sendmail (brian d foy)
TCGREP in Perl Cookbook (Christian M. Aranda)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Mar 1999 06:47:59 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Adding elements to hash
Message-Id: <f5pqc7.hdb.ln@magna.metronet.com>
Donny Widjaja (donny@impulsesoftware.com) wrote:
: I need to add to a couple new elements to the hash from a procedure.
: What I have now is
: %Form = qw(a Apple b Boy);
The above is rather useless...
: %Form = &addElement;
... since you assign to the whole hash again here, which
wipes out any previous values in the hash.
: print $Form{hello}."\n";
'hello' is the *only* key in the hash.
Changing the above to a loop that prints all hash entries
would show that.
: sub addElement {
: local ($href) = @_;
Here you are accessing the function's arguments, but you
did not supply any arguments in the function call!
: $href->{"hello"} = "world";
You do not need to quote the hash key there.
You should use single quotes when you do not need variables
or backslash escapes interpolated.
: return %$href;
: }
: The above procedure will get an address reference and return the whole
: hash table. What I want is a procedure that get an address reference
: and also return the address
Why do you want it to return a reference?
It can "add an element" without any return value...
: I tried "return $href", but it does not work. Any body has an idea?
---------------
#!/usr/bin/perl -w
use strict;
my %Form = qw(a Apple b Boy);
addElement(\%Form); # argument is a reference to a hash
foreach (sort keys %Form) {
print "$_ ==> $Form{$_}\n";
}
sub addElement {
my($href) = @_;
$href->{hello} = 'world';
}
---------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Mar 1999 18:02:54 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: echo pwd
Message-Id: <7crf4a$vsd$1@nnrp1.dejanews.com>
In article <7cpdoa$asa$1@nnrp1.dejanews.com>,
mr_potato_head@my-dejanews.com wrote:
> Hi,
> I need to echo the working directory to the screen and I tried using
>
> $directory = `pwd`;
> print "$directory\n";
>
> But this doesn't work. Any ideas? Thanks in advance...
>
If it doesn't work, you're probably not running on Unix.
You have to figure out and invoke the correct command for pwd on your OS.
This is most easily done with the Cwd module:
#!/usr/bin/perl
use strict;
use Cwd;
my $directory = cwd;
print "$directory\n";
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Mar 1999 18:16:32 +0100
From: Bernard Blundell <blundell@lts.sel.alcatel.de>
Subject: Re: find command problem
Message-Id: <36F134F0.718615A1@lts.sel.alcatel.de>
Bernard Blundell wrote:
> Your example includes an demonstration of escaping a command terminator (the
> semi-colon).
>
> $lines = `find $path* -name qhelp -exec echo \\| {} \\; 2>/dev/null`;
>
Sorry, it's been a long, tiring day. I've just re-read the post and I now see
the original semi is not being used as a shell terminator, but is supplied for
the use of 'find'. I also think I may have provided one too many backslashes.
Please, forgive me. I feel so ashamed.
------------------------------
Date: 18 Mar 1999 19:22:55 GMT
From: ken@halcyon.com (Ken Pizzini)
Subject: Re: find command problem
Message-Id: <slrn7f2i8g.ojl.ken@pulsar.halcyon.com>
On 18 Mar 1999 06:29:35 GMT, Ilya <ilya_NOSPAM_@napavlly.rose.hp.com> wrote:
>I can do the following at the prompt:
>
> > echo | /opt/robelle/bin/qhelp
>QHELP/UX/Copyright Robelle Consulting Ltd. 1981-1995
>(Version 2.1.05)
>
>Enter the help filename?
> >
Can you also do this with:
$ /opt/robelle/bin/qhelp </dev/null
?
>I would like to accomplish the same task programmatically, using the find in a
>Perl script:
>
>$lines = `find $path* -name qhelp -exec echo | {} \\; 2>/dev/null`;
...
>Any tips on how to handle "|" in the find command used in Perl script?
It's not a perl problem, it's a find problem.
First, to have find see the |, you need to quote it from the shell:
$lines = `find $path* -name qhelp -exec echo \\| {} \\; 2>/dev/null`;
But that won't do what you want either, as now find is calling echo
with the arguments "|" and "{}".
To have the pipe executed you need to have find invoke a subshell
to set up the pipeline:
$lines = `find $path* -name qhelp -exec sh -c 'echo \\| {}' \\; 2>/dev/null`;
But if you have very many qhelp executables this can get expensive.
So, if the </dev/null test above works for you, this can become:
$lines = `find $path* -name qhelp -exec {} \\; </dev/null 2>/dev/null`;
That's pretty good. But now let's step back a second and reconsider
the fact that we're running this from within perl. In that case we
can use File::Find to simplify things:
use File::Find;
$lines = '';
find(\&tryit, glob("$path*"));
sub tryit {/^qhelp$/ and $lines .= `echo | $File::Find::name 2>/dev/null`}
--Ken Pizzini
------------------------------
Date: 18 Mar 1999 19:50:28 GMT
From: Ilya <ilya_NO_JUNK_PLS_@napavlly.rose.hp.com>
Subject: Re: find command problem
Message-Id: <7crle4$cfd$1@ocean.cup.hp.com>
In comp.unix.admin Craig Eales <ealesc@deshaw.com> wrote:
> This is probably not the best way..... but I did this a while back on a similar
> problem... use the fact that the | is interpreted by the shell so use the exec to
> construct the exec strings then pipe them to sh...
> in your case
> find $path* -name qhelp -exec echo echo \\| {} 2\\>/dev/null \\; | sh
> note that we construct the command then pipe it into sh (hence need the two echo
> statements)
> Craig
It worked. Thanks. What is the second echo for and why does piping it to sh
gets the result?
--
Please modify the headers to reflect the correct email address.
------------------------------
Date: Thu, 18 Mar 1999 13:46:40 -0500
From: James Tolley <jamesht@idt.net>
To: alam@netscape.net
Subject: Re: Get an image from a URL using LWP
Message-Id: <36F14A10.ED9DC0B0@idt.net>
You're doing everything right except for one thing: you're not writing to the
filehandle in binmode. Put this right after the open call, and it should run
fine.
binmode(dest);
hth,
James
------------------------------
Date: Thu, 18 Mar 1999 13:35:00 -0600
From: "Spike White" <spike_YYwhiteYY@YYdellYY.com>
Subject: Re: gethostname()
Message-Id: <7crjsk$7ss$1@obsidian.us.dell.com>
use Sys::Hostname;
$host = hostname();
Spike
David L. Cassell wrote in message <36F13C59.94D38959@mail.cor.epa.gov>...
>Fernando Ariel Gont wrote:
>>
>> Hullo All , hope you are having a nice day!!
>
>Thank you. It's quite nice here in Oregon today.
>
>> Hi, is there any other way to get the local host name rather than
>> using 'localhost' ?
>>
>> I mean, in C there's gethostname()...
>
>Hmm, clearly a polite individual such as yourself must have read
>through the perl doc first. So I'll assume you were overwhelmed
>by the immense amount of information and missed it somehow. It
>can happen.
>
>Check the perlfunc manpage/perldoc/html-info that came with
>your Perl installation, and you'll find a host [ouch!] of
>valuable info on this. You'll be surprised at the built-ins.
>But you don't have to stop there! Perl also has some extremely
>useful modules that can help you do even more. So zip on over
>to CPAN and check it out. [If you don't know what/where CPAN
>is, the info on it is also in your Perl docs.]
>
>HTH,
>David
>--
>David L. Cassell, OAO cassell@mail.cor.epa.gov
>Senior computing specialist
>mathematical statistician
------------------------------
Date: Thu, 18 Mar 1999 19:39:27 +0100
From: "Hallvard =?ISO-8859-1?B?2A==?=strem" <hallvard@npk.no>
Subject: How to get DOCUMENT_URI variable
Message-Id: <7crh6j$fhb$1@elle.eunet.no>
I just don't get it! Please help me out:
I'm working on a simple html counter script where I'd like to identify the
DOCUMENT_URI environment variable for the page in order to list individual
counters for each page. My problem is that I can't get the script to get th=
e
DOCUMENT_URI from the page.
In the script I use $ENV{DOCUMENT_URI} for the page address, but it returns
nothing. I've tried scripts that collects all variables, and it turns out
that the DOCUMENT_URI is empty here as well.
If I call the DOCUMENT_URI directly from the page, like this:
<!--#echo var=3D"DOCUMENT_URI"-->
the correct URI is displayed on the page.
So how can I pass this information to the script?
regards,
Hallvard =D8strem
------------------------------
Date: Thu, 18 Mar 1999 18:10:30 GMT
From: jon@amxstudios.com
Subject: incrementation with undef results in definition.
Message-Id: <7crfig$cj$1@nnrp1.dejanews.com>
This is a sample of my debugger session:
DB<12> $y = 2
DB<13> $x = $y
DB<14> print 'defined' if defined($x)
defined
DB<15> $x = undef($y)
DB<16> print 'defined' if defined($x)
DB<17> $x .= undef($y)
DB<18> print 'defined' if defined($x)
defined
DB<19>
This seems odd to me. A similar effect occurs with the += operator.
Likewise, if you start with an undefined $x and do:
$x = ((undef) + (undef))
$x will be defined.
Is this a bug, or am I missing something?
The reason this is getting in my way, is that I want to error check a sequence
of function calls like this:
undef ($error);
$error .= func1();
$error .= func2();
print "Something failed" if defined $error.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Mar 1999 14:03:20 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: starplayer2@my-dejanews.com
Subject: Re: Is this "perlish"
Message-Id: <36F14DF8.B9D4A2A3@giss.nasa.gov>
[courtesy copy of post sent to cited author]
starplayer2@my-dejanews.com wrote:
>
> I wonder- would it be considered poor style to use say:
>
> !($yes && print "answer is yes\n") && print "answer is no\n";
print "answer is no\n" unless $yes and print "answer is yes\n";
print "answer is yes\n" if $yes or not print "answer is no\n";
> instead of
>
> if ($yes) {print "answer is yes\n";} else {print "answer is no\n";}
{ $yes and print "answer is yes\n" and last } continue { print "answer is no\n" }
> Any thoughts?
> S
`Just because you can do something a particular way
doesn't mean you should do it that way.'
--_Programming_Perl_
Jay Glascoe
------------------------------
Date: Thu, 18 Mar 1999 19:44:51 +0100
From: Christoph Wernli <cw@dwc.ch>
Subject: Re: Is this "perlish"
Message-Id: <36F149A3.199421F9@dwc.ch>
starplayer2@my-dejanews.com wrote:
>
> Hello People of Perl:
>
> I've started using logical experssions instead of if-else statements mostly
> because they seem easier to read, and tend to be terse. I showed them to a
> collegue and he felt that they were obsufasted or whatever that word is..
>
> I wonder- would it be considered poor style to use say:
>
> !($yes && print "answer is yes\n") && print "answer is no\n";
>
> instead of
>
> if ($yes) {print "answer is yes\n";} else {print "answer is no\n";}
>
> To me the former is clearer as it has fewer {} and is less wordy, but I can
> see his point that in the former, the intent is less obvious, as it looks
> like a dangling logical expression.
>
> Any thoughts?
($yes && print "answer is yes\n") || print "answer is no\n";
is my favourite. YMMV.
-w
------------------------------
Date: Thu, 18 Mar 1999 18:42:08 -0100
From: 'x'campbell-lange@easynet.co.uk (Rory Campbell Lange)
Subject: Re: Mac Newbie: droplet question
Message-Id: <'x'campbell-lange-1803991842080001@campbell-lange.easynet.co.uk>
In article <Arved_37-1803990705280001@dyip-100.chebucto.ns.ca>,
Arved_37@chebucto.ns.ca (Arved Sandstrom) wrote:
> In article
> <'x'campbell-lange-1803991022400001@campbell-lange.easynet.co.uk>,
> 'x'campbell-lange@easynet.co.uk (Rory Campbell Lange) wrote:
>
> > I have a script which I would like to be able to use when:
> > 1) a file is passed on to it
> > 2) or it is double clicked.
> >
> >
> > $file = shift(@ARG);
>
> [ Some snippage ]
>
> @ARGV, not @ARG.
>
> In any case, it might be more elegant to just see if scalar(@ARGV) is
> non-zero, rather than pattern-match on '.' (which you get if you
> double-click a droplet). This would make it more portable.
>
> Arved
Arved
My Macperl pod info has a typo with ARG instead of ARGV,
the problem is now sorted
!== 0 would be the answer to your next point?
Thanks for your advice
Rory
--
Rory Campbell-Lange
The Campbell-Lange Workshop
Remove the 'x' to reply
------------------------------
Date: Thu, 18 Mar 1999 18:43:49 -0100
From: 'x'campbell-lange@easynet.co.uk (Rory Campbell Lange)
Subject: Macperl NEWBIE filename question
Message-Id: <'x'campbell-lange-1803991843500001@campbell-lange.easynet.co.uk>
I am writing a quick script to rename long filenames so that they are
suitable for DOS systems.
I don't know how to change the name of the file after having worked on it!
I'd be grateful for any advice
Rory
#!perl-w
for ($i = 0; $i <= $#ARGV; $i++) { #get each file dropped on droplet
$filer = $ARGV[$i];
@fileres = split(/:/, $filer);
$filest = $fileres[$#fileres];
$colon = ":"; #get
path #works!
for ($i = 0; $i < $#fileres; $i++) {
$pather .= ($fileres[$i].$colon);
}
$filest =~ /([^.]+)([.]*)(\w*)/; #make sure <= 8chars before\.
($front, $mid, $end) = ($1, $2, $3); #and cut out whitespace and \\s
$front =~ s![\\|\s]!!g;
$fronter = length ($front);
if ($fronter > 8) {
$front = substr($front, $fronter - 8);
}
$filer = $pather.$front.$mid.$end;
#####################################################################
# How do I rename the file with $filer as the filename?
#####################################################################
}
--
Rory Campbell-Lange
The Campbell-Lange Workshop
Remove the 'x' to reply
------------------------------
Date: Thu, 18 Mar 1999 10:52:38 -0800
From: Craig <cart@dansie.net>
Subject: Mysterious Perl Bug
Message-Id: <36F14B76.111B161D@dansie.net>
I have a large script about 200k running on Perl 5.00502. It gives an
Internal Server Error when it comes to the second line listed below:
open(FILE,"$path");
@lines = <FILE>;
close(FILE);
The file located at $path does exist by the way. When I take the same
three lines of code and run them in a smaller script, they work fine.
Does anyone know why the second line of code causes a larger script to
error out but not a smaller script?
------------------------------
Date: Fri, 19 Mar 1999 08:20:47 +1300
From: Meh <aghaeim@genesis.co.nz>
Subject: Re: Mysterious Perl Bug
Message-Id: <36F1520F.C53FB7A9@genesis.co.nz>
Craig wrote:
>
> I have a large script about 200k running on Perl 5.00502. It gives an
> Internal Server Error when it comes to the second line listed below:
>
> open(FILE,"$path");
> @lines = <FILE>;
> close(FILE);
>
> The file located at $path does exist by the way. When I take the same
> three lines of code and run them in a smaller script, they work fine.
> Does anyone know why the second line of code causes a larger script to
> error out but not a smaller script?
What's the error message? Sometimes mistakes are in other lines but
because of interpreter mechanism,it catches the error in later lines.
--
---------------------------------------------------------------------
Protect privacy, boycott Intel PIII: http://www.bigbrotherinside.org
---------------------------------------------------------------------
------------------------------
Date: Thu, 18 Mar 1999 17:58:09 +0100
From: "Anders Prior" <b-olsen@post8.tele.dk>
Subject: not my server!
Message-Id: <7crbb9$45d$1@news.inet.tele.dk>
Hi, How do I access a file placed on another server and read its contents?
I'm new to Perl and I would like to show a part of another page on my page
via CGI without having to place it in my server dir.
thanks
------------------------------
Date: Thu, 18 Mar 1999 13:42:48 -0500
From: "Andrew Weiss" <aweiss@csdi.qualcomm.com>
Subject: Perl 4 to Perl 5 Question
Message-Id: <7crhkq$60u$1@thefuture.qualcomm.com>
I'm kinda new to Perl. Got the camel and the llama books. Nowhere near
proficient in it, just dangerous.
I've recently become responsible for maintaining a legacy "application"
written in Perl. When last modified, the application was targeted for Perl
4, and it ran fine. Oh, Perl4 on OS/2, that is.
Now I must take that application, and port it to Windows 95/98. The first
place I started was to download Perl for Windows. The perl.com site allowed
me to download version 5.005_02. Unfortunately, the application blows sky
high, producing many errors, when run with that version of Perl. I can also
download version 5.004_04, but I doubt that it will work either. I tried
ActivePerl, and the same errors came when I ran the application.
Here are my questions:
(1) Should I find a Perl4 and build it for W95/98? If so, where would I
begin?
(2) Or, should I put the time in to find out why the application won't work
under Perl5 (already spent a day at this, and getting frustrated) ?
(3) Or, does anybody know of a program which can translate Perl4 to Perl5,
or can point out what portions of the source may not work under Perl5?
An email in addition to your reply post would also be appreciated.
Andy Weiss
aweiss@csdi.qualcomm.com
------------------------------
Date: Thu, 18 Mar 1999 17:45:13 GMT
From: dstanky@my-dejanews.com
Subject: Perl Excel OLE
Message-Id: <7cre38$uv3$1@nnrp1.dejanews.com>
I need assistance opening an .xls file in ReadOnly mode in Perl. The .xls
file was saved password protected - as a result everytime I use Perl to open
the file I receive an Enter password or ReadOnly dialog box. I would some
how like Perl to just open the file in ReadOnly mode from the begining
avoiding the dialog box.
Thanks,
Dave
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 18 Mar 1999 19:49:15 GMT
From: wweng@ei.org
Subject: Perl/Daemon
Message-Id: <7crlbr$jsb$1@eipipeline.ei.org>
Can I write a perl script and run it as a daemon?
thanks
wei
------------------------------
Date: Thu, 18 Mar 1999 18:42:00 GMT
From: Marcus Harris <mharris@webserver.iie.org>
Subject: Promblems in compiling
Message-Id: <36F14816.6AB052D3@webserver.iie.org>
Hello,
I am having problems compilng PERl 5.5.2 on my RISC6000 running AIX
4.3.1. When I ran 'make test' (after running make) it gives the
following errors:
**************************************************************
Failed 27 test scripts out of 186, 82.80% okay.
### Since not all tests were successful, you may want to run some
### of them individually and examine any diagnostic messages they
### produce. See the INSTALL document's section on "make test".
### If you are testing the compiler, then ignore this message
### and run
### ./perl harness
### in the directory ./t.
###
### Since most tests were successful, you have a good chance to
### get information with better granularity by running
### ./perl harness
### in directory ./t.
u=0.86 s=0.92 cu=65 cs=23.05 scripts=155 tests=5656
make: 1254-004 The error code from the last command is 1. Failed
27 test scripts out of 186, 82.80% okay.
### Since not all tests were successful, you may want to run some
### of them individually and examine any diagnostic messages they
### produce. See the INSTALL document's section on "make test".
### If you are testing the compiler, then ignore this message
### and run
### ./perl harness
### in the directory ./t.
###
### Since most tests were successful, you have a good chance to
### get information with better granularity by running
### ./perl harness
### in directory ./t.
u=0.86 s=0.92 cu=65 cs=23.05 scripts=155 tests=5656
make: 1254-004 The error code from the last command is 1.
**************************************************************
I am fairly new to compiling programs so I may have made a mistake but
is there anyone who can give me an idea what look for before I
recompile?
------------------------------
Date: Thu, 18 Mar 1999 12:53:15 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: jglascoe@giss.nasa.gov
Subject: Re: Regular Expression Help
Message-Id: <36F13D8B.57C79AF2@giss.nasa.gov>
[courtesy copy of post sent to Gala]
Oh, yeah! For once I get to correct myself before
anyone else. :o)
Jay Glascoe wrote:
>
> sorry, but I think split's the way to go. What
> you propose would be more natural in C.
"rindex()"! "rindex()"! "rindex()"!
sub nth_slashes {
my ($string, $number) = @_;
my $pos = length $string;
my $substr = $_[2] || "\\";
$pos = rindex $string, $substr, --$pos while $number-- and $pos >= 0;
unless ($pos == -1)
{ return substr $string, $pos + 1 }
else
{ return "" }
}
> Jay Glascoe
--
"Poit!"
------------------------------
Date: Thu, 18 Mar 1999 13:24:04 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Brahmdeep Jandir <bjandir@hns.com>
Subject: Re: Removing white space.
Message-Id: <36F144C4.C10AC2C@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Brahmdeep Jandir wrote:
>
> $text =~ s#^\s*(.*)\s*$#$1#;
> $text =~ s#(.*)\s*$#$1#;
>
> Will the two above statements remove the white space at the end of the
> string or not ??
no.
> They do not for me ! Why ??
you want a non-greedy star in the parens:
$text =~ s#^\s*(.*?)\s*$#$1#;
$text =~ s#(.*?)\s*$#$1#;
this way the ".*" in parens does not capture all the trailing
white space.
But I think your approach is not as efficient as it could be.
Try this:
$text =~ s#^\s+##; # delete leading spaces
$text =~ s#\s+$##; # delete trailing spaces
Jay Glascoe
--
beep!
------------------------------
Date: Thu, 18 Mar 1999 19:37:35 +0100
From: Christoph Wernli <cw@dwc.ch>
To: Brahmdeep Jandir <bjandir@hns.com>
Subject: Re: Removing white space.
Message-Id: <36F147EF.5FBDFD14@dwc.ch>
Brahmdeep Jandir wrote:
[courtesy copy mailed]
> I am sure this has been asked at least a million times .... but please bear
> with me.
>
> $text =~ s#^\s*(.*)\s*$#$1#;
> $text =~ s#(.*)\s*$#$1#;
>
> Will the two above statements remove the white space at the end of the
> string or not ??
They won't. The .*-part eats up everything till the end of the line.
Make it non-greedy: .*?
See
perldoc perlre
for more info.
-w
------------------------------
Date: Thu, 18 Mar 1999 13:49:30 -0500
From: James Tolley <jamesht@idt.net>
To: Laertis <lerna@terna.com>
Subject: Re: Sending a Unique Image Height From HTML to CGI?
Message-Id: <36F14ABA.53E149CF@idt.net>
This is an html and/or javascript question. Try a more appropriate group.
------------------------------
Date: Fri, 19 Mar 1999 02:25:30 +0800
From: mlc <mlc@glink.net.hk>
Subject: Re: sendmail won't run on www ?
Message-Id: <36F1451A.4C0E3656@glink.net.hk>
The script works after adding the line:
print "Content-type: text/plain\n\nMail Sent.\n";
to the end of the script.
Thanks
John Chan
mlc@glink.net.hk
------------------------------
Date: Thu, 18 Mar 1999 14:48:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sendmail
Message-Id: <comdog-ya02408000R1803991448290001@news.panix.com>
In article <36F11BD6.E4B6E011@orades.nl>, s.filipowicz@orades.nl posted:
> Is it possible to send the mail send by sendmail to two emailaddresses?
>
> Something like this :
> ---------------------------------------------------------------------------
> print MAIL "To: <root\@abc.com> , <root\@def.com>\n";
> ---------------------------------------------------------------------------
Yes. but that has nothing to do with Perl. if you don't want to
think about how sendmail works, you might want to use a Perl module
instead.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 18 Mar 1999 19:16:12 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: TCGREP in Perl Cookbook
Message-Id: <36f14e4f.12330049@news.bmc.com>
In Tom Christiansen's version of grep (Recipe 6.22) in the Perl
Cookbook, he has the following code:
($opt, $matcher) = parse_args()
.
.
sub usage {
die <<EOF
usage: $Me [flags] [files]
.
.
}
sub parse_args {
use Getopt::Std;
$optstring = "incCwsxvhe:f:l1HurtpP:aqT";
getopts($optstring, \%opt) or usage();
if ($opt{f}) { # -f patfile
.
.
}
.
.
return (\%opt, $matcher);
}
my question is this: when would it call usage()? I have written a
hack of this for experimental use (i.e., it doesn't do anything
practical yet).
#!/usr/bin/perl -w
use strict;
my ($opt);
($opt) = parse_args(); # get command line options
sub usage {
die <<EOF
usage: [flags] [files]
EOF
}
sub parse_args {
use Getopt::Std;
my ($optstring, %opt);
$optstring = "v";
getopts($optstring, \%opt) or usage();
if ($opt{v}) {
print "Version 0.01\n";
}
return (\%opt);
}
This code does part of what I need. When invoked as 'mytest -v' it
prints Version 0.01. When invoked as 'mytest' it doesn't do anything.
I just can't seem to figure out when the 'or usage()' would fire.
TIA - SSL
Christian M. Aranda
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5167
**************************************