[7630] in Perl-Users-Digest
Perl-Users Digest, Issue: 1256 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 31 17:07:18 1997
Date: Fri, 31 Oct 97 14:00:21 -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 Fri, 31 Oct 1997 Volume: 8 Number: 1256
Today's topics:
Re: =?iso-8859-1?Q?=A7A=A4=A3=A5i=A4=A3=AA=BE=AA=BA=B0= (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: ANNOUNCE: IndexMaker 2.0: an index.html maker from (Malcolm Reeves)
Re: ANNOUNCE: IndexMaker 2.0: an index.html maker from (I R A Aggie)
Comm.pl good on Linux, bad on HP-UX (Thomas Glen Smith)
Re: Fastest way to call a method or subroutine? (M.J.T. Guy)
Re: if (0<= $hun < 250) doesn't compile (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: if (0<= $hun < 250) doesn't compile (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: multi-line text replacement <usenet-tag@qz.little-neck.ny.us>
Re: multi-line text replacement (Tad McClellan)
Re: multi-line text replacement (Bill Moseley)
newbie .exe question/NT server (Imtsinc)
Re: PDF <camerond@mail.uca.edu>
Perl 5.003? Anybody got the tar.gz? <bgannon@purdue.edu>
Perl 5.003? Anybody got the tar.gz? <bgannon@purdue.edu>
Perl Format Command <gnew@southernvirginia.edu>
perl under win32 <napos@psg.sk>
Perl's Gurus <ray@icix.net>
Reading from bottom, or writing to top of file (COWBYS)
Regex: finding the n'th pattern in a string. Global mat gtuckerkellogg@genetics.com
Re: stdin/stdout pipes to a program (Tad McClellan)
Which builtins can be overridden? (Adrian Hosey)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 31 Oct 97 16:13:44 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: =?iso-8859-1?Q?=A7A=A4=A3=A5i=A4=A3=AA=BE=AA=BA=B0=B7=B1d=AA=BE=C3=D1?=
Message-Id: <345a4a36$6$ofn$mr2ice@speaker>
In <3463a6ae.342922987@elf.bri.hp.com>, on 10/31/97 at 09:38 AM,
keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis) said:
+-----
| > %;$e:K&[$K$Q$;&~$K$k$T$Q$@$iAp&X1_3x2D"6*)!y071d$H!z=g
| > $p$@BI 5u$@BI 7S<K0m.<
| That's easy for _you_ to say...
+--->8
Probably was, too... looks suspiciously like a DBCS character set (and I
noticed the sender's .tw domain).
--
brandon s. allbery [Team OS/2][Linux] bsa@void.apk.net
cleveland, ohio mr/2 ice's "rfc guru" :-) KF8NH
Memo to MLS: End The Burn Scam --- Doug Logan MUST GO! FORZA CREW!
------------------------------
Date: Fri, 31 Oct 1997 18:03:51 GMT
From: mreeves@dial.pipex.com (Malcolm Reeves)
Subject: Re: ANNOUNCE: IndexMaker 2.0: an index.html maker from PDF, HTML and other files
Message-Id: <3459e5c8.17667511@news.dial.pipex.com>
On Wed, 29 Oct 1997 10:52:16 +0000, Fabrizio Pivari
<pivari@geocities.com> wrote:
>I'm glad to announce the version 2.0 of IndexMaker a perl script to make
>an index.html file from PDF, HTML and other files.
>Send me your suggestions.
Sounds useful - but I can't run perl on my PC AFAIK. How about it as
a windows program so I can index all the pdf files I've downloaded
with odd file names :-).
...malcolm
-- Malcolm Reeves MIRSE AMIEE (mreeves@dial.pipex.com) Chippenham, UK
-- Full Circuit Ltd - Design Service for Analogue/Digital H/W & S/W
-- Railway Signalling and Power electronics. For more details and
-- Win95 DUN & Pspice tips, see:
-- http://dspace.dial.pipex.com/mreeves/
------------------------------
Date: Fri, 31 Oct 1997 15:07:33 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: ANNOUNCE: IndexMaker 2.0: an index.html maker from PDF, HTML and other files
Message-Id: <-3110971507330001@aggie.coaps.fsu.edu>
In article <3459e5c8.17667511@news.dial.pipex.com>, mreeves@dial.pipex.com
(Malcolm Reeves) wrote:
+ Sounds useful - but I can't run perl on my PC AFAIK.
Not true. <url:http://www.perl.com/> and look for "alien ports".
James - alien == non-unix, in this case... :)
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 31 Oct 1997 19:35:50 GMT
From: smitty@kcc.com (Thomas Glen Smith)
Subject: Comm.pl good on Linux, bad on HP-UX
Message-Id: <63dbum$6av@gatekeep.kcc.com>
Keywords: Comm.pl
I built the attached script on my Linux host, where it works great.
But I copied it to one of our HP-UX 10.20 systems, and it fails there
with these messages:
$ gpasswd -V oldpswd newpswd cronus
cronus is pingable
Trying for file handle on cronus
getpty_svr4: stat(Comm'PTY)=(1073741827,5133,8630,1,0,0,
-1677721594,0,877622835,
878050356,878050356,,), 6=-1677721594
ptsname not found, using Solaris minor numbers
rdev=-1677721594
slave=/dev/pts/6, ptsname(3)=/dev/pts/6
system (pt_chmod 3)
could not open slave, /dev/pts/6, errno=Permission denied
at /opt/perl5/lib/Comm.pl line 1342.
I'm using perl 5.00401 on both Linux and HP-UX 10.20, and
Comm.pl-1.8.tar.gz. Here's a listing of gpasswd, which you're free
to copy, if you'd find it useful:
#!/usr/bin/perl
# ------------------------------------------------------------------------
# Changelog
# 971027 Created by Smitty.
# --------------------------------------------------------------------------
# Description:
#
# [hostnames | \]
# gpasswd [-v] <old password> <new password> [<hostname1> <hostname2>...]
#
# -v is for verbose messages. If you use -V, Comm.pl will also be told to
# be verbose. Without -v, gpasswd will only list those hosts it
# failed to changes passwords on.
# <hostname1> <hostname2>... is optional. It's the list of hosts on which
# passwords are to be changes. If no hosts are listed, gpasswd expects
# a list to be on STDIN.
#
# Used to globally change your unix login passwords. You must supply the old
# and new passwords as arguments, and the list of hosts on which to change
# passwords, either on the command line, or on STDIN. This command will
# rlogin to each host, issue the passwd command, and supply the old and new
# passwords, then logout(exit).
# -----------------------------------------------------------------------
require "Comm.pl";
&Comm::init( 1.8 );
$|=1; # No buffering of STDOUT.
# -------------------------------------------------------------------------
# Subroutines.
sub sr() {
# -------------------------------------------------------------------------
# Description: $rc=&sr($send,@responses);
# If $send isn't a null string, sends it on $pty. Then it waits for a
# response. Returns 1 if a response is matched, 0 otherwise.
# -------------------------------------------------------------------------
local($send,@responses)=@_;
print $pty "$send\n" if ($send ne "");
( $match, $err, $before, $after ) =
&expect( $pty, $seconds, @responses);
return(0) if ( ! defined $match );
print("Got $match\n") if($debug);
return(1);
} # End sr.
-------------------------------------------------------------------------
# Mainline.
$os=`uname -s`; chop($os);
if ($os eq "Linux") {
$ping="ping -c 1 ";
$pingaft="";
} else {
$ping="/etc/ping ";
$pingaft=" 64 1";
}
$nis_master="helios";
$seconds||=10; # seconds to wait before timeout.
$prompt='\$ $';
@tmp = split(":",$ENV{"DISPLAY"}); # Can't feed split to shift;
$display = shift(@tmp); # get the part to the left of the colon(:).
$ENV{"TERM"}="vt100:$display";
%rlogin=(); # Indicates which hosts got successful rlogins.
%prompt=(); # Indicates which hosts got a shell prompt.
%nis=(); # Indicates which hosts are NIS but not the master.
%passwd=(); # Indicates which hosts got a successful passwd change.
LOOP: while($arg = shift) { # Process the command arguments.
last if (substr($arg,0,1) ne "-");
if (length($arg) > 2) { # Do only one option at a time.
$narg="-".substr($arg,2);
unshift(@ARGV,$narg);
$arg = substr($arg,0,2);
}
SWITCH: {
if ($arg eq "-v" || $arg eq "-V") {
$debug=1;
$Debug=$debug if ($arg eq "-V") ; # Tell Comm.pl.
last SWITCH;
}
die("Unknown parameter = $arg\n");
} # End SWITCH.
} # End LOOP.
$old = $arg;
$new = shift;
die("You must suppy the old and new passwords.\n")
if (!defined($old) || !defined($new));
@hostnames=@ARGV; # List of hosts on which passwords are to be changed.
@ARGV=(); # Empty out argument list.
if (0 == scalar(@hostnames)) {
while (<>) { # Get any hosts listed on STDIN.
chop;
push(@hostnames,$_); # Add hostname to list.
}
}
foreach $host (@hostnames) {
$rlogin{$host}=0; # Add hostname to keys.
next unless (`$ping $host $pingaft` =~ / 0% packet loss/);
print("$host is pingable\n") if ($debug);
print("Trying for file handle on $host\n") if ($debug);
( $pty, $tty, $pid ) = &open_proc( "rlogin $host");
next unless ($rlogin{$host}=defined($pty));
print("Got file handle for login process on $host\n") if ($debug);
BLOCK: { # Lets me use last/next.
last if ( ! &sr("", $prompt, "DISPLAY:", "Password:"));
if ($match eq "Password:") {
last if ( ! &sr($old, $prompt, "login:"));
if ($match eq "login:") {
print("Password invalid on $host\n")
if ($debug);
last;
}
}
if ($match eq "DISPLAY:") {
print $pty "\n";
last if ( ! &sr("",
"not ping-able. Try another",
$prompt));
if ($match eq "not ping-able. Try another") {
last if ( ! &sr("n", $prompt));
}
}
print("Got shell prompt on $host\n") if($debug);
$prompt{$host}=1;
if (&sr("nistest","yes")) { # Host uses NIS.
$nis{$host}=1;
print("$host uses NIS\n") if ($debug);
if ($host ne $nis_master) {
print("Password should only be changed on ".
$nis_master."\n") if ($debug);
last;
}
$cmd="yppasswd";
$confirm="The NIS passwd has been changed";
} else {
$cmd="passwd";
$confirm=$prompt;
}
$new_prompt="New password:"; # Same for both.
last if ( ! &sr($cmd, "Old password:", "Old NIS password:"));
last if ( ! &sr($old, $new_prompt,
"Your entry does not match the old password.",
"Sorry."));
last if ($match ne $new_prompt);
last if ( ! &sr($new,
"Re-enter new password:",
"Retype new password:",
"Enter the new password again:"));
last if ( ! &sr($new, $confirm, $prompt));
if ($match !~ $confirm) {
print("$before\n") if($debug);
last;
}
print("Password changed on $host\n") if($debug);
$passwd{$host}=1;
last if ( ! &sr("exit", "rlogin: connection closed."));
print("Got logged out of $host OK\n") if($debug);
} # End BLOCK
if ($debug && !defined($match)) {
print("before=$before\n");
print("match=$match\n");
print("after=$after\n");
print("err=$err\n");
}
if (defined($pty)) {
print("Closing file handle\n") if($debug);
&close_it($pty);
}
}
if ($debug) {
foreach $host (sort keys(%rlogin)) {
if(!$rlogin{$host}) {
print("Failed to rlogin to $host\n")
} else {
print("Failed to get a shell prompt on $host\n")
if(!$prompt{$host});
}
}
}
$rc=0;
foreach $host (sort keys(%rlogin)) {
next if ($passwd{$host}); # Password was changed ok.
next if ($nis{$host} && $passwd{$nis_master}); # NIS master changed.
$rc=1; # At least one password failed to be changed.
print("Failed to change the password on $host\n")
}
print("Finis.\n") if($debug);
exit($rc);
------------------------------
Date: 31 Oct 1997 18:51:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Fastest way to call a method or subroutine?
Message-Id: <63d9bn$60v$1@lyra.csx.cam.ac.uk>
Toutatis <toutatis@_SPAMTRAP_toutatis.net> wrote:
>What is the fastest way (run time, not compile time) to call a method or
>subroutine, in particular, if this call is made *from whithin* the same
>package?
>
>Package::method();
>method();
>Package->method();
>$object->method();
>
>I'm not only interested in what is the fastest, but also *why*.
This doesn't answer your question, but the way to get the answer is to
use Benchmark.pm. And to get the reason why, read the source.
But my guesses, without bothering to check the source or run Benchmark:
>Package::method();
>method();
I'd expect these two to be identical, since filling in the default
Package:: is done at compile time.
>Package->method();
>$object->method();
The second is equivalent to ref($object)->method(); so I'd expect it to
be very slightly slower in having to evaluate the package rather than
having a constant, but the effect will be tiny compared with the costs
of the call.
And the method calls will have a slight overhead compared with subroutine
calls since they have to check the method cache etc. But again the
effect is probably too small to measure.
If you are designing your class to be inheritable, as perltoot
recommends, the decision between subroutine or method should be taken on
the basis of the desired semantics. One of the two will be right and
the other will be wrong in each particular case.
Mike Guy
------------------------------
Date: Fri, 31 Oct 97 16:04:35 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: if (0<= $hun < 250) doesn't compile
Message-Id: <345a48f2$4$ofn$mr2ice@speaker>
In <3458E336.167E@slac.stanford.edu>, on 10/30/97 at 11:42 AM,
"l. trindle gennari" <gennari@slac.stanford.edu> said:
+-----
| I have a section of a script that's giving me the blues. Here 'tis:
| if (0 <= $hun < 250) {
+--->8
Off the top of my head, the only computer language I can think of that accepts
that syntax is Icon... and there it's only possible because there's a
distinctive out-of-band return value that short-circuits expression evaluation
(&fail).
(Aside --- I'd love to see generators, co-expressions, and &fail in Perl:
Icon is nice, but too limited.)
--
brandon s. allbery [Team OS/2][Linux] bsa@void.apk.net
cleveland, ohio mr/2 ice's "rfc guru" :-) KF8NH
Memo to MLS: End The Burn Scam --- Doug Logan MUST GO! FORZA CREW!
------------------------------
Date: Fri, 31 Oct 97 16:09:31 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: if (0<= $hun < 250) doesn't compile
Message-Id: <345a49bd$5$ofn$mr2ice@speaker>
In <t0yvhyeas4u.fsf@cs.man.ac.uk>, on 10/31/97 at 03:06 PM,
Anthony Bailey <baileya@cs.man.ac.uk> said:
+-----
| > there's no compelling reason for a modern
| > programming language _not_ to support them.
| And since Perl currently gives an error message for such syntax, and so the
| extension shouldn't cause old code to break, is it possibly worth
| considering adding multiple comparisons to Perl?
+--->8
Suggest a mechanism --- preferably one that doesn't require massive parser or
recognizer calisthenics. The only one I'm aware of is that Icon has
comparison operators either fail or return their right argument, so with (0 <=
$hun < 250) either (0 <= $hun) fails and the rest of the expression isn't
executed, or it returns $hun and ($hun < 250) is evaluated.
--
brandon s. allbery [Team OS/2][Linux] bsa@void.apk.net
cleveland, ohio mr/2 ice's "rfc guru" :-) KF8NH
Memo to MLS: End The Burn Scam --- Doug Logan MUST GO! FORZA CREW!
------------------------------
Date: 31 Oct 1997 17:54:57 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: multi-line text replacement
Message-Id: <eli$9710311233@qz.little-neck.ny.us>
Posted and mailed.
Bill Moseley <moseley@netcom.com> wrote:
> There must be a bunch of ways to do this, but I'm wondering what is a good
> (or common) way to replace a block of text in a text file with another block
> of text.
$/=undef; # whole file slurp mode
open(IN,"<$yourfile") || die "Bummer, bad example -- $!\n";
$_=<IN>;
> All I know about the block is that is starts and ends with unique strings,
> but I'm not sure where on the line these unique strings start (may be at the
> start of the line, maybe indented with white space, or may follow other
> text). There may be a number of newlines within the block of text, too.
s/STARTSTRING.*ENDSTRING/replace string/s; # /s so that . matches \n
or
s/[^\n]*STARTSTRING.*ENDSTRING[^\n]*/replace string/s; # replace whole lines
> Should I slurp the entire file into one long scalar and use s// or read
> line-by-line and substr the beginning and ending lines with the unique
> strings and then zap all lines inbetween? This just seems like a common
> task, and there must be an elegant way to do this.
There are many ways to do it; elegant will vary with your goals. It
really helps to know more about the task at hand to advise which is
best. If you are dealing with files that are a goodly percentage of
physical memory don't slurp the whole thing in but use some sort of
state machine.
Elijah
------
perl -e 's Y Yreverse q N ny pm ,srekcah lrep kroy wen emosNYex and s Pmp ynP
P and s MsMjust sMx and print and s NYPM MPYN Nis or reverse and print q q q'
------------------------------
Date: Fri, 31 Oct 1997 11:27:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: multi-line text replacement
Message-Id: <6e4d36.d2h.ln@localhost>
Bill Moseley (moseley@netcom.com) wrote:
: There must be a bunch of ways to do this, but I'm wondering what is a good
: (or common) way to replace a block of text in a text file with another block of
: text.
: All I know about the block is that is starts and ends with unique strings, but
: I'm not sure where on the line these unique strings start (may be at the start
: of the line, maybe indented with white space, or may follow other text). There
: may be a number of newlines within the block of text, too.
: Should I slurp the entire file into one long scalar and use s// or read
: line-by-line and substr the beginning and ending lines with the unique strings
: and then zap all lines inbetween? This just seems like a common task, and
: there must be an elegant way to do this.
There are two elegant ways to do that.
The two ways you described ;-)
I generally go with slurping unless the files are truly large.
You might also be able to use the 'Range Operator' as described in
the perlop man page.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Oct 1997 19:46:37 GMT
From: moseley@netcom.com (Bill Moseley)
Subject: Re: multi-line text replacement
Message-Id: <63dcit$d59$1@nnrp4.snfc21.pbi.net>
Ah, thanks for the help. The "s" option is what I needed.
I guess that I need to get a new Camel book. Mine doesn't have the "s" option
listed.
Thanks!
In article <eli$9710311233@qz.little-neck.ny.us>,
usenet-tag@qz.little-neck.ny.us says...
>s/STARTSTRING.*ENDSTRING/replace string/s; # /s so that . matches \n
--
Bill Moseley
mailto:moseley@netcom.com
------------------------------
Date: 31 Oct 1997 21:38:58 GMT
From: imtsinc@aol.com (Imtsinc)
Subject: newbie .exe question/NT server
Message-Id: <19971031213801.QAA04714@ladder02.news.aol.com>
I can't seem to get perl to run an exe.
I'm running an NT server. The call from perl seems correct. But the exe never
executes. I think it has to do with mapping an extension on NT.
Can anyone help setup the NT server correctly?
Please send responses to davidb@imts-inc.com.
Thanks,
David Burton
------------------------------
Date: Fri, 31 Oct 1997 13:39:06 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: PDF
Message-Id: <345A33DA.7A421557@mail.uca.edu>
Michael Stearns wrote:
>
> You might want to check out:
> http://www.mincom.com/mtr/sdf/
>
> This is written in PERL, and if it can do what it advertises, which
> includes outputting to PDF, it is quite powerful.
>
> I have not used this package myself, but it looks interesting.
>
> Michael Stearns
>
> Charles Thayer wrote:
> >
> > Any PDF generators or readers in Perl around? /charles
Well, it looks like an interesting package, but it does not write PDF
files. According to the web page, it can write RTF files, which can be
used as input to MS Word (or WPerfect, or certainly others), and then
MSW can output to a PDF file, if the user has Adobe Acrobat (_not_
Acrobat Reader, which is freeware from Adobe). Acrobat is used (on Win
systems, anyway) as a printer driver for word processors, or can
translate postscript files to PDF (through Distiller).
Cameron
camerond@mail.uca.edu
------------------------------
Date: Fri, 31 Oct 1997 13:45:23 -0500
From: brian <bgannon@purdue.edu>
Subject: Perl 5.003? Anybody got the tar.gz?
Message-Id: <345A2741.E8C33381@purdue.edu>
I have a program that needs Perl 5.003.. I tried it with 5.004_01 with
no avail..
(even tried 5.004_04) anyway...
Does anyone out there have the main tar.gz for perl 5.003?? If so..
please email me (brian@gannon.com)
Thanks a lot,
Brian Gannon
------------------------------
Date: Fri, 31 Oct 1997 13:46:19 -0500
From: brian <bgannon@purdue.edu>
Subject: Perl 5.003? Anybody got the tar.gz?
Message-Id: <345A277A.A2D7C9C3@gannon.com>
I have a program that needs Perl 5.003.. I tried it with 5.004_01 with
no avail..
(even tried 5.004_04) anyway...
Does anyone out there have the main tar.gz for perl 5.003?? If so..
please email me (brian@gannon.com)
Thanks a lot,
Brian Gannon
------------------------------
Date: Fri, 31 Oct 1997 15:40:03 -0500
From: "Gary C. New" <gnew@southernvirginia.edu>
Subject: Perl Format Command
Message-Id: <345A4223.10AC@southernvirginia.edu>
I've looked and looked and looked for examples and faq's for perl's
format command (I have a perl manuel). I still don't completely
understand how to implament it especially with regards to cgi and
printing to MAIL file handle.
Can anyone direct me to an indepth review of the format command and how
to get the output to remain the same after sending it through MAIL.
gnew@southernvirginia.edu
------------------------------
Date: Fri, 31 Oct 1997 20:17:29 +0100
From: "Dobias" <napos@psg.sk>
Subject: perl under win32
Message-Id: <63dhus$d6b$1@news.psg.sk>
How can I compile under win32 perl scripts?
------------------------------
Date: Fri, 31 Oct 1997 16:49:26 -0500
From: Ramon Castillo <ray@icix.net>
Subject: Perl's Gurus
Message-Id: <345A5266.51D@icix.net>
Sorry for the double post but the reply email address it was wrong.
I wrote a Perl Script that takes a Config. file and declares constants
to any other caller script, it works very well so far, but I wondering
is is there a more efficient way.
Plataform Perl 5.000_01 Solaris 2.5
---------------------------------------------------
file name = config
content :
#######################################
#
# here goes any yada yada bla bla bla
#
######################################
foo: (anyvalue);
####notice the next is a multiline sentence
hash: (joe,
bill,
you,
and,
me);
---------------------------------------------------
sript name : parseconfig
#!/usr/local/bin/perl
{
open (CONFIG, "config") || die"Can't open Config. file: $!";
while (<CONFIG>){
next if (/^#/ || /^\s*$/ ) ;
chop ;
s/^\s+//g;
s/\s+$//g;
$strip = $strip.$_ ;
}
@strip = split (/;/, $strip);
foreach $line (@strip) {
$line =~ /^([^ ]*): * \(([^ ].*?)\)/;
@{$1} = split (/,/, $2);
if (!$#{$1}) {${$1} = $2};
}
};1
--------------------------------------------------------
Any caller script:
#/usr/loac/bin/perl
require "parseconfig";
print "$foo\n"; ####notice returns a scalar context also
print ("@hash","\n"); ### notice in this case returns a hash
------------------------------------------------------------------
running caller this is the result
>./caller
>anyvalue
>joebillyouandme
It works pretty good for me.
Have a nice hacking..
--
#!/usr/local/bin/perl
use Heart::WithBrain;
while ($god->bless == $Internet && $Perl == $Cool){
$Be = "Happy";
$Live = "Love";
$Hack = "Fun";
} # RC ray@icix.net
------------------------------
Date: 31 Oct 1997 19:59:12 GMT
From: cowbys@aol.com (COWBYS)
Subject: Reading from bottom, or writing to top of file
Message-Id: <19971031195901.OAA25731@ladder02.news.aol.com>
I have a form which outputs one line records, (followed by a newline), to a
text file each time the form is submitted
(the file is appended using ">>" with the file handle).
What I am doing is reading thru this file later (using seek and read), and
producing an HTML table
which consists of one row of info for each one line record.
Obviously, doing it the way I am, I write to the bottom of the file (append it)
each time I write a new record to it, and I read the file starting from the
top. My problem is that because i am reading from the top of the file, the
most recent entries from the form that have been appended to this file, are at
the bottom, and therefore information is displayed in my HTML table as oldest
data first (from the top).
I want to be able to display the newest data in the file first, either by
reading from the bottom of my text file up ( not from the end of the file,
using seek, but from the beginning of the last record).
or, if possible, i would prefer the following:
when I output my records to my text file, i want to be able to write the newest
records to the top of the file, so when I read it later, the newest records
are at the top of the page. I tried using "+<" with my file handle instead,
but it works once, writing to the top of the file, and then the second time i
sbmit a form, it relaces the first line that it wrote previously....
any advice appreciated.... TIA DCF (cowbys@aol.com)
------------------------------
Date: Fri, 31 Oct 1997 13:35:33 -0600
From: gtuckerkellogg@genetics.com
Subject: Regex: finding the n'th pattern in a string. Global matching using while and foreach
Message-Id: <878325690.31125@dejanews.com>
My quandry boils down to this: under what circumstances should the first
block shown below succeed and the second block fail?
!/usr2/local/bin/perl -w
$| = 1 ;
use strict;
use CGI qw(:all);
my $lookfor = "xx::^:xxx:x::xx::xx:";
{
my $target = $lookfor;
my $count = 0;
while ($target =~ m/[:xv]/g) {
$count++;
last if $count > 9;
}
print pre($target,"Position is ", pos $target),"\n";
}
{
my $target = $lookfor;
foreach (1..10) { $target =~ m/[:xv]/g; }
print pre($target,"Position is ", pos $target),"\n";
}
__END__
In the script above, both the foreach and the while loops behave, that
is, the program prints:
<PRE>xx::^:xxx:x::xx::xx: Position is 11</PRE>
<PRE>xx::^:xxx:x::xx::xx: Position is 11</PRE>
but
when I paste the *exact* code into a CGI script, I get output like:
<PRE>::x::::x::^x::^^^^:::x:xx Position is 10</PRE>
<PRE>::x::::x::^x::^^^^:::x:xx Position is </PRE>
<PRE>:x::::x::^x::^^^^:::x:xx: Position is 11</PRE>
<PRE>:x::::x::^x::^^^^:::x:xx: Position is </PRE>
<PRE>x::::x::^x::^^^^:::x:xx:: Position is 11</PRE>
<PRE>x::::x::^x::^^^^:::x:xx:: Position is </PRE>
, that is, the foreach loop fails to succeed in the match. In addition,
I'm getting errors of the type
"Use of uninitialized value at (eval 22) line 18."
but line 18 is just "$| = 1".
Any thoughts? What could cause this foreach loop to fail?
Thanks,
Greg
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 31 Oct 1997 07:14:46 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: stdin/stdout pipes to a program
Message-Id: <6klc36.dn.ln@localhost>
brian d foy (comdog@computerdog.com) wrote:
: In article <63b5s3$r7c$1@sloth.swcp.com>, aaron@swcp.com (Aaron Birenboim) wrote:
: >I would like to have a perl program have a "conversation" with a program
: >that uses interractive text questions & responses. (All keyboard
: >and text output interface)
: >
: >What would be the easiest way to do this in perl?
: >(like open(IN,OUT,"|myProgram|") or something.
: the FAQ suggests IPC::Open3
^^^^^^^
That would be Perl FAQ, part 8:
"How can I open a pipe both to and from a command?"
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Oct 1997 15:36:17 -0500
From: ahosey@sherrill.kiva.net (Adrian Hosey)
Subject: Which builtins can be overridden?
Message-Id: <63dfg1$ckn$1@sherrill.kiva.net>
"man perlsub" (and the Camel book) say:
Many builtin functions may be overridden, though this
should be tried only occasionally and for good reason.
Now, using a 'use subs' pragma as described in that same section, we've
found that print and printf cannot be overridden, while chmod and chdir
can. What is the underlying factor that determines which functions may or
may not be overridden this way?
Thanks,
- A
--
"Of course 5 years from now that will be different, but 5 years from
now everyone will be running free GNU on their 200 MIPS, 64M
SPARCstation-5." - Andrew Tannenbaum, 1992
------------------------------
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 1256
**************************************