[9322] in Perl-Users-Digest
Perl-Users Digest, Issue: 2917 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 19 21:07:15 1998
Date: Fri, 19 Jun 98 18:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 19 Jun 1998 Volume: 8 Number: 2917
Today's topics:
Can someone point me to a Perl cookie server? (The Skipster)
Re: Code Efficiency <zenin@bawdycaste.org>
Re: Copying an Anonymous Hash <danboo@negia.net>
Re: first language <dcorbit@solutionsiq.com>
Re: first language <ljz@asfast.com>
Re: How do I periodically run a program in a certain ti <erik@zeno.com>
Re: How do I periodically run a program in a certain ti (Larry Rosler)
Re: How to sort a 2-D array based on the first index? (Dave Lorand)
learning Perl? <se11@stocknet.co.za>
Re: learning Perl? (Craig Berry)
mail script w/ attachments <rferr@voicenet.com>
Re: Need to split a line with spaces (Dave Lorand)
Re: Net::Ftp module <allen@retina.net>
Re: Novell Perl <jhi@alpha.hut.fi>
Re: printf in assignments <jstern@world.northgrum.com>
Re: String Puzzle. (Dave Lorand)
Term::ReadLine::Gnu::bind_key() <terry@eecs.tulane.edu>
Re: Win32 file path separator (Craig Berry)
Re: Win32 file path separator <paladin@uvic.ca>
Re: Win32 file path separator <dcameron@bcs.org.uk>
Re: Win32 file path separator (Craig Berry)
Re: Windows NT, how to copy binary files ! (Tye McQueen)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Jun 1998 22:28:44 GMT
From: rbskipper@wimberley-tx.com (The Skipster)
Subject: Can someone point me to a Perl cookie server?
Message-Id: <358ae5ce.23168033@news.wimberley-tx.com>
I'm trying to find a Perl module that runs in a server background as a
"cookie server." Its purpose will be to keep track of same-client data
from multiple forms. I do not want to plant cookies in browsers, but
rather pass them around to maintain state. I've read the
documentation in CGI.pm and it seems to be for the wrong kind of
cookie. An hour-long search of the CPAN modules has not turned up
anything. Can someone point me in the right direction?
Shishir Gundavaram describes such a server in his book, CGI
Programming on the Worldwide Web. But I'm using NT, not UNIX.
Any thoughts would be welcome
Skipper
------------------------------
Date: 19 Jun 1998 22:24:24 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Code Efficiency
Message-Id: <898295583.779954@thrush.omix.com>
Ray Smith <ismithr@info.curtin.edu.au> wrote:
: I'm using DB_File for this so its a little
: slow (about 1.5 secs to go through 3500 entries), but I'll be installing
: oracle shortly so should be able to over come this.
Not if you have to connect to Oracle for each search. If you don't
use cached database handles (ala ApacheDBI and mod_perl or similar),
you're likely to have up to 10 seconds of time just to connect to
Oracle, before you even start the search.
>snip<
: Here's my code to produce the table, sorry its a quite messy:
>snip<
: #
: #createTimeTable
: #produces the actual booking time table
: #
Use strict when ever you can (which is almost always).
: sub createTimeTable()
: {
: local($firstDate)=@_;
Use my() inplace of local() whenever you can (which is almost
always). Besides it's other features, it's also a little faster.
: local(@entries)=();
No need to initialize arrays to a null list. my @entries; is all
you need.
: #set the initial time => 7 am
: $startDateTime=&Date_SetTime($firstDate,"07:00");
Don't use & if you can avoid it (which is almost always).
: #set @booked from the room dataBase
: #lock the database
: if (open (DB_FH, "<$booked_file")) {
Two common rules of programming style here. First, when you've
got an if/else construct, the shorter block(s) should go first.
Also, it's best to put your error handling as close to the open()
as you can. This is just style issues though.
: &lock(DB_FH,$LOCK_EX);
Lock()? Where is this from? You're not thinking flock(), are you?
BTW, you can also open() with flock() in one call by using sysopen()
with the correct flags.
: for ($st=$booked_recno->seq($key,$values,R_FIRST);
: $st==0;$st=$booked_recno->seq($key,$values,R_NEXT) ) {
:
: #split the values
: ($varNumber, $sdate, $edate, $name,$reason,
: $contact, $school, $user) = split(/\\/,$values);
Is there a reason you're split()ing inside a loop? Can you split()
once before the loop and keep the result in a structure some place?
: next if $varNumber ne $varNum;
Are these numbers? If so, why are you not using != instead of ne?
: next if ($sdate lt $firstDate && $sdate gt $lastDate);
Isn't > and < what you're looking for in place of lt and gt?
>snip<
: #this seems to take forever
: #
FYI. The DateCalc stuff is very cool, but slow. Maybe there is
faster method you can use via time() and/or localtime()?
>snip<
: #set the cell background color according to the $school
: if ($school eq ' OT ') {$cellcolor="6a99e8";} #blue
: elsif ($school eq ' PT ') {$cellcolor="bfffbf";} #green
: elsif ($school eq ' POD ') {$cellcolor="ffffb6";} #Yellow
: elsif ($school eq ' Private ') {$cellcolor="ffbfbf";} #red
: elsif ($school eq ' Exams ') {$cellcolor="6e959e";} #Acqua
: else {$cellcolor="fafafa";} #gray
Hashes are your friend here.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Fri, 19 Jun 1998 19:15:47 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Copying an Anonymous Hash
Message-Id: <358AF123.4974AE57@negia.net>
Sean McAfee wrote:
>
> In article <6med3r$a68$1@nntp.msstate.edu>,
> Boyd Nation <boyd@Ra.MsState.Edu> wrote:
> >I need to be able to copy the contents of a hard reference to an anonymous
> >hash, and can't seem to find the correct syntax.
>
> ># This constructs the original hash:
> >$h1 = {
> > "m1" => 1,
> > "m2" => 2
> >};
>
> ># None of these work:
> >$h2 = $$h1;
> >$$h2 = $$h1;
> >$h2 = \($$h1);
>
> >Is there no way to do this without doing a key-by-key copy?
>
> Yes:
>
> $h2 = { %$h1 };
this does just fine for the example given but i wanted to point
out that it may not be suitable for hashes of references.
$h1->{'r'}->{'i'} = 2;
$h2 = { %$h1 };
$h2->{'r'}->{'i'} = 3;
print $h1->{'r'}->{'i'};
the value of $h1->{'r'} is a reference to a hash which is copied to
$h2->{'r'}. since they point at the same hash, modifying one affects
the other.
to do this by hand you need to develop some iterative procedure, or
look into some of the CPAN modules that are likely to do this.
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Fri, 19 Jun 1998 15:28:46 -0700
From: "Dann Corbit" <dcorbit@solutionsiq.com>
Subject: Re: first language
Message-Id: <6meon3$8vk$1@client2.news.psi.net>
Larry Rosler wrote in message ...
[snip]
>Summary:
>
>My *real* choice for a first language for students who want to become
>"real" (i.e., professional) programmers would be an abstract assembly
>language such as MIX (Knuth, vol. 1). With that as a basis, the C
>concept of pointers becomes transparent.
Hello, ghost of Tim B.
I have a MIX interpreter I can send you if you like [written in C]. BTW,
Knuth has a new edition of "The Art of Computer Programming" Volume 1
Fundamental Algorithms completed. I just got my new copy.
--
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-FAQ ftp: ftp://rtfm.mit.edu, C-FAQ Book: ISBN 0-201-84519-9
Try "C Programming: A Modern Approach" ISBN 0-393-96945-2
Want Software? Algorithms? Pubs? http://www.infoseek.com
------------------------------
Date: 19 Jun 1998 19:55:31 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: first language
Message-Id: <ltwwadvte4.fsf@asfast.com>
abigail@fnx.com (Abigail) writes:
> Randal Schwartz (merlyn@stonehenge.com) wrote on MDCCLIII September
> MCMXCIII in <URL: news:8cbtrpbgn2.fsf@gadget.cscaper.com>:
> ++ >>>>> "Dan" == Dan Nguyen <nguyend7@egr.msu.edu> writes:
> ++
> ++ Dan> The person needs to be a "natural" programmer. [ ... ]
> ++
> ++ I'll second this. I see far too many people *attempting* programming
> ++ that would probably have a better time being firefighters or line
> ++ chefs or congressmen or something. Sure, maybe nearly anyone with
> ++ enough effort can hack out a VB script to automate a repeated task,
> ++ but programming *well* seems to require a twisted aptitude only some
> ++ small percentage of the population seems to have. [ ... ]
> ++
> ++ I suppose it would be too much to ask that if you're not a natural
> ++ programmer, either stay out of the business, or flag your work
> ++ properly so that we cleanup people know what to throw out first. :-)
>
>
> That sounds as if programming would be an art. I disagree with that.
> I believe that most people can be able to learn how to program. Just
> like most people could learn how to become a car mechanic.
>
> Whether everyone has the motivation to learn is a different issue.
I agree. Quite a number of people that I know seem to be capable of
programming, but only a minority of these people are able to much
enjoyment out of it. Without this enjoyment, there's a much lower
motivation to learn.
For me, all the effort I have expended in learning to program and in
programming itself has been a labor of love, and hence, it didn't
*feel* like labor at all.
As for being a car mechanic ... I was very proud of myself 20 years
ago when I finally taught myself how to rebuild my car's engine, but
the work itself was not enjoyable for me, only the pride in
accomplishment. So even though I now know that I could be a very good
car mechanic, I haven't felt the slightest bit motivated to pursue
that vocation.
So, in my opinion, programming doesn't require an inordinate amount of
skill or intelligence or even creativity, but rather, a certain
emotional disposition. Just like some people enjoy vanilla ice cream
and others chocolate, some people enjoy programming and others enjoy
completely different pastimes.
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: Fri, 19 Jun 1998 16:53:44 -0700
From: "Erik" <erik@zeno.com>
Subject: Re: How do I periodically run a program in a certain time interval?
Message-Id: <6metia$rfs$1@nntp1.ni.net>
I hate to pester you about this, but do you know any more about what that
might be called in NT? I'd like to schedule perl script executions in NT,
but I'd hate to try to create scheduled tasks by opening a dos session and
running System Agent command lines with parameters - but I wouldn't be
surprised if that was what I had to do...
# Erik
Larry Rosler wrote in message ...
>On Windows NT, there is some facility, but I haven't used it. Consult
>the docs there, if any.
>
>--
>Larry Rosler
------------------------------
Date: Fri, 19 Jun 1998 17:41:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I periodically run a program in a certain time interval?
Message-Id: <MPG.ff4a5183c1d30a39896af@nntp.hpl.hp.com>
In article <6metia$rfs$1@nntp1.ni.net>, Erik <erik@zeno.com> says...
> I hate to pester you about this, but do you know any more about what that
> might be called in NT? I'd like to schedule perl script executions in NT,
> but I'd hate to try to create scheduled tasks by opening a dos session and
> running System Agent command lines with parameters - but I wouldn't be
> surprised if that was what I had to do...
>
> # Erik
>
> Larry Rosler wrote in message ...
>
> >On Windows NT, there is some facility, but I haven't used it. Consult
> >the docs there, if any.
Forgive me, colleagues -- totally off-topic, but I'll throw him a fish.
The command is 'at' which combines the capabilities of Unix 'cron'
(repetitive) and 'at' (scheduled once), via options /every:date[,...] or
/next:date[,...]. Go to Start:Help:At for the gorious details.
Forgive me, colleagues -- totally off-topic, but I've thrown him a fish.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 19 Jun 1998 23:39:28 GMT
From: davel@spc.uchicago.edu (Dave Lorand)
Subject: Re: How to sort a 2-D array based on the first index?
Message-Id: <davel-1906981839280001@honeybee.spc.uchicago.edu>
In article <6mdjue$p5c$1@nnrp1.dejanews.com>, pugs5@my-dejanews.com wrote:
> Hello...
>
> I am trying to sort a 2-D array or maybe a array inside a array. I am having
> trouble using perl sort function and it is powerful because it uses quick
> sort, but since I can not figure it out, I wrote a code that use selection
> sort but it is too slow since I am using an array of entries of 5000.
>
> Let me give you an example.
>
> Let's say that I have
>
> $bytestohost{$i,$j} = value..
> $i is the port number and $j is the index.
>
> I want to sort the inner array(value) in ascending order.
> I hope that makes sense.
>
> I want to be able to sort the array of a given $i that $i contains.
You don't seem to know Perl very well if you subscript arrays with {} and
try to make a 2-d one by inserting a comma ...
I have a sneaking suspicion that a hash will do what you want much more
simply, but let me attempt it with arrays.
To get a 2-d array at all, your "outer" array must be an array of
references to anonymous arrays. So $bytestohost[0] is a ref to an array.
$bytestohost[3][7] is a value (end of syntax instruction). Read about
hard references if this is beyond you.
If you want to sort the inner array, then you actually want to sort a
whole collection of arrays. So, loop through the outer one sorting the
inner ones, like so:
foreach $outer_ref (@bytestohost) {
@$outerref = sort myarray @$outerref
}
Now, you need a subroutine called "myarray", and you have to declare (but
maybe not define it) before the above. It will look something like this:
sub myarray {
$a <=> $b;
}
Read about sort to understand why this is what you want and how to modify
this to get what you really want. If you want to sort these values as
strings, you can omit the whole "myarray" thing.
HTH,
Dave
____________________________________________________________
| Dave Lorand | davel@spc.uchicago.edu |
| Programmer/Analyst | 773-702-3792 |
| Social Science Research Computing | 773-702-0793 (dept.) |
| University of Chicago | 773-702-2101 (fax) |
+-----------------------------------+------------------------+
------------------------------
Date: Sat, 20 Jun 1998 00:53:01 +0200
From: Roelf Pringle <se11@stocknet.co.za>
Subject: learning Perl?
Message-Id: <358AEBCD.397730EB@stocknet.co.za>
Hi (pls mail me)
Whats the best way to learn and create Perl and with what?
Thanks
Seeker
--
Email: se11@stocknet.co.za
Webpage: http://www.geocities.com/SiliconValley/Peaks/9209/
ICQ number: 4887570
Country: South Africa
------------------------------
Date: 19 Jun 1998 23:03:44 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: learning Perl?
Message-Id: <6meqog$crr$3@marina.cinenet.net>
Roelf Pringle (se11@stocknet.co.za) wrote:
: Whats the best way to learn and create Perl and with what?
The best way to learn Perl (in my opinion, shared with many others) is to
read _Learning Perl_ by Schwartz and Christiansen, do a few of the
exercises in it, then start experimenting with small, simple scripts of
your own. Get _Programming Perl_ when you feel you're outgrowing
_Learning Perl_.
The best way to create Perl is to be Larry Wall.
With what? With a text editor. To run the scripts you create, you will
need a copy of the Perl interpreter which works on your chosen OS. You
can find both source and binaries for Perl via www.perl.com, the Perl
homesite.
Hope this helps, and good luck!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 19 Jun 1998 22:44:32 GMT
From: "rferr" <rferr@voicenet.com>
Subject: mail script w/ attachments
Message-Id: <01bd9bd4$1d0ff900$0a3647d1@rferr.voicenet.com>
Does anyone know how to invoke sendmail with attachments ? I have the cc:,
bcc:
down but attachments is eluding me.
Thanks.
------------------------------
Date: Fri, 19 Jun 1998 23:19:02 GMT
From: davel@spc.uchicago.edu (Dave Lorand)
Subject: Re: Need to split a line with spaces
Message-Id: <davel-1906981819020001@honeybee.spc.uchicago.edu>
In article <6me843$93v@netaxs.com>, joel@wmi0.wmi.com (Joel Coltoff) wrote:
> In article <6me5fs$6fm$1@s00dacf.ssa.gov>,
> John Madden <john.madden@ssa.gov> wrote:
> >
> >6/17/98 09:04p 9,324 file1
> >6/17/98 09:02 5,342 file2
> >
> >foreach $entry(@entries)
> >{
> >$f1=(split/s*/)[4];
> >print ($f1 . "\n");
> >}
> >
> >With no luck..any help would be appreciated...
>
> Lots of problems.
>
> Try \s which should work much better for a space. Try '+' instead
> of '*' so you get some spaces. * means 0 or more so if you use that
> you split up the date string. This is because the date has no spaces
> and you've said split where there aren't any. Your index is wrong unless
> of course you've changed the starting index to 1. You are splitting on
> the wrong pattern. split defaults to $_;
>
> $f1 = (split(/\s+/, $entry))[3];
Better yet, omit the pattern or use ' ' (a space within quotes instead of
slashes) - this special case splits just like /\s+/ but also skips leading
whitespace. I think you have to split $_ if you're going to leave out the
patern. So,
foreach (@entries) {
$f1 = split;
print ("$f1\n"); #better to interpolate than to concatenate
}
HTH,
Dave
____________________________________________________________
| Dave Lorand | davel@spc.uchicago.edu |
| Programmer/Analyst | 773-702-3792 |
| Social Science Research Computing | 773-702-0793 (dept.) |
| University of Chicago | 773-702-2101 (fax) |
+-----------------------------------+------------------------+
------------------------------
Date: Fri, 19 Jun 1998 16:08:13 -0700
From: Wirehead <allen@retina.net>
Subject: Re: Net::Ftp module
Message-Id: <358AEF5D.3C95C374@retina.net>
Bob Trieger wrote:
> [ posted and mailed ]
>
> Wirehead <allen@retina.net> wrote:
> -> I had been looking around for examples of an ftp client until someone
> -> mentioned something about the Net::Ftp module. I hear theres an example
> -> in the modules book within the perl kit. Unfortunately, I don't have
> -> the money at this time to get the kit. Are there any examples or info
> -> around concerning this module? I'm sure its very simple to implement.
>
> Are you too poor to type "perldoc ftp" and hit the enter key?
>
> HTH
>
> Bob Trieger
> sowmaster@juicepigs.com
> " Cost a spammer some cash: Call 1-800-239-0341
> and hang up when the recording starts. "
Hey! You learn something new everyday! Thanks. I managed to scrape up some
change and type the above.
You're a real sport Bob!
------------------------------
Date: 20 Jun 1998 00:54:53 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Novell Perl
Message-Id: <oee1zsldple.fsf@alpha.hut.fi>
Dion Vansevenant <vansevenantd@faxon.ca> writes:
>
> Has anyone out there had experience with Novell's flavour of Perl?
>
> We are trying to modify some scripts to run on a Novell server, but they
> don't seem to work. I'm not sure if things just are not configured
I am sorry but we flunked our telepathy classes.
Unless you are much, much more specific in your detail we cannot help.
"some scripts"? "don't seen to work"? "configured"? "flavour"?
All of these are vague in the utmost.
> properly, or if it's a "flavour" problem.
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Fri, 19 Jun 1998 22:10:05 GMT
From: "James M. Stern" <jstern@world.northgrum.com>
Subject: Re: printf in assignments
Message-Id: <358AE1BD.E448B614@world.northgrum.com>
the count wrote:
>
> I checked the FAQ but see this addressed, so here I am (if it is in
> there, then it is buried well, or only gotten at obliquely, and I missed
> the reference...)
>
> I want to assign the contents of a printf to one element of an array,
> like so:
> $specs[$counter] = printf("\"%4s\", ", $variable);
>
> This, obviously, doesn't work as $specs[$counter] is assigned a value
> of 1 - the return value of a successful printf!
perldoc -f sprintf
--
James M. Stern -- Views here are my own, not my employer's.
(Hawthorne, CA)
------------------------------
Date: Fri, 19 Jun 1998 23:04:27 GMT
From: davel@spc.uchicago.edu (Dave Lorand)
Subject: Re: String Puzzle.
Message-Id: <davel-1906981804270001@honeybee.spc.uchicago.edu>
In article <358AA1A7.33D30B31@pitt.edu>, John Campos <rjcst26@pitt.edu> wrote:
> Anyone,
>
> I'm currently revising a perl script that reads an html document into a
> variable and then split it up into 31k increments and then record each
> piece to my database. For example if the length of the document is 70k,
> I would have 3 pieces (1st piece = 31k, 2nd piece = 31k, 3rd piece =
> 8k). Making sure that each piece does not exceed 31k in length.
>
> Problem: I have to make sure that before I create a piece that I do not
> split up a particular
> tag over two records. It has to be whole. The tag is
> <a .....> .... </a>
>
> I suspect I would create a loop that would append a piece at a time to a
> variable until I reach my 31k limit and than save that last piece to the
> database. And then pick up where I left off and continue through the
> rest of the document.
What a cool puzzle!
If you have memory to spare (which you must, if you're slurping 70K of
text into a variable), try this:
@chunks = split /(<[^>]*>)/, $text;
The pattern in the split matches any html tag. If you only want to match
<a ...> and </a>, you can use /(<\/?a[^>]*>)/ instead (I added an optional
slash and a required 'a' to that really ugly regex). The capturing
parentheses mean that the tags are left in instead of thrown away, as the
split delimiter normally is.
Now, try this:
my %single = ( 'p' => 1 ); # tags which appear singly, rather than opening
# and closing (are there any besides <p>?)
my %open = (); # to keep track of open tags
my ($len, $i, $slash, $tag);
while (@chunks > 0) {
CHUNK:
for ($len=0, $i=0; $len<32768 and $i<@chunks; $i++) {
$len += length $chunks[$i];
if ($chunks[$i] =~ m,^<(/?)(\w+)\s,) {
$slash = $1;
$tag = $2;
next CHUNK if ($single{$tag});
if ($slash) { --$open{$tag} or delete($open{$tag}) }
else { ++$open{$tag} }
}
}
BACKTRACK:
for ($i--; keys %open and $i>=0; $i--) {
if ($chunks[$i] =~ m,^<(/?)(\w+)\s,) {
$slash = $1;
$tag = $2;
next BACKTRACK if ($single{$tag});
if ($slash) { ++$open{$tag} } # reversed
else { --$open{$tag} or delete($open{$tag}) }
}
}
$i > 0 or die "Houston, we have a problem.\n"; #backtracked to the beginning
&save_in_db ( join('', @chunks[0..$i]) );
splice @chunks, 0, $i+1; # remove what we just saved so we can start again
}
Enjoy!
Dave
____________________________________________________________
| Dave Lorand | davel@spc.uchicago.edu |
| Programmer/Analyst | 773-702-3792 |
| Social Science Research Computing | 773-702-0793 (dept.) |
| University of Chicago | 773-702-2101 (fax) |
+-----------------------------------+------------------------+
------------------------------
Date: Fri, 19 Jun 1998 15:36:48 -0500
From: "Nicole D. Terry" <terry@eecs.tulane.edu>
Subject: Term::ReadLine::Gnu::bind_key()
Message-Id: <358ACBE0.12AFFCAF@eecs.tulane.edu>
Hello,
I'm using the Term::ReadLine::Gnu module to create an interface similar
to emacs in that every key is bound to a function. I know how to bind
the standard stuff (letters, numbers and symbols), and
control-(standard-stuff).
$TERM->bind_key(ord("p") , $funcPtr); # p
$TERM->bind_key(ord("\cp") , $funcPtr); # control-p
$TERM->bind_key(ord("\t") , $funcPtr); # tab
I would like to know how to bind meta-(standard-stuff),
alt-(standard-stuff), backspace, delete, insert, home, end, page-up,
page-down, arrow keys, function keys, etc...
Also, I'm using the call $TERM->readline("> ") to get input but I'm
using print to display output. The screen scrolls appropriately with
print but I would like to implement some sort of paging function when
the output fills more than one screen. Is there any sort of equivalent
"WriteLine" library? Can it be done some other way?
Thanks
- Nicole
Nicole Deflaux Terry
Department of Electrical Engineering and Computer Science
Tulane University
terry@eecs.tulane.edu
http://www.eecs.tulane.edu/www/Terry
------------------------------
Date: 19 Jun 1998 22:24:05 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Win32 file path separator
Message-Id: <6meoe5$crr$1@marina.cinenet.net>
Mike Pritchard (mikep@5circles.com) wrote:
: Anyway, I'm trying to use the ActiveWare Win32 (5.00307 build 316) to debug
: some scripts that should work cross platform, and even has a parameter
: setting for PC. It is running on Linux properly, but on Win32 the file path
: separators cause problems.
:
: One script stores a directory name in a file, along with a bunch of other
: information.
:
: On Linux, the stored directory looks like this -
: /home/mikep/public_html/dir1
: On Win32, the stored directory looks like this - c:/inetpub/wwwroot/dir1
: I've tried using backslashes in the directory, but this generates an error
:
: Can't stat c:inetpubwwwrootdir1
(a) Only the shell in DOS demands \ path separators; internally \ and /
both work. Thus, the / version above should work fine.
(b) You get that garbled line because \ is also the string escape meta-
character. Use two slashes \\ to produce one slash \ in the real
string; e.g., "c:\\path\\to\\dir" for c:\path\to\dir .
: [Maybe this is really the source of the problem - this directory is
: specified in a config file as "c:\inetpub\wwwroot\dir1"]
That depends on what's reading the config file. If it's just read in like
that and used, it should work fine. If a Perl app tries to do
doublequotish processing on it, you'd get your symptoms.
: A second script reads the directory name from $_ and is supposed to set up a
: $dir variable appropriately. The code looks like this:
:
: if(m:^(/.*):){
: $dir = $1;
: }
:
: The Linux system works fine. The Win32 match fails so $dir is never
: initialized.
Well, it wouldn't, of course, if the Win32 version has \ seps instead of
/. Change the regex to m:^([/\\].*): -- or, even better, use / seps even
under Win32.
: I'm betting this is really simple, but I'm probably looking too closely at
: it. Any help would be greatly appreciated.
Hope this provides the needed conceptual jolt. :)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 19 Jun 1998 15:26:47 -0700
From: Draco Paladin <paladin@uvic.ca>
To: Mike Pritchard <mikep@5circles.com>
Subject: Re: Win32 file path separator
Message-Id: <Pine.A41.3.96.980619151036.78608A-100000@unix3.UVic.CA>
On Fri, 19 Jun 1998, Mike Pritchard wrote:
> On Linux, the stored directory looks like this -
> /home/mikep/public_html/dir1
> On Win32, the stored directory looks like this - c:/inetpub/wwwroot/dir1
> I've tried using backslashes in the directory, but this generates an error
>
> Can't stat c:inetpubwwwrootdir1
Remember to backslash your backslashes. ie.
c:\\inetpub\\wwwroot\\dir1
> A second script reads the directory name from $_ and is supposed to set up a
> $dir variable appropriately. The code looks like this:
>
> if(m:^(/.*):){
> $dir = $1;
> }
>
If your Win32 dir is stored in the format "drive:\dir1\dir2\dir3" the
above pattern will not match it so the assignment is not done.
To match a format like the above use something like
m/^(.:\\.*)/ for the drive and path together in $1 or
m/^(.):(\\.*)/ for the drive letter in $1 and the path in $2.
Hope this helps.
---------------------------------------------
Mother is the name for GOD on the lips and
hearts of all children. - Eric Draven
------------------------------
Date: 19 Jun 1998 22:38:08 GMT
From: "Duncan Cameron" <dcameron@bcs.org.uk>
Subject: Re: Win32 file path separator
Message-Id: <01bd9bd2$c5295660$3ee6abc3@dns.btinternet.com>
Mike
I'm not sure that I fully understood what your difficulty is, but it's a
(fairly) little-known fact that you can use forward-slash as a path
separator in Win32, so your example c:/inetpub/wwwroot/dir1 should be ok.
Using back-slash in a double-quoted string means that you need to escape
the backslash, as otherwise it is taken as the escape character. That's
why you got c:inetpubwwwrootdir1
Hope that this helps
Duncan Cameron
Mike Pritchard <mikep@5circles.com> wrote in article
<6mekph$n07$1@news7.ispnews.com>...
<snip>
> Anyway, I'm trying to use the ActiveWare Win32 (5.00307 build 316) to
debug
> some scripts that should work cross platform, and even has a parameter
> setting for PC. It is running on Linux properly, but on Win32 the file
path
> separators cause problems.
>
> One script stores a directory name in a file, along with a bunch of other
> information.
>
> On Linux, the stored directory looks like this -
> /home/mikep/public_html/dir1
> On Win32, the stored directory looks like this - c:/inetpub/wwwroot/dir1
> I've tried using backslashes in the directory, but this generates an
error
>
<remainder snipped>
------------------------------
Date: 19 Jun 1998 22:47:19 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Win32 file path separator
Message-Id: <6meppn$crr$2@marina.cinenet.net>
Craig Berry (cberry@cinenet.net) wrote:
: : A second script reads the directory name from $_ and is supposed to set up a
: : $dir variable appropriately. The code looks like this:
: :
: : if(m:^(/.*):){
: : $dir = $1;
: : }
: :
: : The Linux system works fine. The Win32 match fails so $dir is never
: : initialized.
:
: Well, it wouldn't, of course, if the Win32 version has \ seps instead of
: /. Change the regex to m:^([/\\].*): -- or, even better, use / seps even
: under Win32.
Extending what I said before -- actually, that alone won't work, though
it's part of the solution. I forgot you had a drive spec first. One way
to handle that would be to use the regex
m!^((?:[A-Za-z]:)?[/\\].*)!
...though upon even *more* reflection, it occurs to me that the original
check above comes down to "Take the whole thing as a dir name if it starts
with /". If that's all you need to do, I'd recode the conditional as
if (m!^(?:[A-Za-z]:)?[/\\]!) {
$dir = $_;
}
That is, if it looks like an optional drive letter and colon, then a slash
of either flavor, accept it as a path.
I'd want to code some appropriate else branch onto this, too, in order to
die or assign a default to $dir as needed.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 19 Jun 1998 17:49:06 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Windows NT, how to copy binary files !
Message-Id: <6mept2$7ee@fohnix.metronet.com>
Deva Seetharam <psdspss@execpc.com> writes:
)
) What about system("copy $src $dest");
Or, more correctly:
$src =~ s/"/""/g;
$dest =~ s/"/""/g;
system( qq<copy "$src" "$dest"> )
and die qq<Can't copy "$src" to "$dest".\n>;
or, much more portably:
use File::Copy;
copy( $src, $dest )
or die "Can't copy $src to $dest: $!\n";
or, how I do it in certain scripts since I haven't patched File::Copy yet:
use Win32API::File qw(CopyFile);
CopyFile( $src, $dest, 0 )
or die "Can't copy $src to $dest: $^E\n";
but this last one isn't widely available yet so the middle one is
your best bet.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
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 2917
**************************************