[11725] in Perl-Users-Digest
Perl-Users Digest, Issue: 5325 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 8 01:07:21 1999
Date: Wed, 7 Apr 99 22:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Apr 1999 Volume: 8 Number: 5325
Today's topics:
Re: =~tr / / /; problem (George)
Re: =~tr / / /; problem (Larry Rosler)
Re: =~tr / / /; problem <uri@home.sysarch.com>
Re: buggy counter? (Ronald J Kimball)
Create hyperlink from a table cell to a file.... <seugenio@man.amis.com>
Re: Debugger has problems with forking programs. (Ronald J Kimball)
Re: determining the browser? (George)
Re: Dyn-IP "wanna be" 1-liner (Matthew Bafford)
Getting info out of acees Databases (BXTC)
Re: How to compile (perlcc) *.pm, then "use" it? vishalb@my-dejanews.com
Re: my random doesn't return number!! (Ronald J Kimball)
Re: perl reading files/text from commandline under NT (Ronald J Kimball)
problems choosing choice in menu buiding scrpt <gavin@optus.net.au>
Re: Quantum Variable (Ronald J Kimball)
Re: removing the \n at the end of a variable rjshank@postoffice.swbell.net
Re: removing the \n at the end of a variable (Matthew Bafford)
Re: removing the \n at the end of a variable (Larry Rosler)
Re: RFC: new module File::FlockDir (long) (Ronald J Kimball)
Re: Trouble with DBI and Oracle (Darren Greer)
Re: Trouble with DBI and Oracle <jliedeka@facstaff.wisc.edu>
Re: Whre did this GREAT Perl Reference go?? (I R A Aggie)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Apr 1999 22:38:34 -0400
From: fred222@mauimail.com (George)
Subject: Re: =~tr / / /; problem
Message-Id: <fred222-ya023580000704992238340001@news.bellatlantic.net>
In article <m3yakbx9so.fsf@joshua.panix.com>, Jonathan Feinberg
<jdf@pobox.com> wrote:
> Cplee <cplee@bigfoot.com> writes:
>
> > I would like to convert " to " in" by use =~ tr/\" /in/;
> > but not successful
>
> the tr// operator works on individual characters; it does not work on
> arbitrary expressions. You'll need to learn about the s// operator,
> documented in perlop.
I just thought I'd explain a little more. The tr/// operator is the
"transliterate" operator. It lets you, for instance, switch all the letter
A's to letter B's, and all the B's to A's (this isn't possible with the
s///, or substitute, operator).
The general form of the substitute operator is:
s/old-string/new-string/variables;
where variables can be many many letters that change how it works. For
instance, "g" lets it replace multiple copies it runs into, while without
the g it will only do the first. "i" is another, that sets it to ignore
case.
Read up on it, or buy "Learning Perl" from O'Reilly.
Cheers,
George
--
Just another hacking head >l-d
------------------------------
Date: Wed, 7 Apr 1999 20:31:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: =~tr / / /; problem
Message-Id: <MPG.1175c2e524380793989861@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <fred222-ya023580000704992238340001@news.bellatlantic.net> on
Wed, 07 Apr 1999 22:38:34 -0400, George <fred222@mauimail.com >says...
> In article <m3yakbx9so.fsf@joshua.panix.com>, Jonathan Feinberg
> <jdf@pobox.com> wrote:
> > > Cplee <cplee@bigfoot.com> writes:
> > > I would like to convert " to " in" by use =~ tr/\" /in/;
> > > but not successful
> >
> > the tr// operator works on individual characters; it does not work on
> > arbitrary expressions. You'll need to learn about the s// operator,
> > documented in perlop.
>
> I just thought I'd explain a little more. The tr/// operator is the
> "transliterate" operator. It lets you, for instance, switch all the letter
> A's to letter B's, and all the B's to A's (this isn't possible with the
> s///, or substitute, operator).
Oh, sure it's possible. It's just very, very slow.
#!/usr/local/bin/perl -w
use Benchmark;
timethese(1 << (shift || 0), {
S => sub { (my $x = 'AABBBxxxBABABABA') =~
s/([AB])/$1 eq 'A' ? 'B' : 'A'/eg },
Tr => sub { (my $x = 'AABBBxxxBABABABA') =~ tr/AB/BA/ },
});
Benchmark: timing 65536 iterations of S, Tr...
S: 12 wallclock secs (11.59 usr + 0.00 sys = 11.59 CPU)
Tr: 1 wallclock secs ( 0.72 usr + 0.00 sys = 0.72 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 08 Apr 1999 00:09:46 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: =~tr / / /; problem
Message-Id: <x73e2bu511.fsf@home.sysarch.com>
>>>>> "G" == George <fred222@mauimail.com> writes:
G> I just thought I'd explain a little more. The tr/// operator is
G> the "transliterate" operator. It lets you, for instance, switch
s/transliterate/translate/
transliterate means spelling a word in one human language so it sounds
like one in another, e.g. almost anything you see written using english
syllables from chinese or hebrew (my name being transliterated from
hebrew).
G> A's to letter B's, and all the B's to A's (this isn't possible with the
G> s///, or substitute, operator).
as larry showed, it is possible with s/// but slower and clumsier. t///
is meant just for that simple function and to do it fast. you actually
see many newbies doing things with s/// that would be better with t///
like squeezing multiple spaces to one, etc.
G> The general form of the substitute operator is:
G> s/old-string/new-string/variables;
G> where variables can be many many letters that change how it works. For
is many > 7 ? not by my standards. and they are not called variables,
but modifiers.
G> Read up on it, or buy "Learning Perl" from O'Reilly.
you should do some more reading yourself!
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 8 Apr 1999 00:14:05 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: buggy counter?
Message-Id: <1dpwuk7.7cn9rh10k2036N@p75.block2.tc1.state.ma.tiac.com>
Manida Ivan <mis@sparc.spb.su> wrote:
> #!/usr/bin/perl
>
> my $data_file = "../data/visits.cnt";
>
> open(COUNT,"$data_file") || die "can't open counter file";
> my $count = <COUNT>;
> close(COUNT);
> chop($count) if $count =~ /\n$/;
>
> $count++;
>
> open(COUNT,">$data_file") || die "couldn't write";
> &lock(COUNT);
> print COUNT "$count";
> &unlock(COUNT);
> close(COUNT);
> my $file;
> sub lock {
> $file = @_;
> flock($file,2);
> seek($file, 0, 2);
> }
>
> sub unlock {
> $file=@_;
> flock($file,8);
> }
You're doing at least four things wrong here.
First, you open the file twice. Even assuming you locked the file when
you opened it for reading, you'd still have a problem; you unlock the
file, open it for writing, and then lock it again. In between, another
process may have also read the file, and the processes will increment
the counter at the same time, rather than one after the other. Two
processes, but only one incrementation.
Second, you unlock the file before you close it, and without flushing
the buffers. If another process accesses the file after the unlock and
before the close, the file will be empty.
Third, you open the file for writing, then lock it. This means the file
contents are clobbered before the file is locked. Another process could
access the empty file before it is locked.
Fourth, you assign @_ in scalar context. $file = @_; results in $file
getting the number of elements in @_, not the first element. I'm not
sure what this does with flock(); you may be locking STDOUT (fd 1).
Solution: open the file _once_, for read _and_ write access. Lock the
file. Read. Seek to the beginning. Write. Close _without_ unlocking
-- closing the file unlocks it for you. Assign in list context, or use
shift.
open(COUNT, "+<$data_file")
or die "Can't open $data_file for read/write: $!\n";
&lock(COUNT);
chomp($count = <COUNT>);
seek(COUNT, 0, 0) or die "Can't seek to beginning of $data_file: $!\n";
print ++$count;
close(COUNT);
use Fcntl qw(:flock);
sub lock {
my($file) = @_;
flock($file,LOCK_EX);
}
The Fcntl module gives you the system's lock constants, rather than the
non-portable literal numbers you were using.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 8 Apr 1999 02:50:00 GMT
From: "Sheila Eugenio" <seugenio@man.amis.com>
Subject: Create hyperlink from a table cell to a file....
Message-Id: <01be816a$680a6220$2bbe10ac@amipnet>
I have this txt file from an extraction. 15,16, etc are workweeks. Now what
I will do here is parse the file and present it as neatly as I can by using
a table. I have done that so far. Now the user wants me to create a
hyperlink for the NO_WIP/INSUF row of digits under each workweek to
nowip15.txt, nowip16.txt etc. for more info on the data.
This is a rolling info meaning there's a report every week. I wanted it to
be automated such that whatever the workweek is, the script can adjust to
it. I was able to create a hyperlink from a cell. But I cannot create a
hyperlink let's say to <a href =http://company/revenue/nowip$wk.txt >??</a>
if it will change from time to time. (I hope you got what I am trying to
say here) :-)
REVENUE PLAN (APRIL)
WIP_POSITION DELINQUENT 15 16 17
18 TOTAL %
NO_WIP/INSUF 92.99 246.00 331.26 684.10
816.88 2171.23 15.05
SORT 11.52 312.78 170.81
330.98 462.07 1288.16 8.93
DIEBANK-FTA 5.06 5.97 33.91
109.08 107.49 261.51 1.81.
Here's my code:
while ($line = <FILE>) {
chop ($line);
if ($line =~ /^REVENUE/) {
print HTML "<H3>$line</H3>";
print HTML "<H5><b>As of $date, Manila</b></H5><p>";
} elsif ($line =~ /^WIP/) {
@heading = split(/ +/, $line);
foreach $head (@heading) {
print HTML "<th bgcolor=FFCCCC>$head</th>";
}
} elsif ($line =~ /^SORT/) {
@sort = split(/ +/, $line);
} else {
@array = split(/ +/, $line);
foreach $word (@array) {
print HTML "<td><p align=right>$word</td>";
}
}
print HTML "</tr>\n<tr>";
}
Please HELP me. They need this posted on our Intranet ASAP Thank you for
whatever help you can give me.
------------------------------
Date: Thu, 8 Apr 1999 00:14:07 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Debugger has problems with forking programs.
Message-Id: <1dpwwdh.17e0izho42xxcN@p75.block2.tc1.state.ma.tiac.com>
William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de> wrote:
> You send me mail, you get mail back and I don't have the slightest
> notion of why you would care if the rest of the newsgroup knows if
> you got an Email Cc: or not. If you're all that het up about it, I
> suggest you just killfile all mails with Newsgroups: in the header
> and be happy.
No, he cares because he went to all the trouble of responding via
private mail, and then discovered that you had copied him on a newsgroup
posting, and he had to go to the further trouble of repeating his
response in the newsgroup.
The problem is not that the newsgroup didn't know he got a copy, but
that he didn't know the newsgroup got a copy.
If you're going to Cc: someone on a newsgroup post, then include a note
to that effect at the top of the message.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 07 Apr 1999 22:34:42 -0400
From: fred222@mauimail.com (George)
Subject: Re: determining the browser?
Message-Id: <fred222-ya023580000704992234420001@news.bellatlantic.net>
> I suppose the real question is why would you want to determine the
> browser type at all? Valid, portable HTML should render equally well in
> MSIE, Netscape Navigator/Communicator, Lynx, NCSA Mosaic, and
> what-have-you.
Heh, that's what originated my .. original post on this subject, the fact
that different damned browsers display the same HTML in vastly different
ways. My original HTML lined up the backgrounds in seven frames perfectly
in IE, but under netscape the far left was placed too close. I have all my
pages generated by perl scripts, so knowing how to differentiate browsers
allowed me to make one's frameset about 5 pixels wider, fixing the problem.
And no, Mr. Lynx, I don't want you at my site! ;-)
Actually I was thinking of doing something completely text-based as an
option for it, to accomodate both Lynx browsers and low-bandwidth connects,
but I am loath to venture away from the beautiful GUI stuff I've been
doing. Not that I don't like lynx, I've used it before for some time and
it's some fun schtuff ;)
Right now I'm just using an if-useragent-contains-MSIE, then we spit up the
MSIE html, else the netscape. I'd much rather have a way of identifying
the netscape and doing the rest in the IE code, but c'est la vie I suppose.
Best regards,
George
--
Just another hacking head >l-d
------------------------------
Date: Thu, 08 Apr 1999 02:05:36 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Dyn-IP "wanna be" 1-liner
Message-Id: <slrn7gnupn.m2.dragons@dragons.duesouth.net>
7 Apr 1999 22:25:17 GMT -- Andrew Allen <ada@fc.hp.com>:
-> Hmmm... I'm confused. Why do you need to "de-dupe" if you're going to
-> use the first element anyways... looks like another '\.' crept in after
-> the final "255". Also, couldn't the IP start with a single 1-9
-> digit, needing '[1-9]\d*' instead of '[1-9]\d+'?
*shrug* his code -- I barely even looked at it... :-)
Yep, another \. slipped in.
IPs could start with a single digit, I guess. Never looked at the
RFC, to tell you the truth. Again, his code.
Also, the -Mstrict doesn't work like I thought. Not sure how that
slipped by me.
-> Unfortunately, I don't any 'route' output available, but it seems like
-> you should be able to replace
One of the lines:
216.98.0.30 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
-> map{/([1-9]\d*\.\d+\.\d+\.\d+)/}grep{/ppp/}map{split/s+/}
->
-> with something like
->
-> /ppp[^s]*([1-9]\d*(?:\.\d+){3})/g
->
-> (or maybe the 'ppp' is after, I don't know--are you really splitting
-> on the letter 's'???). I guess these suggestions yield:
perldoc perlre
The \s is any whitespace.
-> #!/usr/bin/perl -wl -Mstrict
-> print+(grep{!/(255\.){3}255/}`/sbin/route -n`=~/ppp[^s]*([1-9]\d*(?:\.\d+){3})/g)[0];
Doesn't do the same thing at all...
$ perl ./andrew_huh
5.255.255.255
$ perl ./matthew_huh
216.98.0.30
$
Really, if I was going to write the same thing, I'd probably do:
#!/usr/bin/perl -w
print "216.98.0.30\n";
Since route doesn't give you your IP address, rather the address
you're sending all your data to (ie: your ISP's). Mine hasn't
changed in about 2 years.
If you want your IP address, you want the script to be short, and
insist on using an external command, how about:
#!/usr/bin/perl -w -n -l -000
BEGIN{@ARGV='/sbin/ifconfig|'} next if !
/^p/;print+(/((\d+\.){3}\d+)/gx)[0];exit
or maybe:
#!/usr/bin/perl -w -a -n -U -l -000
BEGIN{@ARGV='/sbin/ifconfig ppp0|'}
print+(/((\d+\.){3}\d+)/xg)[0];exit
This also has the very great advantage of being a perfect block!
Unfortunatly for this thread, it's not that obfuscated.
Hope This Helps!
-> Andrew
--Matthew
------------------------------
Date: Thu, 08 Apr 1999 04:23:52 GMT
From: "(BXTC)" <bxtc@forfree.at>
Subject: Getting info out of acees Databases
Message-Id: <370D39C8.C1BFA672@forfree.at>
Hi, at work we run windows and have some access database files....I have
been tasked with getting some info out of them using linux and Perl.
Basically I need to extract the info. My boss wants me to try it to see
if we could eventually use it on our website...it there a module or easy
way to do this....I am still a novice perl person. I looked at CSPAN
and saw data base stuff but not "access" specific, did I miss one or is
there a common "setup" used and it would be classified under a different
name? Any help would be appriciated , thanks.
(BXTC) ICQ# 23289202
------------------------------
Date: Thu, 08 Apr 1999 02:48:29 GMT
From: vishalb@my-dejanews.com
To: mtaylor@cybernet.com
Subject: Re: How to compile (perlcc) *.pm, then "use" it?
Message-Id: <7eh5dr$ad9$1@nnrp1.dejanews.com>
In article <7eb1fs$72i$1@nnrp1.dejanews.com>,
mtaylor@cybernet.com wrote:
> I've been investigating on how to use something like "perlcc" (the B::CC
> backend) to compile a .pm file, and the "use" it in a script.
>
> The straightforward approach does not work:
> perlcc x.pm
> mv x.pm x.pm.old
> perl -e 'use x qw(); &x::somefunction();'
>
> The "use x" will not load x.so (it only looks for x.pm).
>
> I imagine that I somehow have to use the DynaLoader to bring in x.so? Do I
> have to do anything wierd with the xs stuff?
Yes, you would have to do that
See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1998-10/msg01722.html
if you have not figured it out.
Although plans exist, not much has been done to automate the module
compilation bit. Most of the compiler work has been on compiling scripts with
modules preloaded.
Your chances of success depend on
1. What version of perl you are using.
None of the released versions are very good at the compiler. Among the
development versions, I think 5.005_57 would be pretty good once it comes out
(should be fairly soon now). 56 and 55 are slightly broken wrt compiler. 54
does work but not as well 57 should.
2. You are not using any features that compiler doesnot support that are
documented in the B::CC man page.
3. You are not using any features that compiler doesnot support that are not
documented in the B::CC man page. Currently sort,goto do not work.DATA
filehandle is unimplemented. And there are quite a few bugs.
>
> Also, x.so has too many symbols: it includes compile-time dependencies that
> are needed. So, if x.pm "uses" y.pm, then the y.pm functions referenced in
> x.pm will be compiled into x.so. This is not what I wanted...
Again, plans exist to make that possible, but currently that is not possible.
A trivial workaround is to edit a file called B/C.pm and locate a function
called "should-save" and add this line on the top
return ("$package" eq "x::");
where x is the package you want.This would save only package "x".
when you run perlcc .
>
> Any ideas on:
> 1) How to get "x.so" to load in from another perl script?
> 2) Reduce the symbols in x.so to only those found in x.pm?
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 8 Apr 1999 00:14:10 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: my random doesn't return number!!
Message-Id: <1dpwxuu.1uuhb291mngylmN@p75.block2.tc1.state.ma.tiac.com>
Philip Newton <Philip.Newton@datenrevision.de> wrote:
> Bart Lateur wrote:
> >
> > The "keyword step" is unnecessary, anyway. The keyword itself is never
> > retained! Just an array of the *values* of the hash is enough!
> >
> > @value = values %hash;
> > return $value[int(rand @values)];
>
> The "@value" step is unnecessary, anyway. The array itself is never
> retained! Just writing the two lines in one is enough!
>
> return $value[int(rand values %hash)];
>
> Unless I am missing something?
Yes. You're missing the initialization of the array @value.
Just because it isn't retained doesn't mean it isn't used. ;)
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 8 Apr 1999 00:14:11 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: perl reading files/text from commandline under NT
Message-Id: <1dpwz7f.1exvekml90l7dN@p75.block2.tc1.state.ma.tiac.com>
Eric Von Zee <evonzee@tritechnet.com> wrote:
> if (@$ARGV = "") {@message = &get_message_text;}else{@message = @ARGV;}
@$ARGV has nothing to do with the @ARGV array. @$ARGV treats the value
of the scalar $ARGV as an array reference, and dereferences it.
You want simply:
if (not @ARGV) { ... }
@ARGV is in a scalar context there, which gives you the number of
elements in array. If @ARGV is empty, then 'scalar(@ARGV)' is 0, and
'not scalar(@ARGV)' is true.
See perldata.
> $msg = "@_"; # I guess this is like join(" ", @_); ???
Actually, it's join($", @_). $" is simply the special variable that is
used when you say "@array". The default value of $" is ' '; if you
don't change it, "@_" is in fact join(" ", @_), as you guessed.
See perlop and perlvar.
> I guess what I really need to know is what does @$ do to an array (and
> how do I use it), and why does it act differently when in a 'if' check
> or not?
@$array is actually @ applied to $array; as I said above, this has to do
with references. You probably don't need to worry about it for now, but
when you're ready to start using references, you should refer to
perlreftut or perlref.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 08 Apr 1999 04:01:52 GMT
From: Gavin Cato <gavin@optus.net.au>
Subject: problems choosing choice in menu buiding scrpt
Message-Id: <370C2A26.67B131FD@optus.net.au>
hello all,
I am building a program for route updating etc.. for our customers.
The part of the script I'm having problems with is the bit that reads in the .cfg files that I have created (1 for each
customer) and builds a menu for it.
It then must take a choice from the menu and choose the correct config file.
The problem is , no matter what number you type it always chooses "1"
I think the problem might be with my
$dummy = 0;
if ($choice > $dummy) {
do blah
}
This is because I need to check IF the argument is *NUMERIC*. Was the only way my limited perl head could do it :(
A few choices aren't coded in yet e.g. QUIT from the menu aren't in there yet.
The way I am building the menu is doing a ls *.cfg, and matching $. with the input from the user to grab the correct cfg. The
idea works in my head and when I put debugging print statements in it appeared to work ok..anyway you'll see what i mean by
reading the script.
here is the script, comments greatly appreciated.
#!/usr/local/bin/perl -w
#
# maintain-customer.pl
#
# Used for adding / deleting customers
$basedir = "/optus";
$custdata ="/customers";
&get_mainmenu;
sub get_mainmenu {
system("clear");
print "Customer maintenance menu;\n";
print "\n";
&get_customers;
print "\n";
print "A. Add a customer\n";
print "D. Delete a customer\n";
print "Q. Quit\n";
print "Choice?";
$choice = <STDIN>;
chomp $choice;
$dummynumber = "0";
if ($choice eq "a") {
system(" $basedir/addcustomer.pl\n");
&get_customers;
&get_mainmenu;
}
if ($choice > "0") {
system(" cd $basedir$custdata ; ls *.cfg > /tmp/temp.list.customers ; cd $basedir ");
open(LIST, "</tmp/temp.list.customers") or die "Can't open listing\n";
while (<LIST>) {
if ($choice = "$.") {
$configfile = $_;
open(CUST_CONFIG, "<$basedir/$custdata/$configfile") or die "Error opening
$configfile\n";
while (<CUST_CONFIG>) {
if (/Routes:/) {
$method = (split/:\s+/) [1];
chomp $method;
if ($method eq "RADB") {
system ("$basedir/editcustomer-radb.pl $configfile
");
&get_customers;
&get_mainmenu;
}
if ($method eq "Manual") {
system ("$basedir/editcustomer-static.pl $configfile
");
&get_customers;
&get_mainmenu;
}
print "Error: I could not determine the type of routing used for this
customer. \nExpected RADB or Manual but got $method\n";
sleep 2;
&get_customers;
&get_mainmenu;
}
}
}
}
}
close LIST;
system (" rm -f /tmp/temp.list.customers ");
}
print "Invalid or unimplemented option.\n";
sleep 1;
&get_customers;
&get_mainmenu;
sub get_customers {
system(" cd $basedir$custdata ; ls *.cfg > /tmp/temp.list.customers ; cd $basedir ");
open(LIST, "</tmp/temp.list.customers") or die "Can't open list\n";
while (<LIST>) {
$menunumber = $.;
$configfile = $_;
open(CURRENTCONFIG, "<$basedir/$custdata/$configfile") or die "Can't open $configfile!! \n";
while (<CURRENTCONFIG>) {
chomp $_;
if (/Custname:/) {
$custname = (split/:\s+/) [1];
}
if (/ASNum:/) {
$asnum = (split/:\s+/) [1];
}
}
print "$menunumber\. $custname \(AS$asnum\)\n";
}
close LIST;
system (" rm -f /tmp/temp.list.customers ");
}
------------------------------
Date: Thu, 8 Apr 1999 00:14:16 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Quantum Variable
Message-Id: <1dpx186.a14ctih056i2N@p75.block2.tc1.state.ma.tiac.com>
<erica@coffin.org> wrote:
> I believe I have found the infamous "Quantum String". I will worship for life
> anyone who can help me force its behaviour into a single state.
>
> The variable containing this unusual string is called $country.
> It appears to have some mysterious escaped character on the end that does not
> allow me to concatenate other strings onto the end (they disappear)
Uh huh...
What exactly are you doing with this string that leads you to believe
the other strings "disappear"? How are you concatenating these other
strings onto the end? What do you do with the string after you
concatenate these other strings onto the end?
Where is your code???
You realize, of course, that I'll be forced to laugh at you if it turns
out you're doing
$country . $string;
instead of
$country .= $string;
:)
--
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-
------------------------------
Date: Wed, 07 Apr 1999 22:23:35 -0500
From: rjshank@postoffice.swbell.net
Subject: Re: removing the \n at the end of a variable
Message-Id: <370C2137.689A0975@postoffice.swbell.net>
Matthew Bafford wrote:
> [Followups set, subject adjusted]
>
> Wed, 07 Apr 1999 21:29:37 -0500 -- rjshank@postoffice.swbell.net <rjshank@postoffice.swbell.net>:
> -> J|rgen Exner wrote:
> -> > David Dineen <cbstramo@iol.ie> wrote in message
>
> -> > > I'm not sure about Perl being intuitive. Powerful, useful, omnipotent,
> -> > > certainly, but intuitive? I wrote a Perl script a while ago to
> -> > > automate a website (produce HTML from text file with meta data). To
> -> > > get rid of the newline character from the variable $m I had to do
> -> > > this:
> -> > >
> -> > > $m =~ s/\n$//;
> -> > >
> -> > > Obvious, isn't it?
> -> >
> -> > What was wrong with "chomp"?
> [snip]
> -> chomp? Could you per chance mean chop? That won't work for the problem
> -> he gave.
>
> chop -- trim off the very last character no matter what.
> if $m always has an \n on the end, then chop works fine
> chomp -- trim whatever $/ is set to off of the end of the
> variable. by default this happens to be "\n", so chomp
> would also work fine
>
> Hope This Helps!
Interesting, I never heard of it and it's in neither of my Unix Perl programming
books (the one with the camel on the front and the one with the llama). Is
Perl different for Linux or are my books just outdated?
Rick
------------------------------
Date: Thu, 08 Apr 1999 04:05:41 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: removing the \n at the end of a variable
Message-Id: <slrn7go68t.ej.dragons@dragons.duesouth.net>
[CC'd]
Wed, 07 Apr 1999 22:23:35 -0500 -- rjshank@postoffice.swbell.net <rjshank@postoffice.swbell.net>:
-> I, Matthew Bafford, said:
-> > chop -- trim off the very last character no matter what.
-> > if $m always has an \n on the end, then chop works fine
-> > chomp -- trim whatever $/ is set to off of the end of the
-> > variable. by default this happens to be "\n", so chomp
-> > would also work fine
[snip]
-> Interesting, I never heard of it [chomp] and it's in neither of my *LL SNIP*
-> books (the one with the camel on the front and the one with the llama). Is
-> Perl different for Linux or are my books just outdated?
Probably outdated. You need the newer (blueish) Camel (I guess Llama, too).
chomp is a Perl5 thing
Hope This Helps!
-> Rick
--Matthew
------------------------------
Date: Wed, 7 Apr 1999 20:58:31 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: removing the \n at the end of a variable
Message-Id: <MPG.1175c93fd374f615989862@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <370C2137.689A0975@postoffice.swbell.net> on Wed, 07 Apr 1999
22:23:35 -0500, rjshank@postoffice.swbell.net
<rjshank@postoffice.swbell.net >says...
> Matthew Bafford wrote:
...
> > chop -- trim off the very last character no matter what.
> > if $m always has an \n on the end, then chop works fine
> > chomp -- trim whatever $/ is set to off of the end of the
> > variable. by default this happens to be "\n", so chomp
> > would also work fine
>
> Interesting, I never heard of it and it's in neither of my Unix Perl programming
> books (the one with the camel on the front and the one with the llama). Is
> Perl different for Linux or are my books just outdated?
The latter. The chomp function is new for Perl 5 (which as you know
isn't new itself any more). You should buy the second edition of the
Camel, which has blue instead of pink on the cover. And if you can hack
the Blue Camel, why worry about the Llama at all?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 8 Apr 1999 00:14:17 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: RFC: new module File::FlockDir (long)
Message-Id: <1dpx1k6.urnnsh1hf4uxzN@p75.block2.tc1.state.ma.tiac.com>
William Herrera <posting.account@lynxview.com> wrote:
> # package File::FlockDir
> # flock module for Windows9x and other systems lacking
> # a good perl flock() function (not platform specific)
That's a really bad name for the module. If it flocks directories, why
is it in the File heirarchy? If it flocks files, why is it called
FlockDir? That just doesn't make sense.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 08 Apr 1999 02:33:12 GMT
From: drgreer@qtiworld.com (Darren Greer)
Subject: Re: Trouble with DBI and Oracle
Message-Id: <370c1503.176210036@news.qgraph.com>
Tried what you suggested, below is output from the debugger, just
before it locks up:
DB<1>
Use of uninitialized value at /opt/perl5/lib/perl5db.pl line 1134,
<IN> chunk 217.
DBD::Oracle::dr::connect('DBI::dr=HASH(0x402ac6b4)', '',
'drgreer/drgreer@QTI', undef, 'HASH(0x40265a18)') called at
/opt/perl5/lib/perl5db.pl line 1134
DBI::connect('DBI', 'dbi:Oracle:', 'drgreer/drgreer@QTI')
called at test2.pl line 8
Any suggestions?
Darren
On Wed, 07 Apr 1999 22:02:56 GMT, raymond_ali@my-dejanews.com wrote:
-->Darren,
-->
--> Try using this:
-->
-->my $dbh = DBI->connect('dbi:Oracle:','drgreer','drgreer@QTI');
-->
-->or
-->
-->my $dbh = DBI->connect('dbi:Oracle:','drgreer/drgreer@QTI');
-->
-->
-->this:
-->drgreer/drgreer@QTI
-->means drgreer is your user name
-->and drgreer@QTI is your password.
-->
-->Respectfully,
-->RMA
-->
------------------------------
Date: Thu, 08 Apr 1999 02:40:56 +0000
From: Jim Liedeka <jliedeka@facstaff.wisc.edu>
Subject: Re: Trouble with DBI and Oracle
Message-Id: <370C1738.FC1B8C5@facstaff.wisc.edu>
The form I always use for the connect method is:
$drh = DBI->install_driver('Oracle');
$dbh = $drh->connect($ENV{ORACLE_SID}, 'username', $pw) || die "Connect
error";
I know that theoretically you don't have to set up the driver handle,
but I've found that it's worth typing the extra line of code.
Jim
--
In most countries selling harmful things like drugs is punishable.
Then how come people can sell Microsoft software and go unpunished?
------------------------------
Date: 8 Apr 1999 04:41:52 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Whre did this GREAT Perl Reference go??
Message-Id: <slrn7god1b.i4e.fl_aggie@stat.fsu.edu>
On Thu, 08 Apr 1999 01:19:41 GMT, sstarre@my-dejanews.com
<sstarre@my-dejanews.com> wrote:
+ http://sgra.jpl.nasa.gov/html_dwm/web_info/wdl/webnut/index.html
+
+ This used to be a site called Webmaster in a Nutshull, part of which was a
+ whole section on Perl.
O'Reilly has a book of that title, and high-end version comes on CD-ROM.
WAG: this link was nothing more than the CD-ROM.
+ mirrors perchance?
If it is what I think it is, not a chance in hell.
James
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5325
**************************************