[13204] in Perl-Users-Digest
Perl-Users Digest, Issue: 614 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 22 10:10:41 1999
Date: Sun, 22 Aug 1999 07:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 22 Aug 1999 Volume: 9 Number: 614
Today's topics:
Re: **** pack() function <alex@kawo2.rwth-aachen.de>
DBM File Conversion <hpepper@mindspring.com>
Re: determining a leap year <owensk@cadvision.com>
Re: djgpp, Win98, Perl, and serial port <eliz@is.elta.co.il>
Re: DWIM redux (Was: Why use Perl when we've got Python (Abigail)
Re: finding a running process on NT <carvdawg@patriot.net>
Re: HARASSMENT -- Monthly Autoemail <spamproof@pluggedin.bc.ca>
Re: How to do "or" in IF test? <All@n.due.net>
Re: How to do "or" in IF test? <jimmy@blackhole-designs.com>
Re: Maintaining User Sessions without Cookies <shori_pl@bigpond.net.au>
New to Perl Databases <dchurch@kabana.net>
newbee script prob vod@writemail.com
Newbie Questions <me@nowhere.com>
NT + drag&drop + long filenames? <a8603365@unet.univie.ac.at>
Re: NT + drag&drop + long filenames? <All@n.due.net>
Re: NT + drag&drop + long filenames? <All@n.due.net>
Re: Packages and parent packages (Donovan Rebbechi)
Re: perl + mysql.. <hennein@email.msn.com>
Re: Perl and DBM file questions <groberts@uow.edu.au>
Re: Perl and DBM file questions (Marcel Grunauer)
Re: PERL EDITOR (hoz)
Perl Email With Netscape <jimmy@blackhole-designs.com>
Re: Perl puzzle: array of booleans to ranges (Bart Lateur)
Re: Perl puzzle: array of booleans to ranges (Abigail)
Re: Perl puzzle: array of booleans to ranges (Marcel Grunauer)
Re: Recursing through directory headache (Bart Lateur)
Re: Why use Python when we've got Perl? <xah@best.com>
Re: Why use Python when we've got Perl? <xah@best.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 22 Aug 1999 15:38:47 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: "David A. Desrosiers" <hacker@downcity.net>
Subject: Re: **** pack() function
Message-Id: <37BFFD67.985D7C0@kawo2.rwth-aachen.de>
"David A. Desrosiers" wrote:
> I need to replace this function with it's equivalent in pack().
> Any ideas?
Read perldoc -tf pack
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Sun, 22 Aug 1999 13:35:38 +0000
From: Howard Pepper <hpepper@mindspring.com>
Subject: DBM File Conversion
Message-Id: <37BFFCAA.3107213C@mindspring.com>
This is a multi-part message in MIME format.
--------------51BE360906DDB62B831CCA8B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am working on a project to convert about 30 MB of data (in
seperate files) stored in DBM format (I don't know which format) to
MySQL. The system it's currently running on is an SGI system, running
IRIX Release 6.2 IP2Z? and using Perl 4.
The system we are porting over to is an Intel based system running
RedHat 6.0 with Perl 5.00503. I've used some DBM functions before, but
I can't seem to open these databases. I tried using AnyDBM_File (I read
this one from the manpages) and took a shot with NDBM_File, but I don't
seem to have the module installed on my computer.
Can anyone give me a hand here? It's not a tremendous problem, we
could always export off of the SGI system to a standard text file, but I
am developing the app at my house, using a copy of the DBM files.
Any help would be greatly appreciated.
TIA,
Howard Pepper
hpepper@mindspring.com
--------------------------------------------------------------
Before anyone jumps on the "read the manpages" bandwagon, yes I did.
I'm obviously too stupid to figure it out so that's why I'm asking for
help!
--------------51BE360906DDB62B831CCA8B
Content-Type: text/x-vcard; charset=us-ascii;
name="hpepper.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Howard Pepper
Content-Disposition: attachment;
filename="hpepper.vcf"
begin:vcard
n:Pepper;Howard
tel;home:904-445-3374
tel;work:904-633-4156
x-mozilla-html:FALSE
url:www.mindspring.com/~hpepper/index.htm
org:National Technologies Associates, Inc.;IS
adr:;;3 Carr Lane;Palm Coast;FL;32137;
version:2.1
email;internet:hpepper@mindspring.com
title:Programmer/Analyst
x-mozilla-cpt:;0
fn:Howard Pepper
end:vcard
--------------51BE360906DDB62B831CCA8B--
------------------------------
Date: Sun, 22 Aug 1999 07:21:44 -0600
From: "K C Owens" <owensk@cadvision.com>
Subject: Re: determining a leap year
Message-Id: <37bff96a@news.cadvision.com>
Sorry about the wrong answer--Sami's is correct.
Sami Rosenblad wrote in message ...
>In article <37beb0db@news.cadvision.com>, "K C Owens"
><owensk@cadvision.com> wrote:
>
>> A year divisible by 4 is a leap year unless it is divisible by 400. 2000
is
>> a leap year but 2100 is not.
>
>Uhh, wrong. A year is a leap year if...
>- it is divisible by 4
>- and not divisible by 100
>- or it is divisible by 400
>
>Therefore, year 2000 is a leap year and 2100 is not, but for different
>reasons than stated above.
>
>--
>Sami Rosenblad -- blade@leela.janton.fi -- running linux since 1999
------------------------------
Date: Sun, 22 Aug 1999 10:24:25 +0300
From: Eli Zaretskii <eliz@is.elta.co.il>
Subject: Re: djgpp, Win98, Perl, and serial port
Message-Id: <Pine.SUN.3.91.990822101855.6405A-100000@is>
On Thu, 19 Aug 1999, David Christensen wrote:
> |> The middle level functions I wrote are;
> |>
> |> comopen() open a serial port
> |> comclose() close serial ports
> |> comsetprm() set transmit parameters of a serial port
> |> comgetprm() get transmit parameters of a serial port
> |> comwrite() write to a serial port
> |> comread() read from a serial port
> |> comsetmcr() set MCR (modem control register) of a serial port
> |> comgetmsr() get MSR (modem status register) of a serial port
> |>
> |> I feel the set of these functions is incomplete. Because
> simple binary level transmfer can be executed by using comwrite()
> and comread(), but text level transmfer requires many cares.
If this is for the DJGPP port of Perl, then I don't think you need to
care about the text/binary nuisance, and possibly not about some of the
details of the functions mentioned above. DJGPP provides the so-called
Filesystem Extension feature, whereby you can install a handler for
low-level I/O operations, such as open, read, write, close, etc. This
handler is called when the library is about to call a DOS or Windows
function to handle the request. The handler gets a chance to recognize
handles and file names that reference the special devices or streams
emulated by the extension, and handle the call instead of DOS/Windows.
This approach relieves the extension from handling the gory details such
as text/binary conversion, buffering, etc., which are done by the library
as usual.
------------------------------
Date: 22 Aug 1999 03:42:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: DWIM redux (Was: Why use Perl when we've got Python?!)
Message-Id: <slrn7rve0o.c9p.abigail@alexandra.delanet.com>
Abigail (abigail@delanet.com) wrote on MMCLXXXII September MCMXCIII in
<URL:news:slrn7rva69.c9p.abigail@alexandra.delanet.com>:
&&
&& Having 3/4 == 0, whether with "integer math" or not, breaks the equivalence:
&&
&& p == f1 * f2 iff p == f2 == 0 /\ p/f2 == f1.
That should read:
p == f1 * f2 iff p == f2 == 0 \/ p/f2 == f1.
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 22 Aug 1999 07:33:42 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Re: finding a running process on NT
Message-Id: <37BFE015.A62082B2@patriot.net>
--------------04EBCB2F1B66D7CCB86A22CC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Oops, allow me correct that...
The correct web page is:
http://www.generation.net/~aminer/
Right now, Amine is updating his web page and making the .ppd
files for the modules, so give it a couple of days....
c
"Harlan Carvey, CISSP" wrote:
> Check out Win32::IProc at:
>
> http://www.generation.net/~aminer/Perl/
--------------04EBCB2F1B66D7CCB86A22CC
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Oops, allow me correct that...
<br>The correct web page is:
<br><a href="http://www.generation.net/~aminer/Perl/">http://www.generation.net/~aminer/</a>
<p>Right now, Amine is updating his web page and making the .ppd
<br>files for the modules, so give it a couple of days....<a href="http://www.generation.net/~aminer/Perl/"></a>
<p>c
<p>"Harlan Carvey, CISSP" wrote:
<blockquote TYPE=CITE>Check out Win32::IProc at:
<p><a href="http://www.generation.net/~aminer/Perl/">http://www.generation.net/~aminer/Perl/</a></blockquote>
</html>
--------------04EBCB2F1B66D7CCB86A22CC--
------------------------------
Date: Sun, 22 Aug 1999 04:24:49 -0700
From: Glenn Wittrock <spamproof@pluggedin.bc.ca>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37BFDE01.B2136CF1@pluggedin.bc.ca>
Having missed the bulk of this discussion (thankfully), I throw in the
following
1 Mail-bomb the bastrds, any bastards who deserve it. (after one polite
warning of course)
2 Rat them out to their isp, nothing like a threat of cut the pipeline
to encourage etiquette.
3 Post with a 'hotmail' or alias address, if dirtbags won't quit mailing
it, you can dump it.
Glenn
Ian Clarke wrote:
>
> John Stanley wrote:
>
> > That's right, Dave. You haven't shown me anything that supports your
> > claim that posting is solicitation of email.
>
> For crying out loud! Don't you see that you have been sidelined from
> the real issue (whether it is right to set up an *automatic* email
> designed to irritate and annoy) which you could defend, to a different
> issue that you probably can't? (whether a newsgroup posting is
> solicitation of email).
>
> You should choose your battles more carefully.
>
> Ian.
------------------------------
Date: Sun, 22 Aug 1999 11:54:22 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: How to do "or" in IF test?
Message-Id: <OxRv3.8757$y03.1297@news.rdc1.ct.home.com>
Jim <jkrogerDONCHA_SPAM_ME@earthlink.net> wrote in message
news:jkrogerDONCHA_SPAM_ME-2208990348020001@ip210.princeton.nj.pub-ip.psi.ne
t...
: Please accept my apologies if this is not the appropriate
: place for this question.
Question seems ok to me.
: I am learning Perl using "Learning Perl" (great book). I am not
: able to find info on how to implement a logical OR in an if
: statement test, such as
: if (this or that) {
: }
That is exactally how you do it. <g>
: I tried several permutations such as
: if ((this) || (that))
That may or may not work depending on your this and that but for your stated
tests that should work.
: if ( this || that )
That should work.
: if (this) || (that)
That is going to get you an error
: and nothing seemed to work.
: The actual tests are
: end <= 20
: answer eq "y"
Well, we are going to have to see the actual code but I am willing to bet
(using my ESP module) that you do the test before $end is defined. In such
a case the test of if ($end <=21) is true because the evaulation of $end in
this case returns 0 as undefined values are False (0). Make sure you use -w
and use strict.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
An old pond-
The sound of the water
When the frog jumps in
Basho
------------------------------
Date: Sun, 22 Aug 1999 13:54:13 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Re: How to do "or" in IF test?
Message-Id: <37C000F3.D7E6DDBC@blackhole-designs.com>
--------------2253466EF95679D9A844AB07
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Allan,
Pretty easy,
$var1 = 20; $var2 = 70;
print "gimmie some input: ";
$input = <STDIN>; chomp($input);
if ($input <= $var1 || $input >= $var2) {
print "You got a match!\n";
}
else {
print "No match, error...";
}
You always have to compare variables with other information unless you are just
checking to see if something exist such as if (<STDIN>)
That should help,
Jimmy
ps - get rid of the strict and -w, they'll just cause unneeded error messages
"Allan M. Due" wrote:
> Jim <jkrogerDONCHA_SPAM_ME@earthlink.net> wrote in message
> news:jkrogerDONCHA_SPAM_ME-2208990348020001@ip210.princeton.nj.pub-ip.psi.ne
> t...
> : Please accept my apologies if this is not the appropriate
> : place for this question.
>
> Question seems ok to me.
>
> : I am learning Perl using "Learning Perl" (great book). I am not
> : able to find info on how to implement a logical OR in an if
> : statement test, such as
> : if (this or that) {
> : }
>
> That is exactally how you do it. <g>
>
> : I tried several permutations such as
> : if ((this) || (that))
>
> That may or may not work depending on your this and that but for your stated
> tests that should work.
>
> : if ( this || that )
> That should work.
>
> : if (this) || (that)
> That is going to get you an error
>
> : and nothing seemed to work.
> : The actual tests are
> : end <= 20
> : answer eq "y"
>
> Well, we are going to have to see the actual code but I am willing to bet
> (using my ESP module) that you do the test before $end is defined. In such
> a case the test of if ($end <=21) is true because the evaulation of $end in
> this case returns 0 as undefined values are False (0). Make sure you use -w
> and use strict.
>
> HTH
>
> AmD
> --
> $email{'Allan M. Due'} = ' All@n.Due.net ';
> --Random Quote--
> An old pond-
> The sound of the water
> When the frog jumps in
> Basho
--------------2253466EF95679D9A844AB07
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Allan,
<p>Pretty easy,
<p><tt>$var1 = 20; $var2 = 70;</tt>
<br><tt>print "gimmie some input: ";</tt>
<br><tt>$input = <STDIN>; chomp($input);</tt><tt></tt>
<p><tt>if ($input <= $var1 || $input >= $var2) {</tt>
<br><tt> print "You got a match!\n";</tt>
<br><tt>} <br>
else {</tt>
<br><tt> print "No match, error...";</tt>
<br><tt>}</tt><tt></tt>
<p>You always have to compare variables with other information unless you
are just checking to see if something exist such as if (<STDIN>)
<p>That should help,
<p>Jimmy
<p>ps - get rid of the strict and -w, they'll just cause unneeded error
messages
<p>"Allan M. Due" wrote:
<blockquote TYPE=CITE>Jim <jkrogerDONCHA_SPAM_ME@earthlink.net> wrote
in message
<br><a href="news:jkrogerDONCHA_SPAM_ME-2208990348020001@ip210.princeton.nj.pub-ip.psi.ne">news:jkrogerDONCHA_SPAM_ME-2208990348020001@ip210.princeton.nj.pub-ip.psi.ne</a>
<br>t...
<br>: Please accept my apologies if this is not the appropriate
<br>: place for this question.
<p>Question seems ok to me.
<p>: I am learning Perl using "Learning Perl" (great book). I am not
<br>: able to find info on how to implement a logical OR in an if
<br>: statement test, such as
<br>: if (this or that) {
<br>: }
<p>That is exactally how you do it. <g>
<p>: I tried several permutations such as
<br>: if ((this) || (that))
<p>That may or may not work depending on your this and that but for your
stated
<br>tests that should work.
<p>: if ( this || that )
<br>That should work.
<p>: if (this) || (that)
<br>That is going to get you an error
<p>: and nothing seemed to work.
<br>: The actual tests are
<br>: end <= 20
<br>: answer eq "y"
<p>Well, we are going to have to see the actual code but I am willing to
bet
<br>(using my ESP module) that you do the test before $end is defined.
In such
<br>a case the test of if ($end <=21) is true because the evaulation
of $end in
<br>this case returns 0 as undefined values are False (0). Make sure
you use -w
<br>and use strict.
<p>HTH
<p>AmD
<br>--
<br>$email{'Allan M. Due'} = ' All@n.Due.net ';
<br>--Random Quote--
<br>An old pond-
<br>The sound of the water
<br>When the frog jumps in
<br> Basho</blockquote>
</html>
--------------2253466EF95679D9A844AB07--
------------------------------
Date: Sun, 22 Aug 1999 23:40:01 +1000
From: Shori Pty Ltd - Barry W Anderson <shori_pl@bigpond.net.au>
Subject: Re: Maintaining User Sessions without Cookies
Message-Id: <37BFFDB1.8DDB4F@bigpond.net.au>
Beg to differ. Log them in. Use a database to track their state.
Benjamin Franz wrote:
>
> In article <37bdc6b1@news1.us.ibm.net>, SH <purchase9@hotmail.com> wrote:
> >Is there anyway in Perl to remember a specific users preferences even after
> >they close their browser (without any client side involvement)? Basically a
> >shopping cart that saved information over a period of time. If you could
> >give me a push in the right direction I would be very grateful.
>
> With the restriction postulated (no client side involvement),
> no - there is no way to achieve state persistence after they exit
> their browser.
>
> --
> Benjamin Franz
--
Shori Pty Ltd /
Barry W Anderson \ / /
Senior Consultant \\\' , / //
bwa@shori.com \\\//, _/ //,
\_-//' / //<,
http://www.shori.com \ /// <//`
/ >> \\\`__/_
42 Munich Drive /,)-^>> _\` \\\
Keilor Downs, Victoria (/ \\ / \\\
Australia 3038 // //\\\
----------------------------------------------------------((`-((`-----
------------------------------
Date: Fri, 20 Aug 1999 08:11:05 -0600
From: "Linux GNUBEE" <dchurch@kabana.net>
Subject: New to Perl Databases
Message-Id: <7pjnlp$bh1$1@macaw.cyberport.com>
Can someone please take the time to explain a couple of things to me about
Perl databases?
First of all, I want an effective DYNAMIC storage mechanism for a bunch of
user data. The data will not be the same length for each user every time.
Also, I don't know how many fields I will need, as those will be changing
every time as well.
Second, do I create a DB here on my Windows computer, upload it to my Linux
account on my ISP, and manipulate it further there, or can I create a SIMPLE
DB on my Linux account from scratch?
Thanks.
Dan Church :)
dchurch@kabana.net
------------------------------
Date: Sun, 22 Aug 1999 13:28:09 GMT
From: vod@writemail.com
Subject: newbee script prob
Message-Id: <7pott4$921$1@nnrp1.deja.com>
i am working in windows can some tell me is there
sone thing wrong with this script as i am not able to
call this form a FORM
%pages = ("fred" => "http://www.cgi101.com/~fred/",
"beth" => "http://www.cgi101.com/~beth/",
"john" => "http://www.cgi101.com/~john/" );
print "Content-type:text/html\n\n";
print <<EndHdr;
<html><head><title>URL List</title></head>
<body bgcolor="#ffffff">
<p>
<h2>URL List</h2>
<ul>
EndHdr
;
foreach $key (keys %pages) {
print "<li><a href=\"$pages{$key}\">$key</a>\n";
}
print <<EndFooter;
</ul>
<p> hi all
</body>
</html>
EndFooter
;
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sun, 22 Aug 1999 13:15:42 GMT
From: "Jason Sill" <me@nowhere.com>
Subject: Newbie Questions
Message-Id: <2KSv3.14$yE3.398@sapphire.mtt.net>
Before you tell me, I've already looked over the man pages and I couldn't
find the answers to these questions.
My first question involes calling C functions from perl. Now I know that
when you have a
structure in C, you use the typemap of T_PTROBJ. The question I have is
that once you have this reference in the perl code, is there anyway to
access the elements of the structure or do you have to pass it to another
XSUB to get it to access them.
My next question also involves using C in perl. I created an extension.
Now after testing it, i decided to install it on my machine. I called make
install as root and got it installed. Now, after I have it installed,
shouldn't anybody be able to use it. The problem is that if anyone else
other than the user that created it, trys to run a perl script using my
module they get this error:
Can't load '/opt/perl5/lib/site_perl/PA-RISC1.1/auto/amtest/amtest.sl' for
module amtest: Permission denied at
/opt/perl5/lib/PA-RISC1.1/5.00404/DynaLoader.pm line 166.
at testwx line 3
Does any one know the problem here? Thanks in advance. Please respond to
the newsgroup
Jason
------------------------------
Date: Sun, 22 Aug 1999 14:23:50 +0200
From: Melchior FRANZ <a8603365@unet.univie.ac.at>
Subject: NT + drag&drop + long filenames?
Message-Id: <37BFEBD6.10446EE4@unet.univie.ac.at>
Hi,
I've written a perl script under Linux which gets
a filename as argument, transforms the file contents
and writes the data back under a filename derived
from the input filename.
"1999-08-21-P1-C2.txt" becomes "1999-08-21-P1-C2X.txt"
^
That script works well with Linux, but when I tried
to use it under NT I encountered a cumbersome
NT `feature'. It seems that NT refuses to pass the
long (UNIX-like) filename, but rather takes the
funny archaic 8+3 (DOS-like) filename, when I
`drag&drop' a file upon the script lying around
on the desktop as *.BAT file (created by "pl2bat"
as suggested by the documentation for the win32
perl port).
I know well, that NT is the one to blame, and not
perl. But that Microsoft feature makes using perl
under NT not as pleasureful as under Unix or Linux.
That's the reason why I finally try my luck in this
newsgroup (and because the folks in "comp.windows.misc"
seem to be clueless, and the FAQ for win32-perl doesn't
mention the problem.)
Is there a way to let the Windows OS pass long
filenames to a perl script, or, at least: Is there
a way to deduce the real, long filename from the
mutilated 8+3 thing by means of perl commands.
TIA
m.
PS: Yes, I know. Moving over to a better OS would
instantly solve all my problems.
------------------------------
Date: Sun, 22 Aug 1999 13:31:34 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: NT + drag&drop + long filenames?
Message-Id: <WYSv3.8760$y03.1248@news.rdc1.ct.home.com>
Melchior FRANZ <a8603365@unet.univie.ac.at> wrote in message
news:37BFEBD6.10446EE4@unet.univie.ac.at...
[snip]
: Is there a way to let the Windows OS pass long
: filenames to a perl script, or, at least: Is there
: a way to deduce the real, long filename from the
: mutilated 8+3 thing by means of perl commands.
This is a huge pain in the butt. The only way I know of to deal with this
is to have the script figure out the long file name from the short one.
Below are two subroutines that I use. The first will take longer but checks
to make sure there is not more than one match. I can't see how there could
be, but what the heck better safe than sorry. The second is quicker but
just takes the first match. If your directory is large you might not want
to load all the file names into one array. There may well be a better way
but this works for me.
-----------------
#!/usr/local/bin/perl -w
use strict;
use Win32;
use File::Basename;
sub get_long_name {
my $fullname = shift @_;
my ($name,$path) = fileparse($fullname);
opendir (DIR,"$path") or warn "$!\n";
my @files = grep {uc(Win32::GetShortPathName("$path$_")) eq
uc($fullname)} readdir(DIR);
close(DIR) or warn "$!\n";
if ($#files == 0) {return $files[0]}
else {warn "Error finding the long file name for $name: ",$#files > 0 ?
'too many ' : 'no ','files were found.'; return ()}
}
sub get_long_name2 {
my $found;
my $fullname = shift @_;
my ($name,$path) = fileparse($fullname);
opendir (DIR,"$path") or warn "$!\n";
my @files = readdir (DIR);
close(DIR) or warn "$!\n";;
foreach (@files) {
$found = $_ and last if uc(Win32::GetShortPathName("$path$_")) eq
uc($fullname);
}
if ($found) {return $found;}
else {warn "Error finding the long file name for $name\n"; return ()}
}
my $long_name = get_long_name(shift @ARGV) if @ARGV;
------------
HTH
AmD
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
The beginning of wisdom is the definitions of terms.
Socrates
------------------------------
Date: Sun, 22 Aug 1999 13:31:34 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: NT + drag&drop + long filenames?
Message-Id: <WYSv3.8761$y03.1248@news.rdc1.ct.home.com>
Melchior FRANZ <a8603365@unet.univie.ac.at> wrote in message
news:37BFEBD6.10446EE4@unet.univie.ac.at...
[snip]
: Is there a way to let the Windows OS pass long
: filenames to a perl script, or, at least: Is there
: a way to deduce the real, long filename from the
: mutilated 8+3 thing by means of perl commands.
This is a huge pain in the butt. The only way I know of to deal with this
is to have the script figure out the long file name from the short one.
Below are two subroutines that I use. The first will take longer but checks
to make sure there is not more than one match. I can't see how there could
be, but what the heck better safe than sorry. The second is quicker but
just takes the first match. If your directory is large you might not want
to load all the file names into one array. There may well be a better way
but this works for me.
-----------------
#!/usr/local/bin/perl -w
use strict;
use Win32;
use File::Basename;
sub get_long_name {
my $fullname = shift @_;
my ($name,$path) = fileparse($fullname);
opendir (DIR,"$path") or warn "$!\n";
my @files = grep {uc(Win32::GetShortPathName("$path$_")) eq
uc($fullname)} readdir(DIR);
close(DIR) or warn "$!\n";
if ($#files == 0) {return $files[0]}
else {warn "Error finding the long file name for $name: ",$#files > 0 ?
'too many ' : 'no ','files were found.'; return ()}
}
sub get_long_name2 {
my $found;
my $fullname = shift @_;
my ($name,$path) = fileparse($fullname);
opendir (DIR,"$path") or warn "$!\n";
my @files = readdir (DIR);
close(DIR) or warn "$!\n";;
foreach (@files) {
$found = $_ and last if uc(Win32::GetShortPathName("$path$_")) eq
uc($fullname);
}
if ($found) {return $found;}
else {warn "Error finding the long file name for $name\n"; return ()}
}
my $long_name = get_long_name(shift @ARGV) if @ARGV;
------------
HTH
AmD
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
The beginning of wisdom is the definitions of terms.
Socrates
------------------------------
Date: 22 Aug 1999 10:04:55 -0400
From: elflord@panix.com (Donovan Rebbechi)
Subject: Re: Packages and parent packages
Message-Id: <slrn7s00s7.kb0.elflord@panix3.panix.com>
On 21 Aug 1999 20:38:35 -0500, Abigail wrote:
>Donovan Rebbechi (elflord@panix.com) wrote on MMCLXXXI September MCMXCIII
>Did you read the manpage of Exporter?
Just what I was looking for.
Thanks
--
Donovan
------------------------------
Date: Sun, 22 Aug 1999 08:49:35 -0500
From: "hennein" <hennein@email.msn.com>
Subject: Re: perl + mysql..
Message-Id: <#bwuoUK7#GA.266@cpmsnbbsa03>
> please do it the *right* way too. That means: Cut your quotes to the
> part you're commenting on. You have only responded to Abigail's single
> line, but quoted the whole posting. Then place your reply below the
> quote. The "style" of slapping a reply on top of everything is lazy
> and inconsiderate.
>
> Anno
Relax. Life isn't THAT serious.
------------------------------
Date: Sun, 22 Aug 1999 22:43:09 +1000
From: Geoff Roberts <groberts@uow.edu.au>
Subject: Re: Perl and DBM file questions
Message-Id: <37BFF05D.8C1808F3@uow.edu.au>
I get the same error - records will only be added to "virginal" database
files. If I re-open a database file, then new records are not added.
> A certain amount of data will be cached in memory (not the whole lot).
> This is configurable (see 'perldoc DB_File' and look for cachesize).
> You can force data to be flushed to the underlying file using the object's
> sync method; it will also be flushed when the array is untied.
>
> I've never used DB_RECNO myself for real. I wrote the following example
> program after reading 'perldoc DB_File'. Unfortunately, this appears to
> have two problems:
>
> 1. It can only grow the file if the file didn't exist at the start. If,
> say, the file has 10 records, and I ask it to create record 11, no error
> occurs, but the new record is not created.
>
> 2. Tracing the program reveals that the untie causes the *entire* file
> to be written, which seems crazily inefficient.
>
> Anyone have any ideas about this?
>
> #!/usr/bin/perl -w
>
> use strict;
> use DB_File;
> use Fcntl;
>
> my @recs;
> my $rec_db = '/tmp/recno_example.db';
> my $record_len = 8;
>
> die "Usage: $0 index [value]\n" unless @ARGV >= 1 && @ARGV <= 2;
> my ($index, $value) = @ARGV;
>
> # Create the object and set some attributes
>
> my $R = new DB_File::RECNOINFO
> or die "Error setting attributes: $!";
> $R->{reclen} = $record_len;
> $R->{flags} = R_FIXEDLEN;
>
> # Tie array to file, creating file if necessary
>
> my $T = tie @recs, 'DB_File', $rec_db, O_CREAT | O_RDWR, 0640, $R
> or die "Error tying array to $rec_db: $!";
>
> if (defined $value)
> {
> $recs[$index] = substr($value, 0, $record_len);
> }
> else
> {
> print defined $recs[$index] ? $recs[$index] : 'undef', "\n";
> }
>
> # This is how you would sync, though it's superfluous here:
> #
> # $T->sync(R_RECNOSYNC) == 0 or die "Sync error: $!";
>
> # Finished
>
> undef $T;
> untie @recs;
> __END__
>
> --
> Malcolm Ray University of London Computer Centre
------------------------------
Date: Sun, 22 Aug 1999 12:44:33 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Perl and DBM file questions
Message-Id: <37c0fe91.11871009@news>
On Sun, 22 Aug 1999 22:43:09 +1000, Geoff Roberts
<groberts@uow.edu.au> wasted bandwidth by writing:
> I get the same error - records will only be added to "virginal" database
> files. If I re-open a database file, then new records are not added.
Why do you quote 64 lines just to say
<jeopardy><aol>me too!</aol></jeopardy> ?
Marcel
Perl Padawan
--
sub AUTOLOAD{($_=$AUTOLOAD)=~s,^.*::,,;y,_, ,;print} Just_Another_Perl_Hacker();
------------------------------
Date: Sun, 22 Aug 1999 12:01:19 GMT
From: hoz@rocketmail.com (hoz)
Subject: Re: PERL EDITOR
Message-Id: <37bfe669.421103971@news.netvision.net.il>
>Does anyone of you know an good and nice editor for writting perl code?
for a windows editor I recommend editplus, its shareware
-hoz
------------------------------
Date: Sun, 22 Aug 1999 13:06:09 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Perl Email With Netscape
Message-Id: <37BFF5AF.ADA4EB95@blackhole-designs.com>
I was wondering if it is possible to send e-mail in Netscape 4.6 with a
random quotes using perl 518 (windows perl) acting as the signature
file.
Jimmy
------------------------------
Date: Sun, 22 Aug 1999 09:01:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl puzzle: array of booleans to ranges
Message-Id: <37c2bb81.1158642@news.skynet.be>
Bart Lateur wrote:
>Problem: convert an array of booleans to a list/array of ranges of where
>the boolean is true.
>
>from: @boolean = (1, 1, 0, 1, 1, 1, 0, 0, 1);
>to: @result = ([0, 2], [3,3], [8, 1]);
Here's my own first attempt. It works, but it doesn't look very "clean".
#! perl -w
@ranges = ranges(1,1,0,1,1,1,0,0,1);
foreach (@ranges) {
local $" = ",";
print "\[@$_\]\n";
}
sub ranges {
my(@ranges, $range);
for(my $i=0; $i<=$#_; $i++) {
if ($_[$i]) {
push @ranges,($range = [$i, 0]) unless $range;
$range->[1]++;
} else {
undef $range;
}
}
return @ranges;
}
Bart.
------------------------------
Date: 22 Aug 1999 04:52:19 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Perl puzzle: array of booleans to ranges
Message-Id: <slrn7rvi4b.c9p.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCLXXXII September MCMXCIII
in <URL:news:37bf9c06.1651265@news.skynet.be>:
[] OK, here's a cute little coding problem. The aim is the opposite of
[] obfuscation: make the code as clear as possible; and a variation on Perl
[] Golf: fewer Perl tokens ("words", not keystrokes) is better. For
[] example, "print $x+123" is 4 tokens: ("print", "$x", "+", "123").
[]
[] Problem: convert an array of booleans to a list/array of ranges of where
[] the boolean is true.
[]
[] from: @boolean = (1, 1, 0, 1, 1, 1, 0, 0, 1);
[] to: @result = ([0, 2], [3,3], [8, 1]);
[]
[] In the result, the first number is the starting index, the second number
[] the number of consecutive true values.
my @R = (1, 1, 0, 1, 1, 1, 0, 0, 1);
my ($i, $j, $k) = (-1, 0);
my @r = map {$i++; $k=$j++; $_ ? () : do {$j=0; $k ? [$i-$k, $k] : ()}} @R, 0;
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 22 Aug 1999 10:12:00 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Perl puzzle: array of booleans to ranges
Message-Id: <37bfdb0a.2775220@news>
On Sun, 22 Aug 1999 09:01:08 GMT, bart.lateur@skynet.be (Bart Lateur)
wrote:
> Bart Lateur wrote:
>
> >Problem: convert an array of booleans to a list/array of ranges of where
> >the boolean is true.
> >
> >from: @boolean = (1, 1, 0, 1, 1, 1, 0, 0, 1);
> >to: @result = ([0, 2], [3,3], [8, 1]);
How about using regexes?
my @ranges;
my @boolean = (1, 1, 0, 1, 1, 1, 0, 0, 1);
my $s = join('', @boolean);
push @ranges, ([length $`,length $1]) while $s =~ /(1+)/og;
Marcel
Perl Padawan
--
sub AUTOLOAD{($_=$AUTOLOAD)=~s,^.*::,,;y,_, ,;print} Just_Another_Perl_Hacker();
------------------------------
Date: Sun, 22 Aug 1999 08:56:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Recursing through directory headache
Message-Id: <37c0ba4a.847327@news.skynet.be>
unibrow@my-deja.com wrote:
>I am trying to do a routine which recurses through
>a given directory tree at the same time renaming
>files.
I assume File::Find is out, for the same reason as Ilya: you're changing
to change the directory structure while reading through it. So here's a
hand made solution, which reads the whole directory first, and THEN
works it's way through it. It's a memory friendly solution, so it keeps
not more in arrays than necessary. That's why it isn't defined using
recursion.
I also assume that you only need to process/rename files, not
directories.
#perl -w
traverse (\&process, 'd:/', 'e:/');
sub process {
my($filename) = @_;
#also: $_ is the file's basename on entry
#chdir'ed to file's directory
#example:
if(s/\.jpeg$/.jpg/) {
rename $filename, $_;
}
}
sub traverse {
my $process = shift; # code ref
local $_;
my $dirsep = "/";
while(@_) {
my $dir = shift;
local *DIR;
opendir(DIR,$dir) or die "Cannot open directory $dir: $!\n";
my @file = grep { $_ ne '.' && $_ ne '..' } readdir(DIR);
closedir(DIR);
chdir $dir;
$dir =~ s/\Q$dirsep\E?$/$dirsep/o;
my @dirs;
while (@file) {
$_ = shift @file;
if (-f) {
$process->("$dir$_");
}elsif (-d _) {
push @_, "$dir$_";
}
}
}
}
Bart.
------------------------------
Date: Sun, 22 Aug 1999 04:51:08 -0700
From: "Xah" <xah@best.com>
Subject: Re: Why use Python when we've got Perl?
Message-Id: <37bfe42c$0$221@nntp1.ba.best.com>
>From: miker3@ix.netcom.com (Michael Rubenstein)
>...
>
> The problem in comp.lang.perl.misc is not the beginners -- it is
> the regulars.
We, as Perl programers, enjoy what we do. Flaming is part of the culture,
not to mention a good training ground for stupid newbies. Rather a nice
multi-purpose filtering system. If you have thick skin and you endured, then
you have what to takes to be a Perl preacher like us. Otherwise, we're more
than happy to kick you back to your dustless hospital room or research labs.
Perl wouldn't be a nice community without bad asses like Tom Christensan,
Chris Nador and some other regulars I don't want to mention now. We thrive
on smiting newbies. We live to smite each other too. If you start to feel
uncomfy, get out.
un'stand?
PS I love Tommy's automatic email manifesto on newsgroup line formats. I got
few of them in the past, and I lived to tell the tale. One day I'll write a
bot that bounce one for one of every his spams. Here in comp.lang.perl.misc,
we learn by doing.
Xah
xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
"I -- like many unix weenies -- love stupid nonsensical quotes."
--autononymous
------------------------------
Date: Sun, 22 Aug 1999 05:06:28 -0700
From: "Xah" <xah@best.com>
Subject: Re: Why use Python when we've got Perl?
Message-Id: <37bfe7c4$0$217@nntp1.ba.best.com>
----------
In article <37B7E1AC.FF4FF2CF@strs.co.uk>, Ian Clarke <I.Clarke@strs.co.uk>
wrote:
>> The problem in comp.lang.perl.misc is not the beginners -- it is
>> the regulars.
>
> I agree completely. As the person who started this whole thing
> (sheepish grin) the regulars, Tom in particular, has been rude, and
> resorted to personal insults on a number of occasions, even while I
> remained calm and polite. He repeatedly accuses me of being a troll and
> inciting flames (despite the fact that he was the only one flaming!).
> To top it all off, having posted numerous "courtesy" copies of his
> newsgroup postings to my email address, to which I replied on-subject
> and politely, he then emailed me an email saying that I had been
> killfiled! A rather pathetic way to get the last word in my opinion.
What the fuck do you know? (yes, I used that language often just like Tom
said he does. Check deja news for yourself.) If you didn't public proclaim
that somebody is "trolling" or that you "killfiled" somebody or that you
send somebody to "/dev/null", then you don't deserve to be in
comp.lang.perl.misc.
Lessen one for ya: As soon as you don't agree with someone and it heats up,
you must cry troll or one of the other alternative above. Any thing along
the lines of "auto-deletion" won't do, because it's too not cool. And, you
MUST proclaim it publicly so that you can prove to other perl mongers that
you have the true monger spirit. I guess the other functionality of this
ritual is some kinda warning system. As you know, not all perl programers
are bright like sunshine. The semi-newbies jerk into bad defense. It's
always a show-stopper.
> Lucky I do not judge Perl on the quality of their newsgroup regulars.
Unlucky for you that you didn't. Now go back to your python group and enjoy
your polite studies.
> Ian.
Xah
xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
"The three principle virtues of Perl programers: mundaneness, sloppiness,
and fatuousness." -- Larry Somebody
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 614
*************************************