[10437] in Perl-Users-Digest
Perl-Users Digest, Issue: 4030 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 21 09:03:34 1998
Date: Wed, 21 Oct 98 06:00:24 -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 Wed, 21 Oct 1998 Volume: 8 Number: 4030
Today's topics:
$0 does not contain script name <jurgen@pallas.tid.es>
Re: -Help Please-: Efficiency of substr vs. join for st (David Alan Black)
Re: -Help Please-: Efficiency of substr vs. join for st (David Alan Black)
Re: Amputated Perl Code <ewinter@pop3.stx.com>
Re: Camel book: References. (Michael J Gebis)
Re: CreateObject doesn't work via my browser <msergeant@ndirect.co.uk_NOSPAM>
Displaying the Time <gary.ennis@strath.ac.uk>
Re: Displaying the Time <erhmiru@erh.ericsson.se>
Re: Displaying the Time (Jeffrey R. Drumm)
Re: Displaying the Time <barnett@houston.Geco-Prakla.slb.com>
Re: File Uploading To Webpage From Browser <perlguy@technologist.com>
Re: Installing modules on Win'95 <perlguy@technologist.com>
Perl & Y2K - booby trap code finsol@ts.co.nz
Re: Perl variables and regular expressions <avitala@macs.biu.ac.il>
Re: Perl Y2K copmliance <perlguy@technologist.com>
Perl/Oracle on CGI programs bonham@my-dejanews.com
Re: Perl/Oracle on CGI programs <matt@whiterabbit.co.uk>
perl5.005_02 install problems <aravind@genome.wi.mit.edu>
Problems with Dynamic Loading on HP-UX <csutton@att.net>
Re: Probs w/ redirection and capture of STDERR/STDOUT <erhmiru@erh.ericsson.se>
Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi (David Cantrell)
Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi droby@copyright.com
Re: Randal's Big Day in Big D (I.J. Garlick)
Re: reg-exp: change < to < but keep <I> <avitala@macs.biu.ac.il>
Re: RegExp Hell! <avitala@macs.biu.ac.il>
Re: round a value (Tad McClellan)
Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleig (David Cantrell)
Re: test (Apology!) <dpk@NOSPAM.egr.msu.edu>
Re: Testing a date <matt@whiterabbit.co.uk>
Re: undef $1 ??? (Tad McClellan)
weird socket problem <gcato@nsw.bigpond.net.au>
Re: What isn't Perl good for? (Joergen W. Lang)
Re: Who can help me write full-text search engine in Pe (David Alan Black)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Oct 1998 10:44:48 +0000
From: Jurgen Koeleman <jurgen@pallas.tid.es>
Subject: $0 does not contain script name
Message-Id: <362DBB20.5CBE805@pallas.tid.es>
$0 should contain the name of the file containing the Perl script
being executed.
I try the run the following script, that has the s-bit set for owner,
as a user not equal to owner.
#!/usr/bin/perl -wT
# File: test
print $0;
Instead of printing the filename "test" it prints "/dev/fd/3". If I
unset
the s-bit, the filename is printed correctly.
Any idea what's going on here?
TIA,
Jurgen
PS. The OS is Solaris 2.4
------------------------------
Date: 21 Oct 1998 08:28:41 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: -Help Please-: Efficiency of substr vs. join for string manipulation ?
Message-Id: <70kk1p$a1s$1@pilot.njin.net>
Hello -
chunkstar@my-dejanews.com writes:
>Hello.
> I have perused the newsgroups and FAQ's, but have not found an explicit
>answer to my current dilemma. I am trying to create a new string from a
>combination of literal strings, interpolated strings and substrings in a
>run-time efficient manner. I will sacrifice memory for speed, but dual
>efficiency would be nice :-). I must retain the original string, so I don't
>think I can do a direct replacement/insert job using something like substr(
>$mystring, n, 0 ) = $replacement. In C/C++ I would use something like
>&mystring[offset] to get my "temporary" substring without extra allocation
>and tag it on the end of a new string using strcat or memcpy. In Perl, it
>seems that the only way to do this is using a temporary ( resulting in an
>extra allocation that may be potentially slow with large strings ).
> To illustrate what I am trying to do, here is my Perl snippet:
>sub stringmanipulator {
> my $originalstring = shift;
> my $interpolate = shift;
> my $datapos = index( $originalstring, "KEYWORD" );
> if ( $datapos == -1 ) {
> die 'Didn't find KEYWORD';
> }
Note the single closing quote masquerading as an apostrophe. This
doesn't compile. Anyway....
> $datapos += 7; # find the text after the keyword ( assumes longer string)
> my $tempstring = substr( $originalstring, $datapos );
> my $newstring = join( "", "EXTRA STUFF$interpolate", $tempstring );
> return $newstring; # return new string - $tempstring discarded
>}
My first reaction was:
$orig =~ /KEYWORD(.*)/ or die....
return "EXTRA STUFF$interp$1";
but that was slower.
And yet, I really did want to trim your code :-)
So here's my best shot:
sub stringmanipulator {
my ($orig, $interp) = @_;
my $i = index($orig,"KEYWORD") or die "Didnt find KEYWORD";
"EXTRA STUFF$interp" . substr($orig, $i + 7);
}
Benchmark: timing 60000 iterations of mine, yours...
mine: 9 wallclock secs ( 7.90 usr + 0.09 sys = 7.99 CPU)
yours: 11 wallclock secs (10.72 usr + 0.02 sys = 10.74 CPU)
based on:
timethese (60000, {
'mine' => q( mine("This contains KEYWORD in the middle", "interp me!") ),
'yours' => q( yours("This contains KEYWORD in the middle", "interp me!") ),
});
David Black
dblack@pilot.njin.net
------------------------------
Date: 21 Oct 1998 08:32:07 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: -Help Please-: Efficiency of substr vs. join for string manipulation ?
Message-Id: <70kk87$a3r$1@pilot.njin.net>
dblack@pilot.njin.net (David Alan Black) writes:
> my $i = index($orig,"KEYWORD") or die "Didnt find KEYWORD";
Whoops, slight overcompensation - should be "Didn't" :-)
David Black
dblack@pilot.njin.net
------------------------------
Date: Wed, 21 Oct 1998 05:55:16 -0400
From: "Eric Winter" <ewinter@pop3.stx.com>
Subject: Re: Amputated Perl Code
Message-Id: <70kb4n$k3n@post.gsfc.nasa.gov>
Justin,
I've seen this message when I have an unbalanced =pod/=cut pair in the
code. Any chance a small change like that could have crept in?
Eric Winter
Justin Wilde wrote in message <362CFCDC.F4FA4367@openskies.com>...
>Looking in my perl error log, I see dozens of entries containing:
>
>"Missing right bracket at [path]\xxx.cgi line xxx, at end of line
>syntax error at [path]\xxx.cgi line xxx, at EOF
>Execution of [path]\xxx.cgi aborted due to compilation errors."
>
>Normally these scripts run fine, but it appears that occasionally they
>are cut short, often midway through a bracketed block of code. I assume
>this is what's happening because the line of code the perl compiler
>considers to be EOF is only partway through my file.
>
>What might cause this? The scripts are used only to process STDIN and
>display html pages. Concurrency wouldn't be an issue, would it?
>
>Any ideas would be greatly appreciated.
> Justin Wilde
> jwilde@openskies.com
>
>
------------------------------
Date: 21 Oct 1998 07:39:54 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Camel book: References.
Message-Id: <70k34a$o0n@mozo.cc.purdue.edu>
"misc.word.corp" <misc.word.corp@pobox.com> writes:
}Two questions on references:
}1) On p. 258 of the Camel Book, the authors use the following code to
}illustrate "load[ing] an array from a function:
}for $i (1 .. 10) {
} @tmp = somefunc ($i);
} $LoL[$i] = [ @tmp ];
}What does "somefunc" refer to? A standard (builtin) perl function? A
}user function (i.e. sub)?
It's just "some function that returns a list." This is one:
sub somefunc { my($val)=shift; return($val .. $val + 3); }
Granted, that's a pretty lame example. Here's a rewriting of that
example:
foreach $department (1000 .. 1117) {
@tmp = get_employee_list($department);
$LoL[$i] = [ @tmp ];
}
This of course creates a List of Lists contatining all the employees
at GebismInterNationalMegaGlobalCorp in departments 1000 through 1117.
Assuming, that is, that "get_employee_list" returns a list of
employees in a particular department.
}2) I'm trying to create a simple DBM database out of a multidimensional
}associative array (aka Hash-of-Hash). I'll probably use no more than
}four key/value pairs.
}-Would a Hash-of-Hash of this size be better (and easier) to implement
}via a multidimensional array (aka List-of-List in Camel)?
Stay with the way that makes sense to the task at hand. It's
surprising to many at first, but an array is usually no easier to deal
with than a hash. So pick the one that makes the most sense.
You will want to look at the MLDBM module, however. Go, right now,
and continue reading only after you've vistied CPAN!
See, told you it was cool.
}-A more general question: Would it be easier to write this in C?
In general, the answer to this question is almost always no. In
particular, the answer to YOUR question is no.
}References in Perl seem a bit ornery, at least as presented in Camel.
}I'm sure that they offer many advantages over their complements in C.
}What exactly are those advantages, anyway?
"What are the advantages of using the gear shift in a Ferrari over
the gear shift in a 1984 Cavalier station wagon?"
The answer is: the gear shift in a Ferrari comes with a Ferrari.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Wed, 21 Oct 1998 11:06:40 +0100
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM>
Subject: Re: CreateObject doesn't work via my browser
Message-Id: <362DB230.A7E8ADAC@ndirect.co.uk_NOSPAM>
nicolaslecart@my-dejanews.com wrote:
>
> Thank you Matt for your answer,
>
> but if i create a CSV file (from my excel file), i loose the properties of
> the excel file (Author, Title, Organisation , Date,....). But my main
> objective is to read ,in a directorie on the server, the properties of all
> the Excel files. And then i can make a HTML page with a board containing 3
> columns (Author, Title, Organisation, Date) witch indicate the documents
> available.
>
> Note that the name of the Excel files are not enough and i need the
> Author, Title, Organisation informations.
I suggest you take a look at LAOLA (I think it's been renamed, but a
search for LAOLA would get you the right thing). It is a much better way
to get what you want, and much more lightweight too.
--
<Matt/>
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
Date: Wed, 21 Oct 1998 11:57:38 -0700
From: Gareth Ennis <gary.ennis@strath.ac.uk>
Subject: Displaying the Time
Message-Id: <362E2EA2.41C6@strath.ac.uk>
Easy......
I want to simply display the time and date in a logical format -
(something like - 12:34 Tuesday 23 Oct 1998)
I tried using -
print localtime (time);
but it prints out a whole range of numbers like :
1357112199832931
Please help.....
--
Gareth Ennis
ABACUS - Strathclyde University
email: gary.ennis@strath.ac.uk
http://iris.abacus.strath.ac.uk/new/
------------------------------
Date: 21 Oct 1998 13:09:06 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: Displaying the Time
Message-Id: <lasogi18a5.fsf@erh.ericsson.se>
Gareth Ennis <gary.ennis@strath.ac.uk> writes:
> Easy......
>
> I want to simply display the time and date in a logical format -
> (something like - 12:34 Tuesday 23 Oct 1998)
>
> I tried using -
> print localtime (time);
>
> but it prints out a whole range of numbers like :
>
> 1357112199832931
Try:
print scalar localtime time;
Regards,
Michal
------------------------------
Date: Wed, 21 Oct 1998 11:16:12 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Displaying the Time
Message-Id: <362dc13b.409558213@news.mmc.org>
[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]
On Wed, 21 Oct 1998 11:57:38 -0700, Gareth Ennis <gary.ennis@strath.ac.uk>
wrote:
>Easy......
>
>I want to simply display the time and date in a logical format -
>(something like - 12:34 Tuesday 23 Oct 1998)
>
>I tried using -
>print localtime (time);
>
>but it prints out a whole range of numbers like :
>
>1357112199832931
The documentation for print and localtime in perlfunc should prove most
enlightening.
The short answer: The arguments to 'print' are evaluated in a list context, and
localtime returns a list in that context.
Try:
print scalar localtime; # passing 'time' as an argument to localtime is
# redundant
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: Wed, 21 Oct 1998 07:34:45 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Displaying the Time
Message-Id: <362DD4E5.CF7CA2F0@houston.Geco-Prakla.slb.com>
Gareth Ennis wrote:
>
> Easy......
>
> I want to simply display the time and date in a logical format -
> (something like - 12:34 Tuesday 23 Oct 1998)
>
> I tried using -
> print localtime (time);
Use localtime in a scalar context (print is always in list context):
print scalar localtime(time);
will generate:
Wed Oct 21 07:34:01 1998
If you want it in a different format, you may create one yourself using
the bits returned by localtime.
HTH.
Cheers,
Dave
>
> but it prints out a whole range of numbers like :
>
> 1357112199832931
>
> Please help.....
> --
> Gareth Ennis
> ABACUS - Strathclyde University
> email: gary.ennis@strath.ac.uk
> http://iris.abacus.strath.ac.uk/new/
--
Dave Barnett Software Support Engineer (281) 596-1434
"What do you care what other people think?"
-- __Infinity__, Arline Greenbaum played by Patricia Arquette
------------------------------
Date: Wed, 21 Oct 1998 11:16:43 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: File Uploading To Webpage From Browser
Message-Id: <362DC29B.BD23B69@technologist.com>
Robert,
There is no *secret* to CGI file uploading!
Check out my article at:
http://webreview.com/wr/pub/98/08/14/perl/index.html
I shows you how to do it and how it works...
HTH,
Brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Wed, 21 Oct 1998 11:23:43 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Installing modules on Win'95
Message-Id: <362DC43F.A0704492@technologist.com>
"Allan M. Due" wrote:
>
> Well,
> Apparently I am missing any long term memory processing. Dmake comes
> with the Standard version not the activestate version. Sorry about that.
> Comes from two installations on the same system. It just has always worked
> for me and I forgot when I installed it.
>
> AmD
> Allan M. Due wrote in message <70gbe9$9u7$0@206.165.167.223>...
> >
> >I am sure I am missing something but why not just use dmake which comes
> with
> >the activestate distribution? It works fine for me.
ActiveState Perl comes with the Perl Package manager. It is documented
at:
http://www.activestate.com/ActivePerl/docs/description.html#perl_package_manager
It handles all of the "dirty details" of installing packages/modules on
Windoze systems.
Now, if you need a module that is not listed, you are on your own...
HTH,
Brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Wed, 21 Oct 1998 11:33:00 GMT
From: finsol@ts.co.nz
Subject: Perl & Y2K - booby trap code
Message-Id: <70kgpc$e4b$1@nnrp1.dejanews.com>
I posted a link in an earlier thread on this topic - unfortunately the link
was changed & the article referenced had nothing to do with Perl - it did
spark off an lively discussion however!
The correct link for this article (unless they change it again!) is:
http://www.idg.co.nz/WWWfeat/Y2000/amon1010.htm
Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 14:00:52 +0200
From: "Avshi Avital" <avitala@macs.biu.ac.il>
Subject: Re: Perl variables and regular expressions
Message-Id: <70kih6$cgm$1@cnn.cc.biu.ac.il>
Jason Puyleart wrote in message <70j262$eu2$1@news2.alpha.net>...
>If you are using a variable in a regular expression, what steps can you
take
>to properly escape it so you don't run into parsing problems?
>
>ex.
>
>$foo = "foo\bar"
>if ($foo =~ /$foo/)
>
>or something similar to this....
>
if you meant something like:
$foo = "foo?bar"
if ($foo =~ /$foo/)
then the answer is:
$foo = "foo?bar"
if ($foo =~ /\Q$foo\E/)
Avshalom Avital
Information Retrieval Laboratory
Bar-Ilan University, Israel
avitala@macs.biu.ac.il
------------------------------
Date: Wed, 21 Oct 1998 11:32:20 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Perl Y2K copmliance
Message-Id: <362DC644.CCC3ED34@technologist.com>
Patrick Timmins wrote:
>
> In article <F14nAF.po@midway.uchicago.edu>,
> wdr1@pobox.com (William D. Reardon) wrote:
>
> > In article <70hpgu$s83$1@pilot.njin.net>,
> > David Alan Black <dblack@pilot.njin.net> wrote:
> [snip]
> > >I don't see a single reference to Perl in this article. It's all about
> > >the BIOS on PCs, and how it interacts with Micros**t.
> > >
> > >Please (yawn) check out the usual archives and references for this
> > >topic as it actually relates to Perl.
> >
> > Well, since it affects Microsoft systems, and Perl runs on
> > Microsoft systems, in the end, a person's Perl program may not work as
> > expected in the year 2000.
... rest snipped ...
Crap! When did Microsoft start making __systems__? I thought they just
wrote buggy software!
Did they buy Packerd-Bell? ;-)
Hell, my truck runs on gas from Quik Trip, I wonder if their gas is Y2K
compliant!
Brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Wed, 21 Oct 1998 11:34:08 GMT
From: bonham@my-dejanews.com
Subject: Perl/Oracle on CGI programs
Message-Id: <70kgrh$e4l$1@nnrp1.dejanews.com>
Hi I4m very new to Perl and first of all I don4t want to bother you people
with stupid questions but here4s one I would like to know how perl interacts
with Oracle. The thing it4s that I have a cgi program written in Perl that
performs various searches on text files, but as this files are growing
considerably searches are getting more slow, so my question is Can I make it
work faster or should I change text files for Oracle tables ?? I4ll be
pleased If someone could tell me what to do thanks in advance
--
|/\/\/\/\/\/\/|
| FunkYboY |
|/\/\/\/\/\/\/|
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 13:45:18 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: bonham@my-dejanews.com
Subject: Re: Perl/Oracle on CGI programs
Message-Id: <362DD75E.A54B438@whiterabbit.co.uk>
You can probably make your search faster by making the code more
efficient.
This is a guess, however, as I haven't seen your code....
Matt
bonham@my-dejanews.com wrote:
> =
> Hi I=B4m very new to Perl and first of all I don=B4t want to bother you=
people
> with stupid questions but here=B4s one I would like to know how perl in=
teracts
> with Oracle. The thing it=B4s that I have a cgi program written in Perl=
that
> performs various searches on text files, but as this files are growing
> considerably searches are getting more slow, so my question is Can I ma=
ke it
> work faster or should I change text files for Oracle tables ?? I=B4ll b=
e
> pleased If someone could tell me what to do thanks in advance
> =
> --
> |/\/\/\/\/\/\/|
> | FunkYboY |
> |/\/\/\/\/\/\/|
> =
> -----------=3D=3D Posted via Deja News, The Discussion Network =3D=3D--=
--------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own=
-- =
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: Tue, 20 Oct 1998 16:20:41 -0400
From: Aravind Subramanian <aravind@genome.wi.mit.edu>
Subject: perl5.005_02 install problems
Message-Id: <362CF099.531E391D@genome.wi.mit.edu>
I'm trying to install perl5.005_02 on a solaris 2.5 machine using gcc
2.8.1 and I get the following error at the make depend stage.
make depend
sh ./makedepend MAKE=make
./makedepend: /dev/null: cannot execute
./makedepend: -f: not found
cp: Insufficient arguments (1)
Usage: cp [-f] [-i] [-p] f1 f2
cp [-f] [-i] [-p] f1 ... fn d1
cp -r|R [-f] [-i] [-p] d1 ... dn-1 dn
./makedepend: test: argument expected
*** Error code 1
make: Fatal error: Command failed for target `depend'
I'd appreciate any suggestions.
Thank you,
aravind
------------------------------
Date: Wed, 21 Oct 1998 08:40:39 -0400
From: "Lynxus News" <csutton@att.net>
Subject: Problems with Dynamic Loading on HP-UX
Message-Id: <TwkX1.1996$FV3.3769@news2.randori.com>
I am having a problem with some packages that are using DynaLoader. I am
running Perl 5.005_02 on HP-UX 10.20. I am getting a message that it "Can't
find 'boot_sx' symbol in
/opt/perl5/lib/site_perl/5.005/PA-RISC1.1/auto/Sx/Sx.sl. When I do an 'nm'
on the library I see the symbol. I have had this problem on another
package as well. The only two packages I have added since installing Perl
that use Dynamic loading are Sx and Xforms4Perl. Both have this problem.
Extensions that I selected to be built as dynamic (e.g. POSIX) do not have
this problem with the bootstrap.
Perl was built using gcc 2.7.2.3 and dynamic loading was set to 'y'.
This may a HP-UX 10.20 specific problem. I have heard that others are
successfully running these same packages on other platforms.
Does anyone have any suggestions on where I could look to resolve this
problem?
Any help would be appreciated.
Thanks,
Chip Sutton
------------------------------
Date: 21 Oct 1998 12:36:00 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: silversurf@seanet.com
Subject: Re: Probs w/ redirection and capture of STDERR/STDOUT
Message-Id: <lavhle19tb.fsf@erh.ericsson.se>
"Colin Stefani" <silversurf@seanet.com> writes:
> I have been working on a script that improves upon tar and is tailored for
> my groups particular situation and needs. I have written a script that feed
> tar a path(s) inputted by the user. I then want to capture the output of
> tar's verbose generated output in file as a log of what has been tar'd.
> Pretty straight forward.
How about IPC::Open3? See perldoc open3. You can catch both STDOUT and STDERR.
Regards,
Michal
------------------------------
Date: Wed, 21 Oct 1998 10:53:59 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <362fbd2d.64242936@thunder>
On Tue, 20 Oct 1998 17:16:20 -0400, John Porter <jdporter@min.net>
enlightened us thusly:
>Adam Turoff wrote:
>>
>> Whiskey is made all over the world. Malt whiskeys are made all over
>> the
>> world. But only whiskey brewed, distilled and aged in Scotland may
>> legally receive the appelation 'Scotch [Whiskey]'.
>
>Right, according to U.S. law.
And Scotch is whisky, not whiskey.
--
David Cantrell, part-time Unix/perl/SQL/java techie
full-time chef/musician/homebrewer
http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: Wed, 21 Oct 1998 12:32:58 GMT
From: droby@copyright.com
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <70kk9q$i76$1@nnrp1.dejanews.com>
In article <362CD625.1A991490@bbnplanet.com>,
Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
> droby@copyright.com wrote:
>
> > And no Scotch is Belgian! Blech. Scotch is Scots.
>
> Scotch is made all over the world, but the Scots do seem to have more
> bogs ;)
> The Macallan 25 and Oban and Bowman are all from Scotland I believe.
>
Whiskey is made all over the world. If it's made in Scotland, it's Scotch.
> > Hey, I could use a Sparc at home. I may have to become Gloucester.pm. I'll
> > buy you a beer.
>
> /me rumages around in office closet. Well, lessee, I have an IPC and a
> 3/260 on wheels I could spare :). Gloucester, England or Massachusetts?
>
IPC? 3/260? I think I'll stick with my Linux Pentium thank you very much.
;-)
Massachusetts. Guess I could probably join Boston.pm, but I don't get down
there too often anymore. Would Boston.pm like a field trip to Cape Ann?
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 08:53:03 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: Randal's Big Day in Big D
Message-Id: <F1660F.84J@csc.liv.ac.uk>
In article <8cpvbnuih6.fsf@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> writes:
>>>>>> "Brand" == Brand Hilton <bhilton@tsg.adc.com> writes:
>
[snipped]
>
> And if you're following along to this point, I'd be happy to try to
> arrange my JACPH talk in *any* location in the US. Sorry, can't leave
> the country for a while yet. <sigh> Just write me and we can work out
> the details.
>
Bummer. I'd deffinately travel to London to here this talk. :-)
Ah well perhaps I will be in the States sometime soon. (I think I would have
to also be in the right State at the right time to.)
--
--
Ian J. Garlick
<ijg@csc.liv.ac.uk>
A lack of leadership is no substitute for inaction.
------------------------------
Date: Wed, 21 Oct 1998 14:22:51 +0200
From: "Avshi Avital" <avitala@macs.biu.ac.il>
Subject: Re: reg-exp: change < to < but keep <I>
Message-Id: <70kjqc$g0a$1@cnn.cc.biu.ac.il>
Alex Farber wrote in message <361E43B1.CCD2F3D5@kawo2.rwth-aachen.de>...
>Hi guys,
>
>I am thankful to all who helped me with my previous
>reg. exp. question and would like to ask one more:
>
>the typical way not to let people use HTML-tags
>in a webboard is to s/</</g and s/>/>/g
>
>But how do you still allow people using <I>, </I>,
><A HREF=""> and </A> ? I guess it is probably done
>somehow with (!=...)
you got that right!
"lookahead" in perlre
------------------------------
Date: Wed, 21 Oct 1998 14:19:10 +0200
From: "Avshi Avital" <avitala@macs.biu.ac.il>
Subject: Re: RegExp Hell!
Message-Id: <70kjjn$g08$1@cnn.cc.biu.ac.il>
nanobreath@my-dejanews.com wrote in message
<6vm8ca$400$1@nnrp1.dejanews.com>...
>Hello! Hopefully some kind soul will take mercy on me and defeat the reg
exp
>demons ... I am trying to truncate a variable at one particular point, and
>then save everything before that point in another variable. For instance,
>
>domain.com
>
>What I want it to do is take everything *before* the . and put it into
>another variable. So, if before is domain.com, after is domain
>
>I swear, I have looked through several explanations of regular expressions
>& I think it is something I really have to sit down with. Unfortunately,
>I'm trying to get this done... this is NOT my homework, by the way.
>
>If possible, please send email to me at rbaguer@freenet.columbus.oh.us
>because I am physically unable to check newsgroups all the time. Thanks
>a lot.
>
why not LEARN Perl first? this is much to simple for someone who read -as
you say - info about regexes.
anyway:
for simple file name (e.g- file.com):
$a="file.com";
$a =~ s/\..*$//;
for name such as: files.txt.com.whatever.bin (assuming you want only the
last extention removed):
$a="files.txt.com.whatever.bin";
$a =~ s/\.[^\.]*$//;
Avshalom Avital
Information Retrieval Laboratory
Bar-Ilan University, Israel
avitala@macs.biu.ac.il
------------------------------
Date: Wed, 21 Oct 1998 07:22:09 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: round a value
Message-Id: <hljk07.pqc.ln@flash.net>
dwiesel@my-dejanews.com wrote:
: I would like to know how to round a value so that if it is
: 2.499 it will become 2.5
: and if it is
: 2.999 it will become 3
: (I want the value to become a new value with 0.5 between (sorry for my bad
: english)
sub round_to_nearest_half {
my($num) = @_;
$num = sprintf '%.1f', $num; # round to tenths
return $num if $num =~ /\.5$/; # done if a half
return sprintf '%.0f', $num; # else round to integer
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 21 Oct 1998 10:59:19 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <3630bdcf.64404258@thunder>
On 21 Oct 1998 03:50:05 GMT, Steve Howie <showie@uoguelph.ca>
enlightened us thusly:
>While the Macallan and Oban are great (I lived in Oban for 9 years!), HP,
>Laphroig and Bowmore are the best for me. 15 yo Glenfarclas is up there too.
>Highland Park uniformly scores 9+ out of 10 on reviews I've read. BTW the
>25 yoear old was 99 pounds a bottle at Oddbins at Glasgow Airport Duty
>Free in June ... thats over $200 US. I was tempted ... :)
Try the Glen Moray 17yrs as well. The only place I've seen it is
Oddbins, and only their larger shops stock it.
I can't drink Highland Park, not after hearing a (probably apocryphal)
story about the distillery cats. HP sauce is fine though ;-)
--
Dave, who's just got hold of a 25yr old cask strength Macallan. Yum!
------------------------------
Date: 21 Oct 1998 12:53:01 GMT
From: Dpk <dpk@NOSPAM.egr.msu.edu>
Subject: Re: test (Apology!)
Message-Id: <70klfd$9ea$1@msunews.cl.msu.edu>
Dpk <dpk@brainiac.egr.msu.edu> wrote:
Before everyone sends me email or flames me here! I was testing some
editor changes I made to tin, had a shitty modem connection and butter
fingers and incidently sent this message. I sincerly apologize.
I am aware of the waste people create in newgroups and also find it
rewarding to find the solutions to problems on my own... Because of
this you hardly ever see me post (1 every 6 months maybe).
Thanks for your time,
Dennis
--
Dennis Kelly <dpk@egr.msu.edu>
Network Administrator
College of Engineering, MSU
------------------------------
Date: Wed, 21 Oct 1998 13:42:46 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Josep Jover <jjover@andorra.ad>
Subject: Re: Testing a date
Message-Id: <362DD6C6.9AFB9465@whiterabbit.co.uk>
Josep,
#!/usr/local/bin/perl -w
use strict;
my @number_of_days = qw {
31
28
31
30
31
30
31
31
30
31
30
31
};
my ($error) = "";
my $date = "29/2/1998";
my ($day,$month,$year) = split (/\//,$date);
if ($year !~ /^\d{4}$/) {
$error=$error."The year is not valid.\n";
}
if (($year/4) == int($year/4)) { # leapyear?
$number_of_days[1] = 29; # adjust days in feb
}
print $number_of_days[1];
if (($month < 1) || ($month > 12) || ($month =~ /\D/)) {
$error=$error."The month is not valid.\n";
} elsif (($day < 1) || ($day > $number_of_days[$month-1]) ||
($day=~/\D/)) {
$error=$error."The day is not valid.\n";
}
if ($error) {
print $error;
exit(1);
}
exit(0);
Josep Jover wrote:
>
> Hello everybody,
>
> How can I verify if a date dd/mm/yyyy is a correct data ?
>
> Thanks for helping me.
>
> Josep Jover
> jjover@andorra.ad
--
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: Wed, 21 Oct 1998 07:38:27 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: undef $1 ???
Message-Id: <3kkk07.hvc.ln@flash.net>
dwiesel@my-dejanews.com wrote:
: I've got the following situation:
: $htmlpage =~ /Arial">(.*) <\/TD>/g;
: $value1 = $1;
: $htmlpage =~ /Arial">(.*) <\/TD>/g;
: $value2 = $1;
: If the other expression does not succeed i $value2 will end up with the exact
: value as $value1.
And if the _first_ pattern match does not succeed, then $value1
will get a left over $1 value from a successful previous pattern
match (or undef if there was no previous successful match).
: How can I prevent this?
You should *never* use the $\d variables without first checking
to see if the pattern match succeeded.
Else you just don't know what you are going to get...
$value1 = $htmlpage =~ /Arial">(.*) <\/TD>/ ? $1 : 'no match';
or
if ($htmlpage =~ /Arial">(.*) <\/TD>/)
{$value1 = $1}
else
{$value1 = 'no match'}
: I've tried to undef $1 between the
: both expression and it does'nt work. I've also tried $1 = "" but i does'nt
: work either.
The $\d variables are read-only. You cannot assign to them.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 21 Oct 1998 20:35:17 +1000
From: Gavin Cato <gcato@nsw.bigpond.net.au>
Subject: weird socket problem
Message-Id: <362DB8E5.1AFA@nsw.bigpond.net.au>
Hia all,
Got a very puzzling problem. I have made a perl script that telnet's to
a Cisco Router, enters enable mode on the router (like root) and then
saves the configuration via TFTP to a unix host.
I took the socket routines for the perl "telnet" bit out of a script I
found in a perl script as part of a program called "nocol" (a net
monitoring package)
It is working *PERFECTLY* for Cisco routers. As we also have a few bay
routers I needed to replicate it for the Bay (slightly different command
syntax). I thought this would be easy.
The problem is that when you tell the script to telnet to any host
*other than a cisco* it doesn't seem to get any responses back from the
host (it's supposd to print to STDOUT) and so doesn't work. I first
thought it was a Bay router quirk then I tried telnetting to a unix box
using the script and it exhibited the same behaviour.
Could a Perl guru :) please have a look at the script and tell me what's
wrong? I'm not a perl expert (which is why i used the socket routine
from somewhere else) but I'm not that daft and I can't see what's
different about port 23 on a cisco and port 23 on any other box.
Script is below, if anyone can use it for their network please feel free
to do so (like I said it's working with cisco's) , if anyone can
troubleshoot it I'd greatly appreciate it.
Cheers,
++Gavin
(please cc to gcato@nsw.bigpond.net.au)
**** Start below
#!/usr/bin/perl
##
## Cisco-tftp version 1.00
##
## Perl script to log onto a Cisco router, enter enable mode and
## tftp the configuration offline to a host
##
## This script was designed to be run as a nightly cron job to
## backup all the routers but it has been made a command line
## tool for flexibility and debugging
##
## Written by Gavin Cato 20/10/98
##
## Critical portions (i.e. the open socket section) taken from
## a perl script found in a old NOCOL package
##
## Usage of this script is as follows
##
## <router hostname> <telnet password> <enable password> <tftp host>
<filename>
## Version number in a variable
$version = "1.00";
## This bit clears the screen. Can't remember the perl syntax for
## this so we have to call out to unix for help
system ("clear ");
## Print the version of the script for the user's benefit
print "Cisco-tftp version $version\n";
print "\n";
## Parse the arguments from the command line.
## Check if there have been any commands issued, if not exit gracefully
unless (@ARGV[0]) {
print "Missing 1 or more critical arguments\n";
print "Usage is as follows\n";
print "\n";
print "<router hostname> <telnet password> <enable password>
<tftp host> <filename>\n";
print "\n";
exit;
}
local ($rhost, $rpasswd, $renable, ,$tftphost, $filename) = @ARGV;
## Adjust this section for the TFTP command
## We typically want to capture the running config
## It can be changed to startup-config but that would
## defeat the purpose of regular backups
$rcmd = "copy running-config tftp";
## Display a status of what we are about to do for debug purposes
## May be commented out
print "\n";
print "Command line options shown below\n";
print "\n";
print "\n";
print "Remote Host\t\t$rhost\n";
print "Telnet Password\t\t$rpasswd\n";
print "Enable Password\t\t$renable\n";
print "TFTP Host\t\t$tftphost\n";
print "TFTP Filename\t\t$filename\n";
print "\n";
print "\n";
## Ensure that the filename exists
## Because of the nature of tftp the file must be
## there before it is written
system("touch /tftpboot/$filename ");
system("chmod 777 /tftpboot/$filename ");
local ($rport) = 23; # default telnet port
sub Inet_aton {
local ($hname) = @_;
local ($haddr, $junk);
if ($hname =~ /^\d/) {
local ( @n ) = split(/\./, $hname);
$haddr = pack('C4', @n);
}
else { ($junk,$junk,$junk,$junk, $haddr) = gethostbyname($hname); }
return ($haddr);
}
##
# Create a connected socket to the remote host.
# newSocket ("cisco-gw.abc.com", 23, 'tcp')
# Dies on failure.
sub newSocket {
local ($host, $port, $sproto) = @_ ;
local ($type, $proto);
$sproto = 'tcp' unless $sproto;
`uname -s -r -m` ;
# Depending on version of perl, call 'use Socket' or 'require
socket.ph'
# From Netnews posting by jrd@cc.usu.edu (Joe Doupnik)
local ($AF_INET, $SOCK_STREAM, $SOCK_DGRAM) = (2, 1, 2); # default
values
if ( $] =~ /^5\.\d+$/ ) { # perl v5
# print STDERR "debug: Check for perl5 passed...\n";
eval "use Socket";
$AF_INET = &Socket'PF_INET;
$SOCK_STREAM = &Socket'SOCK_STREAM;
$SOCK_DGRAM = &Socket'SOCK_DGRAM;
}
else { # perl v4
eval {require "socket.ph"} || eval {require "sys/socket.ph"} ;
if ( defined (&main'PF_INET) ) {
# print STDERR "debug: found sys/socket.ph\n";
$AF_INET = &main'PF_INET;
$SOCK_STREAM = &main'SOCK_STREAM;
$SOCK_DGRAM = &main'SOCK_DGRAM;
}
elsif (`uname -s -r -m` =~ /SunOS\s+5/) { # Solaris, need to
run h2ph
require "sys/socket.ph"; # Gives error and exits
die 'Did you forget to run h2ph ??';
}
}
if ($port =~ /\D/) { $port = getservbyname($port, $sproto); }
if ($sproto =~ /tcp/) { $type = $SOCK_STREAM;}
else { $type = $SOCK_DGRAM };
$haddr = Inet_aton($host) || die "Unknown host (no address)- $host";
$paddr = pack ('S n a4 x8', $AF_INET, $port, $haddr);
($junk, $junk, $proto) = getprotobyname($sproto);
socket(SOCK, $AF_INET, $type, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";
return (SOCK);
}
sub cleanup {
kill (9, $child) if $child;
}
###
### main
###
$SIG{'INT'} = 'cleanup';
local ($sock) = &newSocket($rhost, $rport, 'tcp');
select($sock); $| = 1; # make socket unbuffered
select(STDOUT); # set back to standard file handle.
# Now we fork and the child sends commands to the Cisco while the
# parent reads and prints from the stdout.
## Added by Gavin, this is the key bit that actually runs the commands
## on the cisco
## The sleep commands are there to keep things safe
if ($child = fork) {
select $sock;
print "$rpasswd\n";
sleep 1;
print "terminal length 0\n";
print "en\n";
sleep 1;
print "$renable\n";
sleep 1;
print "$rcmd\n";
sleep 1;
print "$tftphost\n";
sleep 1;
print "$filename\n";
sleep 1;
print "\n";
sleep 1;
print "quit\n";
sleep 2;
exit 0; # this will wait in zombie mode until parent exits.
}
# in the parent
while (<$sock>) { print; }
exit 0;
------------------------------
Date: Wed, 21 Oct 1998 13:37:07 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: What isn't Perl good for?
Message-Id: <1dh85w7.hetjcd1rafoqaN@host048-210.seicom.net>
Uri Guttman <uri@camel.fastserv.com> wrote:
> >>>>> "JWL" == Joergen W Lang <jwl@_munged_worldmusic.de> writes:
>
> JWL> Earl Westerlund <earlw@kodak.com> wrote:
> >> Elaine -HappyFunBall- Ashton wrote:
> >>
> >> > The day Perl makes coffee and muffins
> >> > for me in the morning, I'll never have eyes for another language. :)
> >>
> >> So which language does this?? :)
>
> JWL> Perl does ;-)
>
> JWL> But there's some trouble: It handles the make("coffee", "muffins")
> JWL> subroutines fine, but when it's finished making, it push()es the items
> JWL> on the @tray and the coffee gets spilled and the muffins are torn to
> JWL> <CHUNK>s.
>
> JWL> I have tried a workaround in which I pipe the coffee to the bitbucket.
> JWL> Works, technically, but looks ugly on the breakfast table.
>
> JWL> The "strict" pragma does not work, either. If I say:
> JWL> use strict qw(diet); so I have to predeclare the numbers of spoons of
> JWL> sugar and only can order decaf, again it choke()s and tells me it can't
> JWL> find the right sugar package.
>
> JWL> What can I do ??? :-((
>
> stop drinking coffee!
>
> i never touch the stuff! (i don't like the flavor)
>
I hardly do. But if I did I might fall for this o so subtle
indoctrination of Java in this case - naaa, rather stick to tea.
See you at the "Camel" for some roast Gecko or in the "Foo-Bar" where
the Sparcs are just a beer each... ;-))
Joergen
--
To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
"Everything is possible - even sometimes the impossible"
HOELDERLIN EXPRESS - "Touch the void"
------------------------------
Date: 21 Oct 1998 08:55:43 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Who can help me write full-text search engine in Perl with indexing
Message-Id: <70klkf$aa1$1@pilot.njin.net>
Darius Jack <dariusz@usa.net> writes:
>Uri Guttman wrote:
>>
>> >>>>> "DJ" == Darius Jack <dariusz@usa.net> writes:
>>
>> DJ> Who can help me write search engine to search kew words in full texts,
>> DJ> in Perl, running locally under Perl for DOS.
>I don't ask you to work on my project in Perl, [...]
Meaning the original "Who" meant "Who (other than Uri Guttman)" ?
David Black
dblack@pilot.njin.net
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4030
**************************************