[7196] in Perl-Users-Digest
Perl-Users Digest, Issue: 821 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 7 05:17:23 1997
Date: Thu, 7 Aug 97 02:00:40 -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, 7 Aug 1997 Volume: 8 Number: 821
Today's topics:
? decimal to hex / and binary conversion <richowens@tomah.com>
Re: [Q] Converter between ELM filter-rules file to proc (Martin Ramsch)
Re: Case Statement.. <seay@absyss.fr>
Re: Clearing browser screen before sending HTML code to <hollyhp@nospam.one.net>
Code breaks <eric@hilding.com>
Re: Comm.pl doesn't work, need a VTLS front-end (Eric Arnold)
Re: Commandline arguments <fawcett@nynexst.com.spam-me-not>
Re: Creating a lynx -dump script? (Gary Chambers)
Re: Creating a lynx -dump script? (Eric Bohlman)
Re: GROVEL: script that capitalizes unix filenames <tom@mitra.phys.uit.no>
Re: GROVEL: script that capitalizes unix filenames Steve_Kilbane@cegelecproj.co.uk
Re: Help! Migrating CGI scripts from Unix to NT (Eric Bohlman)
Re: how do I entries in a text file in PERL? (Eric Bohlman)
Re: how do I entries in a text file in PERL? (Gary Chambers)
How to send the constructor parameters to the base clas <sgermain@nortel.ca>
Re: How to send the constructor parameters to the base (Nic Gibson)
Re: info from dead child-process in SIGN{'CHLD'} <hhuggins@hercules.engr.sgi.com>
Re: Input a record in the middle of an Array <rootbeer@teleport.com>
Re: MS-DOS port of the Perl programming language <rootbeer@teleport.com>
Re: Opening tcp connections.... <tom@mitra.phys.uit.no>
pack() in middle w/o changing rest? (Trudno zhit' v derevne bez nagana.)
Passing Parameter in Perl <danh@software.org>
Re: pattern match/replace <ajohnson@gpu.srv.ualberta.ca>
Perl to Java compiler by Larry?!?! passani@eunet.no
Re: perl-help me again pls (Jason Costomiris)
Re: Poetry questions <stuartc@ind.tansu.com.au>
Re: Q: creating http post requests (Nathan V. Patwardhan)
Re: Reading from Arrays <ran@engr.sgi.com>
Re: Request help extracting acronyms (Thomas Wernitz)
Re: rounding (Craig Berry)
Re: Seeking object enlightenment (Bill Goffe)
silencing system() <jjv@caesun.msd.ray.com>
Stupid MacPerl StandardFile/Choose Question (Hans DeBano)
Using Perl For CGI Database Program <jhobuss@teleport.com>
Re: XS and variable length ret values <jheck@merck.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Aug 1997 16:27:22 -0500
From: Rich Owens <richowens@tomah.com>
Subject: ? decimal to hex / and binary conversion
Message-Id: <33E8EC3A.5244@tomah.com>
I am a realitively new to Perl. I am trying to write a perl cgi to do
decimal to hex and binary conversion. I for what ever reason ( probably
lack of knowledge ) am not easily finding the solution to my problem. I
know this is quite easy in C, but would like to do this in Perl.
Any help would be appreciated. . . . . . . . . .
Thanks
Rich
------------------------------
Date: 7 Aug 97 00:06:30 GMT
From: ramsch@forwiss.uni-passau.de (Martin Ramsch)
Subject: Re: [Q] Converter between ELM filter-rules file to procmailrc file?
Message-Id: <slrn5ui4bu.558.ramsch@melian.forwiss.uni-passau.de>
On 6 Aug 1997 20:48:25 GMT,
Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>Here is a patch to fix some obvious problems with it (sent seperately
>by email to Martin).
Thanks a lot!
Motivated by your suggestions I did some bug-fixes and enhancment, so
we're now at Version 1.1:
http://www.forwiss.uni-passau.de/~ramsch/Software/elmfilter2procmail.txt
(for viewing the source)
http://www.forwiss.uni-passau.de/~ramsch/Software/elmfilter2procmail.perl
(for downloading)
- bugfix: lines comparisons had the comparison operator missing.
- bugfix: rule conditions with parethesis were cut at the closing ')'.
- bugfix: match rules now may have embedded quote signes.
- bugfix: escaping of pattern meta characters were slightly broken.
- enhancement: added proper semantic for "to" and "from" conditions.
- enhancement: added macro expansion (%d, %m, ...).
- enhancement: changed Procmail variable names to be (hopefully) unique.
- cosmetic: cleaned the source and made some helper functions.
- cosmetic: slightly beautified rule output
- todo: %1, %2, %3, ... submaches (how can I do this?)
- todo: mimic Filter's handling of X-Filtered-By: headers.
I didn't have any time to make tests so far, so please don't consider
this script as a ready-to-use utility but work in progress ...
(But I expect it to be reliable usable in a week or so!)
Regards,
Martin
------------------------------
Date: Wed, 06 Aug 1997 11:54:49 +0200
From: Doug Seay <seay@absyss.fr>
To: CT2963 <ct2963@aol.com>
Subject: Re: Case Statement..
Message-Id: <33E849E9.18AB2D64@absyss.fr>
CT2963 wrote:
>
> Is there any type of case statement in Perl??? I cant seems to find any
> references to one or any code that uses one.
Excuse me, but this is a FAQ. Did you bother reading the FAQs? Did you
think anyone had ever had this same question or do you always have
unique questions? "perldoc perlfaq7" and grep for "How do I create a
switch or case statement?". This gives a summary, and refers you to
perlsyn ("perldoc perlsyn") for more details.
- doug
------------------------------
Date: Wed, 06 Aug 1997 18:49:59 -0400
From: Holly Henry-Pilkington <hollyhp@nospam.one.net>
Subject: Re: Clearing browser screen before sending HTML code to browser.
Message-Id: <33E8FF97.35B@nospam.one.net>
Tom Phoenix wrote:
>
> On Mon, 4 Aug 1997, Steve Schmitz wrote:
>
> > The problem is that when my PERL script sends the output to the browser,
> > instead of the output starting at the top of the screen, it follows the
> > "please wait" message that I already have on the screen. I would like
> > for the "please wait" message to be overwritten at this point.
>
> If this is possible, you need to print something different to the browser.
> Since what you print won't be Perl, I can't help you any more here. You
> should check with a browser newsgroup (or its FAQ) to find out what to
> print, if it's even possible. Good luck!
How would you accomplish thi task if the "something different" WERE
Perl? For example, if you had a routine that might take some time to run
before displaying, how would you send first a "please wait" type
message, then print the resullts on a "fresh" on the fly html screen? Do
you just finish the first html (print "</body></html>\n") and then start
a new one with the content type header, etc. when the background
processing is completed? Does that work?
I guess because I understand http to be sort of transaction based (I ask
for it, you give it to me), I'm having a hard time picturing how it is
possible to send something ELSE that I haven't explicitly ASKED for
other than redirect. And a lot of browsers don't support that, even as
it is implemented in Perl, right?
Really just asking for my own education here, so a pointer to a FAQ or
manpage that would explain these concepts as they relate to Perl would
suffice. :)
Thanks...
Holly
(You know what to get rid of to email me)
------------------------------
Date: Wed, 06 Aug 1997 15:34:19 -0700
From: Eric Hilding <eric@hilding.com>
Subject: Code breaks
Message-Id: <33E8FBEB.340F@hilding.com>
I'm sure I'm 'escaping' things right, but in trying to process
this form data the darn thing breaks. perl -wc checks out okay
for the whole script.
#print MAIL " Work Tel: $FORM{'e7'), \"/\", $FORM{'e8'}, \"ext\",
$FORM{'e9'}\n";
#print MAIL " Home Tel: $FORM{'e10'}, \"/\", $FORM{'e11'},\n";
(presently ###'d out)
Any ideas?
Tnx.
Eric
------------------------------
Date: 6 Aug 97 16:05:36 GMT
From: eric.arnold@sun.com (Eric Arnold)
Subject: Re: Comm.pl doesn't work, need a VTLS front-end
Message-Id: <ERIC.97Aug06160536@m-e-ir1.sun.com>
> Comm.pl is written specifically for SunOS 4 and 5. It won't run
>properly for anything else.
By all reports, false.
It has not been perl5-ized/modularized because I haven't yet summoned
the motivation to make it object-oriented just for the sake of
object-orientedness. I originally simplified the TCL/Expect interface
to only about 3 or 4 main functions, which really are functions not
objects. Also, as a single .pl file, it's easier to deliver with a
script.
However, since more than one person has been concerned when seeing
Comm.pl that somehow a .pl is a second class citizen compared to a .pm,
I may give in and make a .pm.
It was originally written for SunOS/Solaris, but has been ported to
other systems. The main problem is with various support for PTY
types. This turns out to be a fairly snarly problem, as anyone who has
looked at the TCL/Expect code has seen. There have been a several
attempts at a broadly inclusive PTY package, but IMHO have all fallen
short because the details/weirdnesses of obtaining (the easier part)
*AND* properly fork/execing the child in the new PTY.
Also, it would have been nice if somebody contacted me when declaring
a "successor to Comm.pl".
-Eric
In article <33E772CC.4181@collegenet.com>
Austin Schutz <tex@collegenet.com> writes:
>Matthew H. Gerlach wrote:
>>
>> In article <slrn45u0d2f.eh6.samiss@assari.cc.tut.fi> samiss@assari.cc.tut.fi (Sami Sandqvist) writes:
>> >I am trying to write a Perl script to use a VTLS library database with
>> >telnet. The FAQ pointed me to Comm.pl for expect-like functionality, but
>> >it seems to be written in perl4 and even the example programs don't run.
>> >I have some experience with Perl and I don't think I broke the examples. I
>> >only changed the hostname, username and password(for the simple telnet
>> >client example). I am using perl 5.004. What now?
>> >
>>
>
> Comm.pl is written specifically for SunOS 4 and 5. It won't run
>properly for anything else.
> Please try out the Perl 5 Expect.pm available at
>ftp://ftp.habit.com/pub/perl/. I haven't released it to CPAN yet because
>I've been trying to get a little feedback on it first.
> So if you do try it please let me know how well it works for you :)
>
> Tex
>
>--
> Adobe is to pdf as Netscape is to core.
------------------------------
Date: 06 Aug 1997 18:38:57 -0400
From: Tom Fawcett <fawcett@nynexst.com.spam-me-not>
Subject: Re: Commandline arguments
Message-Id: <8jhgd3ey2m.fsf@nynexst.com.spam-me-not>
Ulf Knoblich <knoblich@scr.siemens.com> writes:
> I'm just doing some Perl programming and have the task to compare two
> files and write the output to another file. the problem is that the
> script may get wildcards in the commandline like
>
> dif *.d *.d2
>
> (that means it should compare all files with the suffix .d to the
> equivalent ones with the suffix .d2)
>
> how can i parse this?
> when i do it as one might think, i get as arguments teh first two
> matching files for the first expression.
>
> Does anyone know a solution?
You'll have to turn off "globbing" (filename expansion) in your shell so
you just get the patterns on the command lines. Do something like:
set noglob; perl compare_script.pl ; unset noglob
Then compare_script.pl looks like:
my($pat1, $pat2) = @ARGV;
my(@files1) = glob($pat1);
my(@files2) = glob($pat2);
die "$pat1 and $pat2 match different numbers of files!\n"
unless $#files1 == $#files2;
for $i (0 .. $#files1) {
compare($files1[$i], $files2[$i]);
}
sub compare {
...
}
-Tom
------------------------------
Date: 7 Aug 97 01:23:57 GMT
From: geecee@netquarters.net (Gary Chambers)
Subject: Re: Creating a lynx -dump script?
Message-Id: <slrn5ui90r.337.geecee@flyfish.netquarters.net>
>What I would like to know how to do is to be able to
>run a script so that I could do something like
>
>lynx -dump http://www.someserver.com/fileK.html >fileK
>
>for a large group of files ranging from 1 to N without having
>to run the command each time.
One solution would be to write a script that would telnet into port 80
of each intended server, send "GET /fileK.html HTML/1.0<CR><CR>" and
capture the information. The overhead would likely be significantly
lower than calling Lynx individually. If the port were different,
you'd have to account for that.
--
Gary
//------------------------------------------
// NetQuarters, Inc., Brunswick, ME 04011
// 207-798-8400 (Voice) 207-798-8403 (Fax)
// Midcoast Maine's Total Internet Solution
//------------------------------------------
------------------------------
Date: Thu, 7 Aug 1997 02:25:20 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Creating a lynx -dump script?
Message-Id: <ebohlmanEEIuq8.KHx@netcom.com>
Gary Chambers (geecee@netquarters.net) wrote:
: >What I would like to know how to do is to be able to
: >run a script so that I could do something like
: >
: >lynx -dump http://www.someserver.com/fileK.html >fileK
: >
: >for a large group of files ranging from 1 to N without having
: >to run the command each time.
: One solution would be to write a script that would telnet into port 80
: of each intended server, send "GET /fileK.html HTML/1.0<CR><CR>" and
: capture the information. The overhead would likely be significantly
: lower than calling Lynx individually. If the port were different,
: you'd have to account for that.
Actually, this would be a no-brainer using LWP::Simple's getstore() function:
use LWP::Simple;
my $urlbase="http://www.someserver.com/file";
my $urlext=".html";
my $maxfile=10;
for ($i=1;$i<=$maxfile;++$i) {
if (getstore("$urlbase$i$urlext","file$i")!=200) {
print "Couldn't retrieve file$i\n";
}
}
------------------------------
Date: 06 Aug 1997 15:16:16 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: GROVEL: script that capitalizes unix filenames
Message-Id: <nqozpqv735r.fsf@mitra.phys.uit.no>
Randal Schwartz <merlyn@stonehenge.com> writes:
> Uhh, don't you want:
>
> rename $_, uc($_) unless -e uc($_);
>
> Otherwise, you can clobber existing files. Ouch.
I was expecting to hear
map is your friend. Use map
perl -e 'map{-e uc||rename $_, uc} @ARGV' files
> Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Wed, 06 Aug 1997 10:50:26 GMT
From: Steve_Kilbane@cegelecproj.co.uk
Subject: Re: GROVEL: script that capitalizes unix filenames
Message-Id: <867cd$a321a.2b9@news.cegelecproj.co.uk>
In article <slrn5uemes.gpu.bet@waltz.rahul.net>, bet@network.rahul.net (Bennett Todd) writes:
> It's trickier if you also have directories whose names need to be changed;
But not much. I use the following script, which has names of "upper"
and "lower", so it does the appropriate action according to how it's
invoked:
#!/usr/local/bin/perl -w
# Convert case of tree of names.
use File::Find;
sub to_upper {
return if $_ eq '.' || $_ eq '..';
my $old = $_;
my $new = $_;
$new =~ tr/a-z/A-Z/;
rename($old, $new) unless $old eq $new;
}
sub to_lower {
return if $_ eq '.' || $_ eq '..';
my $old = $_;
my $new = $_;
$new =~ tr/A-Z/a-z/;
rename($old, $new) unless $old eq $new;
}
unless (@ARGV) {
print "Usage: $0 name [...]\n";
exit 1;
}
my $sub = ($0 =~ /lower/)? \&to_lower : \&to_upper;
foreach (@ARGV) {
(-d) ? finddepth($sub, $_) : &$sub;
}
--
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.
------------------------------
Date: Thu, 7 Aug 1997 00:00:26 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Help! Migrating CGI scripts from Unix to NT
Message-Id: <ebohlmanEEIo0q.8IK@netcom.com>
Tom Phoenix (rootbeer@teleport.com) wrote:
: If the script is properly written for portability, you shouldn't have to
: do anything. (And I'm told that NT Perl lets you open 'C:\foo.text' as
: 'C:/foo.text', although I haven't tried it.) But it's common to need to add
Correct. The NT (and DOS) filesystem is perfectly happy with a forward
slash as a directory separator. The command processor, however, isn't, so
if you need to refer to file paths in arguments to system() or backticks,
you need to change the separators to backslashes.
: binmode and watch for other commands being run with backticks or system.
: Some scripts have hidden dependencies on quirks of globbing. And there are
In particular, the Activeware port pre-expands command-line globs so that
they behave the same way as they would under Unix (where the shell
expands them before passing them to perl. Gurusamy Sarathy's binary port
of 5.004.01 does not do this.
------------------------------
Date: Thu, 7 Aug 1997 00:42:29 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: how do I entries in a text file in PERL?
Message-Id: <ebohlmanEEIpyt.D9G@netcom.com>
Suhail Warsi (swarsi@zeus.nmp.com) wrote:
: How can I delete data (some, not all) from a text file using PERL? I
: find it easy enough to write to and read from a text file, but can't
: figure out how to delete.
The Perl FAQ has a section on how to do this. If you don't have a copy,
run over to http://www.perl.com/CPAN/ and get one.
------------------------------
Date: 7 Aug 97 01:18:24 GMT
From: geecee@netquarters.net (Gary Chambers)
Subject: Re: how do I entries in a text file in PERL?
Message-Id: <slrn5ui8me.337.geecee@flyfish.netquarters.net>
> How can I delete data (some, not all) from a text file using PERL? I
> find it easy enough to write to and read from a text file, but can't
> figure out how to delete.
One solution would be to write the data that you *DO* want to keep to a
temporary file. After completion, delete the old data file, then
rename the temporary file the original file's name. How's that?
--
Gary
//------------------------------------------
// NetQuarters, Inc., Brunswick, ME 04011
// 207-798-8400 (Voice) 207-798-8403 (Fax)
// Midcoast Maine's Total Internet Solution
//------------------------------------------
------------------------------
Date: Wed, 06 Aug 1997 09:49:00 -0400
From: "Sylvain St.Germain" <sgermain@nortel.ca>
Subject: How to send the constructor parameters to the base class?
Message-Id: <33E880CC.61B@nortel.ca>
I have a ClassB that inherit from ClassA. ClassB would like to
give its constructor parameters to its ancestor... But how?
package ClassA;
sub new {
my $type = shift;
my $self = {};
print "@_\n";
return bless $self, $type;
}
...
package ClassB;
@ISA = qw(ClassA);
sub new {
my $type = shift;
my $self = {};
print "@_\n";
return bless $self, $type;
}
...
package main;
$a = ClassB->new("Params");
The output is simply...
Params
Regards,
Sylvain St-Germain
------------------------------
Date: 6 Aug 1997 15:54:40 GMT
From: nic@cocoon.co.uk (Nic Gibson)
Subject: Re: How to send the constructor parameters to the base class?
Message-Id: <slrn5uh7ds.c8g.nic@larvae.cocoon.co.uk>
On Wed, 06 Aug 1997 09:49:00 -0400,
Sylvain St.Germain <sgermain@nortel.ca> wrote:
>I have a ClassB that inherit from ClassA. ClassB would like to
>give its constructor parameters to its ancestor... But how?
Reading the docs would have been a good start.
Perl does not call base class constructors implicitly.
I would really suggest reading the perl oo tutorial
(man perltoot).
>package ClassB;
>@ISA = qw(ClassA);
>
>sub new {
> my $type = shift;
> my $self = {};
> print "@_\n";
> return bless $self, $type;
>}
>
A slightly better version would be:
package ClassA;
sub new
{
my $that = shift;
my $class = ref($that) || $that;
my @args = @_;
print "In method new of class A\n";
print "@_\n";
return bless {}, $class;
}
package ClassB;
@ISA = qw(ClassA);
sub new
{
my $that = shift;
my $class = ref($that) || $that;
print "In method new of class B\n";
print "@_\n";
my $self = $class->SUPER::new(@_);
return $self;
}
Then:
use ClassB;
my $object = new ClassB("hello");
The output from this would be:
In method new of class B
hello
In method new of class A
hello
Perl isn't like C++. A constructor is just a method of the class (package)
which returns a blessed reference. There isn't any special meaning to
the "new". You could have called this function anything you liked (as long
as it's a valid sub name). You need to call your parent class "constructor"
explicitly.
Hope that helps (or at least makes sense).
Nic
--
Nic Gibson, Senior Programmer, VFM(UK) Ltd.
http://www.global-strategist.com/
Email: nic@global-strategist.com
Phone: 0171 831 7704 Mobile: 0976 408436
------------------------------
Date: Wed, 06 Aug 1997 16:17:40 -0700
From: Hercules Huggins <hhuggins@hercules.engr.sgi.com>
To: Kristoff Bonne <kristoff.bonne@mpl108.is.belgacom.be>
Subject: Re: info from dead child-process in SIGN{'CHLD'}
Message-Id: <33E90614.2781@hercules.engr.sgi.com>
Kristoff Bonne wrote:
>
> Greetings,
>
> When a forked child-process dies, the father-process receives a 'CHLD'-signal.
>
> Is there a way for the SIGN{'CHLD'}-subroute of the father-process to find out WHAT
> child-process generated the signal. (the PID would be ideal).
>
> Please reply cc: mail as my news-feed is not what is supposed to be. ;-)
>
> Cheerio! Kr. Bonne.
The only thing I know of is
$SIG{CHLD} = sub { wait };
--
It's all in the mind.......
----- __o / /_ / /
----- _`\<,_ /--//_| /- /_/ /
----- (*)/ (*) / / \_ / / \ .
~~~~~~~~~~~~
(Keep on moving don't stop, No..)
Hercules Huggins Silicon Graphics Incorporated
hhuggins@hercules.engr.sgi.com Power Desktop / Low-End Server Division
415-933-7246 (work) 800-946-7029 (pager)
888-857-3184 (pager) 1362446@roam.pagemart.net (pager)
If it's not signed by me, it's not from me!!!!
-----BEGIN PGP MESSAGE-----
Version: 2.6.2
owEBnABj/4kAdQMFADOXazrWRvYbNPAAmQEB8yUC/iHG7jOqXZZ7a4z/R82Cgclm
CwN2KDKmS18SMpHBeg26+liB2cC26m3M9VvAS4iZKvEwqtyACfanP/HMYJ23LXGc
6D9I8k6cySCbvyYJnwpsCQQjdaYS2g0UfExBiaDjR6wiYgouc2lnbmF0dXJlAAAA
AEhlcmN1bGVzIEh1Z2dpbnMKCg==
=MI5g
-----END PGP MESSAGE-----
------------------------------
Date: Wed, 6 Aug 1997 08:37:22 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jeroen Kustermans <kusterma@htsa.hva.nl>
Subject: Re: Input a record in the middle of an Array
Message-Id: <Pine.GSO.3.96.970806083647.29767Y-100000@kelly.teleport.com>
On Wed, 6 Aug 1997, Jeroen Kustermans wrote:
> Is there a way to input a record in the middle of an Array?
Sounds like you might want splice(), documented in the perlfunc(1)
manpage. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 6 Aug 1997 07:44:15 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: MS-DOS port of the Perl programming language
Message-Id: <Pine.GSO.3.96.970806074336.29767N-100000@kelly.teleport.com>
On 5 Aug 1997, it was written:
> Get NEW MS-DOS port of the Perl programming language Shareware As It's
> Written!
Gosh, if you get it from CPAN it's freeware. :-)
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 07 Aug 1997 06:29:25 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: Opening tcp connections....
Message-Id: <nqoafiua4l6.fsf@mitra.phys.uit.no>
Premgith Vidyanandan <vidyanan@pilot.msu.edu> writes:
> Hi I'm new to perl programming and I am starting to get the hang of the
> stuff slowly, however I'm still having trouble understanding socket
> connections.. Can anyone please tell me how I can open up a tcp connection
> with another machine and read or write to it.. I tried a perl script
> given in my book but it does not seem to work and I can't seem to
> understand some of the stuff either..
Why not get comfortable with Perl first, and then try to grasp Sockets?
> When $sockaddr = 'S n a4 x8' , what do they mean by it??
Don't worry about it. Use IO::Socket instead. It's in the standard
distribution as of 5.004, and easily available for less recent
versions.
> thanks a lot...
HTH,
> Premgith Vidyanandan
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 3 Aug 1997 21:14:40 GMT
From: alex@kawo2.rwth-aachen.de (Trudno zhit' v derevne bez nagana.)
Subject: pack() in middle w/o changing rest?
Message-Id: <5s2sc0$bta$1@news.rwth-aachen.de>
Hi,
is it possible to pack() something in the middle of string
without changing the rest? I am doing a small hash-database
for absence plan with fixed sized records which are 52 characters
long (52 weeks / year) and like to set/change some character,
signalling that a person was absent on that week.
Thanks!
/Alex
--
russkaya literatura v ------ http://www.simplex.ru/lit.html
internete http://www.friends-partners.org/~afarber/lit.html
java preferans ------------ http://www.simplex.ru/pref.html
besplatnye kommercheskie ob'yavleniya http://www.simplex.ru
------------------------------
Date: Mon, 04 Aug 1997 14:55:53 -0400
From: Anthony Danh <danh@software.org>
Subject: Passing Parameter in Perl
Message-Id: <33E625B9.6C1E@software.org>
Hi...
How many parameters can you pass using the below syntax?
"/cgi-bin/CGI2Perl.exe/mo/order.pl?id=10&name=testing...."
can a parameters have space between them? (look below)
"/cgi-bin/CGI2Perl.exe/mo/order.pl?id=10&name=This is a test&file=one"
Thanks
Anthony Danh
------------------------------
Date: Wed, 06 Aug 1997 17:45:26 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: pattern match/replace
Message-Id: <33E8FE86.575BFEB5@gpu.srv.ualberta.ca>
Dan Brian wrote:
!
! Perl users,
[snip]
! Assuming this is my line of text:
!
! < blah blah KEYWORD blah blah KEYWORD blah blah blah > KEYWORD <
blah
! KEYWORD blah blah >
!
! I then need a search/replace string that will remove KEYWORD
! from strings where it occurs withing the < > brackets. Note
! that the word can occur numerous times withing the brackets,
! and that there can be several bracket sets on the text line.
! I need the above string to translate to:
!
! < blah blah blah blah blah blah blah > KEYWORD < blah blah blah >
!
! Can someone offer me a clean solution?
clean? well, maybe after some laundering:
s!(<[^>]*>)!($a=$1)=~s#KEYWORD##g;$a!eg;
perhaps a simpler construct might be:
1 while s/(<[^>]*?)KEYWORD/$1/g;
regards
andrew
------------------------------
Date: Wed, 06 Aug 1997 09:11:46 -0600
From: passani@eunet.no
Subject: Perl to Java compiler by Larry?!?!
Message-Id: <870876104.17647@dejanews.com>
Hallo,
I read now that Larry Wall is working on a Perl-to-java cross
compiler (Web Techniques, Sept. 1997, pag. 77).
Is this true?
Is it possible?
Is it useful?
Any details about all this?
Thanx for attention
Luca <passani@eunet.no>
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 4 Aug 1997 15:10:04 GMT
From: jcostom@shaft.sjis.com (Jason Costomiris)
Subject: Re: perl-help me again pls
Message-Id: <slrn5ubs6c.k6g.jcostom@dogbert.sjis.com>
On Sun, 03 Aug 1997 21:44:51 +0200,
.70 Andreas 07. <cascioli@geocities.com> wrote:
: Thanks for the hint, I got it to work now, but the cgi script opens this
: alert in a new blank html page.
: Does anyone know how to make it execute in the same html page?
You might want to take this to a JavaScript newsgroup, since your question
has very little to do with perl.
Oh, and look at the onLoad event.
--
Jason Costomiris | Finger for PGP 2.6.2 Public Key
jcostom@sjis.com | "There is a fine line between idiocy
My employers like me, but not | and genius. We aim to erase that line"
enough to let me speak for them. | --Unknown
http://www.jasons.org/~jcostom
------------------------------
Date: 07 Aug 1997 13:49:20 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: Poetry questions
Message-Id: <yeo2046iren.fsf@kudu.ind.tansu.com.au>
toutatis@remove.this.toutatis.net (Toutatis) writes:
> How to write cleaner scripts:
1)
> $var2 = $var;
> $var2 =~ tr/qwerty/asdfg/;
>
> Can I do that in a single statement?
> like: $var2 = $var =~ tr/qwerty/asdfg/;
> But then in a way that it does what I want?
2)
> Another one:
$var = $long->{'variable'}->{'name'} ? $long->{'variable'}->{'name'} : "nope";
> Is there a way so I don't have to write that long variable name twice?
>
1) The two line way *is* the clean way. What the one line one is doing is:
$var2 = ( $var =~ tr/qwerty/asdfgh/);
... the stuff inside () changes qwerty to asdfgh in $var (changing $var)
but $var2 is assigned the return value of all of this which is *not* $var.
The return value of tr is the number of characters replaced or deleted.
So you can do
$num_changed = $var =~ tr/qwerty/asdfgh/;
but you'd want a comment explaining what you're doing.
This one liner makes me want to prattle on about side-effects;
viz: # sets $num_changed to the number of characters changed
# by replacing "qwerty" by "asdfgh" in $var; changing $var
# as a side effect
The reason you thought you could do this is you're used to seeing
$a = $b = 5;
which works because the return value of the = operator is what was assigned
ie $a = ($b = 5); return val of () is 5 so it's $a = 5 too
However the =~ operator is *not* an assignment operator; it's a
use-something-else-instead-of-the-default-$_ operator. In such
cases the return value is always the return value of whatever operator
is now working on $var (in this case tr); it's not what was changed
like it would be if it was =.
The one liner clobbers $var which I don't think is what you want.
Stick with the 2 liner; viz
$new = $orig;
$new =~ tr/qwerty/asdfgh/;
You had it right the first time- it was already clean code.
NB- code does not become cleaner by throwing as many statements as you can
on one line.
2)
$var = $long->{'variable'}->{'name'} ? $long->{'variable'}->{'name'} : "nope";
Can I suggest a 2 liner here.
Use a nice short temporary variable; called $a
my($a)= $long->{'variable'}->{'name'};
$var = (defined($a)) ? $a : "nope";
I'm using defined() to see if the hash element exists; you're just using
the variable name which will check if it's non-zero and should barf
about uninitialised variable if you run your scripts with the -w flag
like you always should. You probably want to use defined() here.
Confident this helps,
Stuart Cooper
stuartc@ind.tansu.com.au
------------------------------
Date: 6 Aug 1997 13:42:05 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Q: creating http post requests
Message-Id: <5s9uvd$bce@fridge-nf0.shore.net>
Peter Riocreux (peter.riocreux@cs.man.ac.uk) wrote:
: I am seeking a way to (from the command line) send requests using the
: post method from an html form. In perl, obviously. I guess I need
: the libwww bundle, but I am still relatively new to this perl lark, so
: has anyone any pointers as to which modules (if any) I should look at
: first.
Although you seemed hesitant to use LWP, I'd strongly suggest that you
use it anyways - to my knowledge there aren't any other modules as
comprehensive in the WWW department as LWP. LWP includes a file
called lwpcook.pod that has a *ton* of excellent examples about
GETting and POSTing.
In fact, if you're using a flavor Unix or your PC has Unix tools like
grep installed, you can grep for POST in lwpcook.pod.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Wed, 06 Aug 1997 19:42:23 -0700
From: Ramesh Nagarajan <ran@engr.sgi.com>
Subject: Re: Reading from Arrays
Message-Id: <33E9360F.41C6@engr.sgi.com>
Hi,
I have a huge array, I would like to read it in chunks and write to the
database. I know that there is a read() function to read suitable size
of text data but the problem is it should be done via filehandle and
even then I should open two file handles to do the job.
I currently have something like this...
@array #some huge array
for (@array){
open(OUT, ">Test.pl"); print; close(OUT); }
open(IN, "Test.pl"); while(read(IN, $buf, 512)){}; close(IN);
Is there an easier way to do this? Thanks
-Ramesh
------------------------------
Date: 6 Aug 1997 21:40:39 GMT
From: thomas_wernitz@tait.co.nz (Thomas Wernitz)
Subject: Re: Request help extracting acronyms
Message-Id: <5sar0n$1ni@gatekeeper.tait.co.nz>
In article <33e5ea2e.4177625@news>, roswell@umbc.edu (Marjorie Roswell) wrote:
>Now, wouldn't it be nice if U.S.A. sorted *after* UNICEF? Suggestions
>are welcome! Once we get this last piece ironed out, (or even if we
>foreach $key (sort keys %h) {
> chop($key) if $key =~ tr/.// ==1; #remove final period if only one.
> print "$key\n";
>}
Hi Margie,
use this:
foreach $key
(sort {($_a=$a,$_a=~s/\.//go,$_a) cmp ($_b=$b,$_b=~s/\.//go,$_b)} keys %h) {
..
}
HTH,
Thomas
------------------------------
Date: 7 Aug 1997 01:19:00 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: rounding
Message-Id: <5sb7q4$og5$3@marina.cinenet.net>
michael james mangino (mangino@cis.ohio-state.edu) wrote:
: Is there any way to find out the length (i.e. number of characters) in a
: scalar variable? I am writing a cgi-script that averages some data and I
: want to chop off a lot of the trailing characters.
First, read the manual or FAQ.
Second, be more specific about what you want. Truncating a character
string and rounding a number are two related but very different
operations. You probably want length() and/or substr() and/or s/// for
the former, sprintf() for the latter.
Third, read the manual or FAQ.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 6 Aug 1997 16:25:39 GMT
From: bgoffe@cook.cba.usm.edu (Bill Goffe)
Subject: Re: Seeking object enlightenment
Message-Id: <5sa8i3$67h$1@thorn.cc.usm.edu>
Steven W McDougall (swmcd@world.std.com) wrote:
: neil@domingo.concordia.ca (Neil Kandalgaonkar) writes:
: >I'm a reasonably smart person, and have programmed perl for $, but I
: >am having difficulty understanding objects.
: http://world.std.com/~swmcd/steven/Programming/paradigms.html
: gives some of the motivation for OOP.
This is indeed quite useful, but some hints on how to use objects
with perl would be useful as well.
.---. Bill Goffe Bill.Goffe@usm.edu
( | Dept. of Econ. and International Business office: (601) 266-4484
)__*| University of Southern Mississippi fax: (601) 266-4920
(_| Southern Station, Box 5072
Hattiesburg, MS 39406-5072
------------------------------
Date: Wed, 06 Aug 1997 15:31:05 -0400
From: Jason Varsoke <jjv@caesun.msd.ray.com>
Subject: silencing system()
Message-Id: <33E8D0F9.2196@caesun.msd.ray.com>
system("tar cfv foo.tar *"); or similar system() statement throws its
output to my screen. How do I redirect it from inside perl?
I would use an open (SYSTEM, "command @args|"); but I need the return
code from the system statement.
any suggestions? Please duplicate response in e-mail.
jason
--
________oOOOo__/----\__oOOOo________________________________
Jason Varsoke jjv@caesun.msd.ray.com
For good mental hygene, shave with Occam's Razor twice a day.
------------------------------
Date: Wed, 06 Aug 1997 20:06:37 -0700
From: Hans.DeBano@asu.edu (Hans DeBano)
Subject: Stupid MacPerl StandardFile/Choose Question
Message-Id: <Hans.DeBano-ya02408000R0608972006370001@news.asu.edu>
I'm sorry about this gang - the solution should be banging me over the
head. I'm trying to make MacPerl give me the standard Mac "open" and "save"
input boxes for filenames using "&StandardFile::GetFile" and
"&StandardFile::PutFile". The boxes show up fine and I can specify
or change the file name, but I haven't been able to control the
initial directory (folder) that the boxes come up with... (I don't
want the end user to have to navigate to the "right" folder - I'd
like to start there :)
So I've got lines in my code like this:
$infilename = &StandardFile::GetFile($prompt, @types, $defaultinfilename);
I've tried including the "path" (volume name, directories, etc.) as
part of "$defaultinfilename" in the hope that an absolute file name
would control which directory the input box came up in... That didn't
work.
I also tried using "chdir" to change the directory before I called
"GetFile" and that didn't have an effect.
Any I missing something simple? I'd be happy to use "MacPerl::Choose"
if someone could point me in the right direction there... Thanks!
Hans DeBano
DeBano@asu.edu
------------------------------
Date: Wed, 06 Aug 1997 09:56:39 -0600
From: Jim Hobuss <jhobuss@teleport.com>
Subject: Using Perl For CGI Database Program
Message-Id: <33E89EB7.3810@teleport.com>
I'm writing an article for a monthly publication and want to find
someone to interview whose company has used Perl to build CGI programs
in support of a Web database application.
If this is you, please get ahold me of ASAP. Here are the details of how
to get ahold of me:
Jim Hobuss
email: jhobuss@teleport.com
Phone: (503) 661-3421
Thanks... Jim
------------------------------
Date: Wed, 06 Aug 1997 09:42:22 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: Re: XS and variable length ret values
Message-Id: <33E87F3E.41C6@merck.com>
Andreas,
I am familar with the perlxs, perlstut, and the perlembed manpages.
However, the example they give to return multiple values has to do with
calling the procedure numerous times. I would like build and array of
sorts in the C function and then make each element passed back to Perl
for manipulation.
James
> hello james
>
> take a look in the perlxs, perlxstut and perlembed manpages. especially in the
> perlxs manpage there is an example how you can return a list of values from an
> xs-function. see the section where the 'PPCODE:' keyword is explained.
>
> ========================================================================
> andreas schmidt email: schmidt@iai.fzk.de
> institut fuer angewandte informatik (iai) phone: +49 7247 82 5714
> forschungszentrum karlsruhe gmbh
> - technik und umwelt -
> postfach 3640 76021 karlsruhe (germany)
--
--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck
The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, Merck & Co., Inc. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.
------------------------------
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 821
*************************************