[7993] in Perl-Users-Digest
Perl-Users Digest, Issue: 1618 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 11 16:07:29 1998
Date: Sun, 11 Jan 98 13:00:26 -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 Sun, 11 Jan 1998 Volume: 8 Number: 1618
Today's topics:
Re: [Help] Capturing STDOUT under DOS ? <swarren@eclipse.net>
Re: [Help] Capturing STDOUT under DOS ? (William Byrd)
Re: A newbie is trying to use perl (Tad McClellan)
Re: A newbie is trying to use perl (George Russell)
Re: How can i create a file in perl? <mine@mycom.com>
Re: How to modify master variables from a forked thread <rootbeer@teleport.com>
Re: How to modify master variables from a forked thread (Andrew M. Langmead)
Re: How to move a directory to another level in NT? <swarren@eclipse.net>
Re: how to put % in replace text of s///??? <rparr@temporal.com>
Re: Looping through hashes (Andrew M. Langmead)
Re: Mailing binary file <rootbeer@teleport.com>
Password protection and control <JochenBuehler@gmx.net>
Re: Perl oddity... <rootbeer@teleport.com>
Re: perl under windows95 <duncan.cameron@btinternet.com>
remote file transfer and edit (Mike Otter)
Re: Scheduler service doesn't see Perl file association <swarren@eclipse.net>
Re: serious post about gmtime and year-1900 <Russell_Schulz@locutus.ofB.ORG>
Re: simple perl script to add directory to PATH if not <swarren@eclipse.net>
Re: simple perl script to add directory to PATH if not <swarren@eclipse.net>
Sorry (was: req: A) Perl/Tk ...) (TheTom)
Re: Unpacking length-infor style data. <rjc@liddell.cstr.ed.ac.uk>
Re: WWW-pages generated by Perl-scripts <ken@bitsko.slc.ut.us>
Re: WWW-pages generated by Perl-scripts (Tad McClellan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Jan 1998 14:43:37 -0500
From: "Stephen Warren" <swarren@eclipse.net>
Subject: Re: [Help] Capturing STDOUT under DOS ?
Message-Id: <69b7em$2qq$1@news.eclipse.net>
>In article <34B6F815.46DA@erols.com>, wtansill@erols.com wrote:
>>Under DOS/Windows STDOUT may be redirected at will regardless of the
>>source. STDERR can't be redirected from the command prompt (unlike
>>UNIX).
Under WinNT at least (using cmd.exe not command.com perhaps), you can do:
perl script.pl > stdout.txt 2> stderr.txt
or
perl script.pl > output.txt 2>&1
--
-----------------------------------------------------------------
Stephen Warren, Systems Engineer, Technology House Inc., New York
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@eclipse.net http://www.eclipse.net/~swarren/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Sun, 11 Jan 1998 22:22:37 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: [Help] Capturing STDOUT under DOS ?
Message-Id: <69baqn$9bv$2@winter.news.erols.com>
On Fri, 09 Jan 1998 23:24:53 -0500, "William B. Tansill, III"
<wtansill@erols.com> wrote:
>Jan Krynicky wrote:
>>
>> Augusto Cardoso wrote:
>> >
>> > What can I do to capture the output of Perl programs to a disk file
>> > insted of screen ? I tried all "redirection" and other "piping" I
>> > could think of, no results!
>> > Ex.
I've never had any problem using
perl myscript.pl >outfile.txt
to generate a file under win95
-----------------------------------------------------
Please always check the syntax before applying any fix
anyone gives you on a newsgroup, no one is perfect.
Not everyone reads the newgroups every day, but most
check their e-mail. A private e-mail with the answer
as well as the NG posting is often appreciated.
Just my 2 cents worth.
------------------------------
Date: Sun, 11 Jan 1998 11:25:20 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A newbie is trying to use perl
Message-Id: <0ava96.jq4.ln@localhost>
George Russell (george.russell@clara.net) wrote:
[snip]
: I'd like it to be able to reverse the order
: the rows in the table are displayed, so that the latest entries in the
: log are first in the table, and the oldest is at the bottom.
: reverse(@indata) doesn't seem to work - has anyone any ideas?
It will work fine if you use it correctly ;-)
: If you
: do, could you include source code with your suggestions as well, as
: i'm a newbie.
^^^^^^^^^^^^
a *Very Good Idea* is to use the -w switch on ALL of your scripts.
It would have pointed out something wrong with your use of reverse()...
Try it and see.
: I'd also like to display a number in the table in each
: row to indicate the number of the entrie in the log file, but at the
: moment it will start at 0, and increment once to 1, and never beyond
: this point - why?
: ===============================================================
: #!/usr/bin/perl
#!/usr/bin/perl -w
use strict; # also a Very Good Idea...
: $filename = "access.log";
: $number=0;
: print "Content-type:text/html\n\n";
: print "<html><head><title>Access Log</title></head>";
: print "<body>";
:
: open(INF,$filename);
open(INF,$filename) || die "could not open '$filename' $!";
Always check the return value from open() calls.
Really.
Always.
[snip]
: reverse(@indata);
Reverse the elements of the @indata, and then throw them away...
-w complains...
: foreach $i (@indata) {
foreach $i (reverse @indata) {
Reverse the elements of the @indata, and then iterate through the
reversed elements.
: chop($i);
: ($domain,$dash1,$dash2,$name,$garbage,$get,$file,$extra1,$extra2,$extra3)
: =split(/\ /,$i);
^
^
You don't need to backwack the space there.
With a recent version of perl, you can (if you want to) use 'undef'
in the above list for elements that you don't plan to use:
($domain,undef,undef,$name,undef,undef,$file,$extra1,undef,undef)
=split(/ /,$i);
Or, just get the ones you want in the first place:
($domain,$name,$file,$extra1) = (split(/ /,$i))[0,3,6,7];
: # HERE, see if the variable $domain contains a match for
: # "clara.net". See the "perlre" and "perlop" manpages
: next if $domain =~ /clara.net/;
This will also match if:
$domain = 'santaclara.net';
and also:
$domain = 'clara-net';
and even:
$domain = 'clara.net.us';
See 'perlre' and 'perlop' yet again ;-)
Then you may want to go with something like:
next if $domain =~ /\bclara\.net$/;
^^ ^^ ^
^^ ^^ ^ require it to be at end of string
^^ ^^
^^ ^^ escape the dot to get a literal dot
^^
^^ match a "word boundary"
: print "<tr>";
: print "<td>$domain</td>";
: print "<td>$name</td>";
: #actually $name is the date and time
: print "<td>$file</td>";
: print "<td>$extra1</td>";
: print "<td>$number</td>";
: print "</tr>\n";
Using a "here-doc" sure would make the above printing code easier
to read and maintain.
Your style of indenting is a little odd too...
print <<ENDSTUFF;
<tr>
<td>$domain</td>
<td>$name</td>
<td>$file</td>
<td>$extra1</td>
<td>$number</td>
</tr>
ENDSTUFF
That puts them on separate lines rather than mashing it altogether
on a single output line.
: ++($number ='$number');
Not sure what you were trying to do there.
Maybe increment the value in $number by one?
$number++;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 11 Jan 1998 20:28:34 GMT
From: george.russell@clara.net (George Russell)
Subject: Re: A newbie is trying to use perl
Message-Id: <34b928f8.232459@news.clara.net>
On Sun, 11 Jan 1998 11:25:20 -0600, tadmc@flash.net (Tad McClellan)
wrote:
Thanks for the help, btw.
> use strict; # also a Very Good Idea...
I get a lot of error mesg's and finally refuses to run.
Any idea why i get "symbol requires explicit package name" and
"variable is not imported"
Works without it.
>: print "<tr>";
>: print "<td>$domain</td>";
>: print "<td>$name</td>";
>: #actually $name is the date and time
>: print "<td>$file</td>";
>: print "<td>$extra1</td>";
>: print "<td>$number</td>";
>: print "</tr>\n";
>
>Using a "here-doc" sure would make the above printing code easier
>to read and maintain.
>
>Your style of indenting is a little odd too...
It doesn't survive too well between kedit in linux, then to windows
and agent.
>print <<ENDSTUFF;
><tr>
><td>$domain</td>
><td>$name</td>
><td>$file</td>
><td>$extra1</td>
><td>$number</td>
></tr>
>ENDSTUFF
>
>That puts them on separate lines rather than mashing it altogether
>on a single output line.
Gives me the error " can't find string terminator anywhere before EOF"
My new and improved version
======================================================
#!/usr/bin/perl -w
# use strict;
# under advice to do so wonder why :-)
#not yet - it won't run
# tests for file open failure
use diagnostics;
$filename = "access.log" || die "could not open '$access.log'
$!" ;
$number=0;
print "Content-type:text/html\n\n";
print "<html><head><title>Access Log</title></head>";
print "<body>";
open(INF,$filename);
@indata = <INF>;
close(INF);
print "<table border=1>";
print
"<tr><th>Domain</th><th>Time</th><th>File?</th><th>HTTP</th><th>No</th></tr>\n";
foreach $i (reverse @indata) {
chop($i);
($domain,$datetime,$file,$extra1) =(split(/
/,$i))[0,3,6,7];
#take only needed stuff adjust numbers to pick stuff
# stuff seperated by spaces
# HERE, see if the variable $domain contains a match for
# "clara.net". See the "perlre" and "perlop" manpages
next if $domain =~ /clara\.net$/;
# if when clara.net not at end of string - . is escaped
#print <<TABLEROW; gives an error reverting to earlier
print "<tr>";
print "<td>$domain</td>";
print "<td>$datetime</td>";
print "<td>$file</td>";
print "<td>$extra1</td>";
print "<td>$number</td>";
print "</tr>\n";
#TABLEROW can't be found before eof , hmmmm
$number++;
#trying to increment number for display of lines in file
excluding entries including clara.net
#actually $name is the date and time
}
print "</table>";
print "</body></html>"
------------------------------
Date: Sun, 11 Jan 1998 12:47:37 -0500
From: "Phil" <mine@mycom.com>
Subject: Re: How can i create a file in perl?
Message-Id: <34b90697.0@news.one.net>
OK, I've got a question, how would you chmod that file once it's created?
Phil
Sebastian Kaps wrote in message <697kpt$1pi$1@toyland.sauerland.de>...
>In article <697ghg$5rt$1@news2.isdnet.net>
>Anthony DIMINO wrote:
>
> AD> I would want to write into files,but in perl you can't write into a
not
> AD> existing file?
>
>???
>"open(FILE, ">" . $filename)" creates a new file at least on my System
>(Linux 2.0.33).
>--
>Ciao, Sebastian
>
>* Email: toyland@sauerland.de
>* HP: www.sauerland.de/~toyland/ PGP-Key available
------------------------------
Date: Sun, 11 Jan 1998 09:56:04 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ansel Sermersheim <AGSerm@netwizards.net>
Subject: Re: How to modify master variables from a forked thread?
Message-Id: <Pine.GSO.3.96.980111095516.12363I-100000@user2.teleport.com>
On Sat, 10 Jan 1998, Ansel Sermersheim wrote:
> I've managed to get it to block properly using semaphores but I can't
> get the forked server proccess to modify the master hashes.
It sounds as if you have one process which needs to hand some information
off to another. If that's the case, the methods in the perlipc manpage
should be able to help. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sun, 11 Jan 1998 19:09:20 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How to modify master variables from a forked thread?
Message-Id: <EMMvvK.Enz@world.std.com>
AGSerm@netwizards.net (Ansel Sermersheim) writes:
>The problem I'm having is this: Most of the time, the request will be
>for a chunk of data built on the fly from two fairly static hashes.
>However, occasionally a client will upload a piece of information that
>needs to be integrated into the data. At this point, I'd like to have
>the server block for a moment until it recalculates the data, and then
>continue.
The quote that you cited doesn't apply. fork()ing doesn't create a new
thread, but a new process, with its own memory space. (initially
starting with a copy of memory identical to its parent, but any
changes to its variables are entirely independant.)
You'll have to design some way for the child processes to communicate
to the parent. Then have the parent update its hashes on a request
from the child. (and if necessary, have the parent then update the
other children about the change in data and update their copies of the
parents data.)
In parent/child interprocess communication, often the best method is a
call to pipe(). If the parent has to be modified so that it is not
only waiting for new connections, but also waiting for data from its
children, then you might want to take a look at the select() call. (In
perl, often called the "four argument select" to differentiate itself
from the entirely different "one argument select".
--
Andrew Langmead
------------------------------
Date: Sun, 11 Jan 1998 14:47:09 -0500
From: "Stephen Warren" <swarren@eclipse.net>
Subject: Re: How to move a directory to another level in NT?
Message-Id: <69b7lb$360$1@news.eclipse.net>
Angy wrote in message <34B82048.20A5@interport.net>...
>How can I move a directory in NT to another level using Perl?
>e.g. move c:\temp\dir_1 to c:\perl\source\code\dir_1
>("rename" seems not working)
Read the NT documentation (what little there is...) to find out what works
when you type it manually at the command prompt, then simply system() it.
e.g. the following should work:
system( "move c:\\temp\\dir_1 to c:\\perl\\source\\code\\dir_1" )
== 0 || die "err msg" ;
Perhaps the problem you had was using \ instead of \\ in the paths.
--
-----------------------------------------------------------------
Stephen Warren, Systems Engineer, Technology House Inc., New York
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@eclipse.net http://www.eclipse.net/~swarren/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Sun, 11 Jan 1998 10:59:25 -0600
From: "Randall J. Parr" <rparr@temporal.com>
To: Neil Sedley <neil@nsedley.dircon.co.uk-antispam>
Subject: Re: how to put % in replace text of s///???
Message-Id: <34B8FA6D.C253DA8E@temporal.com>
perl -v -->
This is perl version 5.003 with EMBED built under svr4 at Sep 27 1996 + suidperl
security patch.
I believe it was installed from the UnixWare packaged version obtained from
www.freebird.org. This is also the newest version available via SCO Skunkworks
as well.
R.Parr
Neil Sedley wrote:
> Randall J. Parr wrote in message <34B7AC72.85BF50BB@temporal.com>...
> >How can I include a "%" (percent sign) in the replacement text of the
> >s/// command.
> >
> >The following line
> >
> >s~\\begin{DBTable}~<TABLE BORDER WIDTH=100%>\n<TR><TH>Name</TH></TR>~g
> >
> >produces
> >
> ><TABLE BORDER WIDTH=10
> ><TR><TH>Name</TH></TR>
> >
> <snip>
>
> Which version of Perl are you using? I have tried the latest builds for both
> Unix and NT and neither produces the results you describe.
>
> Neil Sedley
------------------------------
Date: Sun, 11 Jan 1998 18:54:02 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Looping through hashes
Message-Id: <EMMv62.8pC@world.std.com>
mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
>Andrew M. Langmead <aml@world.std.com> wrote:
>>
>>and of course, if you are going to add one element and then exit out
>>of the loop, you might as well just add it and break out, the messing
>>up of the iterator only happens on the next iteration.
>>
>>while(($key,$val) = each %myhash) {
>> if($somecondition) {
>> $myhash{parrot} = 'silly bird';
>> last;
>> }
>>}
>Beware. That will leave the iterator for %myhash in a mess. When
>using each(), always make sure that you iterate to the end of the hash.
>(Unless of course you don't plan to iterate over the hash ever again.)
True, although you can always fix the iterator with a call to keys()
in either a scalar or a void context.
keys %myhash;
--
Andrew Langmead
------------------------------
Date: Sun, 11 Jan 1998 10:26:43 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Khemarath Choke-Mangmi <mike@hq.npc.co.th>
Subject: Re: Mailing binary file
Message-Id: <Pine.GSO.3.96.980111102623.12363N-100000@user2.teleport.com>
On Sun, 11 Jan 1998, Khemarath Choke-Mangmi wrote:
> open(FILE, "gif/home_icon.gif");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sun, 11 Jan 1998 20:16:26 +0100
From: "Jochen Buehler" <JochenBuehler@gmx.net>
Subject: Password protection and control
Message-Id: <34b919b4.0@news.swol.de>
Dear Reader!
Is it possible to open passwords only 5 respectively 10 times/month?
So that the user can only input his password and username 5/10 times per
month. Does
there exist a possiblitity to realize this?
I`m not to good in programing Java, so I would be very pleased for any help!
I look forward to hearing from you...
Sincerely
Jochen
------------------------------
Date: Sun, 11 Jan 1998 10:07:27 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Big Ape <bigape@grungyape.com>
Subject: Re: Perl oddity...
Message-Id: <Pine.GSO.3.96.980111100559.12363J-100000@user2.teleport.com>
On Fri, 9 Jan 1998, Big Ape wrote:
> EDP#: 216 Quantity: 4 Total: 24.839999999999999858
If you want a particular output format for numbers, use (s)printf to
specify it. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 11 Jan 1998 17:51:55 GMT
From: "Duncan Cameron" <duncan.cameron@btinternet.com>
Subject: Re: perl under windows95
Message-Id: <01bd1eb9$96f71480$da3063c3@dns.btinternet.com>
The installation of Perl should have modified your autoexec.bat to have the
perl.exe in your PATH. To run a script then all you have to do is run a
DOS prompt and then
perl myscript.pl (assuming that you're in the right directory)
------------------------------
Date: Sun, 11 Jan 1998 19:44:54 -0000
From: motter@netcentral.co.uk (Mike Otter)
Subject: remote file transfer and edit
Message-Id: <MPG.f23318e63fc840a989680@news.netcentral.co.uk>
Can anyone help me with a perl project, I need to find a way of
copying a file from a novell server to my nt box, and once on
my box I need to rename the file to reflect the date of the transfer.
Once the file has been copied, I need to send a empty file back
to the novell server. I need to keep some form of log file,
any of you tech heads able to help ????
------------------------------
Date: Sun, 11 Jan 1998 14:52:53 -0500
From: "Stephen Warren" <swarren@eclipse.net>
Subject: Re: Scheduler service doesn't see Perl file associations??
Message-Id: <69b803$3cl$1@news.eclipse.net>
>You will note that Perl is NOT in the PATH which is also strange
>because it is has been set in the Control Panel/System/Environment...
You need to reboot the machine to update the schedule services after
they're changed in CP... (Basically, the updates only affect new
processes, or those spawned by explorer.exe/progman.exe, but the service
control manager is what starts/stops the schedule service and it never
re-starts except on reboot)
This probably also applies to assoc/ftype settings too.
>I also tried changing "c:\foo\bar.pl" to "perl c:\foo\bar.pl". Still
>wouldn't work. It finally worked with I changed the line to
>
>c:\Perl5\bin\perl c:\foo\bar.pl
This is simply because perl.exe wasn't in the PATH. Reboot and you should
be able to schedule "perl c:\foo\bar.pl" fine.
I'd recommend not scheduling just "bar.pl" - I/O redirection doesn't seem
to work quite right doing this...
>I should add that I am not having this problem on any of
>my Intel servers?
You've probably rebooted them since installing Perl?
--
-----------------------------------------------------------------
Stephen Warren, Systems Engineer, Technology House Inc., New York
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@eclipse.net http://www.eclipse.net/~swarren/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Sun, 11 Jan 1998 14:37:55 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: serious post about gmtime and year-1900
Message-Id: <19980111.143755.9J3.rnr.w164w_-_@locutus.ofB.ORG>
[ I changed the Subject: for those who have killfiled the y2k jokes ]
phenix@interpath.com (John Moreno) writes:
>>> but what your local C library does is beyond anybody except the people
>>> using it.
>>
>> such as the people using perl, if you compiled it locally.
>
> Yes, they are the ones that know.
only if they test it. the people building perl may not know.
>> which doesn't address the people who don't compile perl locally, and
>> want to have emprical reassurance that it works as documented.
>
> Ok, serious question. Do you know of any implementation of the current
> version of Perl which doesn't do the right thing?
irrelevant -- if I say `yes' or `no', it doesn't say much except that
I'm ignorant of any problems. especially since I don't use perl on
many platforms.
I assume that if there WAS such an implementation, it would have its
own special notice in the FAQ, to warn people about it.
oh right, but only if it was tested for. nasty disclaimer, that.
> There's no more reason to expect this not to work than there is to
> expect something like printf or chdir.
I agree entirely. do we test printf or chdir? should we stop?
>> I think that any decision as bad as returning 98 for 1998 and 101 for
>> 2001 should be documented, with examples past the border case, so the
>> implementors know how to get it right, and users know what to expect.
>
> It *IS* documented
`...with examples past the border case'?
> Straight from perlfunc for gmtim: "Also, $year is the number of years
> since 1900, not simply the last two digits of the year."
nope.
and that sentence could be replaced by ``so 1998 returns 98, and 2001
returns 101'', which is SHORTER AND CLEARER.
> The thing is that it's not such a particularly bad representation
> - the only disadvantage in using it is for people who don't read
> the documentation.
if you truly believe this, then you should probably killfile me now,
because I gave up on that ``users should read every line of the
documentation before starting, because half of the things they will
use are unintuitive'' way of thinking long ago.
well, I hope I did. I really try. my users may disagree. :-(
> After reading the documentation, anybody who doesn't believe what it
> plainly says can check it out very easily.
even easier if it's a perl test script, right? aren't there a bunch
of those test scripts that already ship with Perl? why are they there?
> Should there be test code for every perl function to show that it
> does what the documentation says it does?
for a lot of them, yes. how many errata have you seen for printf?
I've seen a few. do you think printf is important enough to test?
do you think there is software that is used but shouldn't be tested?
> Doing this for the regex functions is going to be a bit, how
> shall I put it, *difficult*.
how many regex errors have you seen? do you think those were caused
by people who are morons, or people who made an error? if the latter,
do you think sufficient testing would have caught them? if so, why
do you think insufficient testing was done?
or are you implying that there are regex features which are not
testable (even in isolation)? (obviously, even a nonmalicious
programmer could have a regex error where regexes of exactly 256
bytes didn't work, but I'm not talking about errors of this type.)
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Sun, 11 Jan 1998 14:56:41 -0500
From: "Stephen Warren" <swarren@eclipse.net>
Subject: Re: simple perl script to add directory to PATH if not there already
Message-Id: <69b877$3nf$1@news.eclipse.net>
The way I do this kind of thing is:
I have a Perl script e.g. setup.pl
I setup an alias (I use tcsh) to execute the script:
setup alias to 'eval `/path/setup.pl !*`!
and get setup.pl to print():
set var=value
or
setenv var value
Alternatively, you could get the Perl script to generate a .sh/.csh file
that you then . or source in your shell after executing the Perl script.
You could then wrap the execution of the Perl script, .-ing/source-ing of
the generated shell script and deletion of the shell script, that you . or
source instead of running the Perl script directly.
--
-----------------------------------------------------------------
Stephen Warren, Systems Engineer, Technology House Inc., New York
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@eclipse.net http://www.eclipse.net/~swarren/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Sun, 11 Jan 1998 14:58:50 -0500
From: "Stephen Warren" <swarren@eclipse.net>
Subject: Re: simple perl script to add directory to PATH if not there already
Message-Id: <69b8b7$3nk$1@news.eclipse.net>
Justin Vallon wrote in message
<1998011102322499585@user-37kb34g.dialup.mindspring.com>...
>case $PATH in
>*:$new:*|*:$new|$new:*) ;;
>*) PATH=$new:${PATH}
>esac
Maybe replace line two with:
*:$new:*|*:$new|$new:*|$new) ;;
^^^^^
--
-----------------------------------------------------------------
Stephen Warren, Systems Engineer, Technology House Inc., New York
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@eclipse.net http://www.eclipse.net/~swarren/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Sun, 11 Jan 1998 20:31:17 GMT
From: the.tom@usa.net (TheTom)
Subject: Sorry (was: req: A) Perl/Tk ...)
Message-Id: <69b7of$esb$1@freenet-b.fen.baynet.de>
Hi all,
I am sorry. Usually I dont post in german lang into
an english groups. This time my posting went (by
accident) into comp.lang.perl.misc instead of
de.comp.lang.perl.
Nevertheless - meaning: even more - I want to thx all
ppl who tried to help me w/ my req.
will be more carefull next time
tom
---
sig censored in physical layer --- The Stack
------------------------------
Date: 11 Jan 1998 18:24:43 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: Unpacking length-infor style data.
Message-Id: <eyhn2h2c1hw.fsf@liddell.cstr.ed.ac.uk>
In article <Pine.GSO.3.96.980108131322.26818f-100000@user2.teleport.com>, Tom Phoenix (tp) writes:
tp> while (length $data) {
tp> my $len = unpack "s", $data;
tp> push @list, unpack "x2a$len", $data;
tp> $data = substr($data, $len+2);
tp> }
More or less what I'm doing (I found strlen was a bit quicker to get
the data as you don't have to build the unpack template).
However, after several years of perling I've become firmly convinced
that whenever I have a straight forward way of doing something, there
is probably a one line equivalent which is an order of magnatude
faster. This is one of the few easy cases I have hit where that seems
not to be the case.
--
rjc@cstr.ed.ac.uk _O_
|<
------------------------------
Date: 11 Jan 1998 11:46:21 -0600
From: Ken MacLeod <ken@bitsko.slc.ut.us>
Subject: Re: WWW-pages generated by Perl-scripts
Message-Id: <m3btxi7vkh.fsf@biff.bitsko.slc.ut.us>
tadmc@flash.net (Tad McClellan) writes:
> Honza Pazdziora (adelton@fi.muni.cz) wrote:
> : "Paul Weingarten" <paulweingarten@hotmail.com> writes:
>
>
> : > $filename = "data.txt";
>
> : No use strict and no my.
>
> ... and using double quotes when there is nothing to interpolate.
I thought that was optimized out? If not, I've got a lot of editing
to do...
--
Ken MacLeod
ken@bitsko.slc.ut.us
------------------------------
Date: Sun, 11 Jan 1998 13:21:39 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: WWW-pages generated by Perl-scripts
Message-Id: <346b96.695.ln@localhost>
Ken MacLeod (ken@bitsko.slc.ut.us) wrote:
: tadmc@flash.net (Tad McClellan) writes:
: > Honza Pazdziora (adelton@fi.muni.cz) wrote:
: > : "Paul Weingarten" <paulweingarten@hotmail.com> writes:
: >
: >
: > : > $filename = "data.txt";
: >
: > : No use strict and no my.
: >
: > ... and using double quotes when there is nothing to interpolate.
: I thought that was optimized out? If not, I've got a lot of editing
^^^^^^^^^^^^^
: to do...
It appears that it is:
--------------------------
#!/usr/bin/perl -w
use Benchmark;
timethese(10000000, {
'single' => q/$filename='data.txt'/,
'double' => q/$filename="data.txt"/,
});
--------------------------
outputs:
Benchmark: timing 10000000 iterations of double, single...
double: 24 secs (23.77 usr 0.00 sys = 23.77 cpu)
single: 23 secs (23.34 usr 0.00 sys = 23.34 cpu)
But my reason for implying that it is "bad" has to do with
maintenance, not execution speed.
When reading code, I _expect_ interpolation when double quotes are
used. It is a futile distraction for me to examine the quoted
stuff only to find out that it is a constant string, which I
would have expected (ie. known immediately) were it single quoted.
I hope to eliminate as many "brain farts" as possible for the poor
souls that need to make sense of my code after I'm gone ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 1618
**************************************