[8142] in Perl-Users-Digest
Perl-Users Digest, Issue: 1760 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 29 11:17:15 1998
Date: Thu, 29 Jan 98 08:00:36 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 29 Jan 1998 Volume: 8 Number: 1760
Today's topics:
Re: -dates in perl- <James@cydaps.nospam.co.uk>
Another "uninitialized variable" problem ()
ARRAYS of filehandles posssible ?!? <vlierd@uni-oldenburg.de>
Re: delete function <dgwilson@gte.net>
Re: delete function (Andrew M. Langmead)
Re: Don't use signal handlers (was Re: Child processes) (Chip Salzenberg)
Re: Don't use signal handlers (was Re: Child processes) (Chip Salzenberg)
Re: email address (G. E. Terry)
Re: Internet Community needs cgi scripts like it needs (Chris Nandor)
Re: Is there a WebRing Script? <warchie@att.net.hk>
Re: Multiple copies of the same option on command line (Ed Avis)
Re: open in append mode <TomJenkins@worldnet.att.net>
perl and Microsoft Sqlserver SQLDMO <eckert@neosoft.com>
Perl for NT on IIS <nathan_stanford@cabp.com>
Re: Perl ISAPI Build 315 for NT & Arguments (Erik Y. Adams)
Perl like functions for Delphi <todd@nbn.com>
perl script -> secure webpage (alex)
Problems with strings (again) (Stephen Howe)
Re: Profiler for Perl4 (yup. Perl4) (Clay Irving)
Re-using STDIN <boschini@cilea.it>
Seek Help for copying binary files <dlam@kdn0.attnet.or.jp>
Socket problem <bteague@aol.net>
Re: Split (Zachary Brown)
Re: Strip Trailing Spaces. How? (Andrew M. Langmead)
Re: Survival Of perl (Chris Nandor)
Re: unzip utility for alpha NT? (Brian Raven)
Using Perl Library Module Term::Complete <jim.blackwell@gsfc.nasa.gov>
Webring <warchie@att.net.hk>
Word -> HTML <patrick@husi.ch>
Re: Word -> HTML <CarryDOTMegens@nym.sc.philips.com>
Writing Multilingual Software <sbekman@iil.intel.com>
Re: Writing Multilingual Software <jim.michael@gecm.com>
WWWBoard2.0 A Multiple Boards <warchie@att.net.hk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Jan 1998 10:25:55 +0000
From: James <James@cydaps.nospam.co.uk>
Subject: Re: -dates in perl-
Message-Id: <4BbIrSAzkF00EwfV@cydaps.co.uk>
On Wed, 28 Jan 1998, John Moreno wrote:
>
>First off, the date in seconds is NOT platform independent.
>
>Secondly look at the manual and faq and localtime.
>
Thanks for all the assistance, have got it working perfectly now. I was
placing the $date in the wrong location (just being thick as normal!)...
Cheers
James
------------------------------
Date: 29 Jan 1998 15:19:01 GMT
From: faverNoSpam@austin.ibm.com ()
Subject: Another "uninitialized variable" problem
Message-Id: <6aq6l5$qkq$1@ausnews.austin.ibm.com>
I am using Perl for some hardware bring-up code that controls
initialization. Using Perl 5.002 on a Unix workstation with
the -w option.
The following code is resulting in an "uninitialized variable"
warning:
sub xbow_fence_find {
my $this_xb;
my $fence_bits;
my @ncas;
my $this_nca;
my $xnode_num;
$this_xb = $_[0];
$fence_bits="00000";
@ncas=equip_filter($nca_filter); #get an array of NCA chips
foreach $this_nca (@ncas) {
($xnode_num)=($this_nca =~ /([0-9])/);
if ($xnode_num eq '0')
{$fence_bits = ($fence_bits | "10000")}
elsif ($xnode_num eq '1') <<---ERROR ON THIS LINE
{$fence_bits = ($fence_bits | "01000")}
elsif($xnode_num eq '2')
{$fence_bits = ($fence_bits | "00100")}
elsif($xnode_num eq '3')
{$fence_bits = ($fence_bits | "00010")}
elsif($xnode_num eq '4')
{$fence_bits = ($fence_bits | "00001")}
}
return $fence_bits;
}
NCAs are a type of chip we are testing. Names will be in a format
of ncaXY, where x and y are digits.
The code appears to work fine, in spite of the warning. The
comparison works, and the $fence_bits are set properly.
I looked in the archives for this newsgroup, and found some
similar problems related to the use of "my". Removing the
"my" from $xnode_num does not help. I also changed the
"elsif"s to "if"s with a useless non-empty statement inbetween,
but it did not help. The users of my tool keep asking me
to fix my bug, but I don't know what to do.
Thanks,
Dave
--
My views are my own, and not necessarily those of my employer.
------------------------------
Date: Thu, 29 Jan 1998 13:45:25 +0100
From: Claus van de Vlierd <vlierd@uni-oldenburg.de>
Subject: ARRAYS of filehandles posssible ?!?
Message-Id: <34D079E5.B9178645@uni-oldenburg.de>
As a PERL-novice I would like to call a subroutine
with a parameter which contains an array of
FileHandles which this subroutine should use to read the
approppiate files --- but unfortunately I do not know
how to do this.
Is it possible ?! and if "yes" : HOW ?!?
thank you very much!
Claus van de Vlierd
------------------------------
Date: Thu, 29 Jan 1998 10:01:42 -0500
From: Douglas Wilson <dgwilson@gte.net>
Subject: Re: delete function
Message-Id: <6aq5i8$nin$1@gte1.gte.net>
Justin wrote:
>
> Hi,
>
> I'm having a hard time understanding the delete function in perl. Some
> of the scripts that I have running on a BSDI machine require that I
> delete certain lines of a file. It seems that the delete function only
> likes to delete a specified key and associated value from a specified
> hash. If I have a file full of tilde delimited text, do I have to dump
> all of it into an associative array?
If you're deleting lines from a file, then its just a matter of not
printing those lines back to the file. The following will delete
all lines with the word 'hello' in it:
perl -pi -e 's/.*hello.*//s' filename
Cheers,
Douglas Wilson
------------------------------
Date: Thu, 29 Jan 1998 15:46:32 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: delete function
Message-Id: <EnJyHK.2Jp@world.std.com>
Justin <jwhite@thegrid.net> writes:
>I'm having a hard time understanding the delete function in perl. Some
>of the scripts that I have running on a BSDI machine require that I
>delete certain lines of a file. It seems that the delete function only
>likes to delete a specified key and associated value from a specified
>hash.
delete() is the wrong thing for this type of operation. What you want
are the techniques listed in the FAQ. Sorry for just cutting and
pasting the entry instead of creating an individualized response, but
the FAQ's author is such a good writer, and the answers have been
reviewed and tested. I think you're much better of with its
information rather than what I would write off the cuff.
> How do I change one line in a file/delete a line in a file/insert a
> line in the middle of a file/append to the beginning of a file?
>
> Although humans have an easy time thinking of a text file as being a
> sequence of lines that operates much like a stack of playing cards --
> or punch cards -- computers usually see the text file as a sequence of
> bytes. In general, there's no direct way for Perl to seek to a
> particular line of a file, insert text into a file, or remove text
> from a file.
>
> (There are exceptions in special circumstances. Replacing a sequence
> of bytes with another sequence of the same length is one. Another is
> using the `$DB_RECNO' array bindings as documented in the DB_File
> manpage. Yet another is manipulating files with all lines the same
> length.)
>
> The general solution is to create a temporary copy of the text file
> with the changes you want, then copy that over the original.
>
> $old = $file;
> $new = "$file.tmp.$$";
> $bak = "$file.bak";
>
> open(OLD, "< $old") or die "can't open $old: $!";
> open(NEW, "> $new") or die "can't open $new: $!";
>
> # Correct typos, preserving case
> while (<OLD>) {
> s/\b(p)earl\b/${1}erl/i;
> (print NEW $_) or die "can't write to $new: $!";
> }
>
> close(OLD) or die "can't close $old: $!";
> close(NEW) or die "can't close $new: $!";
>
> rename($old, $bak) or die "can't rename $old to $bak: $!";
> rename($new, $old) or die "can't rename $new to $old: $!";
>
> Perl can do this sort of thing for you automatically with the `-i'
> command-line switch or the closely-related `$^I' variable (see the
> perlrun manpage for more details). Note that `-i' may require a suffix
> on some non-Unix systems; see the platform-specific documentation that
> came with your port.
>
> # Renumber a series of tests from the command line
> perl -pi -e 's/(^\s+test\s+)\d+/ $1 . ++$count /e' t/op/taint.t
>
> # form a script
> local($^I, @ARGV) = ('.bak', glob("*.c"));
> while (<>) {
> if ($. == 1) {
> print "This line should appear at the top of each file\n";
> }
> s/\b(p)earl\b/${1}erl/i; # Correct typos, preserving case
> print;
> close ARGV if eof; # Reset $.
> }
>
> If you need to seek to an arbitrary line of a file that changes
> infrequently, you could build up an index of byte positions of where
> the line ends are in the file. If the file is large, an index of every
> tenth or hundredth line end would allow you to seek and read fairly
> efficiently. If the file is sorted, try the look.pl library (part of
> the standard perl distribution).
>
> In the unique case of deleting lines at the end of a file, you can use
> tell() and truncate(). The following code snippet deletes the last
> line of a file without making a copy or reading the whole file into
> memory:
>
> open (FH, "+< $file");
> while ( <FH> ) { $addr = tell(FH) unless eof(FH) }
> truncate(FH, $addr);
>
> Error checking is left as an exercise for the reader.
--
Andrew Langmead
------------------------------
Date: Thu, 29 Jan 1998 15:31:12 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Don't use signal handlers (was Re: Child processes)
Message-Id: <6aq7fg$7vp$1@cyprus.atlantic.net>
According to Zenin <zenin@best.com>:
>Chip Salzenberg <chip@mail.atlantic.net> wrote:
>: You should not use signal handler subroutines in Perl programs you
>: depend on. Perl doesn't do signals right, yet.
>
> Perl does signals as perfectly as your OS can.
I meant what I said, and I know what I'm talking about.
In Perl 5 delivery of signals resulting the the immedate execution of
Perl code (i.e. Perl signal handlers) does not work consistently. The
internals of Perl are just not designed for interruption at arbitrary
times.
I repeat, with feeling: IT DOES NOT WORK CONSISTENTLY. I know this
for a fact. I've creatd a patch for reliable signals, but because it
incurs a 3% performance penalty (though modifying the main Perl
operation loop) it hasn't been incorporated into official Perl.
According to second-hand reports (I haven't seen the code yet), if you
enable threads in the code that will eventually become 5.005, then a
separate thread is used for signal handler execution and things just
work. But, ironically, turning on threads also incurs a performance
penalty, which at present is a whole lot more than 3%. :-(
Bottom line: Don't use Perl signal handlers if you care whether you
program works.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
Like Perl? Want to help out? The Perl Institute: www.perl.org
-> Ask me about Perl training and consulting <-
"It's the lemon zester of death!!" // MST3K
------------------------------
Date: Thu, 29 Jan 1998 15:33:27 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Don't use signal handlers (was Re: Child processes)
Message-Id: <6aq7jp$80d$1@cyprus.atlantic.net>
According to joseph@5sigma.com:
>I'm going to have to temper what I just said. It's pretty likely
>that $SIG{CHLD} = sub { wait } is going to cause a problem if
>your program is spawning and reaping children at a good clip
>for a period of time.
That's not strong enough.
Any given signal resulting in a signal handler being executed can
kill your Perl, or worse, make it sick.
Don't use Perl signal handlers. Ever.
>I am definitely looking forward to seeing signals working more
>reliably in the future, though.
You and me both.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
Like Perl? Want to help out? The Perl Institute: www.perl.org
-> Ask me about Perl training and consulting <-
"It's the lemon zester of death!!" // MST3K
------------------------------
Date: Thu, 29 Jan 98 14:50:43 GMT
From: admin@net-ops.net (G. E. Terry)
Subject: Re: email address
Message-Id: <6aq504$co6$1@ns2.adult-host.net>
Keywords: from just another new york perl hacker
>i guess you'll never be able to mail Elijah then. perhaps you
>should read his email address FAQ, which i'm sure he'll tell you
>about when he gets to this post :)
>
Thanks to all who posted, and the Address FAQ gave me more
information about email addresses that I could ever use.... :)
I think I might have a handle on it now.
------------------------------
Date: Thu, 29 Jan 1998 08:20:32 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Internet Community needs cgi scripts like it needs ...
Message-Id: <pudge-2901980820330001@ppp-9.ts-1.kin.idt.net>
... a hole in the head ...
... AlterNIC ...
... spammers ...
Play along!
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== New Book: MacPerl: Programming for the Rest of Us ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Wed, 28 Jan 1998 23:48:12 +0800
From: Walter Archie <warchie@att.net.hk>
To: brian d foy <comdog@computerdog.com>
Subject: Re: Is there a WebRing Script?
Message-Id: <34CF533B.CB70E047@att.net.hk>
I am looking for a Perl script based on a webring. Please if you can help then okay. If
not what does your reply have to do about Perl?
Justin Archie
brian d foy wrote:
> [there is no need to post the same question twice]
>
> In article <34CB53D5.4E8B6C50@att.net.hk>, Walter Archie <warchie@att.net.hk> posted:
>
> > I am looking for a webring script out there. If someone has one or knows
> > of one please help find it. I am looking for a site I am putting
> > together. This is really appreciated if you can help me.
>
> what does this have to do with Perl, other than it's possible
> implementation?
>
> why not just ask the people that already have such things what
> they use?
>
> --
> brian d foy <http://computerdog.com>
> Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Thu, 29 Jan 1998 15:17:24 GMT
From: epa@datcon.co.uk (Ed Avis)
Subject: Re: Multiple copies of the same option on command line
Message-Id: <34d06309.689249488@news-direct>
On 27 Jan 1998 12:27:24 -0500, charlot@CAM.ORG (Richard Bellavance)
wrote:
>I'm sorry I can't help you with your Getop problem, but I can help you read
>the module documentation on Win32. Simply use a command like:
>
> perldoc Getopt::long
I'm using the ActiveState port, which doesn't include perldoc as far
as I can tell.
I'd love to be proved wrong though...
--
Ed Avis
------------------------------
Date: Thu, 29 Jan 1998 10:32:35 -0500
From: "Tom Jenkins" <TomJenkins@worldnet.att.net>
Subject: Re: open in append mode
Message-Id: <6aq7ar$jel@bgtnsc01.worldnet.att.net>
Chad R Cordero wrote in message <34CF8530.41C67EA6@wiley.csusb.edu>...
>For some reason I can't figure out how to append text to a file. I
>originally tried the following:
>
> open(FILE, ">>file");
> print FILE ("$variable");
> close(FILE);
>
>but that failed. I have gone through all of the books in my office to
>find an example for open in append mode but cannot find one. What am I
>doing wrong? How should I do this?
Just tried this and works fine under Win95 ...
E:\work>copy con test.file
test
test
test
test
^Z
1 file(s) copied
E:\work>perl
open( FILE, '>> test.file' ) ;
print FILE "\n\nTom was here\n" ;
close ( FILE ) ;
[CTRL][D][ENTER]
E:\work>type test.file
test
test
test
test
Tom was here
============================
Tom Jenkins
------------------------------
Date: Thu, 29 Jan 1998 15:27:24 GMT
From: "ESG" <eckert@neosoft.com>
Subject: perl and Microsoft Sqlserver SQLDMO
Message-Id: <EnJxLM.D1G@twisto.eng.hou.compaq.com>
We have been able to get the following code to work, but we don't know how
to check the error status of each call to SQLDMO. Any help would be
appreciated.
Ex: perl test_sqldmo.pl "select @@SERVERNAME"
-------------------------------------------
#! d:/unixbin/perl/bin/perl.exe -w
use strict;
use OLE;
if ( ! $ARGV[0] ) { die "Usage: $0 \"SqlString\"\n"; }
my $SS = OLE->new("SQLOLE.SqlServer", sub {$_[0]->Quit;}) or die "Couldn't
create new instance";
my $rv = $SS->Connect("SERVERNAME", "sa","password") ;
my $QR = $SS->ExecuteWithResults("$ARGV[0]") ;
my $setcnt = $QR->ResultSets;
my $is = my $ir = my $ic = 1;
for ( $is = 1; $is <= $setcnt; $is++)
{
$QR->{CurrentResultSet} = $is;
my $rowcnt = $QR->Rows;
my $colcnt = $QR->Columns;
for ( $ir = 1; $ir <= $rowcnt; $ir++)
for ( $ic = 1; $ic <= $colcnt; $ic++)
{
if ($ic == 1) {
print $ir . "|" . $QR->GetColumnString($ir,$ic);}
else {
print "|" . $QR->GetColumnString($ir,$ic);}
}
print "\n";
}
}
$SS->Close;
------------------------------
Date: Thu, 29 Jan 1998 08:41:32 -0600
From: Nathan Stanford <nathan_stanford@cabp.com>
Subject: Perl for NT on IIS
Message-Id: <886084523.330301444@dejanews.com>
If you still need help email me...
nathan_stanford@cabp.com - Work
nathan@cyberservices.com - Home
The Perl N.uT.
1. install the 3 Files from ActiveState 2. add to the path--
C:\perl\bin;C:\perl\lib (use the correct path according to your machine.)
3. run regedit and go to My
Computer\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3Svc\Param
ete rs\Script Map
If it is not there make a string value .pl and then double click on it
and type C:\Perl\bin\PerlIS.dll or your correct path to this file.
4. Reboot your machine the try running the below script in the script
directory.
---------------------cut just below here -----------------
#
print "Content-type: text/html\n\n"; # This is
needed to make a web page
#
($browser, $version) = split(/\//, $ENV{'HTTP_USER_AGENT'}); # Split the
string into two, browser and version
if ($browser eq "Mozilla") # Change
Mozilla to something more recognized
{ #
$browser = "Netscape"; # Netscape
Browser
} #
if ($version =~ /MSIE/) # Check to
see if MSIE is pretending to be Netscape
{ #
$browser = "Microsoft Internet Explorer"; # Microsoft
Internet Explorer
} #
#
print "<HTML>";
print "<HEAD><TITLE>Hello!</TITLE></HEAD>";
print '<BODY TEXT="#000000"
BGCOLOR="#FFFFFF"
LINK="#FF0000"
VLINK="#800080"
ALINK="#0000FF">';
print "<BLOCKQUOTE>";
print "<H1>Hello!</H1>";
if ($ENV{'REMOTE_HOST'})
{
print "Hello user from $ENV{'REMOTE_HOST'}
($ENV{'REMOTE_ADDR'})!<BR>";
}else {
print "Hello user from $ENV{'REMOTE_ADDR'}!<BR>";
}
print "I see you're using
$browser, version $version.
Do you like it? <BR>";
if ($ENV{'HTTP_REFERER'})
{
print "You have requested the document
$ENV{'DOCUMENT_URI'} from ";
print "<A HREF=\"$ENV{'HTTP_REFERER'}\">go back</A> to
<BR>$ENV{'HTTP_REFERER'}.<BR>";
print "I hope you enjoy it!";
}
print "</BLOCKQUOTE>";
exit;
----------------- end cut above here ----------------------
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 29 Jan 1998 07:14:52 -0800
From: erik@earthlink.net (Erik Y. Adams)
Subject: Re: Perl ISAPI Build 315 for NT & Arguments
Message-Id: <erik-2901980714520001@pool019-max8.mpop2-ca-us.dialup.earthlink.net>
This really is a CGI question, not a Perl question.
CGI do not actually get anything passed to them on the command line, no
matter what language they're written in. Instead of
> #!/usr/bin/perl
>
> print "Content-type: text/html\n\n";
> print "Argument= $ARGV[0]\n";
Use this:
> #!/usr/bin/perl
>
> print "Content-type: text/html\n\n";
> print "Argument=$ENV{QUERY_STRING}";
And, read up on CGI programming.
Erik
--
----------------------------------------------------------
Erik Y. Adams erik@earthlink.net
Information Systems Consultant 626/795-2701
Internet and Intranet Specialist
------------------------------
Date: Thu, 29 Jan 1998 07:36:36 -0800
From: Todd Cary <todd@nbn.com>
Subject: Perl like functions for Delphi
Message-Id: <34D0A204.2C0974A3@nbn.com>
I lost a reference to a library of Perl like functions for Delphi. Does
anyone know of the source of the library?
Todd
------------------------------
Date: Thu, 29 Jan 1998 13:51:06 GMT
From: alex@online.emap.com (alex)
Subject: perl script -> secure webpage
Message-Id: <34d088c1.173402671@news.dircon.co.uk>
Hi,
Is there anyway in which to create a perl script and the output from
that page be displayed as a secure web page?
The perl script is on one server which does database stuff and
generates the application form. I want this application form to be
secure.
Any ideas?
Alex
------------------------------
Date: Thu, 29 Jan 1998 12:55:36 GMT
From: stephen@bcl.com (Stephen Howe)
Subject: Problems with strings (again)
Message-Id: <34d0760d.10509232@194.72.35.45>
Thank you all soooooooooooooo much for the responses I had to the
questions I had last time about finding the user in user@sitename...
you helped SOOOOOOOO much. thank you sincerely.
But... I need to prevail upon your generosity again :(
I've hunted everywhere and I can't find how to do this...
I need to figure out this..:
if I have a line.. say
"stephen howe" <stephen@bcl.com>
I need to take away everything between and including the " " 's...
I've wondered about index'ing the " " 's and removing everything
between them but I'm not quite sure how to manage that
Any generous souls around out there please..?
Thank you sincerely
Stephen Howe
------------------------------
Date: 29 Jan 1998 08:33:39 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Profiler for Perl4 (yup. Perl4)
Message-Id: <6aq0fj$p2n@panix.com>
Keywords: from just another new york perl hacker
In <comdog-ya02408000R2901980153530001@news.panix.com> comdog@computerdog.com (brian d foy) writes:
>In article <6ap7lr$154$1@towncrier.cc.monash.edu.au>, bren@fangorn.cs.monash.edu.au (Brendan Macmillan) posted:
>>Perhaps you should change the name of this newgroup, then, to
>>comp.lang.perl5.misc? And then people who read about how helpful
>>the perl community won't be misled?
>there is no Perl 5, it's just Perl.
>a better suggestion would be comp.lang.perl.archaic which won't
>have a V6 problem like the suggestion above.
comp.lang.perl.dead-flea-bitten-camels
--
Clay Irving <clay@panix.com> I think, therefore I am. I think?
http://www.panix.com/~clay/
------------------------------
Date: Thu, 29 Jan 1998 14:17:48 +0100
From: Matteo Boschini <boschini@cilea.it>
Subject: Re-using STDIN
Message-Id: <34D0817C.2296@cilea.it>
Hi all,
I have the following problem:
without going into to much detail, I need to read STDIN without clearing
it. That is, I do a
read(STDIN, $mybuffer, $mylength);
and use $mybuffer for all I need, but at the end of the script, I need
STDIN again , the same one as before, to be passed to another script ?
Any suggestions ?
Thanks,
Matteo Boschini
------------------------------
Date: 29 Jan 1998 15:40:18 GMT
From: "David Lam" <dlam@kdn0.attnet.or.jp>
Subject: Seek Help for copying binary files
Message-Id: <01bd2ccc$4e2f11a0$537c4ca5@davidlam>
Being a novice of Perl, I don't know how to write codes for copying or
moving binary files (.exe, .jpg,...) from one directory to another. Can
anybody help? Thanks.
------------------------------
Date: Thu, 29 Jan 1998 10:38:50 -0500
From: Bryan Teague <bteague@aol.net>
Subject: Socket problem
Message-Id: <34D0A28A.EAD71A0B@aol.net>
Grettings,
I have actually 2 problems that run along the same lines.
1) I am trying to write a "store and forward" program that ships data
to a socket. When I drop my socket connection, the sending program
needs to detect this and stop sending the data and start storing it.
However, instead, it never detects the server has gone away, and
therefor the socket so when it tries to write to the socket, the
program dies with a Broken Pipe.
I set my code up to do a select to verify that the socket handle is
still writable. However, it never detects that the socket has gone
away. This is the snippet of current code.
local ($msg, $output) =@_;
my($win,$wout, $wfound, $timeout);
$win = "";
$timeout = 1;
vec ($win, fileno($output), 1) = 1;
$rc = 0;
($wfound) = select(undef, $wout=$win, undef, $timeout);
print "wfound: $wfound \n";
print "error : $!\n";
$msg .= "\n";
$len = length($msg);
$rc = syswrite $output, $msg, $len;
print "$rc\n";
print "$!\n";
return ($rc);
I also tried writing just a basic socket usin IO::Socket. However, I
am unable to get the client going because of this error:
(run from an HP)
IO::Socket::INET: Bad peer address at ./delme.socket line 4
Socket could not be created. Reason Bad file number
(run from an SGI)
IO::Socket::INET: Bad peer address at
/usr/freeware/lib/perl5/IO/Socket.pm line 42
Socket could not be created. Reason Bad file number
I have tried putting in my host name, my FQDN as well as connecting
from another workstation. Still every time, I have the above errors.
Here is the code:
#!/usr/local/bin/perl -w
use IO::Socket;
$sock = new IO::Socket::INET (PeerHost => 'localhost',
PeerPort => 2345,
Proto => 'tcp'
);
die "Socket could not be created. Reason $!\n" unless $sock;
foreach (1.. 10) {
print $sock "Msg $_: How are you?\n";
}
close ($sock);
Help! What am I doing wrong?
Bryan
--
Bryan Teague bteague@aol.net Phone: 703-453-4397
If you must choose between two evils, pick the one you've never tried
before.
------------------------------
Date: 29 Jan 1998 08:31:55 -0500
From: zbrown@lynx01.dac.neu.edu (Zachary Brown)
Subject: Re: Split
Message-Id: <6aq0cb$off@lynx01.dac.neu.edu>
In article <34D01E38.734AE2A1@coos.dartmouth.edu>,
Chipmunk <rjk@coos.dartmouth.edu> wrote:
>Zachary Brown wrote:
>> Moshe Aaron Allen <moshea@jen.co.il> wrote:
>> > I'm need to split() a pararaph after every five words. Can anyone help?
>>
>> $paragraph =~ s/(\s.*?\s.*?\s.*?\s.*?\s.*?)/$1\n\n/g;
>
>Non-greedy quantifiers are definitely not what you want to use here.
>In particular, that last .*? will *never* match anything.
>The other .*?'s will be happy to match nothing, allowing the entire regexp
>to match something as simple as " " (five spaces).
I have to agree. The line I poseted is flawed in that way. But I tested
it before I posted it, and it worked! I used the following program:
$paragraph = "Now is the time for all good men to come to the aid of their party. Now is the time for all good men to come to the aid of their party. Now is the time for all good men to come to the aid of their party.";
$paragraph =~ s/(\s.*?\s.*?\s.*?\s.*?\s.*?)/$1\n\n/g;
print $paragraph;
Well? What's going on?
Zack
------------------------------
Date: Thu, 29 Jan 1998 15:33:13 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Strip Trailing Spaces. How?
Message-Id: <EnJxvE.EzK@world.std.com>
Dzuy Nguyen <dzuy@dazel.com> writes:
>Use chop() to chop off trailign charaters:
>while (($c = chop($string)) eq " ") {
>...
>}
But if you use this, then you chop off the final non-space character
as well. And it winds up being much slower than the regex solution
mentioned in the FAQ.
As a general rule. Remember, each perl operator and function is
written in C and compiled into machine language. Machine language is
fast, and interpreters like perl are slow. The more you can get perl's
functions to processes your data, and the less time you force perl to
be interpreting your script, the faster your script can be.
In this case, I pass the string to the substitute operator and it
returns when all the spaces are removed. Only after it is done does
the interpreter check to see what the script needs to do next. In your
while loop, the program keeps going back and forth between
intperpreting your script and munging your data for each trailing
character.
#!/usr/bin/perl -w
use Benchmark;
use vars '$string';
$string = 'test' . ' ' x 100;
timethese(10000, { regex => q[$_=$string; s/\s+$//],
loop => q[$_=$string;while(($c=chop($_)) eq " "){} $_.=$c]
}
);
--
Andrew Langmead
------------------------------
Date: Thu, 29 Jan 1998 08:25:49 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Survival Of perl
Message-Id: <pudge-2901980825500001@ppp-9.ts-1.kin.idt.net>
In article <6aol4k$5a9$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
(Tom Christiansen) wrote:
# [courtesy cc of this posting sent to cited author via email]
#
# In comp.lang.perl.misc,
# Jon Drukman <jsd@hudsucker.gamespot.com> writes:
# :i prefer to think of it as the universal GUI. here at the office i
# :write tons of perl scripts to do various tasks. i could give all the
# :users accounts on the unix machines and let them invoke the scripts
# :from the command line (no doubt suffering 8 billion "what do i type if
# :i want it to delete all the files when it copies" calls in the
# :process) or i can whip up a quick front end html page and a back end
# :perl script and let them invoke it from their win95 browsers with
# :pretty drop down lists and radio buttons.
#
# Command line runs on user's current computer. CGI runs on the
# webserver instead. I don't really see these as equivalent.
Not _fully_ equivalent, of course not! But that is obviously not what he
was saying. This is case where users do not need to be on the Unix box
and would only screw up things if they were, but they need access to
functions on the Unix box.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== New Book: MacPerl: Programming for the Rest of Us ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Thu, 29 Jan 1998 14:48:36 GMT
From: Brian.Raven@liffe.com (Brian Raven)
Subject: Re: unzip utility for alpha NT?
Message-Id: <34d0958d.18389622@news.liffe.com>
On Tue, 27 Jan 1998 19:02:59 +0800, angyny@interport.net wrote:
>Does anyone know which unzip utility tool that I can use to unzip
>the Perl installation file on alpha NT?
>(I try WinZip and info-zip, they don't work on alpha NT)
IIRC the Intel DOS version of PKZIP works on alpha NT, but you don't
get long filename support..
Alternatively, there is a package somewhere on Dec's web server that
emulates Intel win32, so you may be able to get WinZip to work.
------------------------------
Date: Thu, 29 Jan 1998 10:08:00 -0500
From: "James H. Blackwell" <jim.blackwell@gsfc.nasa.gov>
Subject: Using Perl Library Module Term::Complete
Message-Id: <34D09B50.6201@gsfc.nasa.gov>
Hi all,
Anyone tried using this module in a web form to emulate what I see in
many other software programs (including some Microsoft products). This
is where you type something and immediately a set of possible words
stored in a file come up. The more you type, the more gets matched to a
word in the list ?
Got a list of things I want to assist users in getting the right format
for the input to a database query. Thought this was what I was looking
for, but does not completely do what I'd like.
Any help is useful
Jim Blackwell
jim.blackwell@gsfc.nasa.gov
Raytheon STX
NASA GSFC
------------------------------
Date: Wed, 28 Jan 1998 13:40:40 +0800
From: Walter Archie <warchie@att.net.hk>
Subject: Webring
Message-Id: <34CEC4D8.7D070978@att.net.hk>
Is there a webring Script?
Please help me find one.
Thank You,
Justin Archie
------------------------------
Date: Thu, 29 Jan 1998 13:29:40 +0100
From: Patrick Husi <patrick@husi.ch>
Subject: Word -> HTML
Message-Id: <34D07634.3BEC1D16@husi.ch>
Hi,
I'm looking for a converter from Word format (i.e. .doc files) to HTML,
preferably for Perl or Java. Anyone ??
Thanks
Patrick
------------------------------
Date: Thu, 29 Jan 1998 15:19:52 GMT
From: Carry Megens <CarryDOTMegens@nym.sc.philips.com>
To: Patrick Husi <patrick@husi.ch>
Subject: Re: Word -> HTML
Message-Id: <34D09E18.337C@nym.sc.philips.com>
Patrick Husi wrote:
>
> Hi,
>
> I'm looking for a converter from Word format (i.e. .doc files) to HTML,
> preferably for Perl or Java. Anyone ??
>
> Thanks
> Patrick
See the LAOLA homepage:
http://user.cs.tu-berlin.de/~schwartz/pmh/
--
Carry Megens Designflow Services M 2.039 !!!
Philips Semiconductors Consumer IC (0o0)
Gerstweg 2 6534 AE Nijmegen \U/
Nijmegen the Netherlands
------------------------------
Date: Thu, 29 Jan 1998 15:15:17 +0200
From: Bekman Stanislav <sbekman@iil.intel.com>
Subject: Writing Multilingual Software
Message-Id: <34D080E5.41C6@iil.intel.com>
Hello,
I know that this is not a very perl specific question. But since I write
the tool in perl
I couldn't think of something else (if you think that this is a post to
a wrong group can you please tell me which one is correct? Thanks)
Anyway I wrote a tool in Perl. Now I have to port it (its output of all
print() calls ) to a different human languages, (french, italian,
russian and etc.)
Do any of you has an experience of how these things should be done?
I think that making the original in English and then translating all
print()'s arguments to
some language is unfeasable... (especially because of upgrades)
I thought about writing a map file per language where real text will be
stored like:
$MESS1 = "This is message one";
$MESS2 = "This is message two";
but I'll have to track what's $MESS1 and I'll get lost if I 'll have
only
print $MESS1 in the code.
I know that these things are exist, e.g. mysql can talk to you in a few
languages, but there are only a limited number of possible replies
there. In my case there are pretty interactive system with many print()s
statements
Do you familiar with some other techniques of solving this problem?
Thank you!
______________________________________________________________________
Stas Bekman
Home Page: http://www.eprotect.com/stas
A must visit: http://www.eprotect.com/stas/TULARC (Java,CGI,PC,Linux)
Linux-il Home: http://www.linux.org.il/
------------------------------
Date: Thu, 29 Jan 1998 09:13:12 -0500
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: Writing Multilingual Software
Message-Id: <34D08E78.313E@gecm.com>
Bekman Stanislav wrote:
> Anyway I wrote a tool in Perl. Now I have to port it (its output of all
> print() calls ) to a different human languages, (french, italian,
> russian and etc.)
Sounds like a good place to use a hash.
Cheers,
Jim
------------------------------
Date: Wed, 28 Jan 1998 20:52:33 +0800
From: Walter Archie <warchie@att.net.hk>
Subject: WWWBoard2.0 A Multiple Boards
Message-Id: <34CF2A11.C9A2D8C5@att.net.hk>
Is it possible to run multiple boards under one script? Without having
to use the DBasic.com script. I do not want to have to pay that over
crowded fee. So, please help me. Thank you.
Thanx,
Justin Archie
------------------------------
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 1760
**************************************