[9717] in Perl-Users-Digest
Perl-Users Digest, Issue: 3311 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 1 22:04:51 1998
Date: Sat, 1 Aug 98 19:00:20 -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 Sat, 1 Aug 1998 Volume: 8 Number: 3311
Today's topics:
Re: # in a print statement <tchrist@mox.perl.com>
Re: # in a print statement <upsetter@ziplink.net>
Re: binary uploading.. <jdporter@min.net>
Coverage Tool? <shenge@ece.ucdavis.edu>
Re: FTP without Net::FTP module <camerond@mail.uca.edu>
Re: hiding user input (Michael J Gebis)
Re: hiding user input (Gary L. Burnore)
Re: hiding user input (Gary L. Burnore)
Re: hiding user input (Abigail)
Re: How to change one field in a flat database? (Tad McClellan)
Re: How to change one field in a flat database? (Tad McClellan)
Re: Im Willing to pay or give a free DOMAIN for a custo (nobody)
Re: Interesting Question needs Quick Answer (Jack Ostroff)
Re: List files by creation date? (Tad McClellan)
Re: newbie split question <mpersico@erols.com>
Re: newbie split question (Tad McClellan)
Re: non-perl question about linux <paladin@uvic.ca>
Re: number (6 -> 06) conversion question <mpersico@erols.com>
Re: Overriding print?? <mpersico@erols.com>
Re: Passing Large Numbers of Parameters to Subroutines <bowlin@sirius.com>
Re: Passing Large Numbers of Parameters to Subroutines (Abigail)
Re: Passing Large Numbers of Parameters to Subroutines (Mark-Jason Dominus)
Re: perl and shell help required - 2 related(?) questio <mpersico@erols.com>
Re: Q:How to "mkdir -p"? <dereks@fc.hp.com>
Variable length exceed? <pryzby@tux.org>
Re: Variable length exceed? (Tad McClellan)
Re: What's the future of Perl? <tchrist@mox.perl.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Jul 1998 16:24:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: # in a print statement
Message-Id: <6pq6oa$k7j$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
:P.P.S. Obfuscative probably isn't a word.
Certainly not. It's ``obfuscatory''.
--tom
--
"Oh, I'm totally outrageous--I just never seem to inspire any outrage. :-)"
--Larry Wall
------------------------------
Date: 30 Jul 1998 22:10:34 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: # in a print statement
Message-Id: <6pqr0q$sq7@fridge.shore.net>
Abigail <abigail@fnx.com> wrote:
: I'll be as I please. If you don't want to read my postings, RTFM of your
: newsreader.
If you don't want to answer newbies' questions, please read the portion of
your newsreader's manual that explains how to move on to another article
without following-up.
--Art
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 30 Jul 1998 18:42:22 GMT
From: John Porter <jdporter@min.net>
Subject: Re: binary uploading..
Message-Id: <35C0BF2C.41B1@min.net>
Indra Rosadi wrote:
>
> Hi,
> I have a problem with binary uploading..
> I tried to do the following code as part of my uploading code:
>
> ....
>
> open(OUTFILE,">>$fileLocation");
You are aware, of course, that >> means append to file;
so if the file already exists and has some contents, the
result will naturally be larger than the source.
> while ($bytesread = read($filename,$buffer,1024){
Um, read() doesn't normally take a filename as its first arg.
So, is $filename here really a filehandle? I hope so.
Also, if the data is binary (I assume it is), you should
probably set binary mode on the two files before doing
any reading and writing; use binmode().
--
John Porter
------------------------------
Date: 30 Jul 1998 17:35:45 GMT
From: Eric Sheng <shenge@ece.ucdavis.edu>
Subject: Coverage Tool?
Message-Id: <6pqath$3so$1@mark.ucdavis.edu>
Hi,
I've gotten the gz file and tried to install the package. There were some
error messages about missing man pages on coverage but that's about it. Everything
happened quite smoothly. I, however, don't think I have the installation done in the
right directory. The document on the web doesn't explicitly say where. So I just picked
a directory.
I went ahead and tried to do some test runs with:
perl -d:Coverage test.pl
but got:
Unrecognized switch: -:Coverage.
Please tell me what I have wrong.
Thanks so much.
--Eric
------------------------------
Date: Thu, 30 Jul 1998 13:34:14 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: I R A Aggie <fl_aggie@thepentagon.com>
Subject: Re: FTP without Net::FTP module
Message-Id: <35C0BCA6.67413983@mail.uca.edu>
[cc'd to iraa]
They all five came with mine, but then I'm using GS's Win32 port
(5.004.02). I really don't know what comes with a standard Unix
distribution.
Cameron
camerond@mail.uca.edu
I R A Aggie wrote:
>
> In article <35BF2636.EB6F661D@mail.uca.edu>, Cameron Dorey
> <camerond@mail.uca.edu> wrote:
>
> [just tossing the contents of Net::FTP into a script as a set of
> subroutines]
>
> + why wouldn't it work just like the module does (maybe with a little bit
> + of futzing)?
>
> Because Net::FTP immediately uses these modules?
>
> use Socket 1.3;
> use IO::Socket;
> use Time::Local;
> use Net::Cmd;
> use Net::Config;
>
> Ok, the first three should be perl 5 standard items. You'd have to add
> in the next two, I think.
>
> James
------------------------------
Date: 2 Aug 1998 00:56:44 GMT
From: gebis@noble.ecn.purdue.edu (Michael J Gebis)
Subject: Re: hiding user input
Message-Id: <6q0dgc$2be@mozo.cc.purdue.edu>
gbacon@cs.uah.edu (Greg Bacon) writes:
}Please tell us that you've stopped beating your poor wife.
Dammit not this again.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Sun, 02 Aug 1998 01:17:24 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: hiding user input
Message-Id: <35cbbde6.167502682@nntpd.databasix.com>
On 2 Aug 1998 00:56:44 GMT, in article <6q0dgc$2be@mozo.cc.purdue.edu>,
gebis@noble.ecn.purdue.edu (Michael J Gebis) wrote:
>gbacon@cs.uah.edu (Greg Bacon) writes:
>}Please tell us that you've stopped beating your poor wife.
>
>Dammit not this again.
Apparently.
--
for i in databasix primenet ; do ; gburnore@$i ; done
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH! | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3 3 4 1 4 2 ]3^3 6 9 0 6 9 ][3
spamgard(tm): zamboni | Official Proof of Purchase
===========================================================================
------------------------------
Date: Fri, 31 Jul 1998 01:12:25 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: hiding user input
Message-Id: <35c119eb.27518843@nntpd.databasix.com>
On 31 Jul 1998 00:54:28 GMT, in article <6pr4k4$2uu$2@client3.news.psi.net>,
abigail@fnx.com (Abigail) wrote:
>Gary L. Burnore (gburnore@databasix.com) wrote on MDCCXCIV September
>MCMXCIII in <URL: news:35c8e560.14065952@nntpd.databasix.com>:
>++
>++ Besides, in this case, John is correct. If Abigail is too lazy to answer the
>++ qustion, Abigail should just shut the fuck up.
>
>
>I don't think so.
Well of course you don't.
--
for i in databasix primenet ; do ; gburnore@$i ; done
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH! | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3 3 4 1 4 2 ]3^3 6 9 0 6 9 ][3
spamgard(tm): zamboni | Official Proof of Purchase
===========================================================================
------------------------------
Date: 31 Jul 1998 02:56:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: hiding user input
Message-Id: <6prbpi$493$1@client3.news.psi.net>
Scott Stark (sstark@informix.com) wrote on MDCCXCIV September MCMXCIII in
<URL: news:6pqtda$aql1@webint.na.informix.com>:
++
++ As a matter of fact I did check the faq and didn't find any such animal, exce
++ "Is there a way to hide perl's command line from programs such as "ps"?". Tha
++ one didn't make sense to me. So either there's something wrong with my eyes o
++ I'm too stupid to figure out the FAQ.
Must be the latter. Which doesn't surprise as you're too stupid to
indicate on your email that you posted a copy as well.
$ grep password perlfaq?.pod | head -1
perlfaq8.pod:=head2 How do I ask the user for a password?
$
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
------------------------------
Date: Thu, 30 Jul 1998 21:27:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to change one field in a flat database?
Message-Id: <e2arp6.rfa.ln@localhost>
Bjorn Malmberg (news@NOSPAM.gb-design.com) wrote:
: On Thu, 30 Jul 1998 13:41:06 -0500, tadmc@flash.net (Tad McClellan)
: wrote:
: > perlfaq, part 5:
: >
: > "How do I change one line in a file/
: > delete a line in a file/
: > insert a line in the middle of a file/
: > append to the beginning of a file?"
: >
: > Those sound similar to me.
: >
: Thanks a lot, I'll try that one.. Hmm, why didn't I find that one in
: the CPAN before I posted this msg??
CPAN is not needed for checking Perl FAQs.
They are *included with* the perl distribution.
If you have perl installed, then you should already have
them on your HD somewhere...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 30 Jul 1998 13:41:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to change one field in a flat database?
Message-Id: <2oeqp6.4r8.ln@localhost>
Bjorn Malmberg (news@NOSPAM.gb-design.com) wrote:
: Subject: How to change one field in a flat database?
perlfaq, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
Those sound similar to me.
If you are having trouble with some other aspect of your program,
then mention what aspect that is, and someone here will likely
try and help you.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Jul 1998 03:07:23 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: Im Willing to pay or give a free DOMAIN for a custom cgi!
Message-Id: <6prcdb$50g@newsserver.trl.OZ.AU>
Send your $400 cash to GPO Box 235E Melbourne 3001 Australia
and I'll see what I can do :).
method98 (method98@iname.com) wrote:
: Can Anyone Make a Hidden Cgi that clicks on sponser
: undectably to the user viewing the web page and the sponsers
: itself... I am willing to pay Webmasters or Hosters $400 USD with my
: credit card, or buy a DOMAIN to anyone how can make this cgi-script
: and the DOMAIN is for 1 year.
: IT MUST BE 110% UNDECTABLE TO THE SPONSERS AND THE USERS!!!
: if you can make this, email a.s.a.p
: method98@iname.com
: Regards
------------------------------
Date: 30 Jul 1998 15:49:53 GMT
From: ostroj@gsun150.pfizer.com (Jack Ostroff)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <6pq4n1$c3l4@mascagni.pfizer.com>
It's still a homework problem. I have done this in the
long distant past in both Fortran and C.
I'll be real generous and give a hint that you need to
have one or two quoted strings whose values are significant
parts of the program. They can then be used to print both
the program and themselves.
However, I wouldn't be surprised if someone else in
the class points out that this hint was made available.
I think the only way to explain exactly what the problem
is is for you to post YOUR solution when you have one.
Good luck.
------------------------------
Date: Thu, 30 Jul 1998 13:46:38 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: List files by creation date?
Message-Id: <e2fqp6.4r8.ln@localhost>
Curt Cranfield (curt@vphos.net) wrote:
The Unix filesystem does not have any information about when
a file was created.
: Subject: List files by creation date?
So it is not possible to sort by creation date ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 30 Jul 1998 22:20:55 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: tyler <tyler@uakron.edu>
Subject: Re: newbie split question
Message-Id: <35C12A07.667229FB@erols.com>
Yes, you are doing something stupid here. :-) But that's ok; you should
see some of the stupid things I write!
Anyway, chomp removes the line terminator (usually newline) from the end
of a string. So instead of chomping the array, chomp the line.
Next, the ^ is a SPECIAL CHAR in the regular expression you have
specified. It means "the beginning of the string". It is NOT the SHIFT-6
character on your keyboard. Either
1) split on a character expression, not a regexp
2) use the correct regexp
split("^") - char expr
split(/\^/) - regexp expr
If you didn't realize you were using a regexp, well, you need to do some
more studying:
open(MINN,"klaisjul2.txt") || die "no $!\n";
while (<MINN>)
{
chomp; # take the carriage return off
@list=split("^"); # split up the fields
print $list[0],"\n"; # print out first field
}
close(MINN);
Extra bonus question: Just what variable are you really chomping and
splitting?
------------------------------
Date: Thu, 30 Jul 1998 22:17:43 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: newbie split question
Message-Id: <n0drp6.vpa.ln@localhost>
Matthew O. Persico (mpersico@erols.com) wrote:
: Yes, you are doing something stupid here. :-) But that's ok; you should
: see some of the stupid things I write!
^^^^^^^^^^^^^^^^^^^^^
There's another instance of that below...
: It is NOT the SHIFT-6
: character on your keyboard. Either
Huh?
It is on my keyboard...
[
perhaps you are confusing how some editors use a carot to show
control characters?
]
: 1) split on a character expression, not a regexp
What is a "character expression"?
: split("^") - char expr
Oh. What you call a "character expression" is what most folks
call a "string".
: If you didn't realize you were using a regexp, well, you need to do some
: more studying:
If you didn't realize that _you_ were using a regex, well, _you_ need
to do some more studying.
[
Snip code that obviously was not tested, nor was it marked as untested.
We can tell that it was untested because it does not work!
]
Here is a complete (and actually tested) program that illustrates
that "^" does the same thing as /^/:
-------------
#!/usr/bin/perl -w
while (<DATA>)
{
chomp; # take the carriage return off
@list=split("^"); # split up the fields
print "string: '$list[0]'\n"; # print out first field
@list=split(/^/); # split up the fields
print "regex : '$list[0]'\n"; # print out first field
}
__DATA__
first^second^third
-------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 30 Jul 1998 12:32:42 -0700
From: Draco Paladin <paladin@uvic.ca>
Subject: Re: non-perl question about linux
Message-Id: <Pine.A41.3.96.980730122851.22860A-100000@unix4.UVic.CA>
On Thu, 30 Jul 1998, John Porter wrote:
> Brent Verner wrote:
> > distribution of linux to install. if any of you out there are running
> > linux, i'd appreciate your recommendation(s) on which linux to get. i've
To answer Brent's question, I use Slackware 3.4 and haven't had any
problems yet. It's almost as easy as RedHat to set up too. (I've done
both.)
> I've heard that some flavors of linux don't run perl too well --
> compile problems, non-functioning functions, whatever -- and
And to answer John's, like I said above I use Slackware 3.4 and installed
Perl 5.004_04 with no problems at all, and haven't seen any problems with
functions that don't. :)
---------------------------------------------
Mother is the name for GOD on the lips and
hearts of all children. - Eric Draven
------------------------------
Date: Thu, 30 Jul 1998 22:30:23 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Adam Donahue <amd0978@acf2.nyu.edu>
Subject: Re: number (6 -> 06) conversion question
Message-Id: <35C12C3F.896163CB@erols.com>
Looks ok to me. However, in the spirit of there always being a few ways
to say anything in Perl:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
map { ($_ < 10) ? ("0" . $_) : $_ } localtime(time);
This one betrays my roots as a 'C' programmer :-).
Of course, if you need to pass these variables into and out of
subroutines, I'd package them all up like so:
my %hash = undef;
($hash{sec},$hash{min},$hash{hour},
$hash{mday},$hash{mon},$hash{year},
$hash{wday},$hash{yday},$hash{isdst}) =
map { ($_ < 10) ? ("0" . $_) : $_ } localtime(time);
Now, of course, the question begs: Is there a more elegent way of doing
that!
------------------------------
Date: Thu, 30 Jul 1998 22:32:04 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Kevin Williams <kevin@today.com>
Subject: Re: Overriding print??
Message-Id: <35C12CA4.D7219E8B@erols.com>
Make a module, say package MyFunkyPrint.
Write a print function that does what you want.
Change all references to print to MyFunkyPrint::print.
The change can be accomplished easily with sed.
HTH
------------------------------
Date: Thu, 30 Jul 1998 17:54:08 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: George Kuetemeyer <george.kuetemeyer@mail.tju.edu>
Subject: Re: Passing Large Numbers of Parameters to Subroutines
Message-Id: <35C115B0.434C676D@sirius.com>
George Kuetemeyer wrote:
>
> I'm trying to develop a reasonable approach to passing parameters in
> Perl subroutines. Some of my routines require many (often the same)
> parameters, so explicitly passing large numbers of individual parameters
> to subroutines seems ungainly. Usage of global variables is generally
> considered a bad thing, even in Perl (we all know the Perl motto), so
> I've started using a %v hash, which I define in an initialization
> routine and then pass around to various routines as a reference. See
> below for a simple example. This method is working OK for me, but I
> sometimes wonder if I'm not fooling myself. Is passing around that hash
> reference really much different from using global variables?. If I
> misspell a key value, for example, that's the same as misspelling a
> variable name. I'm wondering if anyone can suggest ways to safeguard
> this approach (check for undefined values, etc.) or another approach
> altogether?
>
> -------------------------------------------------Sample
> Code---------------------------------------------------------------------
>
> main: {
> my $v = init_program();
> my %v = %$v;
> $v{newString} = combine_strings($v);
> print_new_string($v);
> }
>
> sub init_program {
> my %v;
> $v{var1} = "The quick brown fox ";
> $v{var2} = "jumped over the lazy dog."";
> # and so on and so forth, maybe params coming in from CGI, etc.,
> references to arrays/other hashes, etc.
> # return reference to hash
> return \%v;
> }
>
> sub combine_strings {
> my $v = shift; my %v = %$v;
> return "$v{var1} $v{var2}";
> }
>
> sub print_new_string {
> my $v = shift; my %v = %$v;
> print "$v{newString}\n";
> }
This is the best way. Take a look at some of the docs that talk about
objects and modules such as perltoot.html and perlobj.html.
I suggest that instead of saying "my %v = %$fv" which copies all
of the keys and values and creates a new hash, you are better off
using the reference directly by refering to things like $$v{newString}.
HTH -- Jim Bowlin
------------------------------
Date: 31 Jul 1998 03:06:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Passing Large Numbers of Parameters to Subroutines
Message-Id: <6prcbc$493$2@client3.news.psi.net>
George Kuetemeyer (george.kuetemeyer@mail.tju.edu) wrote on MDCCXCIV
September MCMXCIII in <URL: news:35C0F949.A7BCD0D2@mail.tju.edu>:
++ I'm trying to develop a reasonable approach to passing parameters in
++ Perl subroutines. Some of my routines require many (often the same)
++ parameters, so explicitly passing large numbers of individual parameters
++ to subroutines seems ungainly. Usage of global variables is generally
++ considered a bad thing, even in Perl (we all know the Perl motto), so
++ I've started using a %v hash, which I define in an initialization
++ routine and then pass around to various routines as a reference. See
++ below for a simple example. This method is working OK for me, but I
++ sometimes wonder if I'm not fooling myself. Is passing around that hash
++ reference really much different from using global variables?. If I
++ misspell a key value, for example, that's the same as misspelling a
++ variable name. I'm wondering if anyone can suggest ways to safeguard
++ this approach (check for undefined values, etc.) or another approach
++ altogether?
Misspelling a key value is actually worse, as 'use strict;' will
catch misspelling a variable name, but not misspelling a hash key
name. (Unless of course you use tied hashes, but that's too much of
a hassle).
What I often do is have the subroutine accept a hash, not a hashref:
function param1 => value1, param2 => value2, param3 => value3;
sub function {
%parameters = @_;
....
}
If you want to call another function with the same, or almost the
same parameters, you can use the %parameters hash, for instance:
sub function {
%parameters = @_;
other_func (%parameters, param2 => other_value2);
}
This of course makes the initial call much longer - but the benefit is
that you don't have to worry about order, or use undefs for parameters
you're not using.
The drawback is again misspelled hash keys - use strict will not get those.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 30 Jul 1998 22:55:37 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Passing Large Numbers of Parameters to Subroutines
Message-Id: <6prbn9$520$1@monet.op.net>
In article <35C0F949.A7BCD0D2@mail.tju.edu>,
George Kuetemeyer <george.kuetemeyer@mail.tju.edu> wrote:
>If I misspell a key value, for example, that's the same as
>misspelling a variable name. I'm wondering if anyone can suggest ways
>to safeguard this approach (check for undefined values, etc.) or
>another approach altogether?
Abigail has a tied hash class which lets you say in advance which keys
are valid; if you try to access an invalid key, the program aborts.
It might be useful here.
See` Strict hashes' at <URL:http://cthulhu.mandrake.net/~abigail/Perl/>.
------------------------------
Date: Thu, 30 Jul 1998 22:45:56 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Arran Price <arranp@datamail.co.nz>
Subject: Re: perl and shell help required - 2 related(?) questions
Message-Id: <35C12FE4.1C5F971E@erols.com>
Arran Price wrote:
>
> Hi all,
>
> Question 2 (which quite possibly is related)
> Some of the user programs which are run, need to use system variables.
> eg export $LD_LIBRARY_PATH=/whatever/ (would generally be typed at the
> shell prompt) is used by a cobol program.
> Is it possible to set these variables from within the perl script.
> Then at a later part of the program run the non perl user program and
> expect it to retain the variables I have exported?
>
>From the perlvar manpage:
$ENV{expr}
The hash %ENV contains your current environment. Setting a value in
ENV changes the environment for child processes.
Try this:
make a file called foo.sh:
#!/bin/shell
echo "envvar FOO=|$FOO|" > foo.dat
Then make a perl script bar.pl:
#!/usr/local/bin/perl
$ENV{FOO}="yoMama";
system("./foo.sh");
1;
If foo .dat contains:
envvar FOO=|yoMama|
all is well.
------------------------------
Date: Sun, 02 Aug 1998 01:00:11 +0000
From: Derek <dereks@fc.hp.com>
Subject: Re: Q:How to "mkdir -p"?
Message-Id: <35C3BA1B.CD3C7A8@fc.hp.com>
Hi, and thanks,
Glad to see I'm not the _only_ one who failed to adequately RTFM. :-)
See Randal's reply, using File::Path.
Cheers,
Derek.
Mark-Jason Dominus wrote:
> In article <35C38061.2BB3EBEB@fc.hp.com>, Derek <dereks@fc.hp.com> wrote:
> >I could write some iterative thing, but I'm sure there's already
> >a tidy solution somewhere.
>
> Hey, if you need to iterate, you have no choice but to iterate.
>
> Although I can imagine a solution where the iteration is buried in a
> `map'.
>
> >Any ideas?
>
> This appears in a program I use a lot, but I haven't ever tested it
> carefully, so beware.
>
> sub mkdir_p {
> my ($dir, $mode) = @_;
> my $pdir = '';
>
> my @components = split(m./., $dir);
> foreach $c (@components) {
> $pdir .= $c . '/';
> next if -d $pdir;
> if (-e $pdir) {
> warn "File `$dir' already exists, but is not a directory! Skipping.\n";
> return 0;
> } else {
> my $pdirp = $pdir;
> chop $pdirp;
> my $rc = mkdir $pdirp, $mode;
> unless ($rc) {
> next if $! =~ /exists/;
> warn "Couldn't make directory `$pdirp': $!. Skipping.\n";
> return undef;
> }
> }
> }
> return 1;
> }
>
> Caution: This is not portable to systems without directories.
------------------------------
Date: Thu, 30 Jul 1998 21:57:11 -0400
From: gregory j pryzby <pryzby@tux.org>
Subject: Variable length exceed?
Message-Id: <35C12477.931C0DD5@tux.org>
I am trying to read a file. I am concatenating lines that should be
together. If the length of the second line is long (447 characters after
chomp), the first line is lost.
Here is sample code:
<IF>;
chomp;
$line = $_;
<IF>
chomp;
$line .= $_;
The file being read:
<meta XXXXX
xxx="dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd">
The second line is 447 characters long.
If I place the data file with:
<one
two or more>
it works fine...
Any ideas?
Thanks.
--
gregory j pryzby | gjp@sddi.com
Founder of Linux Users Group of Manassas | lugman@vtci.com
Check out the Home Pages |
http://www.sddi.com/lugman.html
Love animals-- don't eat them! |
http://www.sddi.com/gjp.html
------------------------------
Date: Thu, 30 Jul 1998 21:58:25 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Variable length exceed?
Message-Id: <hsbrp6.9ka.ln@localhost>
gregory j pryzby (pryzby@tux.org) wrote:
: I am trying to read a file. I am concatenating lines that should be
: together. If the length of the second line is long (447 characters after
: chomp), the first line is lost.
: Here is sample code:
: <IF>;
: chomp;
You should always use the -w switch to enable warnings.
Really!
Always.
(and then, of course, you should not ignore any warning messages)
It would have complained about an uninitialized value for that chomp()
Why?
Because $_ has not been given any value.
<IF>; # read a line of input, and discard it
You probably want to put the line in a variable or something?
$_ = <IF>;
: If I place the data file with:
[snip]
: it works fine...
Maybe _your_ code does.
But I doubt that the code you posted ever works fine.
(unless you are simulating redirecting to /dev/null or something ;-)
: Any ideas?
Nope.
Need code that reproduces the problem...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Jul 1998 16:12:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What's the future of Perl?
Message-Id: <6pq615$k7j$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
qcoldiro@deal.unl.edu writes:
:I have heard some various things about the future versions of Perl. The
:one rumor I heard that excites me the most is that the next release will
:have a compiler, so we can make compiled code if we want, or keep
:running our code as an interpreted script. Is this true? Another thing
:I have wondered is will Perl every get a Case or Switch statement?
Sure, it's there, but it's not what you think it is. The compiler does
not, except in a few very rare cases, do any of these things:
increase security
increase portability
decrease size
decrease runtime
As for a switch statement, we spell that "for",
for ($variable) {
if (/foo/) { ...... }
if (/bar/) { ...... }
# etc
}
Or if you want to have it more syntactically distinct:
for ($variable) {
/foo/ && do { ...... };
/bar/ && do { ...... };
# etc
}
--tom
--
``Imagination is more important than knowledge.''
(A. Einstein)
------------------------------
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 3311
**************************************