[7997] in Perl-Users-Digest
Perl-Users Digest, Issue: 1622 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 12 14:08:00 1998
Date: Mon, 12 Jan 98 11:00:33 -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 Mon, 12 Jan 1998 Volume: 8 Number: 1622
Today's topics:
Re: $2 and $3 are unreliably unset? (Ilya Zakharevich)
Re: A newbie is trying to use perl (George Russell)
alphabetical subset of hash keys (John Capell)
Re: File permissions and umask <kenvogt@sni.net>
Re: Finding the TITLE to a HTML page (brian d foy)
Free Online Computer Books at mcp.com mcp@weblogic.cncoffice.com
Re: LWP problem in a loop (brian d foy)
Re: Mailing binary file <eryq@zeegee.com>
Modem Control through Perl. <corcordt@cs.purdue.edu>
no DBM file on disk? <otis@POPULUS.net>
Re: perl CGI output to server file (brian d foy)
Re: Perl syscall on Irix 6.x <jhi@alpha.hut.fi>
Re: Perl to Binary? (Jeroen Kustermans)
Re: perl under windows95 cwtalbot@intellex.com
Re: perl under windows95 cwtalbot@intellex.com
problem MAKEing perl5 on FreeBSD keng@REMOVETHIS.wco.com
Re: problem MAKEing perl5 on FreeBSD (Mike Stok)
Re: Range Operator (M.J.T. Guy)
Re: simple perl script to add directory to PATH if not (Randy Bey)
Re: Subroutine arguements (newbie) (Tad McClellan)
Test post, ignore <NerveGas@nospam.com>
Re: WHY DOES THIS FAIL? <clark@s3i.com>
Re: win32 drive letters (Ronald L. Parker)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jan 1998 18:43:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: $2 and $3 are unreliably unset?
Message-Id: <69do8r$i6p$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Mike Giroux
<mgiroux@icon.com>],
who wrote in article <34BA4498.B864E845@icon.com>:
> A co-worker asked me if $2 and $3 get unset if a later s// only has one
> set of (). I thought so, but I decided to test it. That works
> properly,
> but what doesn't seem to work reliably is preservation of $1, $2, and $3
> when a match _fails_. From this test case, it looks like the values get
> preserved across one failed match, but not always across the second, and
> this
> only in a while loop. Is there an easy explanation for this??
This is too long. Please prepare the shortest possible test, include
the actual output, the output you expect, and why you expect what you
expect. (Preferably without <DATA>, so it may be pasted into
perl -
).
Ilya
------------------------------
Date: Mon, 12 Jan 1998 17:59:02 GMT
From: george.russell@clara.net (George Russell)
Subject: Re: A newbie is trying to use perl
Message-Id: <34ba566b.1360755@news.clara.net>
Things to do - how can i get code to run when the domain does contain
a match for clara.net?
anyone point me to a simple tutorial on if-then-else type code in
perl? And can anyone tell me
howto count the number of times a certain string or regular expression
(i'm not entriely sure
which it is i want to find, but its probably fragments of an url)
appear in the $file variable?
========================
#!/usr/bin/perl -w
use strict;
# under advice to do so wonder why :-) ho hum, i do know, i'm not a cs
student
# for nothing, my failings in code are multiple :-(
# runs now under strict
# tests for file open failure
use diagnostics;
my $filename = "access.log" ;
my $number=0;
my $i;
my @indata;
#my $claranets=0;
#my $FAQs=0;
my $lines=0;
my $buffer="";
print "Content-type:text/html\n\n";
print "<html><head><title>Access Log</title></head>";
print "<body>";
# from perl faq
open(FILE,$filename) or die "could not open '$filename' $!" ;
while (sysread FILE,$buffer,4096) {
$lines += ($buffer =~ tr/\n// );
}
close(FILE);
open(INF,$filename)|| die "could not open '$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) {
chomp($i);
my($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
# howto excute code when it is equal?
next if $domain =~ /clara\.net$/;
# if when clara.net not at end of string - . is escaped
print <<TABLEROW;
<tr>
<td>$domain</td>
<td>$datetime</td>
<td>$file</td>
<td>$extra1</td>
<td>$number</td>
</tr>
TABLEROW
$number++;
#trying to increment number for display of lines in file excluding
entries including clara.net
#next if $domain == /clara\.net$/;
#$claranets++;
#hopefully count claranets that are excluded from report.
#doesn't work, hmmm
}
#print "<tr><td colspan=5 align=center>";
#print $claranets;
#print "</tr></td>";
print "<tr><td colspan=5 align=center>";
print "Number of Lines in File ";
print $lines;
print "</tr></td>";
print "</table>";
print "</body></html>";
------------------------------
Date: Mon, 12 Jan 1998 17:35:15 GMT
From: jcapellSpamMeNot@mindspring.com (John Capell)
Subject: alphabetical subset of hash keys
Message-Id: <34ba4d7e.7380826@news.mindspring.com>
If I have a large hash, how can I run a routine on just the keys that
start with a certain letter? I want something that looks like:
foreach $key (keysthatstartwithA %myhash) {
print "$myhash{$key}\n";
}
to work like:
foreach $key (keys %myhash) {
if ( substr($key,0,1)=="A" ) { print "$myhash{$key}\n" };
}
but without having to bang through every key in the hash to see if it
starts with 'A' (that just seems inefficient to me)
BTW - this hash is tied to a BTREE Berkely DB, so the hash keys will
be returned in alphabetical order. What I'm trying to do is allow the
user to 'query' the database by letter.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
John L Capell (remove "SpamMeNot" from reply-to eMail) u?u
Montgomery, Alabama
=-=-=-=-=-=-=
http://www.mtgy.net
" Changing the way Montgomery Surfs the 'NET "
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Mon, 12 Jan 1998 10:33:35 -0700
From: Kenneth Vogt <kenvogt@sni.net>
Subject: Re: File permissions and umask
Message-Id: <34BA53EF.D67FDABA@sni.net>
So if I want xrw_rw_rw would I use:
umask 011;
or
umask 0011;
or something else?
Tom Christiansen wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> Kenneth Vogt <kenvogt@sni.net> writes:
> :umask 755;
>
> You forgot many things, like a leading 0 for octal, and
> remembering that umask specifies bits to turn off, not on.
>
> You usually want one of these:
>
> umask 022;
> umask 002;
> umask 027;
> umask 007;
>
> I suggest the first one.
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
>
> Hey, I had to let awk be better at *something*... :-)
> --Larry Wall in <1991Nov7.200504.25280@netlabs.com>1
--
Kenneth Vogt
KenVogt@sni.net
http://ModernShopping.com
Buy Tupperware(r) products right on the WWW!
------------------------------
Date: Mon, 12 Jan 1998 13:54:55 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Finding the TITLE to a HTML page
Message-Id: <comdog-ya02408000R1201981354550001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34B95334.10C6846C@tcs.co.at>, mahe@tcs.co.at posted:
>brian d foy wrote:
>
>> In article <34B69098.EAC50B34@tcs.co.at>, mahe@tcs.co.at posted:
>> >if (/<title>(.*)<\/title>/si){print $1;}
>> hasn't it already been shown why this doesn't work?
>No.
>I'v tested it and it worked (with perl5)
time for a more broad range of sample input then (and time to
read up on the past responses)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 12 Jan 1998 17:48:03 GMT
From: mcp@weblogic.cncoffice.com
Subject: Free Online Computer Books at mcp.com
Message-Id: <MPG.f2411e6972d13e0989732@news.ais.net>
Mcp.com, the Web site for Que, Sams, and other Macmillan computer book
publishers, has free full-text books online. If you register in
mcp.com's *Personal Bookshelf,* you can have up to 5 active books online,
and you can change books at any time. The books are active for 90 days.
Then you can choose 5 different books - or choose the same ones. The
company has a little over 150 books that it rotates. Topics include
Visual C++ , Visual Basic, and Database Programming; Perl, TCP/IP ,
ActiveX, HTML, Java, and JavaScript; Web graphics; and general
productivity applications. The Personal BookShelf is located at:
http://www.mcp.com/personal/
------------------------------
Date: Mon, 12 Jan 1998 13:50:34 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: LWP problem in a loop
Message-Id: <comdog-ya02408000R1201981350340001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34ba6b66.3282719@news.imaginet.fr>, Gilles.Maire@ungi.com posted:
>I use LWP and lauch requests on 200 Web pages. After 10 requests
>qorking fine I have the message : Can-t resolve address xxxx ...
i like to use URI::URL when working with LWP. helps to weed out the
bad addresses.
>Any idea ?
time to practice the same debugging techniques one would use for
any other problem :)
> open ( F1, "<sniffer.in" ) ;
> @URL=<F1> ;
>foreach ( @URL )
just a digression, since i like to be nice to memory and to be
scalable - wouldn't you rather
while( defined($url = <F1>) ) { ... }
--
brian d foy <comdog@computerdog.com>
Fifth Avenue Disaster! <URL:http://computerdog.com/brian/fire/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 12 Jan 1998 12:54:11 -0500
From: Eryq <eryq@zeegee.com>
Subject: Re: Mailing binary file
Message-Id: <34BA58C3.5D94@zeegee.com>
Khemarath Choke-Mangmi wrote:
> use Net::SMTP;
> use MIME::Base64;
(snip)
> ## change MIME type here
> $smtp->datasend("Content-Type: IMAGE/GIF; name=\"home.gif\"\n");
>
> $smtp->datasend("Content-Transfer-Encoding: BASE64\n\n");
>
> ## change filename here
> open(FILE, "gif/home_icon.gif");
> while (read(FILE, $buf, 60*57)) {
> $smtp->datasend(encode_base64($buf));
> }
As long as you're using the MIME:: modules, why not make life
easier on yourself? Might I suggest...
use MIME::Lite;
# Create a new single-part message, to send a GIF file:
$msg = new MIME::Lite
From =>'me@myhost.com',
To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'Helloooooo, nurse!',
Type =>'image/gif',
Encoding =>'base64',
Path =>'hellonurse.gif';
$msg->send;
You could also print() the message to an SMTP stream,
if you want to bypass sendmail altogether.
See http://www.enteract.com/~eryq/CPAN/MIME-Lite for
documentation and code. Attachments, etc. are also
easy, BTW:
$msg = new MIME::Lite
From =>'me@myhost.com',
To =>'you@yourhost.com',
Subject =>'Your GIF file',
Type =>'TEXT',
Data =>"Here's the GIF file you wanted";
attach $msg
Type =>'image/gif',
Path =>'/foo/bar.gif';
HTML docs on-line at:
http://www.enteract.com/~eryq/CPAN/MIME-Lite/docs/
Hope that helps,
--
___ _ _ _ _ ___ _ Eryq (eryq@zeegee.com)
/ _ \| '_| | | |/ _ ' / President, Zero G Inc: http://www.zeegee.com
| __/| | | |_| | |_| | "Talk is cheap. Let's build." - Red Green.
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: Mon, 12 Jan 1998 11:23:25 -0600
From: David Corcoran <corcordt@cs.purdue.edu>
Subject: Modem Control through Perl.
Message-Id: <34BA518D.5CB442EE@cs.purdue.edu>
I am trying to figure out a way in perl to dial a phone number (which
could be done through dip.) but communicating out the modem and
receiving data from the modem. I'm not sure if this could be done with
a handle or what. I am using Linux. Any suggestions ?
Thanks
Dave
corcordt@cs.purdue.edu
------------------------------
Date: Mon, 12 Jan 1998 13:34:02 -0500
From: "Otis Gospodnetic" <otis@POPULUS.net>
Subject: no DBM file on disk?
Message-Id: <69dock$2qh2@tortola.acunet.net>
Hello,
I wrote the following little piece of test-code to check memory (RAM)
consumption of large DBM files as they are created.
Problem 1: no .dir and .pag files were created on disk when I started
running this script. Any idea why?
Problem 2: as the DBM gets larger (larger loop) the memory (RAM) consumption
grows (e.g. 70 MB RAM). Why is that? I thought DBMs get stored on the disk
and are not held in RAM (then the size of DBM/loop wouldn't matter)
use NDBM_File;
$dbQQQ = tie %QQQ, "NDBM_File", "Q-QQQ", O_RDWR|O_CREAT, 0640;
foreach (1 .. 500000) {
$QQQ{"skdjflksdjfksjlkdfjsdlkjfisodjfliasjcnzxcmzxnccsdfisdhfjcxznvmxn"}++;
print "$_\n";
}
untie (%QQQ);
__END__
Thanks!
Otis
------------------------------
Date: Mon, 12 Jan 1998 13:59:10 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl CGI output to server file
Message-Id: <comdog-ya02408000R1201981359100001@news.panix.com>
Keywords: from just another new york perl hacker
In article <199801121231001006293@cybertron132.cybertron.at>, bernard@look.in.signature (Bernard M. Piller) posted:
>I am just starting to learn Perl. I want to write a little cgi that
>records the version of the browser that is accessing pages on my web
>server.
your server might already be able to do this for you...
>How can a cgi script invoked by a client visiting a web page, write the
>ENV data of the client to a file on the server?
you may want to check the CGI Meta FAQ or ask in a more appropriate
newsgroup such as comp.infosystems.www.authoring.cgi.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 12 Jan 1998 19:53:08 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Perl syscall on Irix 6.x
Message-Id: <oeeoh1h37gb.fsf@alpha.hut.fi>
Chris Mihaly <cmihaly@fa.disney.com> writes:
>
> We downloaded Perl 5.003 and build it for the IRIX 6.2 system and it
> does not contain the syscall.ph header file. The Perl manual (O'Reilly)
> mentions that there are special installation instructions to get syscall
> (says its in the install file), but it is not.
> How do I get this file?
>
> Chris
# cd /usr/include
# h2ph sys/syscall.h
h2ph shoull be installed in the same directory where your Perl binary
(really) is. If not, the Perl you installed (supplied by SGI?) (why
5.003? There is 5.004_04) is incomplete (or you have not installed
all of it?) and I suggest you get the latest stable Perl source code
release from
http://www.perl.com/CPAN/src/latest.tar.gz
Unpack that, read INSTALL, and so on.
Note also that the h2ph translator is not perfect, it may produce
a syscall.ph (which gets installed where the Perl is installed, btw)
that does not parse. Meaning: when you try to use it from Perl,
you are in effect where you started: you may not have a (working)
syscall.ph.
Last but not least: for what application do you need the syscall.ph?
Using it should not be necessary for any modern application.
P.S. Now, I do get free Disneyworld tickets? :-)
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Mon, 12 Jan 1998 16:56:41 GMT
From: NightLight@webcity.nl.WEGSPAM!!!!!! (Jeroen Kustermans)
Subject: Re: Perl to Binary?
Message-Id: <34bd3203.13169680@news.xs4all.nl>
On 11 Jan 1998 00:54:32 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:
: [courtesy cc of this posting sent to cited author via email]
:
: In comp.lang.perl.misc, jwbacon@ix.netcom.com (J. Bacon) writes:
: :There is a shareware Perl compiler available (cost is $35, it works on the
: :ActiveState port build 3.13+ and has at least one 'bug').
:
: I'm virtually certain that this is not a real compiler. If
: it claims that, they're either prevaricating or I'm very
: highly confused.
:
: --tom
Can anybody make a version which is for free?
This should a great weapon against the Money-Earning-Demobuilder.
Greets,
Jeroen
P.S.: for email-reply, remove ".WEGSPAM!!!!" from the email-address.
NightLight, your online reporter from Aruba, the dutch Carribean
Website: http://NightLight.webcity.nl
------------------------------
Date: Mon, 12 Jan 1998 11:02:52 -0600
From: cwtalbot@intellex.com
Subject: Re: perl under windows95
Message-Id: <884624328.1618739206@dejanews.com>
In article <01bd1eb9$96f71480$da3063c3@dns.btinternet.com>,
"Duncan Cameron" <duncan.cameron@btinternet.com> wrote:
>
> 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)
>
>
Thank you for you response suggesting I run the program from DOS. I
should have indicated in my original message that I had already tried
that, and got a message stating "This program cannot run in this mode"
Thanks again.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 12 Jan 1998 11:12:17 -0600
From: cwtalbot@intellex.com
Subject: Re: perl under windows95
Message-Id: <884624767.1604517901@dejanews.com>
I already tried that. The screen flashes with black page and a one line
message, but the exlporer screen returns before I can read the message. I
changed the program to print several lines to force the page to stay
longer, but that didn't work. The one line that is displayed must be an
error message of some kind, but it disappears before I can read it.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 12 Jan 1998 17:35:19 GMT
From: keng@REMOVETHIS.wco.com
Subject: problem MAKEing perl5 on FreeBSD
Message-Id: <69dk8n$68$1@news.ncal.verio.com>
Hello;
This morning I tried to build Perl 5 (from "latest.tar.gz" on Perl.com)
on FreeBSD 2.2.5-RELEASE and ran into the following error messages during
the MAKE:
gcc -L/usr/local/lib -o miniperl miniperlmain.o libperl.a
/usr/lib/libcrypt.a
pp.o: Undefined symbol `_pow' referenced from text segment
pp.o: Undefined symbol `_atan2' referenced from text segment
pp.o: Undefined symbol `_sin' referenced from text segment
pp.o: Undefined symbol `_cos' referenced from text segment
pp.o: Undefined symbol `_exp' referenced from text segment
pp.o: Undefined symbol `_log' referenced from text segment
pp.o: Undefined symbol `_sqrt' referenced from text segment
pp.o: Undefined symbol `_floor' referenced from text segment
pp.o: Undefined symbol `_floor' referenced from text segment
*** Error code 1
can anyone help me fix this? Please remove the REMOVETHIS from
my e-mail address before replying.
Thanks!
-Ken
------------------------------
Date: 12 Jan 1998 13:20:35 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: problem MAKEing perl5 on FreeBSD
Message-Id: <69dmtj$19n$1@stok.co.uk>
Looks like you're missing -lm from the list of libraries to link against.
There should be a config.sh in the directory where you built perl, chewck
the line beginning with
libs=
and see if it has -lm in it. If it doesn't you might like to try adding
-lm and then reading the comment at the beginning of config.sh to see how
to propagate your change.
Hope this helps,
Mike
In article <69dk8n$68$1@news.ncal.verio.com>, <keng@REMOVETHIS.wco.com> wrote:
>Hello;
>
>This morning I tried to build Perl 5 (from "latest.tar.gz" on Perl.com)
>on FreeBSD 2.2.5-RELEASE and ran into the following error messages during
>the MAKE:
>
>gcc -L/usr/local/lib -o miniperl miniperlmain.o libperl.a
>/usr/lib/libcrypt.a
>pp.o: Undefined symbol `_pow' referenced from text segment
>pp.o: Undefined symbol `_atan2' referenced from text segment
>pp.o: Undefined symbol `_sin' referenced from text segment
>pp.o: Undefined symbol `_cos' referenced from text segment
>pp.o: Undefined symbol `_exp' referenced from text segment
>pp.o: Undefined symbol `_log' referenced from text segment
>pp.o: Undefined symbol `_sqrt' referenced from text segment
>pp.o: Undefined symbol `_floor' referenced from text segment
>pp.o: Undefined symbol `_floor' referenced from text segment
>*** Error code 1
>
>can anyone help me fix this? Please remove the REMOVETHIS from
>my e-mail address before replying.
>
>Thanks!
>-Ken
>
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 12 Jan 1998 17:46:13 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Range Operator
Message-Id: <69dkt5$o6h$1@lyra.csx.cam.ac.uk>
In article <34BA4220.CA0CAE0C@sdrc.com>, Joe Kline <Joe.Kline@sdrc.com> wrote:
>
>I was passing a list slice into another list and got some
>unexpected results.
Because you wrote
> @temp = $inputs[ 1 .. $#inputs ];
when you meant
@temp = @inputs[ 1 .. $#inputs ];
Mike Guy
------------------------------
Date: Mon, 12 Jan 1998 17:26:12 GMT
From: randolph.a.bey@norwest.com (Randy Bey)
Subject: Re: simple perl script to add directory to PATH if not there already
Message-Id: <34ba510a.327224093@relay>
On Fri, 09 Jan 1998 13:32:07 GMT, randolph.a.bey@norwest.com (Randy
Bey) wrote:
>Greetings,
>I am hoping to someday be able to do this myself, but.....
>does anyone have a perl script that adds a directory to a PATH if the
>directory is not already in the PATH? So that it could be invoked as
>in:
>
>eval `add_to_path.pl /some/directory`
>
>to add "/some/directory" to your path if it wasn't already there, or
>just output your PATH if it already was?
>
OK, I wasn't too clear the first time around. Here is what I came up
with via a script that maybe explains what I want to do better. I
tried it with an associative array first, (much simpler logic that
way) but the darned associated array always printed out sorted(!)
which is not necessarily what you want in a good PATH.
Sooo, you would use this script ala:
eval `add_to_path.pl /my/new/directory`
and it would either echo out your new PATH or nothing if the directory
was already included.
#! /usr/local/bin/perl
# add_to_path.pl
# Usage: eval $(add_to_path.pl /new/dir /another/new/dir)
$ This means we need to output a PATH
$gotone = false ;
# Scarf the existing PATH from the environment
$path = $ENV{PATH};
# Split it up into a bunch of directories
@patharray = split( /:/, $path );
# Run through the command line arguments and add them to the end of
@path
# if they are not there already.
while ( $ARGV[$j] ) {
# We track if any directories are matched with this var
$notthere = true ;
# Run through the path directories in search of a match
while ( $patharray[$i] ) {
if ( $patharray[i] eq $ARGV[j] ) {
$notthere = false ;
}
# Next!
$i++
}
if ( $notthere eq true ) {
# It's not there, so add it to the end
$path=$path . ":" . $ARGV[j] ;
$gotone = true ;
}
$j++ ;
}
if ( $gotone eq true ) {
print "PATH=$path\n";
}
Disclaimer: My words and opinions are my own,
and Norwest neither is aware of or endorses anything
I say or do. Actually, Norwest would throw me to
the wolves if it came down to it.
And now, for some tasty spammer bait:
root@127.0.0.1
postmaster@127.0.0.1
webmaster@127.0.0.1
info@127.0.0.1
sales@127.0.0.1
fraud@UU.NET (MassMail Complaint)
spam-complaint@UU.NET (Usenet Complaint)
abuse@hotmail.com
net-abuse@nocs.insp.irs.gov
fraud@uspis.gov
fraudinfo@psinet.com
piracy@spa.org
postmaster@fbi.gov
contact@bsa.nl
downwithwarez@hotmail.com
postmaster@cyberpromotions.com
postmaster@cyberpromo.com
postmaster@mail-promo.com
FreeWay5@dm1.com
toby@becsplace.com
associates@savoynet.com
wmgroupr@pobox.com
51189123456@aol.com
74072325@compuserve.com
abanks@ultramax.net
link-signup@chac.com
frick@bigfoot.daltek.net
05838448@ibm.net
nobber@ibm.net
computerphys@hotmail.com
privuser@mailexcite.com
Important@usa.net
456S15P1008@juno.com
1mktg00@juno.com
members@your.com
netbiz@03403.com
neil@venus.gmds.com
homedirectory@hotmail.com
webtech@mmaildirect.com
dstadler@savoynet.com
Majordomo-Owner@rtfm.be
sendnim@15509.com
52614725@ismi.net
Racanaw@TRIValley.com
harmony@ultra-mail.com
39988580@hotmail.com
UcanDoit@hotmail.com
UcanDoit@kolomiec.rosmail.com
charel@cyberopp.com
aarica@chacaltaya.com
nt@ntec.net
1056_fred@flash.net
2760_ur@careeropp.com
deserthome@worldnet.att.net
MoneyMaker18@juno.com
associates@bigfoot.daltek.net
panzer@goplay.com
2700_dave@cymx.net
osgood@aixmiced.mi.unicatt.it
------------------------------
Date: Mon, 12 Jan 1998 10:25:17 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Subroutine arguements (newbie)
Message-Id: <d5gd96.mf2.ln@localhost>
John Walker (john@5points.net) wrote:
: Excuse me if this is an obvious question...
It's not obvious to me what your question _is_ ;-)
: I want to write a subroutine that accepts a single arguement. This
: arguement would be the name of the file to operate on, and the name of
: the variable which the subroutine returns. The returned variable is an
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Subroutines return _values_, not variables (though the value returned
might be taken from a variable, or put into a variable).
: associative array.
: To put it another way... I want to call
: &snarfffile(somefile);
^^^^^^^^ needs quotes, no barewords
: which manipulates the file somefile and returns a value %somefile.
Sounds to me like you want to define a global hash named %somefile?
Global variables are Bad, and I can't bring myself to help someone
use them.
How about if you called it this way instead?
%somefile = snarfffile('somefile');
That will be inefficient if the hash is of any appreciable size. If so,
then use a reference to a hash instead (see perlref man page)
: Getting the varible to be named %somefile is what's giving me fits.
You might be able to do something with 'Symbolic references',
also documented in 'perlref'.
Anyway, here is an inefficient psuedo-perl way to get close to what
I think you are asking for:
%somefile = snarfffile('somefile');
sub snarfffile {
my($filename) = @_;
my(%hash);
open(IN, $filename) || die...
...
$hash{first_key} = 'first value';
$hash{second_key} = 'second value';
return %hash; # return hash flattened out into one big list
}
Returning a reference would be Much Better...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 12 Jan 1998 09:30:36 -0700
From: NerveGas <NerveGas@nospam.com>
Subject: Test post, ignore
Message-Id: <34BA452C.2869@inconnect.com>
Hey... I said ignore this!
: )
steve
------------------------------
Date: 12 Jan 1998 11:54:11 -0500
From: Clark Dorman <clark@s3i.com>
Subject: Re: WHY DOES THIS FAIL?
Message-Id: <dsoqtbpl8.fsf@elmo.s3i.com>
"Shade L. Jenifer" <sjenifer@isc.mds.lmco.com> writes:
> when I run this code:
>
> $x = "yes";
> ($x eq "yes") ? $y = "YES\n" : $y = "NO\n";
> print $y;
>
> I expect(ed) "YES\n" to be written to STDOUT. However,
> "NO\n" appears. Why is this?
Hmm....I don't know why it does this. However, this is not the way
that I would use the test statement, since the whole idea is to use
the return value. I think that you really want:
$y = ($x eq "yes") ? "YES\n" : "NO\n";
--
Clark
------------------------------
Date: Mon, 12 Jan 1998 16:49:00 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: win32 drive letters
Message-Id: <34bb478e.12626095@10.0.2.33>
On Fri, 09 Jan 1998 16:23:28 +0100, "Peter J. Acklam"
<jacklam@ulrik.uio.no> wrote:
>> Is there a way to get a list of drive letters on a win32 system?
>> Eg it might return something like ( 'a:', 'c:', 'd:', 'e:' ).
>
>I don't have a Win32 machine here, so this is untested.
>I think this should work, though
>
> @drives = grep( -e "$_:\\", "a" .. "z" );
This works, but it complains when there is no disk in a removable
drive, such as a floppy, PC Card, or CD-ROM drive (which describes 4
of the 6 drives on my machine - that's a lot of errors.) There is a
Windows API function, SetErrorMode(0x8000), that may be called to
disable this message. You'll probably need the Win32::API module to
execute it, unless someone's created a dedicated module for this
purpose.
------------------------------
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 1622
**************************************