[6485] in Perl-Users-Digest
Perl-Users Digest, Issue: 110 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 13 14:27:11 1997
Date: Thu, 13 Mar 97 11:01:05 -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, 13 Mar 1997 Volume: 8 Number: 110
Today's topics:
Re: Am I hosed? (Can't compile modules) <rootbeer@teleport.com>
Do I need to store return from tie()? (Gregory Tucker-Kellogg)
Re: Elegant way to strip spaces off the ^ and $ of a va <tchrist@mox.perl.com>
Re: getting system date on NT? (Reinoud van Leeuwen)
Re: How to print a number in binary? (Robert L. Urban)
Re: I'm scared and don't know what to do. Do you know?? (Chris Russo)
Re: Installing Modules under Macperl & Getting the best <neilkohl@netaxs.com>
Re: Mail an attatchment with Perl <eryq@enteract.com>
Re: Making ror to really Rotate Right <rootbeer@teleport.com>
Re: Numeric function <tchrist@mox.perl.com>
Re: Regex searches in all files (or selected files) in <dfan@harmonixmusic.com>
Resolving variables in print statement? (Subesh Ghose)
Re: Resolving variables in print statement? (Nathan V. Patwardhan)
Re: Socket reading problem. Help, please (Nathan V. Patwardhan)
Re: Sort question (Bennett Todd)
syntax correction (Subesh Ghose)
Re: Using the print-command with colors (A. Deckers)
Re: weird digit regexp behaviour (Pete Hartman)
Re: What language do Perl REs recognize? (Chris Russo)
Re: what's the advantage of a shared libperl.so?? <seay@absyss.fr>
Re: what's the advantage of a shared libperl.so?? <tchrist@mox.perl.com>
Re: what's the advantage of a shared libperl.so?? <marclang@saxifrage.cs.washington.edu>
Re: Who makes more $$ - Windows vs. Unix programmers? <derek.clarke@gecm.com>
Re: year 2000 question (Bennett Todd)
Re: year 2000 question (Michael Stillwell)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 Mar 1997 08:22:31 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ross Carlson <webmaster@metacraft.com>
Subject: Re: Am I hosed? (Can't compile modules)
Message-Id: <Pine.GSO.3.95q.970313081958.1286G-100000@kelly.teleport.com>
On Wed, 12 Mar 1997, Ross Carlson wrote:
> I have an SGI Indy Webforce workstation that came very
> bare bones, and without the SGI developer's package.
> As a result, I have no compiler! (ARGH)
>
> Lately I have been trying to make use of some of the
> perl modules on CPAN, and it seems that they need to
> be compiled. Am I hosed?
Certainly not! First, you write a compiler, byte by byte, and then... :-)
I don't know for sure, but you may be able to get a compiler like gcc for
your system. Check your favorite GNU archives (and maybe ask in a
newsgroup which discusses your hardware) to find out. If there's no free
compiler, you're not hosed unless you can't buy one either! :-)
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 13 Mar 1997 16:48:41 GMT
From: gtk@walsh.med.harvard.edu (Gregory Tucker-Kellogg)
Subject: Do I need to store return from tie()?
Message-Id: <5g9b59$l9@mufasa.harvard.edu>
Keywords: tie,core,bug
If I have a tie that is implemented via:
use NMR::PeakFile;
$hsqc = tie (%hsqc,'NMR::PeakFile','hsqc.peaks');
($npeaks,$nassigned) = $hsqc->NumAssigned();
print "$nassigned of $npeaks assigned\n";
untie %hsqc;
I get
96 of 96 assigned
which is correct, but if I use tied() instead (without storing the
return of tie()), i.e.:
use NMR::PeakFile;
tie (%hsqc,'NMR::PeakFile','hsqc.peaks');
($npeaks,$nassigned) = tied(%hsqc)->NumAssigned();
print "$nassigned of $npeaks assigned\n";
untie %hsqc;
I get
96 of 96 assigned
Bus error (core dumped)
. If I store the return value of tie(), the use of tied()
doesn't cause any problems, i.e.:
use NMR::PeakFile;
$hsqc = tie (%hsqc,'NMR::PeakFile','hsqc.peaks');
($npeaks,$nassigned) = tied(%hsqc)->NumAssigned();
print "$nassigned of $npeaks assigned\n";
untie %hsqc;
gives
96 of 96 assigned
.
What you see above is in each case the *entire* perl script. Has
anybody else had similar trouble?
If you are concerned about the NMR::PeakFile::NumAssigned sub, it
is
sub NumAssigned {
my $self = shift;
my ($npeaks,$nassigned,$key,$peak);
$npeaks = $nassigned = 0;
while (($key,$peak) = each %{ $self->{PEAK} } ) {
$npeaks++;
$nassigned += NMR::Peak::IsAssigned($peak);
}
return ($npeaks,$nassigned);
}
NMR::Peak::IsAssigned($peak) is a simple function that returns 1 or
0. I have "-w" on and "use strict" in all of the modules. The only
warning I get is "Use of uninitialized value at
/usr/local/lib/perl5/File/Copy.pm line 84."
[gtk ~] perl -v
This is perl, version 5.003 with EMBED
built under irix at Dec 3 1996 13:54:51
+ suidperl security patch
Any help is appreciated.
--
Gregory Tucker-Kellogg
Department of Biological Chemistry and Molecular Pharmacology
Harvard Medical School, Boston MA 02115
"Mojo Dobro" Finger for PGP info
------------------------------
Date: 13 Mar 1997 18:11:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <5g9g0t$l22$1@csnews.cs.colorado.edu>
[courtesy cc of this news posting sent to poster via email]
In comp.lang.perl.misc, Dave@Thomases.com writes:
:No, its just _another_ way.
As I indicated to Dave in private email, I am not fond of
using a construct whose principal use involves a return
value when you toss the return value.
For example, these:
$ok ? cool() : crud();
map { $_++ } @nums;
run counter to understandable coding practices. You discard their
return values, and the map in particular is evil for its side-effects.
I prefer that those be written as:
if ($ok) { cool() }
else { crud() }
for (@nums) { $_++ }
It's not that things like ?: and map() are inherently bad.
For example, they work well in constructs like these:
$result = $ok ? cool() : crud();
@incnums = map { $_ + 1 } @nums;
Modification in the grep and map constructs is pretty tricky. I suppose
I can construe a use for it -- just rarely.
Here, for example, we combine several of the topics under discussion:
@mucked_with = map { s/^\s+$// } @lines;
for $i ( 0 .. $#lines ) {
printf "%s %s\n", $mucked_with[$i] ? "clean" : "dirty", $lines[$i];
}
Or even the more japhian
for $i ( 0 .. $#lines ) {
printf "%s %s\n", (qw!clean dirty!)[ $mucked_with[$i] ], $lines[$i];
}
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"I have many friends who question authority. For some reason most of 'em
limit themselves to rhetorical questions."
--Larry Wall
------------------------------
Date: Thu, 13 Mar 1997 17:31:26 GMT
From: reinoud@xs4all.nl (Reinoud van Leeuwen)
Subject: Re: getting system date on NT?
Message-Id: <332c39be.1108814@news.xs4all.nl>
On Thu, 13 Mar 1997 03:25:02 GMT, cwyatt@cris.com (Chuck Wyatt) wrote:
>Hello!
>
>I'm familiar with how one might assign the system date to a variable
>when programming Perl on a UNIX system.
>
>eg:
>$date= `/bin/date "+%D %r"`;
>
>However, it isn't clear to me how to do this in a Windows NT
>environment.
>
>eg:
>$date= `c:\command\date`;
>
>doesn't cut it for me! You end up with:
>Current date is Wed 03-12-1997
>Enter new date (mm-dd-yy):
In the resource kit is a program called now:
D:\>now
Thu Mar 13 18:31:03 1997
Hope this helps...
__________________________________________________
Reinoud van Leeuwen reinoud@xs4all.nl
http://www.xs4all.nl/~reinoud
I specifically DO NOT give anyone permission to use my email adress
for any commercial or non commercial mailings. I will bill everyone
who sends me this kind of mail for wasting my time. Under Dutch law,
people who don't let me know they disagree with such a bill are obliged
to pay it.
------------------------------
Date: 13 Mar 1997 17:37:24 GMT
From: urban@nasaxp.rto.dec.com (Robert L. Urban)
Subject: Re: How to print a number in binary?
Message-Id: <5g9e0k$8e1@rtnews.rto.dec.com>
In article <Pine.GSO.3.95.970111162726.7518H-100000@linda.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> writes:
>On Fri, 10 Jan 1997, Craig Votava wrote:
>
>> How can I print the binary string of a given number in perl?
>
>> The only way I've been able to come up with a way is the following:
>>
>> print "0xaf = ", unpack("B32", pack("I1", 0xaf));
>>
>> But this seems like a really stupid way to do it. Isn't there an easier
>> way?
>
>What's stupid? What's easier? :-)
>
>I'd probably make a sub to convert to binary (with a specified number of
>bits, of course), but that's about it. There's not much call to hack a
>binary format into sprintf(). Hope this helps!
>
>-- Tom Phoenix http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com PGP Skribu al mi per Esperanto!
>Randal Schwartz Case: http://www.lightlink.com/fors/
>
here's something I hacked together:
#!/usr/local/bin/perl
$num = $ARGV[0];
if (!$num) {
print "usage: $0 <decimal number>\n";
exit;
}
$binary = ConvertBinary($num);
print "BINARY: $binary\n";
sub ConvertBinary {
my($num) = @_;
my($out) = '';
my($pos) = 0;
while($num) {
if ($num & (1<<$pos)) {
$out = "1$out";
$num -= (1<<$pos);
} else {
$out = "0$out";
}
$pos++;
}
$out;
}
--
Rob Urban
Digital Equipment GmbH
Freischuetzstr. 91
81927 Muenchen
Germany
------------------------------
Date: Thu, 13 Mar 1997 07:56:23 -0800
From: crusso@alink.net (Chris Russo)
Subject: Re: I'm scared and don't know what to do. Do you know??
Message-Id: <crusso-1303970756230001@buzz.alink.net>
Save yourself a lot of anguish by hiring someone to do the project for
you. In such a short time-frame, you're not going to learn all you need
in order to do a good job on the project. Be prepared to spend a bit o'
money.
Regards,
Chris Russo
----------------------------------------------------------------------
Chris Russo A-Link Network Services, Inc.
crusso@alink.net Bolo me
http://www.alink.net/~crusso
------------------------------
Date: Wed, 12 Mar 1997 19:30:05 -0500
From: Neil Kohl <neilkohl@netaxs.com>
To: geoff@no.spam.leeds.ac.uk
Subject: Re: Installing Modules under Macperl & Getting the best out of Makemaker
Message-Id: <Pine.SUN.3.95.970312192840.15764D-100000@unix1.netaxs.com>
There is a port of lib-www for MacPerl (along with other useful MacPerl
stuff) at:
http://mors.gsfc.nasa.gov/MacPerl.html
Neil Kohl American College of Physicians
------------------------------------------------------------------
neilkohl@netaxs.com 215.351.2400x2638, 800.523.1546x2638
On Tue, 11 Mar 1997 geoff@no.spam.leeds.ac.uk wrote:
> I feel compelled to ask a question about Macperl in this group because
> I have been unable to get the answers I need from any FAQ, deja news or
> the usual Macperl sources (which, sadly, appear to be slumbering).
>
> My objective is to install the libwww modules(s). (To be honest, at this
> stage, I would be pleased to receive guidance on installing any module).
------------------------------
Date: Thu, 13 Mar 1997 10:13:27 -0600
From: Eryq <eryq@enteract.com>
To: Cheng Tyh Lin <a00lcj00@elc012.nchc.gov.tw>
Subject: Re: Mail an attatchment with Perl
Message-Id: <332827A7.5FF50D9D@enteract.com>
Cheng Tyh Lin wrote:
>
> How can I do that by using attatchment to mail a non-ascii code's document?
> Or is there any mail size limit that I must cut them by myself?
> Please reply to my mail add. Thankx
I'm not sure if this is a repost of your earlier question; I have CC'ed
to your email address, but I hope you read the enwsgrou as well.
Get a copy of MIME::Lite, in the CPAN. You can also get it from:
http://enteract.com/~eryq/CPAN/MIME-Lite/
There is no size limit on what it can handle, not even a core limit if
you're sending a file that's currently on disk.
The module has numerous examples, but here's how to send a GIF file:
# Create a new single-part message, to send a GIF file:
$msg = new MIME::Lite
-From =>'me@myhost.com',
-To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'Helloooooo, nurse!',
Type =>'image/gif',
Path =>'hellonurse.gif';
$msg->send; # UNIX only!
And here's a message with a binary attachment:
# Create a new multipart message:
$msg = new MIME::Lite
-From =>'me@myhost.com',
-To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'A message with 2 parts...',
Type =>'TEXT',
Data =>"Here's the GIF file you wanted";
# Attach a part:
attach $msg
Type =>'image/gif',
Path =>'aaa000123.gif',
Filename =>'logo.gif';
Hope this helps,
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.enteract.com/~eryq
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: Thu, 13 Mar 1997 08:16:53 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Bekman Stanislav <sbekman@iil.intel.com>
Subject: Re: Making ror to really Rotate Right
Message-Id: <Pine.GSO.3.95q.970313075152.1286F-100000@kelly.teleport.com>
On Wed, 12 Mar 1997, Bekman Stanislav wrote:
> I need to do a simple ror (Rotate Right) function
> But not the way perl implement it. ror throws out the shifted bits
> and I need to push them from the left side. That's why it's called
> rotate and no shift.
Ah, but for what wordsize? Perl does many things in a way that hides the
underlying machine from the programmer, so that you don't have to worry
about the machine's details.
(Also, I don't know what you mean by "the way perl implements it", since
Perl doesn't have such a function, to my knowledge.)
Assuming that you want 32-bit words, this might help. There are some
more-or-less subtle issues with this kind of stuff, so don't implement
this until you've tested it thoroughly on each machine. (And making it
work with different wordsizes isn't as obvious as it seems, alas. This
should perhaps be best written as an external C routine linked into Perl.
Maybe someone has done that, but I didn't find it on CPAN. Another way,
not requiring C and linking, might be to use pack and unpack, but I
didn't think of it until I had written this. :-)
sub ror ($$) {
my($word, $bits) = @_;
return $word unless $bits = $bits % 32;
my($lowmask) = (1 << $bits) - 1;
my($highmask) = ~$lowmask;
(($lowmask & $word) << (32 - $bits)) |
(($highmask & $word) >> $bits)
}
sub rol ($$) {
my($word, $bits) = @_;
ror $word, 32 - $bits;
}
On my system, these seem to work fine for both positive and negative shift
amounts. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 13 Mar 1997 16:17:45 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Numeric function
Message-Id: <5g99b9$g9m$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
gml4410@ggr.co.uk (Lack Mr G M) writes:
:|> warn "not a decimal number" unless /^[+-]?\d+\.?\d*$/
: ^^^
: Surely should be \d*?
Ah, so the null string is a valid number, eh? I think not.
/
^ # start of string
[+-]? # maybe a sign
\d* # maybe some digits
\.? # maybe a dot
\d* # maybe some digits
$ # end of string
/x
All those maybes add up to a big fat nothing, and you lose. Bad idea.
See p127 of `Mastering Regular Expressions' from ORA by Jeffrey Freidl,
which treats with this precise topic.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Most of what I've learned over the years has come from signatures."
--Larry Wall
------------------------------
Date: 13 Mar 1997 11:16:15 -0500
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: Regex searches in all files (or selected files) in a directory
Message-Id: <wkzpw76a40.fsf@turangalila.harmonixmusic.com>
jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey) writes:
| David Parkhurst <parkhurs@indiana.edu> wrote:
| |> I'd like to use regex to search all *.txt files (say) in a particular
| |> directory that match some pattern. I'm working in Windows95, and I'm a
|
| You might find my 'search' program useful.
| It's at
| http://enterprise.ic.gc.ca/~jfriedl/perl
search.pl is indeed amazingly useful. I had to make some changes to
make it work under Windows 95; here's the patch (Jeffrey has noted it
but hasn't had time to approve it, so it might be slightly (or
completely) different in the next real release). Put the line
"option: -win" in your .search file so it knows to do the special
Win95 stuff.
Note also that you MUST have the environment variable HOME set, as
that's where it looks for the .search configuration file.
Dan
----- patch follows -----
*** c:/src/old/search.pl Tue Feb 11 20:33:10 1997
--- c:/src/search.pl Wed Feb 12 11:49:02 1997
***************
*** 123,128 ****
--- 123,131 ----
$retval=1; ## will set to 0 if we find anything.
$DESCEND_SUBDIRECTORIES=1;## set to false by -depth=0
+ $WINDOWS=0; ## under windows?
+ $USE_INODES=1; ## are inodes valid?
+
## various elements of stat() that we might access
$STAT_DEV = 1;
$STAT_INODE = 2;
***************
*** 194,199 ****
--- 197,203 ----
-showrc show what the rc file sets, then exit.
-norc don\'t load the rc file.
-dorep check files with multiple hard links multiple times.
+ -win necessary if running under Windows 95.
INLINE_LITERAL_TEXT
print "Use -v -help for more verbose help.\n" unless $VERBOSE;
print "This script file is also a man page.\n" unless $stripped;
***************
*** 253,258 ****
--- 257,266 ----
$LIST_ONLY=1,$opt{'-list'}=1,
next if $arg =~/^-l(ist)?$/;## only list files
+ $WINDOWS=1, $USE_INODES=0, $DOREP=1,
+ next if $arg eq '-win'; ## running under Windows
+
+
if ($arg =~ m/^-depth=(\d+)$/) {
die qq/$0: only -depth of 0 currently supported\n/ if $1 != 0;
$DESCEND_SUBDIRECTORIES=0;
***************
*** 962,970 ****
}
## skip things that are empty
! unless (-s _) {
! warn qq/skip (empty): $file\n/ if $WHY;
! next;
}
## Note file device & inode. If -xdev, skip if appropriate.
--- 970,981 ----
}
## skip things that are empty
! if (!$WINDOWS) { # -s fails for all dirs under Windows
! # or should we just put the -d test before this?
! unless (-s _) {
! warn qq/skip (empty): $file\n/ if $WHY;
! next;
! }
}
## Note file device & inode. If -xdev, skip if appropriate.
***************
*** 973,979 ****
warn qq/skip (other device): $file\n/ if $WHY;
next;
}
! $id = "$dev,$inode";
## special work for a directory
if (-d _) {
--- 984,990 ----
warn qq/skip (other device): $file\n/ if $WHY;
next;
}
! $id = "$dev,$inode" if $USE_INODES;
## special work for a directory
if (-d _) {
***************
*** 993,1004 ****
next;
}
! ## _never_ redo a directory
! if (defined $dir_done{$id}) {
! warn qq/skip (did as "$dir_done{$id}"): $file\n/ if $WHY;
! next;
! }
! $dir_done{$id} = $file; ## mark it done.
unshift(@todo, $file); ## add to the list to do.
next;
}
--- 1004,1018 ----
next;
}
! if ($USE_INODES)
! {
! ## _never_ redo a directory
! if (defined $dir_done{$id}) {
! warn qq/skip (did as "$dir_done{$id}"): $file\n/ if $WHY;
! next;
! }
! $dir_done{$id} = $file; ## mark it done.
! }
unshift(@todo, $file); ## add to the list to do.
next;
}
------------------------------
Date: 13 Mar 1997 10:44:11 -0600
From: sghose@tiger.lsu.edu (Subesh Ghose)
Subject: Resolving variables in print statement?
Message-Id: <5g9asr$1oa2@tiger3.ocs.lsu.edu>
I am having trouble resolving the variable in my print statement. Here
are the lines of code:
$outfile = 'g:\\htmldoc\\dc\\docs\\wkreport\\wkreport.htm';
open (OUTFILE, ">$outfile") || die "Couldn't open #!\n";
print OUTFILE '<dt>Report week ending <a href="/wkreprt/$week.htm">$date</a>';
^^^^^^^^^ ^^^^^
I cannot get these variables to resolve. Is my syntax correct for the
print line? Any help is appreciated.
Subesh
--
--
subesh
XXX Has Your Back
------------------------------
Date: 13 Mar 1997 17:46:34 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Resolving variables in print statement?
Message-Id: <5g9ehq$ine@fridge-nf0.shore.net>
Subesh Ghose (sghose@tiger.lsu.edu) wrote:
: $outfile = 'g:\\htmldoc\\dc\\docs\\wkreport\\wkreport.htm';
Firstly. I know I might have used the drive:\\ notation in the past,
but DON'T use it. Check out details at http://www.perl.com. You should
be doing: $outfile = 'g:/path/filename.ext'; instead.
: open (OUTFILE, ">$outfile") || die "Couldn't open #!\n";
No. open(OUTFILE, ">$outfile") || die ("File error: $!");
OR (if you need to send to STDOUT - like on the web):
open(OUTFILE, ">$outfile") || print("File error: $!");
: print OUTFILE '<dt>Report week ending <a href="/wkreprt/$week.htm">$date</a>';
Where have you declared $week? What have you assigned it to? Where
have you declared $date? What have you assigned it to?
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 13 Mar 1997 17:06:12 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Socket reading problem. Help, please
Message-Id: <5g9c64$fq4@fridge-nf0.shore.net>
Alexander Osipov (shu@iis.nsk.su) wrote:
: Does this program work???
What aren't you using perl -w?
: For me it prints "Connected" and doesn't read something from socket.
: As I think it should read 'login: ' at least.
Have you tried telnet'ing to port 9999 and seeing what happens? I suspect
that your question might be answered this way.
: #!/usr/local/bin/perl
-w -> Use it.
: my ($remote,$port, $iaddr, $paddr, $proto, $line);
: $remote = "java";
^^^^^^^^^^^^^^^^^^
# Although I hate to nit-pick, what's the fullname of this host?
# Is it java.sun.com? Of have you written a server on a your own
# machine (aliased to java.yourhost.com) that runs on port 9999? If
# you're arbitarily calling the host 'java,' without any name resolution,
# or entries in /etc/hosts I'm surprised your program is getting as far
# as it is (now).
: $port = 9999; # telnet port
: $iaddr = inet_aton($remote) || die "no host: $remote";
: $paddr = sockaddr_in($port, $iaddr);
: $proto = getprotobyname('tcp');
: socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
: connect(SOCK, $paddr) || die "connect: $!";
# ADD THIS LINE RIGHT HERE -> for flushing the buffer
select(SOCK); $| = 1; select(STDOUT);
: print "Connected\n";
: $line = <SOCK>; # HANGS HERE. WHY?
### Why not try?:
while(<SOCK>) {
print;
}
### OR: Is your server on port 9999 waiting for some kind of input?
### Is it waiting for a \r\n? See the top of this message about telnet'ing
### to the port to see what it outputs.
Hope this helps!
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Thu, 13 Mar 1997 17:00:30 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: Sort question
Message-Id: <slrn5igcld.690.bet@onyx.interactive.net>
On 9 Mar 1997 23:46:45 GMT, viet@airmail.net <viet@airmail.net> wrote:
>How do I sort a list with elements: ("Dec96", "Nov96", "Jan97", "Feb97",
>...) so that the latest the newest (Feb97) would come out first?
Well, you need to get those months converted into something amenable to easy
comparison. How about integers?
my(%Mon) = ( Jan => 0, Feb => 1, Mar => 2, Apr => 3, May => 4, Jun => 5,
Jul => 6, Aug => 7, Sep => 8, Oct => 9, Nov => 10, Dec => 11 );
print map { $_->[0] }
sort { $b->[2] <=> $a->[2] or $b->[1] <=> $a->[1] }
map { /(...)(..)/; [ $_, $Mon{$1}, $2 ] } <>;
-Bennett
------------------------------
Date: 13 Mar 1997 10:51:51 -0600
From: sghose@tiger.lsu.edu (Subesh Ghose)
Subject: syntax correction
Message-Id: <5g9bb7$2pd6@tiger3.ocs.lsu.edu>
Can variables be resolved inside of a system command?
Here is my line of code:
system ('wp2html v:\status\$datafile g:\htmldoc\wkreport\$datafile.htm');
^^^^^^^^^ ^^^^^^^^^
*NOTE* wp2html is a program that is being executed that translates WP
files into html.
Any help is appreciated.
Subesh
--
--
subesh
XXX Has Your Back
------------------------------
Date: 13 Mar 1997 17:59:13 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: Using the print-command with colors
Message-Id: <slrn5igg3i.prb.Alain.Deckers@nessie.mcc.ac.uk>
In <5g48u9$3gr@butch.lmsc.lockheed.com>,
Jan Schipmolder <schip@lmsc.lockheed.com> wrote:
>Mikael Hallendal (micke@cel95mhl.campus.mdh.se) wrote:
>: I got a little problem.
>: I want to use different colors in my output ..
>
>That has nothing to do with perl (I think).
The article you followed up to hasn't reached my server yet, but I think
it's actually OK. There's a Perl module that simplifies colour output.
It's written by Russ Allbery and called TERM::ANSIColor (I think). Should
be on CPAN.
<URL:http://www.perl.com/CPAN/modules/>
HTH,
--
Alain.Deckers@man.ac.uk <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl software: <URL:http://www.perl.com/CPAN/>
------------------------------
Date: Thu, 13 Mar 97 17:56:38 GMT
From: elmegil@i1.net (Pete Hartman)
Subject: Re: weird digit regexp behaviour
Message-Id: <5g9f4m$3r0_002@news.i1.net>
In article <5g88he$2o4_002@news.i1.net>, elmegil@i1.net (Pete Hartman) might have said:
>I'd think this would be a faq, but I don't see the answer in the
>regexp section of the online faq.
>
>I'm trying to match a number. I want to match 12345 but not
>12.34.56.78; note that the latter has "." in it.
>
>The perl books both say that \d is the same as [0-9], which sounds
>to me like "just the digits 0 through 9". However, both m/\d+/ and
>m/[0-9]+/ match "12.34.56.78".
>
>Why? "." is not a digit. If I *want* to match it, I can add it to the
>regexp. If this is a feature not a bug, how can I disable it to get
>the behaviour I want (JUST the digits 0 through 9)?
Thanks to those who responded and pointed out my bonehead mistake.
It's been a little while, and it failed to occur to me that I needed anchors
to require the whole string to be digits and not just match the partial sets
of digits.
Thanks especially to Tom Christiansen with the chunk of the FAQ I missed
about checking for decimals etc.
------------------------------
Date: Thu, 13 Mar 1997 08:13:24 -0800
From: crusso@alink.net (Chris Russo)
Subject: Re: What language do Perl REs recognize?
Message-Id: <crusso-1303970813240001@buzz.alink.net>
In article <33274678.73835889@news.swva.net>, bernie@fantasyfarm.com
(Bernie Cosell) wrote:
>I was wondering if anyone has characterized the languages accepted by Perl
>Regular Expressions. The class is larger than the Regular Languages but
>isn't the context-free languages... what is it? It has been a VERY long
>time since I took language/grammar in school, but I didn't recall that
>there was a class of languages between regular and CF, but I guess there
>is... [also, any ideas on what sort of machine implements Perl REs? It
>shouldn't need a PDA [because Perl REs can't do all Cf languages and PDAs
>can], but I don't know what it might be...]
Feeling.... dizzy...
----------------------------------------------------------------------
Chris Russo A-Link Network Services, Inc.
crusso@alink.net Bolo me
http://www.alink.net/~crusso
------------------------------
Date: Thu, 13 Mar 1997 17:35:12 +0000
From: Douglas Seay <seay@absyss.fr>
To: Marc Langheinrich <marclang@saxifrage.cs.washington.edu>
Subject: Re: what's the advantage of a shared libperl.so??
Message-Id: <33283AD0.68D2@absyss.fr>
Marc Langheinrich wrote:
> What exactly does that buy me? Less storage space on disk? (obviously
> not) Faster compilation? (didn't Tom mention someplace else that this
> would actually take longer?) Less Memory consumption when executing a
> script?
>
> I hoped for the latter one, but it seems it makes no difference
> whether I compile Perl w/ or w/o shared libperl.so -- either way, my
> script uses the same amount of memory while running. So why would I
> want to do this -- only to enjoy an 11k small binary?!
If you have several perl processes running at one time, shared
objects are a winner. Fewer page faults, smaller memory image,
and stuff like that. The savings come from shareing. I'd guess
that TomC has dozens of perl scripts running at any given moment,
so it is a good idea for him. If you normally just have one
running at a time, the .so might not be for you. Like every
thing else in Perl, try both and then use the one that makes
you the happiest.
doug
------------------------------
Date: 13 Mar 1997 17:16:19 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: what's the advantage of a shared libperl.so??
Message-Id: <5g9cp3$ipc$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Douglas Seay <seay@absyss.fr> writes:
:If you have several perl processes running at one time, shared
:objects are a winner. Fewer page faults, smaller memory image,
:and stuff like that. The savings come from shareing. I'd guess
:that TomC has dozens of perl scripts running at any given moment,
:so it is a good idea for him. If you normally just have one
:running at a time, the .so might not be for you. Like every
:thing else in Perl, try both and then use the one that makes
:you the happiest.
The sharing happens at both the binary level and the library level.
The perl binary is shared if you have many different scripts running
at once. It's all the same binary. Only if you compile the scripts
and have many separate ones running is it a problem.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Do we define evil as the absence of goodness? It seems only logical
that shit happens--we discover this by the process of elimination."
--Larry Wall
------------------------------
Date: Thu, 13 Mar 1997 17:21:59 GMT
From: Marc Langheinrich <marclang@saxifrage.cs.washington.edu>
Subject: Re: what's the advantage of a shared libperl.so??
Message-Id: <qyjlo7remh4.fsf@saxifrage.cs.washington.edu>
Roderick Schertler <roderick@argon.org> writes:
> Further, if you have multiple different compiled applications
> running at once (or even just one application and one uncompiled
> script) they each get their own copy of most of perl. With
> libperl.so all the applications and all the compiled programs run
> from the same text pages.
I'm not sure if I'm familiar enough w/ that OS-term: "run from the same text
pages"... Does that change the main/virtual memory consumption during
execution at all? Only one chunk of perl-core-code in memory, and all
applications 'share' it?!
Douglas Seay <seay@absyss.fr> writes:
> Fewer page faults, smaller memory image, and stuff like that.
"Smaller Memory image"? So we're talking about execution here?
But Tom Christiansen <tchrist@mox.perl.com> writes:
> Of course, if the only thing on your system is /usr/bin/perl, well
> yes, there's no great savings.
But if I understand Tom correctly, he says that: the only way to save
here is in terms of disk space. Right?
So - when all I do is execute a large number of (exactly the same)
large perl scripts all at the same time (on a httpd server, for
serving user queries), then a shared libperl.so will make things
worse, since Roderick Schertler <roderick@argon.org> writes:
> You still pay for it in execution time due to the position independent
> code, though.
The only way to save time here is to either
a) compile the script, and save the compilation time, or
b) use mod_perl and embedd perl & (compiled) script into the
apache server
Roderick seems to agree, because he <roderick@argon.org> writes:
> Right, the memory use isn't changed because it's the same system image
> executing all Perl scripts, so the text is always shared. Text sharing
> is per-program with static libraries, but per-library with shared
> libraries. When there's only a single program using the library it
> doesn't save memory to share it, it just costs CPU time.
Sure, but the reason I want to use libperl.so is because I have
_dozens_ of programs running at the same time, and they're all the
same perl script.
I'm confused... I understand that using a single /usr/bin/perl with
shared libperl.so executing a single perl script will def. slow
down execution, w/o changing memory consumption. But what about using
a single /usr/bin/perl with a shared libperl.so and running, say, 50
scripts at the same time?! Does that save anything? If I understand
Tom correctly it doesn't, but the other postings seem to suggest it
would (or do I just want to believe they do :) ?!?)
Marc
---
Marc Langheinrich Department of Computer Science & Engr.
office phone: (206) 543-5129 University of Washington, Box 352350,
email: marclang@cs.washington.edu Seattle, WA 98195-2350, USA
www: http://www.cs.washington.edu/homes/marclang/
------------------------------
Date: 13 Mar 1997 17:58:54 GMT
From: Derek Clarke <derek.clarke@gecm.com>
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g9f8u$vcj@gcsin3.geccs.gecm.com>
Frithiof.Jensen@jet.uk (Frithiof Jensen) wrote:
<snip>
>Ah yes, but JAVA is going to kill that cirkus dead.
>British Telecom estimates that more than 50% of the workstations in a typical
>enterprise will be NC machines by year 1998! (The Guardian, 3 march 1997).
BT also predicted that everyone would buy a One-Per-Desk in the mid-80s.
------------------------------
Date: Thu, 13 Mar 1997 16:21:36 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: year 2000 question
Message-Id: <slrn5igacf.24a.bet@onyx.interactive.net>
[ followups redirected; this followup is no longer perl-specific ]
On Wed, 12 Mar 1997 12:44:30 -0600, Tad McClellan <tadmc@flash.net> wrote:
>Dan Ellsweig (Enterprise Management) (dxe@sbi.com) wrote:
>: [...] I have a question regarding the 'localtime()' library function.
>
>: Does anyone know of a version of PERL which will support 4 character year
>: as returned by localtime()??
The standard perl works fine. Of course, the year field returned by
localtime() is defined to be the year with 1900 subtracted, so to see a
4-digit year you need to specify a date past January 1, 2900 --- and such
dates don't fit in 32-bit time_ts. But if you have a system with a 64-bit
time_t (and we all will soon enough) then you can go
perl -le 'print ((localtime 29348024400)[5])'
and it'll print "1000".
>: Currently the localtime function calculates the correct year then it
>: subtracts 100 from the year before returning the year value in the
>: localtime array.
No, it calculates the correct year then subtracts 1900, as documented in
perlfunc(1).
>: The result is a 2 character year (99 for 1999 or 00 for 2000).
No, the result is an integer, 99 for 1999 and 100 for 2000 and (as the man
page points out) 123 for 2023.
>localtime() (and all of Unix, BTW) have a "year 2037" problem.
Well, those Unixes (currently still a majority) with 32-bit time_t values. But
that'll be fixed.
-Bennett
------------------------------
Date: 13 Mar 1997 09:26:55 GMT
From: mist@yoyo.cc.monash.edu.au (Michael Stillwell)
Subject: Re: year 2000 question
Message-Id: <slrn45ifi2v.egs.mist@aurora.cc.monash.edu.au>
On 12 Mar 1997 23:28:08 GMT, Tom Christiansen <tchrist@mox.perl.com> wrote:
: In comp.lang.perl.misc,
: dxe@cassidy.sbi.com (Dan Ellsweig (Enterprise Management)) writes:
: :I am in the process of insuring year 2000 compliance for all of
: :my PERL code.
:
: I suspect that you're ensuring its compliance. If you were insuring it,
: you'd be paying premiums.
Wow, I'm impressed, I thought you lot didn't distinguish between the
two.
Actually, the on-line Webster's <http://www.m-w.com/> gives, as one
definition of "insure", "to make certain especially by taking
necessary measures and precautions" and also says "ENSURE, INSURE,
and ASSURE are interchangeable in many contexts where they indicate
the making certain or inevitable of an outcome" which would seem to
apply above.
Michael
--
.. ABSOLUT .SIG. ..
.. Michael Stillwell ..
.. mist@yoyo.cc.monash.edu.au ..
.. http://yoyo.cc.monash.edu.au/~mist/ ..
------------------------------
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 110
*************************************