[8790] in Perl-Users-Digest
Perl-Users Digest, Issue: 2407 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 23 23:07:37 1998
Date: Thu, 23 Apr 98 20:00:27 -0700
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, 23 Apr 1998 Volume: 8 Number: 2407
Today's topics:
Re: A.B.I.G.A.I.L. (Alan Barclay)
best way to find disk space for a directory (Alex Krohn)
Re: BUG or FEATURE? -- splice() doesn't extend arrays <ajh@rtk.com>
Re: cgi.pm book <chasecreek.systemhouse@usa.net>
Re: cgi.pm book (Kelly Hirano)
Re: cgi.pm book <bill@astro.fccj.cc.fl.us>
Re: Connecting to a socks server without recompiling Pe mlehmann@prismnet.com
Re: Eat my dust - Perl running on Windows 95 <chasecreek.systemhouse@usa.net>
Free http perl cgi windows95 practice platform <Mark.Fynes@cs.tcd.ie>
Re: Hash ref slice syntax? <igor.k@usa.net>
Re: Hash ref slice syntax? <danboo@negia.net>
Re: Hash ref slice syntax? <chasecreek.systemhouse@usa.net>
Re: Hash ref slice syntax? <ljz@asfast.com>
Re: help with s/$foo/$bar/go; oddness (Martien Verbruggen)
Re: How do you read e-mail with Perl/MailTools? (Martien Verbruggen)
Re: how to put subject in a email? (Abigail)
Re: how to put subject in a email? (Martien Verbruggen)
Re: parsing data (Martien Verbruggen)
Re: Perl vs. Java (Charles DeRykus)
Re: Pragma error (Martien Verbruggen)
Re: socket input problems <jdf@pobox.com>
Re: socket input problems (Martien Verbruggen)
split... jcoffey@connectnet.com
Re: split... (H. Paul Hammann)
Re: split... (Gabor)
Re: spoiled noobie <chasecreek.systemhouse@usa.net>
Re: spoiled noobie <tchrist@mox.perl.com>
Re: spoiled noobie <rjk@coos.dartmouth.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Apr 1998 00:48:32 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: A.B.I.G.A.I.L.
Message-Id: <893378910.527795@elaine.drink.com>
In article <353A35EF.2D99FCD2@shaw.wave.ca>,
Rick Delaney <rick.delaney@shaw.wave.ca> wrote:
>Bob Trieger wrote:
>It should be noted that ABIGAIL is meant to complement, not replace the
>friendly Mark I version, Tom Phoenix (origin of name, unknown).
I belive it was a back formation from Test Program.
------------------------------
Date: Fri, 24 Apr 1998 01:37:05 GMT
From: alex@gossamer-threads.com (Alex Krohn)
Subject: best way to find disk space for a directory
Message-Id: <353fec44.583264@coburg>
Hi,
I need to find how much disk space is used within a directory. Two
possible ways I can go are:
1. do a `du -a -b $dir` and look at the last entry..
2. use find to get a list of files and then loop through and stat each
one to get the file size.
Which option is preferable? Is there a better way?
Any help is really appreciated!
Alex
------------------------------
Date: Thu, 23 Apr 1998 17:21:24 -0700
From: "Aaron Harsh" <ajh@rtk.com>
Subject: Re: BUG or FEATURE? -- splice() doesn't extend arrays
Message-Id: <6hom0v$pp1$1@brokaw.wa.com>
Jason Gloudon wrote in message ...
>Tom Phoenix <rootbeer@teleport.com> wrote:
>>I'd like to see this fixed. The problem I see is that, if we were to fix
>>it now, it might cause some older program to break. :-P
It would cause some code I wrote last week to break:
@thingies = sort get_thingies();
@top_ten_thingies = @thingies;
splice @top_ten_thingies, 10;
If splice was "fixed" I might end up with undefs in my array (if there are
fewer than 10 thingies).
I suppose I could also have written it as:
@top_ten_things = @thingies > 10 ? @thingies[0..9] : @thingies;
although I'm not sure if that's any better in any way...
>This bug means that these are not equivalent:
>
> $a[$x] = $y splice(@a,$x,1,$y);
Wierd. I can't imagine anyone getting any use out of that behavior. Unlike
that behavior I depend on, which is so obviously useful :-)
--
Aaron Harsh
ajh@rtk.com
------------------------------
Date: Fri, 24 Apr 1998 01:06:45 GMT
From: Bill 'Sneex' Jones <chasecreek.systemhouse@usa.net>
Subject: Re: cgi.pm book
Message-Id: <353FE400.2D2D3831@usa.net>
David Turley wrote:
>
> TPJ has an ad for a book called Lincoln Stein's Guide to CGI.pm. My
> bookstore has a book called Official Guide to Programming with cgi.pm, by
> Stein.
>
> Same book?
I think so! I purchased a book this past weekend
that is ISBN 0-471-24744-8 $29.99 (Official Guide...CGI.pm)
Yesterday I was browsing a magazine about programming
langauges and had seen a CGI.pm book by Lincoln for $19.99,
It was called Lincoln Stein's Guide to CGI.pm, with a
different cover. Now, I am looking at what I purchased
and I am looking at TPJ, page 4 (all ads) and the ISBN is
the same. So what happened? Oh well, it's an excellent
book and worth it, either way :-)
-Sneex-
__________________________
Bill Jones...............|
Sneaker's Nest...........|
Chasecreek Systemhouse...|
------------------------------
Date: 23 Apr 1998 18:57:16 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: cgi.pm book
Message-Id: <6horhs$s8d@Xenon.Stanford.EDU>
i couldn't imagine buying a book for cgi.pm since it changes so often. just
use the online reference at:
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
it covers the latest version 2.39 (released 3/24/98).
In article <353FE400.2D2D3831@usa.net>,
Bill 'Sneex' Jones <sneaker@mediaone.net> wrote:
>David Turley wrote:
>>
>> TPJ has an ad for a book called Lincoln Stein's Guide to CGI.pm. My
>> bookstore has a book called Official Guide to Programming with cgi.pm, by
>> Stein.
>>
>> Same book?
>
>I think so! I purchased a book this past weekend
>that is ISBN 0-471-24744-8 $29.99 (Official Guide...CGI.pm)
>
>Yesterday I was browsing a magazine about programming
>langauges and had seen a CGI.pm book by Lincoln for $19.99,
>It was called Lincoln Stein's Guide to CGI.pm, with a
>different cover. Now, I am looking at what I purchased
>and I am looking at TPJ, page 4 (all ads) and the ISBN is
>the same. So what happened? Oh well, it's an excellent
>book and worth it, either way :-)
>
>-Sneex-
>__________________________
>Bill Jones...............|
>Sneaker's Nest...........|
>Chasecreek Systemhouse...|
--
Kelly William Hirano Stanford Athletics:
hirano@cs.stanford.edu http://www.gostanford.com/
hirano@alumni.stanford.org (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20
------------------------------
Date: Fri, 24 Apr 1998 02:06:25 GMT
From: Bill 'Sneex' Jones <bill@astro.fccj.cc.fl.us>
Subject: Re: cgi.pm book
Message-Id: <353FF1FC.A6C21CC9@astro.fccj.cc.fl.us>
Kelly Hirano wrote:
>
> i couldn't imagine buying a book for cgi.pm since it changes so often. just
> use the online reference at:
> http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
> it covers the latest version 2.39 (released 3/24/98).
Call me weird :-) I like having something besides a computer
to hold onto :-)
-Sneex-
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 904-632-3089 | Fax 904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.cc.fl.us | http://www.fccj.cc.fl.us
------------------------------
Date: Thu, 23 Apr 1998 17:06:04 -0600
From: mlehmann@prismnet.com
Subject: Re: Connecting to a socks server without recompiling Perl source code.
Message-Id: <6hoe0c$jbu$1@nnrp1.dejanews.com>
I needed to make LWP connect through a socks server. I recompiled perl with
Socks support, but the IO::Socket::Inet calls fail with that support, and LWP
is based on that. I then decied to simplify my design to not require LWP,
even though I prefer using this excellent Perl Class library, and write the
socks connect support in Perl itself. So here is the procedural oriented
subroutine (not Object Oriented) to do this. I would have prefered object
oriented code, but I had lots of problems with using the pseudo object type
globs passed back from IO::Socket::Inet and even IO::Socket.
You may freely use and modify this code. Please mention my name near the
function if you make only subtle modifications.
Grahm Barr, please look at this and determine if you can find a way to get
this integrated into the IO::Socket routines. I'll be glad to assist.
use IO::Socket;
# socks_connect by Mark Lehmann (mlehmann@prismnet.com), Jan 1998.
# socks_connect:
#
# create a socket to a machine through a socks firewall
#
# my ($socket, $errmsg) =
# socks_connect('socks_server' => 'socks.example.com',
# 'remote_ip_addr' => 'www.perl.com',
# 'remote_ip_port' => 80);
#
# where:
# socks_server is the hostname or ip address of the socks server
#
# remote_ip_addr is the hostname of the real machine we are trying
# to contact
#
# remote_ip_port is the port of the real machine we are trying to contact
#
# $socket is the sock of the port being contacted, or undef if there was
# any error
# $errmsg is the text message describing the problem or success
sub socks_connect {
my %parms = @_;
# Address/Name of the socks server passed in as a parameter or the
# default socks host
my $socks_server = $parms{'socks_server'} || 'socks.domain.org';
# Address/Name of true host we are trying to contact
my $remote_ip_addr = $parms{'remote_ip_addr'};
# Port of true host we are trying to contact
my $remote_ip_port = $parms{'remote_ip_port'};
my $socks_port = 1080;
# Make a connection to the Socks server
my $timeout = 6;
my $socks_session = Symbol::gensym();
my $rc = 1;
while ( $timeout-- > 0) {
my $internet_addr = Socket::inet_aton($socks_server);
my $physical_addr = Socket::sockaddr_in($socks_port, $internet_addr);
my $protocol = getprotobyname('tcp');
$rc = socket($socks_session, Socket::PF_INET, Socket::SOCK_STREAM,
$protocol);
if ( ! $rc ) {
next;
}
$rc = connect($socks_session, $physical_addr);
if ( $rc ) {
last;
}
}
if ( $rc == 0 ) {
die "Could not connect to the socks server $socks_server after $timeout
retries. $!";
}
# Create a Socks "connect" session to chat host machine
# ($hostname_chat) on the proper port ($port_chat).
my $socks_vn = 4; # This is a version 4 socks request
my $socks_cd = 1; # This is a SOCKS 4 connect request
my $dstport = $remote_ip_port; # True port we want to use
my $dstip = IO::Socket::inet_aton($remote_ip_addr); # True machine we want
to use
# Pack the command into socks format:
# +----+----+----+----+----+----+----+----+----+----+....+----+
# | VN | CD | DSTPORT | DSTIP | USERID |NULL|
# +----+----+----+----+----+----+----+----+----+----+....+----+
# # of bytes: 1 1 2 4 variable 1
#
# VN is the SOCKS protocol version number and should be 4. CD is the
# SOCKS command code and should be 1 for CONNECT request. NULL is a
# byte of all zero bits. The DSTPORT is the 16-bit big-endian port
# number, the DTSIP is the 32-bit big-endian IP address. USERID is
# unused and the NULL is 0 represented in 8-bits.
$socks_info = pack('C C n a4 x', $socks_vn, $socks_cd, $dstport, $dstip);
#print $session $socks_info;
send($socks_session, $socks_info, 0);
my $socks_rc_length = 8;
my $socks_rc;
#$socks_rc = <$session>;
recv($socks_session, $socks_rc, $socks_rc_length, 0);
# +----+----+----+----+----+----+----+----+
# | VN | CD | DSTPORT | DSTIP |
# +----+----+----+----+----+----+----+----+
# # of bytes: 1 1 2 4
#
# VN is the version of the reply code and should be 0. CD is the result
# code with one of the following values:
#
# 90: request granted
# 91: request rejected or failed
# 92: request rejected becasue SOCKS server cannot connect to
# identd on the client
# 93: request rejected because the client program and identd
# report different user-ids
#
# The remaining fields are ignored.
my ($serv_vn, $serv_cd, $serv_dstport, $serv_dstip) =
unpack('C C n a4', $socks_rc);
my $socks_request_granted = 90;
my %socks_connect_error =
( 90 => 'request granted',
91 => 'request rejected or failed',
92 => 'request rejected becasue SOCKS server cannot connect to identd on
the client',
93 => 'request rejected because the client program and identd report
different user-ids');
#Check for good return code
if ( $serv_cd != $socks_request_granted) {
close($socks_session);
return (undef, $socks_connect_error{$serv_cd});
}
return ($socks_session, 'Successfully set the socks socket');
}
1;
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 24 Apr 1998 00:25:28 GMT
From: Bill 'Sneex' Jones <chasecreek.systemhouse@usa.net>
Subject: Re: Eat my dust - Perl running on Windows 95
Message-Id: <353FDA54.4B6BD966@usa.net>
Fain wrote:
>
> Bart Lateur wrote:
>
> > Fain wrote:
> >
> > > Wow! you guys really know how to get off subject!
> >
> > What subject?
> >
> > Bart.
>
> The original subject was on how a guy got perl working on his 486. Now
> they are talking about porn. Change your USENET view to sort the
> messages by subject and read them all for this subject, you'll see.
>
> - Nathan
> mindmore@mindless.com
Warning: All joking should now stop.
The P word was used and it wasn't Perl.
--
__________________________
Bill Jones...............|
Sneaker's Nest...........|
Chasecreek Systemhouse...|
------------------------------
Date: Fri, 24 Apr 1998 03:06:37 +0100
From: "Mark Fynes" <Mark.Fynes@cs.tcd.ie>
Subject: Free http perl cgi windows95 practice platform
Message-Id: <6horuv$j1j@web3.tcd.ie>
Hi,
Can anyone recommend a freeware setup for testing / learning perl web
programming ( through cgi )
on the windows95 platform?
I've had not success with mod_perl and apache as it requires winNT4
Any suggestions would be most appreciated
regards
Mark Fynes
------------------------------
Date: Thu, 23 Apr 1998 18:16:59 -0700
From: "Igor Krivokon" <igor.k@usa.net>
Subject: Re: Hash ref slice syntax?
Message-Id: <6hoovg$ra3$1@news.ncal.verio.com>
Craig Berry wrote in message <6hoico$gep$1@marina.cinenet.net>...
>I've banged away at this for a while, but seem to be suffering partial
>brain lock today, so...
>
>Suppose I have a hash reference:
>
> $hr = { a => 1, b => 2, c => 3 };
>
>Now, suppose I want to obtain two of the values of this hash as a list
>through a hash slice. With an ordinary hash, I'd use syntax like this:
>
> %h = ( x => 11, y => 12, z => 13 );
> @xyvals = @h{'x', 'y'};
> print "@xyvals\n"; # Prints: 11 12
>
>What's the equivalent syntax for getting a slice {'a', 'b'} of the hash
>refered to by $hr? I've tried a number of increasing ugly variants
>without success. I can't find it in the docs, on or offline.
>
@abvals = @$hr{'a', 'b'};
Hope this helps,
Igor Krivokon
<igor.k@usa.net>
------------------------------
Date: Thu, 23 Apr 1998 20:00:22 -0400
From: Dan Boorstein <danboo@negia.net>
To: cberry@cinenet.net
Subject: Re: Hash ref slice syntax?
Message-Id: <353FD616.78413E4E@negia.net>
Craig Berry wrote:
>
> I've banged away at this for a while, but seem to be suffering partial
> brain lock today, so...
>
> Suppose I have a hash reference:
>
> $hr = { a => 1, b => 2, c => 3 };
>
> Now, suppose I want to obtain two of the values of this hash as a list
> through a hash slice. With an ordinary hash, I'd use syntax like this:
>
> %h = ( x => 11, y => 12, z => 13 );
> @xyvals = @h{'x', 'y'};
> print "@xyvals\n"; # Prints: 11 12
>
@$hr{'a', 'b'} should do the trick here. but if you've got deaper
nested hashes that you want to slice, you can follow the general
rule of wrapping your hash ref in @{ }.
$hr = {
a => {
foo => 1,
bar => 3,
}
};
@vals = @{ $hr->{a} }{'foo', 'bar'};
print "@vals\n"; # Prints: 1 3
so, in this more explicit format your original would be:
@{ $hr }{'a', 'b'}
hope this helps,
--
Dan Borstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Fri, 24 Apr 1998 01:20:20 GMT
From: Bill 'Sneex' Jones <chasecreek.systemhouse@usa.net>
Subject: Re: Hash ref slice syntax?
Message-Id: <353FE730.290B05E0@usa.net>
Craig Berry wrote:
> %h = ( x => 11, y => 12, z => 13 );
> @xyvals = @h{'x', 'y'};
> print "@xyvals\n"; # Prints: 11 12
>
> What's the equivalent syntax for getting a slice {'a', 'b'} of the hash
> refered to by $hr? I've tried a number of increasing ugly variants
> without success. I can't find it in the docs, on or offline.
Effective Perl Programming says something like this:
@char_num{'A'..'Z'} = 1..26;
Is that what you mean?
-Sneex-
__________________________
Bill Jones...............|
Sneaker's Nest...........|
Chasecreek Systemhouse...|
------------------------------
Date: 23 Apr 1998 22:20:00 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Hash ref slice syntax?
Message-Id: <ltogxsot9r.fsf@asfast.com>
cberry@cinenet.net (Craig Berry) writes:
> I've banged away at this for a while, but seem to be suffering partial
> brain lock today, so...
>
> Suppose I have a hash reference:
>
> $hr = { a => 1, b => 2, c => 3 };
>
> Now, suppose I want to obtain two of the values of this hash as a list
> through a hash slice. With an ordinary hash, I'd use syntax like this:
>
> %h = ( x => 11, y => 12, z => 13 );
> @xyvals = @h{'x', 'y'};
> print "@xyvals\n"; # Prints: 11 12
>
> What's the equivalent syntax for getting a slice {'a', 'b'} of the hash
> refered to by $hr? I've tried a number of increasing ugly variants
> without success. I can't find it in the docs, on or offline.
This worked for me in Perl 5.004_04 (given your `$hr' definition, above):
@bcvals = @{$hr}{'b', 'c'};
print "@bcvals\n"; # prints 2 3
In most (all?) cases, you can dereference a hash as follows:
<typecode>{$hash}
where `<typecode>' is `@', `%', `&', etc.
Good luck!
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: 24 Apr 1998 01:40:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: help with s/$foo/$bar/go; oddness
Message-Id: <6hoqi8$j3i$1@comdyn.comdyn.com.au>
In article <xieEruGz2.7ns@netcom.com>,
xie@netcom.com (Sheppard) writes:
> #!/usr/local/gnu/bin/perl
>
> # the object is to globally replace all instances of the bar character (|)
> # with the colon character (:). however...
>
> $text = "now|is|the|time";
>
> $copy = $text;
> $copy =~ s/|/:/go;
Time for some documentation:
# perldoc perlre
[snip]
In particular the following metacharacters have their
standard egrep-ish meanings:
\ Quote the next metacharacter
^ Match the beginning of the line
. Match any character (except newline)
$ Match the end of the line (or before newline at the end)
---> | Alternation
() Grouping
[] Character class
[snip]
Aha, so '|' is a metacharacter. Hmmm. Wonder what it does,
# perldoc perlre
[snip]
You can specify a series of alternatives for a pattern using "|"
to separate them, so that fee|fie|foe will match any of "fee",
"fie", or "foe" in the target string (as would f(e|i|o)e).
[snip]
So, the regexp /|/ matches nothing or nothing, which is nothing. Which
is exactly equal to //.
Try escaping the thing, and please browse through the documentation
now and again. Oh, and you also don't need the o.
$copy =~ s/\|/:/g;
> print "text = $copy \n";
> # prints "text = :n:o:w:|:i:s:|:t:h:e:|:t:i:m:e:" not what I expected!
>
> $copy = $text;
> $copy =~ s/\|/:/go;
Ah, so you did know?
I'm not going to erase all that typing though.
> $token = "|";
> $new_token = ":";
>
> $copy = $text;
> $copy =~ s/$token/$new_token/go;
> print "text = $copy \n";
> # prints "text = :n:o:w:|:i:s:|:t:h:e:|:t:i:m:e:" not what I expected again!
Try \Q and \E
# perldoc perlre
[snip]
\Q quote (disable) regexp metacharacters till \E
[snip]
Since there is nothing that doesn't need quoting, you can leave off
the \E
# perl
$t = "now|is|the|time";
$tok = '|';
$t =~ s/\Q$tok/:/g;
print $t, "\n";
__END__
now:is:the:time
There, an answer after all :)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd. | why kamikaze pilots wore helmets - Dave
NSW, Australia | Edison
------------------------------
Date: 24 Apr 1998 01:00:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do you read e-mail with Perl/MailTools?
Message-Id: <6hoo7k$ipr$1@comdyn.comdyn.com.au>
In article <6hnssp$2bm$1@clarknet.clark.net>,
cwatson@nuevo.com (C. Watson) writes:
> The FAQ suggests using Internet.pm from the MailTools package to read e-mail,
> which I have installed. I am not (as yet) a perl wizard, and find that the
> documentation and examples for this package don't give me enough information
> on using it to read e-mail. I've searched DejaNews and this newsgroup for
> information on reading e-mail, and have found nothing.
You don't have to be a wizard to use those modules. They're pretty
straight forward, if you know what they're about. You might need to
have a bit of a primer on how mailboxes are organised, and how mail
works. I can't tell you where to get that info, but reading the FAQ
from one of the mail usenet groups might be a good start.
> I am sure I could use sockets to open a connection to a pop server, but I am
> looking for an easier, softer way.
You seem to be a bit confused about 'reading' mail and 'retrieving'
mail from a server. i think the Mail::Internet stuff is meant to use
on a local mailbox, something you have on disk. To retrieve mail from
a POP server, you will need a separate module:
# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.36)
ReadLine support enabled
cpan> i /pop/
Distribution SDOWD/POP3Client-1_15.tar.gz
Module Mail::POP3Client (SDOWD/POP3Client-1_15.tar.gz)
Module Net::POP3 (GBARR/libnet-1.0605.tar.gz)
Module QPopupMenu (AWIN/PerlQt-1.06.tar.gz)
It looks like Mail::POP3Client might be what you need. If you also
want to send mail, you might need to have a look at some of the other
Mail:: modules, or even Net::SMTP
But before you start implementing any of this, you should have a good
think about what is what, and how exactly all of this works.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: 24 Apr 1998 00:15:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how to put subject in a email?
Message-Id: <6holif$rkl$2@client2.news.psi.net>
tw96 (tw96@email.msn.com) wrote on MDCXCVI September MCMXCIII in
<URL: news:OiHcaCwb9GA.126@upnetnews03>:
++ Hello:
++
++ i'm practicing to write a program to send email, but i don't know how to put
++ sth. in
++ Subject:
++ all i got now is an empty area, will somebody tell me how to do that?
Then of course entirely depends on which program you use to
send email. If you prefer to avoid the Mail:: modules, please
ask in a group dealing the program of your choice.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 24 Apr 1998 01:05:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how to put subject in a email?
Message-Id: <6hooh9$ipr$2@comdyn.comdyn.com.au>
In article <OiHcaCwb9GA.126@upnetnews03>,
"tw96" <tw96@email.msn.com> writes:
> Hello:
>
> i'm practicing to write a program to send email, but i don't know how to put
> sth. in
> Subject:
> all i got now is an empty area, will somebody tell me how to do that?
What is sth.?
What are you using to compose the message? What are you using to send
the mail? Unfortunately, my crystal ball is all fogged up today, and
my tarot cards have been eaten by the baby. So you'll have to help us
along a bit here.
Just to make sure you don't post non-perl-related posts in answer to
this: If you use an external mail program (mail, sendmail, blat,
whatever), you need to read the documentation for that program. If you
are using one of the Mail:: modules (which you probably should) you
should read the documentation for those.
Only if you are absolutely sure that the problem you have is a perl
problem, you should reply, and give us more info.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Advertising: The science of arresting
Commercial Dynamics Pty. Ltd. | the human intelligence long enough to
NSW, Australia | get money from it.
------------------------------
Date: 23 Apr 1998 23:52:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: parsing data
Message-Id: <6hok8a$h20$2@comdyn.comdyn.com.au>
In article <353E515F.7EA5@mailhost.netdot.com>,
"John T. Otto" <ottojt@mailhost.netdot.com> writes:
> I'm having trouble parsing data from an INFILE, and placing it in the
> appropriate place in my OUTFILE.
And *how* are you trying to accomplish this?
> I'm assigning a variable to the INFILE, and trying to grab a substring
> out of it. For instance, a variable called $name, which is a substring
> of the INFILE variable occurring at position 75, and is 7 characters
> long. The script pulls out data from that position if its there, but
> not the right stuff, resulting in lots of repeats, wrong data, etc.
And how are you doing this?
> The format works, and the script doesn't crash, it's just a matter of
> getting the right data from the approprite place, and putting it where I
> need it. I can't seem to find the answer in my manuals. Does anyone
> have any experience reformatting large files, and if so, can you help me
> out?
>
> I'd be glad to give you some of my sample data, and the a copy of the
> initial script if needed.
It would be a good idea to provide us with the code of your script,
and if it is very large, please just provide the relevant parts. it's
very hard for us to guess what you might be doing wrong, without
actually seeing the code, and I really have a hard time guessing what
exactly it is you want to do from your description.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Fri, 24 Apr 1998 01:32:46 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Perl vs. Java
Message-Id: <Erw9Mn.BL7@news.boeing.com>
In article <6hnqen$f2h$1@hecate.umd.edu>,
Wayne C. McCullough <wayne@Glue.umd.edu> wrote:
>Jason Taylor <jtaylor@ala.net> wrote:
>: Remember that comparing Java with Perl is like comparing Apples and
>: Coffee :)
>
>Also, Java is intended to work in such a way that you can theoreticly
>run anyone's java script and not have to worry about what damage it
>will do to your system.
>
>On the other hand, Perl is used by system administrators for configuration.
>
>Would you run a strange perl program from an unknown site without
>carefully examining it first?
>
Nah, too much work to examine. I'd use the wonderful Safe
module (part of Penquin's armory):
use Safe;
use strict;
my $user_code = <<'END'; # wrap the program here
...
...
END
my $safe = new Safe;
my $result = $safe->reval($user_code);
if ($@) {
die "something wicked comes this way... : $@";
}
--
Charles DeRykus
------------------------------
Date: 23 Apr 1998 23:49:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Pragma error
Message-Id: <6hok24$h20$1@comdyn.comdyn.com.au>
In article <6hligt$q0l$1@owl.slip.net>,
"Beau Giles" <giles@agentware.com> writes:
> From time to time I get syntax error on scripts using pragmas. For instance
In this case it's not a pragma, but just a module :). If you're
confused about when a module is a pragma, you can read more about it
in perlmod and perlmodlib
# perldoc perlmod
# perldoc perlmodlib
> the following script produced this error:
> syntax error in file Hello.pl at line 3, next 2 tokens "use Socket"
> execution aborted due to compilation errors.
>
> Here is the script:
> #!/usr/local/bin/perl
Hmmmm. Are you sure that /usr/local/bin/perl is perl 5.004_04? Try
# /usr/local/bin/perl -v
# perl -v
I suspect that you have a /usr/local/bin/perl as well as a
/usr/bin/perl. The latter probably is 5.004_04, the former probably an
older (4?) version. And your path is probably has /usr/bin before
/usr/local/bin.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: 23 Apr 1998 22:37:29 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: socket input problems
Message-Id: <u37jc2km.fsf@mailhost.panix.com>
web@calarts.edu writes:
> In article <ra2ok3ar.fsf@mailhost.panix.com>,
> Jonathan Feinberg <jdf@pobox.com> wrote:
>
> > You might want to check out perlfaq8, "Can I use perl to run a telnet
> > or ftp session?", which has some sample code that's similar to what
> > you're trying to do.
>
> Naturally, I checked all the faqs before posting. There's no sample
> code in that faq. All perlfaq8, "Can I use perl to run a telnet or
> ftp session?" has to say is:
>
> "Try the Net::FTP and TCP::Client modules (available from CPAN)."
Hmm. My local copy of perlfaq8 goes on to say:
If all you want to do is pretend to be telnet but don't need the
initial telnet handshaking, then the standard dual-process approach
will suffice:
use IO::Socket; # new in 5.004
$handle = IO::Socket::INET->new('www.perl.com:80')
|| die "can't connect to port 80 on www.perl.com: $!";
$handle->autoflush(1);
if (fork()) { # XXX: undef means failure
select($handle);
print while <STDIN>; # everything from stdin to socket
} else {
print while <$handle>; # everything from socket to stdout
}
close $handle;
exit;
I have just checked the perl.com web-based FAQ, and it sure enough has
deleted that section from the answer. I don't know why. Did you
consult the perlfaq8 that came with your Perl distribution, or was it
the online version that you saw? (In other words, is my faq out of
date, or is theirs weirdly edited?)
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 24 Apr 1998 02:17:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: socket input problems
Message-Id: <6hosns$j8f$1@comdyn.comdyn.com.au>
In article <6hoh2t$nei$1@nnrp1.dejanews.com>,
web@calarts.edu writes:
> In article <ra2ok3ar.fsf@mailhost.panix.com>,
> Jonathan Feinberg <jdf@pobox.com> wrote:
>
>> You might want to check out perlfaq8, "Can I use perl to run a telnet
>> or ftp session?", which has some sample code that's similar to what
>> you're trying to do.
>
> Naturally, I checked all the faqs before posting. There's no sample code in
> that faq. All perlfaq8, "Can I use perl to run a telnet or ftp session?" has
> to say is:
I don't know which version of the perl documentation you have, but mine says:
Can I use perl to run a telnet or ftp session?
Try the Net::FTP, TCP::Client, and Net::Telnet modules
(available from CPAN).
http://www.perl.com/CPAN/scripts/netstuff/telnet.emul.shar
will also help for emulating the telnet protocol, but
Net::Telnet is quite probably easier to use..
If all you want to do is pretend to be telnet but don't need
the initial telnet handshaking, then the standard dual-
process approach will suffice:
use IO::Socket; # new in 5.004
$handle = IO::Socket::INET->new('www.perl.com:80')
|| die "can't connect to port 80 on www.perl.com: $!";
$handle->autoflush(1);
if (fork()) { # XXX: undef means failure
select($handle);
print while <STDIN>; # everything from stdin to socket
} else {
print while <$handle>; # everything from socket to stdout
}
close $handle;
exit;
Which is most definitely example code.
If you don't even want to use these sorts of low-level modules, you
might be able to find some example code on CPAN in the scripts
directory, or the misc directory. Most people here will probably tell
you not to reinvent the wheel :)
http://www.perl.com/CPAN/scripts/
http://www.perl.com/CPAN/misc/
Alternatively, you can look inside the Net::FTP module to see how it's
done there.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Thu, 23 Apr 1998 19:01:43 -0600
From: jcoffey@connectnet.com
Subject: split...
Message-Id: <6hokp7$v2b$1@nnrp1.dejanews.com>
Hey, does anybody have any idea how to split a string with a varying number of
fields? Let's say (for example...) I have a string from a hashed value of:
blah1,blah2,blah3,blah4 and I want to split it so I can get all of the blahs.
Okay, so:
($blah1, $blah2, $blah3, $blah4) = split /,/, $_;
fine, BUT what if this is in a while loop and the lines have varying numbers
of blah?
so I have a file with:
blah1,blah2,blah3,blah4
poop1,poop2,poop3
crapola1,crapola2
so...
open (DUMB_FILE, "dumb.file");
while (<DUMB_FILE>) {
(????????) = split /,/, $_;
}
what the hell do I put in for "???????" Is there anything built in to perl
that allows that sort of thing, or am I gonna have to write a sub routine to
count the number of fields and spit out incremented variables? Help please
:).
-Justin
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 24 Apr 1998 01:10:08 GMT
From: hpaul@more.net (H. Paul Hammann)
To: jcoffey@connectnet.com
Subject: Re: split...
Message-Id: <6hoopg$ndj$1@news.more.net>
[Posted and mailed]
In article <6hokp7$v2b$1@nnrp1.dejanews.com>,
jcoffey@connectnet.com writes:
>
. . . .
>
> open (DUMB_FILE, "dumb.file");
> while (<DUMB_FILE>) {
> (????????) = split /,/, $_;
> }
>
> what the hell do I put in for "???????" Is there anything built in to perl
> that allows that sort of thing, or am I gonna have to write a sub routine to
> count the number of fields and spit out incremented variables? Help please
>:).
How about using an array? You could replace that line with:
@ArrayVariable = split /,/, $_;
--
Regards,
The heart has its NeXT, SGI, & Sun sysadmin
H. Paul Hammann reasons that reason MOREnet, Missouri
hpaul@more.net does not know. Research and Education Network
------------------------------
Date: 24 Apr 1998 00:34:32 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: split...
Message-Id: <slrn6jvnkg.lfg.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, jcoffey@connectnet.com <jcoffey@connectnet.com> wrote :
# Hey, does anybody have any idea how to split a string with a varying number of
# fields? Let's say (for example...) I have a string from a hashed value of:
#
# blah1,blah2,blah3,blah4 and I want to split it so I can get all of the blahs.
# Okay, so:
#
# ($blah1, $blah2, $blah3, $blah4) = split /,/, $_;
#
# fine, BUT what if this is in a while loop and the lines have varying numbers
# of blah?
#
# so I have a file with:
#
# blah1,blah2,blah3,blah4
# poop1,poop2,poop3
# crapola1,crapola2
#
# so...
#
# open (DUMB_FILE, "dumb.file");
# while (<DUMB_FILE>) {
# (????????) = split /,/, $_;
@fields = split /,/;
# }
#
# what the hell do I put in for "???????" Is there anything built in to perl
# that allows that sort of thing, or am I gonna have to write a sub routine to
# count the number of fields and spit out incremented variables? Help please
# :).
#
# -Justin
#
# -----== Posted via Deja News, The Leader in Internet Discussion ==-----
# http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 24 Apr 1998 00:16:31 GMT
From: Bill 'Sneex' Jones <chasecreek.systemhouse@usa.net>
Subject: Re: spoiled noobie
Message-Id: <353FD83A.4F8FD8A3@usa.net>
Kevin Reid wrote:
>
> $you{intelligence} += 65535 if $^O eq "MacOS"; # :-)
>
Someone asked me just today if I knew of a good Win95 Uninstall program; they wanted to get rid of some scattered DLLs and other useless programs.
I said "I have found that Delete works best for me." They prolly still have that curious expression of what is he talking about look... :-)
-Sneex-
__________________________
Bill Jones...............|
Sneaker's Nest...........|
Chasecreek Systemhouse...|
PS - Anyone else thinks it's funny that Kevin 'Thinks Different', but still surfs in on IBM.NET ??? Just wondering... :-)
------------------------------
Date: 23 Apr 1998 22:20:26 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: spoiled noobie
Message-Id: <6hoera$ojk$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Larry Rosler" <lr@hpl.hp.com> writes:
:$string =~ m/^\s*(.+?)\s*$/;
I wish I knew why you people liked such really slow solutions
that ignore the FAQ.
Since you seem to like to play around, try this:
#############################################################
# remove leading and trailing white space.
# inputs of undef turn into a defined null
# to silence -w warnings.
#############################################################
sub trim {
my @out = @_;
for (@out) {
s/^\s+//;
s/\s+$//;
}
return wantarray ? @out : $out[0];
}
sub trim_inplace {
for (@_) {
s/^\s+//;
s/\s+$//;
}
}
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"A pithy saying is worth its weight in gold." --Larry Wall
------------------------------
Date: Thu, 23 Apr 1998 22:24:41 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: spoiled noobie
Message-Id: <353FF7EA.BD2F6AC1@coos.dartmouth.edu>
Tom Christiansen wrote:
>
> In comp.lang.perl.misc,
> "Larry Rosler" <lr@hpl.hp.com> writes:
> :$string =~ m/^\s*(.+?)\s*$/;
>
> I wish I knew why you people liked such really slow solutions
> that ignore the FAQ.
I wish I knew why you quoted Larry's suggestion entirely out of context in
order to flame him for ignoring the FAQ.
Perhaps you didn't read this far into his message:
(And yet, it's on the very next line.)
> This is discussed in perlfaq4. Also, there is a recent thread comparing
> several approaches, with Benchmark results.
Who's ignoring what, I wonder?
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2407
**************************************