[7387] in Perl-Users-Digest
Perl-Users Digest, Issue: 1012 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 11 15:18:48 1997
Date: Thu, 11 Sep 97 12:01:18 -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, 11 Sep 1997 Volume: 8 Number: 1012
Today's topics:
Re: Anyone else seeing this core dump in perl5.004_03 o lvirden@cas.org
Re: array of references won't work (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Can't call method ... <manolis@cytanet.com.cy>
CGI ? <kendal@freenet.tlh.fl.us>
Concurrency Issues (Perl/CGI/UNIX) <bkyan@mindcast.com>
Configure syntax error in line 141 ()
Re: flock() time <doug@tc.net>
Re: Flushing STDOUT? (Andrew M. Langmead)
grepping for parens <jom@net1plus.com>
How to email text file (Bud Siebold)
Re: How to email text file twod@not.valid
Re: how to generate permutations of an array (Joel Coltoff)
Loading modules or subroutines at execution <L_McLaughlin@fccc.edu>
Loading modules or subroutines at execution <L_McLaughlin@fccc.edu>
Re: manipulating chars inside strings? (Jim Michael)
Re: manipulating chars inside strings? (Andrew M. Langmead)
Re: Perl script question for gurus (Tad McClellan)
Re: Pipes in perl <fawcett@SPAMLESS.nynexst.com>
Re: Please help me with locking! Using NDBM! (Richard Bellavance)
Problems using typeglobs to export arrays <tonyk@nscedu.com>
Re: Q: Building Perl as shared object? <doug@tc.net>
redirect output of system function <dennis.kowalski@daytonoh.ncr.com>
reg expression help! (Alex Krohn)
Returning Hashes from Sub (newbie question) <nospam.gibsonc@aztec.asu.edu>
Re: Returning Hashes from Sub (newbie question) (Brian Wheeler)
Re: shell command "more" (Will Morse)
Syntax Error Configure ()
Timeout <support@holt.ie>
Re: Um... a bug? ()
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Sep 1997 15:00:26 GMT
From: lvirden@cas.org
Subject: Re: Anyone else seeing this core dump in perl5.004_03 on solaris 2.5.1 [Was: Re: Compiling perl5.004.01 on solaris 2.5.1
Message-Id: <5v912a$o49$1@srv38s4u.cas.org>
Turned out to be a problem with the Term::ReadLine::Gnu package - it
was documented in the README, but I had used CPAN to build it so I
didn't see the README...
--
Larry W. Virden INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
------------------------------
Date: Thu, 11 Sep 97 13:27:14 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: array of references won't work
Message-Id: <34182b30$6$ofn$mr2ice@speaker.kf8nh.apk.net>
In <5v5al3$957$1@u30039.rsv.svskt.se>, on 09/10/97 at 05:19 AM,
matlar@rsv.se (Mats Larsson) said:
+-----
| There is apparently something I don't understand about references (yes I
| have read the manual).
> ( . . . )
| # array of references won't work
| # @tab = (\$one, \$two);
| $tab[0] = \$one;
| $tab[1] = \$two;
| # both of the two methods above tested, neither works as intended
| print $$tab[0],"\n"; # ? prints just an empty line
+--->8
The problem is not with putting the references into an array, but with getting
them back out again: "$$tab[0]" doesn't do what you think it should. This
*is* documented, BTW.
Basically, "$$tab[0]" acts like ($$tab)[0]; and because "$" is not an
operator, you have to use special syntax to get what you want: ${$tab[0]}
(note braces, *not* parens). (Whether "$" should be an operator or not is not
for me to answer, but I suspect it would cause serious problems with the Perl
parser.)
Once you have that right, you'll find that both the above-quoted methods of
getting a list of references do indeed work.
--
brandon s. allbery [Team OS/2][Linux] bsa@void.apk.net
cleveland, ohio mr/2 ice's "rfc guru" :-) FORZA CREW!
Warpstock '97: OS/2 for the rest of us! http://www.warpstock.org
------------------------------
Date: Thu, 11 Sep 1997 14:01:06 +0300
From: Manolis <manolis@cytanet.com.cy>
Subject: Can't call method ...
Message-Id: <3417CF72.F02E994B@cytanet.com.cy>
when i run rcor_copies.pl i get:
Can't call method "import" in empty package "Rcor_module" at
./rcor_copies.pl line 7.
BEGIN failed--compilation aborted at ./rcor_copies.pl line 7.
line 7 has this:
use Rcor_module;
any1 can help?
--
cheers!
------------------------------
Date: Thu, 11 Sep 1997 14:27:51 -0400
From: Kendal Van Dyke <kendal@freenet.tlh.fl.us>
Subject: CGI ?
Message-Id: <34183827.E11303AD@freenet.tlh.fl.us>
Is is possible to use PERL CGI to return a compressed file to a user
after they click on a form submit button and then after that file has
been sent redirect the user to another page (with all the control coming
from the script - no Javascripting involved at all)??
--
Kendal Van Dyke
- Web => www.cs.fsu.edu/~vandyke
- E-mail => kendal@freenet.tlh.fl.us
- Mobile => (850) 980-6658
------------------------------
Date: Thu, 11 Sep 1997 09:20:20 -0700
From: Benjamin Kyan <bkyan@mindcast.com>
Subject: Concurrency Issues (Perl/CGI/UNIX)
Message-Id: <34181A44.92399BD7@mindcast.com>
Hi,
I'm would like to try to improve on the way I'm currently handling
concurrency issues in my CGI scripts... The code snippets to
follow show how I'm currently handing concurrency at the session
level. Also, I "use Fcntl;" at the beginning of scripts that
utilize these functions, as suggested by one of the FAQs I read.
Using "flock", by itself, seemed to cause my scripts to start
blocking indefinitely, every once in a blue moon, even when there
is not evidence of hanging scripts. (My best guess for why this
happens is that when a CGI process that is waiting for another
process to finish gets killed, the flock count fails to decrement
properly. However, this is strictly a guess...)
Anyways, that's why I resorted to the eval/alarm combination,
which unlinks the flocked inode altogether if the process gets
blocked for too long -- usually I set the alarm for 30 seconds
or so. Under light and medium load, this seems to work just fine.
Under heavy load, however, I am concerned about degenerate cases
where the script would correctly try to block beyond the time
limit, triggering the alarm and putting the flock system out of
synch.
Any suggestions for a better way to handle this? Thanks! Also, on
a bit of a tangent, after perusing the man pages for GDBM, I came
away with the notion that GDBM provides implicit locking? Is that
true when used with Perl?
==
sub sessionlock
{
my($sessionfile) = $path{'data'} . $file{'lock'};
my($locktype) = shift(@_);
open(SESSIONLOCK, "+>" . $sessionfile);
eval
{
local $SIG{ALRM} = sub { die "alarm clock reset" };
alarm $lock{'wait'};
flock SESSIONLOCK, $locktype;
alarm 0;
};
if ($@)
{
die unless ($@ =~ /alarm clock reset/);
close(SESSIONLOCK);
unlink $sessionfile;
open(SESSIONLOCK, ">" . $sessionfile);
close(SESSIONLOCK);
&errormessage("File Locked By Another Process");
}
}
sub sessionunlock
{
my($unlock) = shift(@_);
eval
{
local $SIG{ALRM} = sub { die "alarm clock reset" };
alarm $lock{'wait'};
flock SESSIONLOCK, $unlock;
alarm 0;
};
die if (($@) && ($@ !~ /alarm clock reset/));
close(SESSIONLOCK);
}
--
Best Regards,
Benjamin Kyan (bkyan@mindcast.com)
Clickstream Communications (http://www.mindcast.com)
------------------------------
Date: 11 Sep 1997 16:47:23 GMT
From: fina@tahiti.geodyn.psu.edu ()
Subject: Configure syntax error in line 141
Message-Id: <5v97ar$1dk6@r02n01.cac.psu.edu>
------------------------------
Date: 11 Sep 1997 13:16:45 -0400
From: Douglas McNaught <doug@tc.net>
Subject: Re: flock() time
Message-Id: <m27mcnn536.fsf@ono.tc.net>
david@unico.com.au (David Goh) writes:
> Oh, and be *sure* that flock() is being called on a local file. If you
> try to do this on a file available via NFS or some other networked file
> system, it will fail dismally. You need to use fcntl() instead.
This is not necessarily the case--on systems where fcntl() is better
(SYSV derivatives) Perl emulates flock() via fcntl(). It's been this
way since 5.001m or so.
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
Date: Thu, 11 Sep 1997 15:48:52 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Flushing STDOUT?
Message-Id: <EGCp9G.Ev1@world.std.com>
ckc@dmi.min.dk writes:
>This, however, does not work, since print() needs a "\n" to flush the
>output buffer.
(As a side note, print doesn't necessarily flush on a newline. It
depends on the C library that perl was built on, but in all likelyhod,
it will flush on a newline _if_the_output_is_a_terminal_, but when the
output is a file or pipe, it will flush on some larger block size.)
You can change the flushing characteristic of an output channel with
the $| variable or the autoflush method of the FileHandle module. For
either, a boolean true value causes the filehandle to be flushed after
every call to print/printf/write (or any other output call except for
syswrite that I might be missing.) A boolean false value leaves it at
its default.
So either:
$| = 1;
or
STDOUT->autoflush(1);
--
Andrew Langmead
------------------------------
Date: Thu, 11 Sep 1997 13:29:33 -0400
From: "Jeremy L. Mordkoff" <jom@net1plus.com>
Subject: grepping for parens
Message-Id: <34182A7D.1510@net1plus.com>
This seems simple, but it's driving me batty.
I used to use
next if ( $team && ! /\b$team\b/;
to see if the current line contained the team I was interested in when
specified. The problem occurs if $team (and $_) has parens in it. For
instance, if $team is "Merrimac (MA)" and $_ is "10/12:Merrimac
(MA):Peabody", this test apparently passes (i.e /\b$team\b/ is false ).
I thought it was misinterpreting the parens in $team as the text to be
captured in $1, so I added
if ( $team ) {
$team =~ s/\(/\\\(/g;
$team =~ s/\)/\\\)/g;
}
so that "Merrimac (MA)" would become "Merrimac \(MA\)" but this did not
help. Is there a simple way to turn off ()'s in a search?
JLM
--
Jeremy L. Mordkoff
http://www.net1plus.com/users/jom/pictel.htm
------------------------------
Date: 11 Sep 1997 17:53:22 GMT
From: blndhrse@callamer.com (Bud Siebold)
Subject: How to email text file
Message-Id: <5v9b6i$rhb$1@zinger.callamer.com>
Hello!
All I want to do is to open a text file, read it's contents in and email
it to an address that a person had entered on a form.
I think I need an open and close statement and a while loop but all the
possible examples that I've looked at always has a few bells or whistles
extra that I haven't wanted.
Please delete the ** from my address to reply. Anti-spam stuff.
Thanks.
Bud.
--
------------------------------
Date: 11 Sep 1997 18:38:25 GMT
From: twod@not.valid
Subject: Re: How to email text file
Message-Id: <5v9dr1$8hd$2@vnetnews.value.net>
: All I want to do is to open a text file, read it's contents in and email
: it to an address that a person had entered on a form.
: I think I need an open and close statement and a while loop but all the
: possible examples that I've looked at always has a few bells or whistles
: extra that I haven't wanted.
: Please delete the ** from my address to reply. Anti-spam stuff.
There's more than one way to do that (tm) :-
Here is one way that differs slightly from your requirements in that it
just uses the the Unix mailx command to do all the grunt work with the file :-
-- snip --
$text = "mailx -s$subject $recipients < $file 2>&1";
$text = `$text`;
if ($?)
{
die("Mail command had error - $text - $!");
}
-- snip --
Otherwise RTFM ('perldoc perlfunc') and read the section on 'open' paying
particular attention to the section on piping to external processes.
Here's a bare bones example :-
-- snip --
# Get file contents
#
open(FILE, "<$ThisIsMyFileName") || die;
@doc = <FILE>;
close(FILE) || die;
# Open a pipe to the mailer
#
open(PIPE, "| mailx -s'$MailSubject' $EmailRecipients") ||
die "Cannot open a pipe for mailing";
print PIPE @doc;
close(PIPE) || die "Cannot close pipe after mailing";
-- snip --
IAP
--
In an attempt to reduce junk email I use an invalid 'From' address.
My correct email address can be determined by replacing 'not.valid' with with
'value.net'
------------------------------
Date: Thu, 11 Sep 1997 17:29:59 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: how to generate permutations of an array
Message-Id: <5v99qk$9c5@netaxs.com>
You should be able to modify this code to do what you want.
This routine takes a string as input. I didn't write it and
dont't remember where I picked it up.
#!/usr/bin/perl -w
#use strict;
# perms takes a string as input, and returns a list of the possible
# permutations of that input string, treating all characters as
# different. That is, if the input string is n characters long,
# the returned list will have n! elements.
sub perms {
my $input = $_[0];
my $length = length $input;
# Impose an arbitrary limit:
die "Too many elements ($length)\n" if $length > 8;
return $input if $length < 2; # For efficiency
return scalar(reverse $input), $input
if $length == 2; # For more efficiency
my $last; # Each element gets a turn at being last
my $tried = ''; # Elements which have already been last
my @results; # Finished permutations
while ('' ne ($last = chop $input)) {
push @results, map "$last$_",
&perms("$input$tried");
substr($tried,0,0) = $last; # Prepend $last to $tried
}
@results;
}
# scalar reverse is kind of nice here
print map {join('.', unpack('C4', $_)), "\n"}
&perms(scalar reverse pack("C4", split(/\./, "205.164.154.177")));
__END__
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: Thu, 11 Sep 1997 12:54:52 -0400
From: Lorna McLaughlin <L_McLaughlin@fccc.edu>
Subject: Loading modules or subroutines at execution
Message-Id: <3418224E.EF121558@fccc.edu>
Is there a way to not load a module or subroutine within a module until
it is actually needed? This would reduce compile time. Or, is there
anyway to use an if statement to selectively "require" a module only
when needed?
My program has about 10 modules and is a total of about 700k of code.
It compiles each time the program is run, although only certain modules
are used in any one execution. Please e-mail your responses to me at
L_McLaughlin@fccc.edu
Thanks
Lorna
------------------------------
Date: Thu, 11 Sep 1997 14:10:50 -0400
From: Lorna McLaughlin <L_McLaughlin@fccc.edu>
Subject: Loading modules or subroutines at execution
Message-Id: <34183419.DD7F66@fccc.edu>
Is there a way to not load a module or subroutine within a module until
it is actually needed? This would reduce compile time. Or, is there
anyway to use an if statement to selectively "require" a module only
when needed?
My program has about 10 modules and is a total of about 700k of code.
It compiles each time the program is run, although only certain modules
are used in any one execution. Please e-mail your responses to me at
L_McLaughlin@fccc.edu
Thanks
Lorna
------------------------------
Date: Thu, 11 Sep 1997 16:41:50 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: manipulating chars inside strings?
Message-Id: <genepoolEGCrpr.FHM@netcom.com>
Yoav Zach (zachy@nite.org.il) wrote:
: Can anyone tell me how to manipulate single chars inside
: strings, something like 'str[j] = c;' in C?
Check out substr.
------------------------------
Date: Thu, 11 Sep 1997 18:22:06 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: manipulating chars inside strings?
Message-Id: <EGCwCv.1u6@world.std.com>
zachy@nite.org.il (Yoav Zach) writes:
> Can anyone tell me how to manipulate single chars inside
>strings, something like 'str[j] = c;' in C?
If you want things really like C, then split the string between each
character, and join them together when you are done.
@str = split //, $str;
$str[$j] = $c;
$str = join '',@str;
Although you'd have to perfrom more than just one assignment to make
that efficient.
You can also use substr() as an lvalue:
substr($str,$j,1) = $c;
--
Andrew Langmead
------------------------------
Date: Thu, 11 Sep 1997 07:05:45 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl script question for gurus
Message-Id: <pqm8v5.hs.ln@localhost>
Parillo (lparillo@newshost.li.net) wrote:
: Will you have to do a printf in order to get the leading zeros?
: BTW, the perldoc on printf and sprintf is not helpful to non-c
: programmners. Is there a better source (other than deja news?)
The perlfunc man page for 5.004 has a description under sprintf() that
is not in earlier versions:
----------------------------------------
=item sprintf FORMAT, LIST
Returns a string formatted by the usual printf conventions of the
C library function sprintf(). See L<sprintf(3)> or L<printf(3)>
on your system for an explanation of the general principles.
Perl does all of its own sprintf() formatting -- it emulates the C
function sprintf(), but it doesn't use it (except for floating-point
numbers, and even then only the standard modifiers are allowed). As a
result, any non-standard extensions in your local sprintf() are not
available from Perl.
Perl's sprintf() permits the following universally-known conversions:
%% a percent sign
%c a character with the given number
%s a string
%d a signed integer, in decimal
%u an unsigned integer, in decimal
%o an unsigned integer, in octal
%x an unsigned integer, in hexadecimal
%e a floating-point number, in scientific notation
%f a floating-point number, in fixed decimal notation
%g a floating-point number, in %e or %f notation
In addition, Perl permits the following widely-supported conversions:
%X like %x, but using upper-case letters
%E like %e, but using an upper-case "E"
%G like %g, but with an upper-case "E" (if applicable)
%p a pointer (outputs the Perl value's address in hexadecimal)
%n special: *stores* the number of characters output so far
into the next variable in the parameter list
Finally, for backward (and we do mean "backward") compatibility, Perl
permits these unnecessary but widely-supported conversions:
%i a synonym for %d
%D a synonym for %ld
%U a synonym for %lu
%O a synonym for %lo
%F a synonym for %f
Perl permits the following universally-known flags between the C<%>
and the conversion letter:
space prefix positive number with a space
+ prefix positive number with a plus sign
- left-justify within the field
0 use zeros, not spaces, to right-justify
# prefix octal with "0", hex with "0x"
number minimum field width
.number "precision": digits after decimal point for floating-point,
max length for string, minimum length for integer
l interpret integer as C type "long" or "unsigned long"
h interpret integer as C type "short" or "unsigned short"
There is also one Perl-specific flag:
V interpret integer as Perl's standard integer type
Where a number would appear in the flags, an asterisk ("*") may be
used instead, in which case Perl uses the next item in the parameter
list as the given number (that is, as the field width or precision).
If a field width obtained through "*" is negative, it has the same
effect as the '-' flag: left-justification.
If C<use locale> is in effect, the character used for the decimal
point in formatted real numbers is affected by the LC_NUMERIC locale.
See L<perllocale>.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Sep 1997 12:38:25 -0400
From: Tom Fawcett <fawcett@SPAMLESS.nynexst.com>
To: itlm007@dilbert.ucdavis.edu
Subject: Re: Pipes in perl
Message-Id: <8j3enbn6v2.fsf@SPAMLESS.nynexst.com>
itlm007@dilbert.ucdavis.edu (Mark Cervarich) writes:
> I am sending 4 lines of data to an IRR program (iterative rate of return)
> to determine the annualized performance of said stock data. I have
> figured out how to send the data to the pipe, but I don't know how to
> capture it. Here's what I've got
> -----------cut here------------
> [mark@serge]$ more t2
> $data="1/1/97 1000.00\n2/1/97 1000.00\n3/1/97 1000.00\n4/1/97 -3300.00";
> open TEST, "| /home1/mark/tmp/irr/irr";
> print TEST $data;
> close TEST;
> $answer = $?;
> print "answer is [$answer]\n";
>
> [mark@serge]$ perl t2
> 77.786194 % (annualized)
> answer is [0]
> -----------cut here------------
> The answer "77.786194 % (annualized)" is being dumped to STDOUT.
> Arghh.
> I'm sure the answer is real easy--so if you know what I'm doing wrong,
> could you please tell me.
The variable $? holds the command status, which simply indicates whether
the command succeeded. You want the characters from the command output
(STDOUT). You have to do something like this:
use IPC::Open2;
open2(\*OUT, \*IN, "my_program");
print IN $data;
close(IN);
$answer = <OUT>;
-Tom
------------------------------
Date: 11 Sep 1997 13:37:01 -0400
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Please help me with locking! Using NDBM!
Message-Id: <5v9a7t$8m4@stratus.CAM.ORG>
In article <5v8ffo$8cl$1@brie.direct.ca>,
Jason Hazzard <hazzard@usa.net> wrote:
>Hello Perlers,
>
> I am using Tie() with NDBM_File, and I am very confused about locking.
> How can I make sure that the DBM is locked properly? When using a tie, how
>can I make sure it is locked, if another tie() is being tried. Basically, on
>a webpage, if a CGI opens the DBM, and another user runs the same cgi, how can
>I make sure the first is closed, before the other is allowed to run?
>
I had a need for this while implementing my homebrew database. What I ended
up doing is using a "lock file" (just an empty file) on which I need to get
a lock before tie'ing. I use something like:
open(LOCKFILE, ">lockfile");
flock(LOCKFILE, 2);
tie(...);
untie(...);
flock(LOCKFILE, 8);
close(LOCKFILE);
Of course, add some error checking in there before using it...
Hope that helps,
Richard.
--
Richard Bellavance -- charlot@CAM.ORG -- http://www.cam.org/~charlot/
"All along this path I tread / My heart betrays my weary head
With nothing but my love to save / From the cradle to the grave"
(Eric Clapton, "From the cradle")
------------------------------
Date: Thu, 11 Sep 1997 10:26:17 -0700
From: Tony Kay <tonyk@nscedu.com>
Subject: Problems using typeglobs to export arrays
Message-Id: <341829B9.DA22C851@nscedu.com>
Hi,
Can anyone explain the following:
1 package a;
2 @arr = (1,2);
3 *b::arr = *a::arr;
4
5 package b;
6 print "@arr\n";
which gives a compilation error on line 6: "In string, @arr must be
written \@arr", which I don't want to do because I want to see the
SPACE separated VALUE of the array, not a literal @arr.
I am using Perl 5.004_02 on Win NT and 5.003 on Solaris.
I have the same problem on both machines.
Please respond to tonyk@nscedu.com as well as the newsgroup.
- Tony
------------------------------
Date: 11 Sep 1997 13:08:21 -0400
From: Douglas McNaught <doug@tc.net>
To: David Buttrick <buttrick@sportingnews.com>
Subject: Re: Q: Building Perl as shared object?
Message-Id: <m2afhjn5h6.fsf@ono.tc.net>
[mailed and posted]
David Buttrick <buttrick@sportingnews.com> writes:
> I have a situation in which our server spawns sometimes as many as 30
> Perl programs which might remain idle for hours.
>
> We run an SGI Origin, with IRIX 6.4, and I am interested in building the
> PERL binary such that one copy of the interpreter is residnet and shared
> among multiple processes or scripts that are using it.
>
> Is this what dynamic loading is, and is done by default, so I dont have
> to worry?
>
> Is this possible? Has anyone done it?
Even without dynamic loading, this will be the case. Unix handles
running multiple copies of a binary (in this case, the Perl
interpreter) by putting the executable code (called 'text' by Unix
types) into sharable, read-only memory pages. You don't have to do
anything special.
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
Date: Thu, 11 Sep 1997 14:36:45 -0400
From: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: redirect output of system function
Message-Id: <34183A3D.741F@daytonoh.ncr.com>
I am doing the following on a WINDOW95 box in an attempt to redirect
the output of a command executed via a system call.
$cmd = "progname parm1 parm2 >outfile";
system($cmd);
I get a "File creation error" message
I have also tried the following
system "progname","parm1","parm1",">outfile";
and I get the same thing
Anybody have an answer as to why I get the error message.
I can execute the command from the DOS prompt with no problem.
------------------------------
Date: Thu, 11 Sep 1997 18:38:01 GMT
From: alex@gossamer-threads.com (Alex Krohn)
Subject: reg expression help!
Message-Id: <3418386b.172810570@news.supernews.com>
I'm having some problems with reg expression and variable
substitution. Here's what I have so far:
$search = "\\Qtest\\E";
$match = ($values[$field] =~ /$search/);
won't produce a match, yet
$match = ($values[$field] =~ /\Qtest\E/);
will! I was under the impression that $search would be expanded to
'\Qtest\E' and the \Q and \E would be interpreted properly (as meaning
quote whatever is in between).
Any clues/help on what I'm doing wrong?
Thanks!
------------------------------
Date: Thu, 11 Sep 1997 10:40:08 -0700
From: Gip <nospam.gibsonc@aztec.asu.edu>
Subject: Returning Hashes from Sub (newbie question)
Message-Id: <34182CF8.7CE3A4E0@aztec.asu.edu>
What's the right way for returning hashes for subroutines? I believe I
need to reference the hashes with the ref operator "\", but I'm new to
that...The following does NOT work, as big contains both hashA and
hashB.
:
my(%big, %small);
(%big, %small) = &a();
:
sub a {
my(hash);
$hashA{...} = ...;
$hashB{...} = ...;
%hashA, %hashB;
}
------------------------------
Date: 11 Sep 1997 18:19:17 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: Returning Hashes from Sub (newbie question)
Message-Id: <5v9cn5$3qj$1@dismay.ucs.indiana.edu>
In article <34182CF8.7CE3A4E0@aztec.asu.edu>,
Gip <nospam.gibsonc@aztec.asu.edu> writes:
>What's the right way for returning hashes for subroutines? I believe I
>need to reference the hashes with the ref operator "\", but I'm new to
>that...The following does NOT work, as big contains both hashA and
>hashB.
>
> :
>
> my(%big, %small);
>
> (%big, %small) = &a();
>
> :
>
>sub a {
>
> my(hash);
> $hashA{...} = ...;
> $hashB{...} = ...;
>
> %hashA, %hashB;
>
>}
>
>
>
Things which are passed to/from subs are converted to a list. To
return two distinct hashes, you're going to have to return them as references
to hashes.
($big_ref,$small_ref)=&A();
%big=%$big_ref;
%small=%$small_ref;
sub A {
my(%hashA,%hashB);
$hashA{...}=...;
$hashB{...}=...;
return (\%hashA,\%hashB);
}
Hope this helps!
--
Brian Wheeler
bdwheele@indiana.edu
------------------------------
Date: 11 Sep 1997 12:35:51 -0500
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: shell command "more"
Message-Id: <5v9a5n$995$1@Starbase.NeoSoft.COM>
Just a thought, could you do something like
open (FILEHANDLE, "|xterm -e more ")?
Will
In article <34173F69.7FB1@cello.hp.hpl.com>,
Marty O'Brien <mobrien@cello.hp.hpl.com> wrote:
>Lorenzo Pesce wrote:
>>
>> I have a question about how to send the output through
>> more | less |whatever a pager is.
>>
>> I know how to:
>> open (FILEHANDLE,"|more ...)
>>
>> but I'd like:
>> open (FILEHANDLE,"|xterm ....)
>> ^^^^^
>> Because I'd like to send the report to an xterm.
>> Hope it's not a faq.
>>
>> thanks in advance,
>> lrnz
>
>Well, there's always
>
> open(FILEHANDLE,">foo");
> print FILEHANDLE @report;
> close FILEHANDLE;
> system "xterm -e more foo";
>
>I don't think xterm has does any (useful) processing
>of standard input.
>
>If you need to display the report at the same time
>you're generating it, maybe there's some funky
>mknod(1) thing you can do. (See the part in the FAQ
>about determining if there's a character waiting to
>be read on a file handle)
>
>That's about the limit of my expertise, but I hope
>it helped.
>
>Marty O'Brien
>HP Labs-Palo Alto
--
# Copyright 1997 Will Morse. Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
#
# Gravity, # Will Morse
# not just a good idea, # Houston, Texas
# it's the law. # will@starbase.neosoft.com
#
# These are my views and do not necessarly reflect anyone else/
=========================================================================
By US Code Title 47, Sec.227(a)(2)(B), a computer/modem/printer
meets the definition of a telephone fax machine. By Sec.227(b)
(1)(C), it is unlawful to send any unsolicited advertisement to
such equipment, punishable by action to recover actual monetary
loss, or $500, whichever is greater, for EACH violation.
=========================================================================
------------------------------
Date: 11 Sep 1997 19:07:16 GMT
From: fina@tahiti.geodyn.psu.edu ()
Subject: Syntax Error Configure
Message-Id: <5v9832$1dk6@r02n01.cac.psu.edu>
I am having problems running sh Configure on my AIX network.
I am currently trying to up install Perl5.004_01 on my machine.
Unfortunately, when run sh Configure runs though some of the file and comes
back with an error.
Syntax error line 141 ')' not expected.
AIX version is 4.1.2. Please e-mail me if there is a solution to my problem.
Greg Fina
fina@geodyn.psu.edu
System Admin
------------------------------
Date: 11 Sep 1997 15:54:39 GMT
From: "Richard Draper" <support@holt.ie>
Subject: Timeout
Message-Id: <01bcbeca$13ae6a00$0201a8c0@richie.my.domain>
Hi,
I have a PERL script which reads a text file and updates a Postgres
database based on the data from the text file. Simple so far. The problem
is that when this script is run from a HTML page and used to update a
database of hundreds of thousands of records. Understandably this process
will take some time, the problem is that the browser times out thinking
that the server is gone down (through lack of response). How could I output
an intermediate page, say every minute or so. I tried outputting a page
every minute but nothing gets output until the program finishes.
Any suggestions would be greatly appreciated
Thanks
Richie
rdraper@tinet.ie
------------------------------
Date: 11 Sep 1997 16:42:36 GMT
From: fina@tahiti.geodyn.psu.edu ()
Subject: Re: Um... a bug?
Message-Id: <5v971s$1eou@r02n01.cac.psu.edu>
Antti Rauramo (arauramo@alpha.hut.fi) wrote:
: Hello.
: As far as I can see, the following program displays a very
: obvious bug in Perl. Tell me if I'm wrong.
: Works (doesn't work, that is to say) at least with Perl
: versions 5.004_01 and 5.003 in SunOS 5.5 and OSF1 v4.0.
: --- 8< --- clipety clap --- 8< ---
: #!/usr/local/bin/perl
: for($i=1;$i<7;$i+=0.1){
: print "$i\t".int($i)."\n";
: }
: --- 8< --- clipety clap --- 8< ---
: Antti Rauramo | In a Rhodes tailor shop: Order your summers suit. Because
: arauramo@ | is big rush we will execute customers in strict rotation.
: cc.hut.fi |
: 0422 - 326 311|
------------------------------
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 1012
**************************************