[18974] in Perl-Users-Digest
Perl-Users Digest, Issue: 1169 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 21 00:10:32 2001
Date: Wed, 20 Jun 2001 21: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: <993096612-v10-i1169@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 20 Jun 2001 Volume: 10 Number: 1169
Today's topics:
Re: problem with 'spaces' in url... <bwalton@rochester.rr.com>
Re: problem with CGI <nbatada@tempdb.com>
Re: problem with CGI <ron@savage.net.au>
Re: Reference-problem <bwalton@rochester.rr.com>
Re: Salary for teaching intro to perl <time4tea@monmouth.com>
Re: Setting Return-Path in sendmail from Perl (Per Hedeland)
shmctl()'s shmid_ds (data structure) (Rodney Broom)
Sorting array on multiple keys (Prad S)
Re: Sorting array on multiple keys <ron@savage.net.au>
Re: string tokenization <der.prinz@gmx.net>
Re: string tokenization <lfzhang@lbl.gov>
Re: string tokenization <der.prinz@gmx.net>
Re: Why does this split not work? <nospam@cfl.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 21 Jun 2001 03:22:09 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: problem with 'spaces' in url...
Message-Id: <3B316825.FD7ED0BC@rochester.rr.com>
Benjamin wrote:
>
> i wrote this perl script to check for broken links of my homepage:
>
> #!/usr/bin/perl -w
>
> use LWP::Simple;
>
> print "test the link to a file!\n";
>
> if(!head('ftp://192.168.0.2/pub/README'))
> {
> print "link is dead!";
> }
> else
> {
> print "link is good!";
> }
>
> ########################end.
> this is running without problems. but if the url has spaces in it, i don't
> know how to write it in the script.
> i testet ==> if(!head('ftp://192.168.0.2/pub/%20/README')) # after the
pub
> directory there is one with only one space for its name.
Hmmmm...maybe you mean .../pub%20/README or .../pub/%20README or
.../pub%20README ? Having a directory name which is just a space
character would be rather unusual and pretty dumb (it's bad enough just
having a space character in a directory or file name). Some braindead
OS's won't permit a file or directory name which is just spaces, or with
leading or trailing spaces (actually, maybe that's not a braindead
feature??). In any event, your question isn't a Perl question...you
might try a www newsgroup for better results. It is probably the case
that file/directory names consisting of just spaces are not permitted in
URL's. But folks here mostly aren't URL gurus, we're Perl gurus.
>
> i've to test links where are spaces, in the filename and the directory path.
> but the hex code "%20" don't work. "\ ", like in unix, the same way.
In a URL, you will need to %-escape a \ (along with many other special
characters). I would be surprised if that were a legal character in a
directory/file name in a URL as well.
> although i set the url in " ", but no working too.
> hope someone can help me! and sorry for my awful english.
------------------------------
Date: Wed, 20 Jun 2001 18:08:31 -0700
From: John Cat <nbatada@tempdb.com>
Subject: Re: problem with CGI
Message-Id: <Pine.LNX.4.33.0106201807330.9808-100000@schewanella.stanford.edu>
> easily. my favorite is simply to set the environment variable
> REQUEST_METHOD to GET. at the same time you could set other
> CGI relevant environment variables to affect how CGI.pm acts.
>
can you show me how i can set the REQUEST_METHOD to GET?
thanks
------------------------------
Date: Thu, 21 Jun 2001 12:25:20 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: problem with CGI
Message-Id: <CYcY6.8685$qJ4.352483@ozemail.com.au>
John
See below.
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
[snip]
> (offline mode: enter name=value pairs on standard input)
>
> then when i type in Ctrl-d it continues properly. How can i prevent this
> message?
>
>
> my code is....................
>
> #!/usr/bin/perl
>
> use CGI qw/:standard :html3/;
[snip]
Also try:
use CGI qw/-no_debug/;
or
use CGI qw(-no_debug :standard);
You can search the source of CGI.pm for 'no_debug'.
------------------------------
Date: Thu, 21 Jun 2001 02:48:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Reference-problem
Message-Id: <3B31604F.E90BFF59@rochester.rr.com>
Stefan Serena wrote:
>
> Thx, that was the point. I thought I understood that part... maybe I should
> reread it :-)
> Yes, I could use a hash, but I wanted to use references as I've never used
> them until now...
${$foo[0]} is *not* a hash, and has nothing to do with a hash. In this
case, the {...} is a block. It would be a hash lookup if it were, say:
$hash{$foo[0]}
Also, the construct you are using with ${$foo[0]} is not a proper
reference, but rather a "symbolic reference". See perldoc perlref,
under the "Symbolic References" section. Using symbolic references is a
*bad idea*. It corrupts your symbol table by creating variable names
that depend on your data -- so then you don't know for sure if maybe you
will overwrite a variable you didn't plan on overwriting because someone
put just the wrong thing in the data.
>
> "Rafael Garcia-Suarez" <rgarciasuarez@free.fr> schrieb im Newsbeitrag
> news:slrn9j13rr.ul1.rgarciasuarez@rafael.kazibao.net...
> > Stefan Serena wrote in comp.lang.perl.misc:
...
> > } What's wrong? It doesn't cause an error, but I want it to print "Hello
> > } World!"...
> > }
> > } @foo = ('bar', 'anything');
> > } $$foo[0] = "Hello World!";
> > } print $bar;
> >
> > You should write
> > ${$foo[0]} = "Hello World!";
> >
...
> > Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
--
Bob Walton
------------------------------
Date: Wed, 20 Jun 2001 22:20:48 -0400
From: "James Richardson" <time4tea@monmouth.com>
Subject: Re: Salary for teaching intro to perl
Message-Id: <9grlqf$q4u$1@nntp9.atl.mindspring.net>
"Allan Peda" <tl082@yahoo.com> wrote in message
news:20010620.103148.480298490.1213@yahoo.com...
> I am interested in teaching a basic perl class, say 20
> hours, which I expect will cover references and possibly
> some object oriented programming (just how to create an object).
[...]
> What are reasonable salary numbers?
Depends if you are teaching one of those shite classes with loads of flashy
handouts, but no content, or a real course.
James
------------------------------
Date: Wed, 20 Jun 2001 22:22:26 +0000 (UTC)
From: per@bluetail.com (Per Hedeland)
Subject: Re: Setting Return-Path in sendmail from Perl
Message-Id: <9gr7n2$2nkh$1@hedeland.org>
In article <oA7Y6.1987$bR5.694752@typhoon2.gnilink.net> "Steven Stalzer"
<steve@newmediacreations.com> writes:
>Hmm, I have indeed been using a valid From. This seems to allow a receiver to
>reply to me (such as to ask to be removed from the mailing list), but invalid
>emails in the list still get bounced back to the default Return-Path set up by
>the virtual server, rather than coming back to From, where I can deal with them.
More or less - the header sender address, i.e. on the From: header line,
decides (mostly) where human replies go, but bounces are sent to the
envelope sender address - and it so happens that the envelope sender
address is also often copied into the Return-Path: header on final
delivery. To set the envelope sender, use sendmail's -f option - see the
man page.
--Per Hedeland
per@bluetail.com
------------------------------
Date: Thu, 21 Jun 2001 00:47:31 GMT
From: NOrbroomS@PaMdesert.net (Rodney Broom)
Subject: shmctl()'s shmid_ds (data structure)
Message-Id: <9grfcs$jv6$1@nnrp2.phx.gblx.net>
I'm working with shared memory and wanting to learn about what segments are
already in use before trying to create new ones. From the docs, I think that I
can say:
$ret = shmctl($segment_id, IPC_STAT, $shmid_ds);
In fact, this works fine. But I don't know what to do with the data in
$shmid_ds. I suppose I'll need to unpack() it, but with what?
Rodney
P.S. I can't just use IPC::Shareable, my code is going into that module. ;-)
------------------------------
Date: Wed, 20 Jun 2001 23:18:52 GMT
From: ps@siteindia.com (Prad S)
Subject: Sorting array on multiple keys
Message-Id: <3b312e7e.711277112@news1.sfba.home.net>
Hi Experts,
I want to sort my array on multiple keys, right now it is sorted on
one key date and it has another field description
i want to sort first on date and then under date on description. Any
help or pointer is greatly appreciated.
my(@itemList) = sort {
return 0 if !defined($$a{date}) and !defined($$b{date});
return -1 if !defined($$a{date});
return 1 if !defined($$b{date});
$$a{date} <=> $$b{date}
} ( @Fees);
Thanks
Prad S
------------------------------
Date: Thu, 21 Jun 2001 11:32:40 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Sorting array on multiple keys
Message-Id: <fbcY6.8657$qJ4.351506@ozemail.com.au>
I'd start here: http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
------------------------------
Date: Thu, 21 Jun 2001 00:11:38 +0200
From: "Stefan Weiss" <der.prinz@gmx.net>
Subject: Re: string tokenization
Message-Id: <3b311f4d@e-post.inode.at>
Matthew Zhang da LBNL <lfzhang@lbl.gov> wrote:
> emailadd FirstName LastName
> emailadd2 FN2 LN2
> ...
>
> I want to read this file one line at a time, then basically extract the
> email address so that I can email another text file out...
> I am new to pearl, and from my java exp. The way I am tackling this is
> that I will look for the index of the white space of each line I read
> then substr. to get the first token...
Ah, this is Perl country ;-)
# untested:
open (FILE, "< /path/filename") or die "$!";
while (<FILE>) {
my ($email, $first, $last) = split ' ';
# do something here
}
close FILE;
BTW, a space might be not be the best choice as a field delimiter in
this case.
cheers,
stefan
------------------------------
Date: Wed, 20 Jun 2001 15:21:35 -0700
From: Matthew Zhang da LBNL <lfzhang@lbl.gov>
Subject: Re: string tokenization
Message-Id: <3B3121EF.DFCC0ED9@lbl.gov>
yes, I suppose space is NOT the best one...I am thinking tab as another
possible candidate...I suppose I can replace the space in your code by
tab...but i have a new question, that what if I want more character (more
than one) to be set as my tokenizer's separating character? I mean....if I
am just guaranteed that the each field will only be separated by whitespace
(can be space, tab, whatever)?
would that code still work if I am just guaranteed that the textfile consist
of a series of "words" separated by some kind of white space..like, my file
can be really weird like:
email1
FN1 LN1
email2 FN2 LN2
email3 FN3 LN3 email4
FN4 LN4 email5 FN5 LN5
thank you!
Stefan Weiss wrote:
> Matthew Zhang da LBNL <lfzhang@lbl.gov> wrote:
>
> > emailadd FirstName LastName
> > emailadd2 FN2 LN2
> > ...
> >
> > I want to read this file one line at a time, then basically extract the
> > email address so that I can email another text file out...
> > I am new to pearl, and from my java exp. The way I am tackling this is
> > that I will look for the index of the white space of each line I read
> > then substr. to get the first token...
>
> Ah, this is Perl country ;-)
>
> # untested:
> open (FILE, "< /path/filename") or die "$!";
> while (<FILE>) {
> my ($email, $first, $last) = split ' ';
> # do something here
> }
> close FILE;
>
> BTW, a space might be not be the best choice as a field delimiter in
> this case.
>
> cheers,
> stefan
------------------------------
Date: Thu, 21 Jun 2001 00:41:04 +0200
From: "Stefan Weiss" <der.prinz@gmx.net>
Subject: Re: string tokenization
Message-Id: <3b312632$1@e-post.inode.at>
Matthew Zhang da LBNL <lfzhang@lbl.gov> wrote:
> but i have a new question, that what if I want more character (more
> than one) to be set as my tokenizer's separating character? I mean....if I
> am just guaranteed that the each field will only be separated by whitespace
> (can be space, tab, whatever)?
> would that code still work if I am just guaranteed that the textfile consist
> of a series of "words" separated by some kind of white space..like, my file
> can be really weird like:
>
> email1
> FN1 LN1
> email2 FN2 LN2
> email3 FN3 LN3 email4
> FN4 LN4 email5 FN5 LN5
No, it would not work with a file like this. Hrm, who generates
such unstructured datafiles? Some sort of sadistic project manager? ;-)
If your file is not too large, the easiest way is probably to treat
the whole file as a single string:
#/usr/bin/perl -w
use strict;
undef $/;
my $file = <DATA>; # replace this with open() statement
while ($file =~ /(\S+)\s+(\S+)\s+(\S+)/g) {
print "mailto: $1 ($2 $3)\n";
}
__DATA__
email1
FN1 LN1
email2 FN2 LN2
email3 FN3 LN3 email4
FN4 LN4 email5 FN5 LN5
cheers,
stefan
------------------------------
Date: Thu, 21 Jun 2001 00:14:19 GMT
From: tuxy <nospam@cfl.rr.com>
Subject: Re: Why does this split not work?
Message-Id: <3B313D27.440674D0@cfl.rr.com>
Hi Ren:
I solved the problem. I went to a box with Perl 5.004 and botta-bing
botta-boom just as I suspected, my code is pristine, it's Perl 5.6
that's wacked. Apparently. Anyhow, now I either have to re-write this
algorithm in something 5.6-friendly, or have to revert to 5.004 on this
other box. Neither prospect is overly appealing.
A little surprizing too that in a forum this large, none of the guru's
would chime in with "oh split has some serious problems in 5.6".... That
message would have saved me many hours of study and experimentation. Oh
well what can I expect for free LOL..
Thanks for the replies Ren. Long live 5.004
Ren Maddox wrote:
>
> On Wed, 20 Jun 2001, nospam@cfl.rr.com wrote:
>
> > This doesn't occur in any loops, and I don't even have a filehandle
> > named IN! Is this weird or what? Good suggestion though with the $/
> > - I'll try it (But I shouldn't HAVE TO!)..
>
> See if you can reproduce the problem outside of the larger context and
> post the relevant code here.
>
> --
> Ren Maddox
> ren@tivoli.com
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 1169
***************************************