[13750] in Perl-Users-Digest
Perl-Users Digest, Issue: 1160 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 23 18:05:22 1999
Date: Sat, 23 Oct 1999 15:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940716307-v9-i1160@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 23 Oct 1999 Volume: 9 Number: 1160
Today's topics:
Re: building extensions on win32 <dchrist@dnai.com>
CGI script to start a perl script in the background. <newsgroups@selectweb.co.uk>
eval using the wrong namespace? jlamport@calarts.edu
Re: eval using the wrong namespace? (Brett W. McCoy)
hashes of hashes to/from DBM files... <seetherNOseSPAM@bellsouth.net.invalid>
Re: Help................ (Craig Berry)
Long menus -- any solutions? <stacy.doss@amd.com>
Re: Mac text files vs PC text files -- How are they dif <flavell@mail.cern.ch>
Re: multiple SUB's reading from single Filehandle? (G.S. Academic Affairs)
Re: not Perl, but please read! (Craig Berry)
Re: passing an array as a hash value? <r28629@email.sps.mot.com>
Re: perl on windows ? <dchrist@dnai.com>
Re: Reference challenge (Randal L. Schwartz)
Re: Reference challenge (Sean McAfee)
Re: Reference challenge <jeffp@crusoe.net>
Re: Reference challenge (Sean McAfee)
Re: Reference challenge (Sean McAfee)
Re: Save output from foreach loop outside loop? <dutch@mindspring.com>
uninitialized value on ftp subroutine <dutch@mindspring.com>
Re: Unlink (Craig Berry)
Re: Unlink <dan@tuatha.sidhe.org>
Re: Win32: Communicate w/ printer <dchrist@dnai.com>
Re: Win32: Communicate w/ printer <dchrist@dnai.com>
Re: Win32: Communicate w/ printer <dchrist@dnai.com>
Writing to Access97 - help jimbo69@bigfoot.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 23 Oct 1999 14:20:37 -0700
From: "David Christensen" <dchrist@dnai.com>
Subject: Re: building extensions on win32
Message-Id: <7ut8u0$scl$1@pollux.dnai.com>
Mike:
> I'm not a perl hacker, but I'm trying to use swig to produce a
> perl extension wrapper for a C library. This works on linux and
> other versions of unix with no problem, but for some reason, I
> can't get it to compile correctly on windows. I can't afford MS
> VC++ so I'm using cygwin and mingw32.
>
> My question is: where can I get a set of perl header files that
> either cygwin or mingw32 will accept?
>
> Any ideas?
It's my understanding that you have to use the same compiler for
modules as was used to build Perl itself. So, starting with a
binary distribution and then using another compiler for modules
simply won't work.
Go here: http://www.cpan.org/src/index.html
Grab this file: stable.zip
I seem to recall there's a top-level readme and one for each
compiler.
Build Perl and then build your modules. Take notes and post them
here so I can do it too :-)
--
David Christensen
dchrist@dnai.com
------------------------------
Date: Sat, 23 Oct 1999 21:30:54 GMT
From: Col <newsgroups@selectweb.co.uk>
Subject: CGI script to start a perl script in the background.
Message-Id: <s14a8een85932@corp.supernews.com>
Hi
I've been looking for a way to have a cgi script start off a perl script
on my server and then carry on.
To explain this better:
I load my cgi script through my browser and it then starts off a perl
script in the background and displays some text on the page and stops.
But the perl script is still running in the background until it finishes.
I've tried both system and exec (and even placing an & after the path of
the script) to call the perl script but the cgi script doesn't complete
until the backgrounded process has finished (I can stop the cgi
script/close the browser and the backgrounded script still runs but I'd
rather the cgi finished and left the perl script to do its business).
I've read something about fork but haven't got a clue how to use this and
can't find any 'dummy' guides.
Thanks for any help.
Col
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Sat, 23 Oct 1999 18:55:45 GMT
From: jlamport@calarts.edu
Subject: eval using the wrong namespace?
Message-Id: <7ut0bg$1rb$1@nnrp1.deja.com>
Here's the deal: I've got a global variable called $content. Then,
inside a block, I've created a local variable (using my) also called
$content. Inside this block, I eval a string which contains code that
sets $content. In other words, here's the gist of the program (much,
much simplified):
my $content;
{
$_ = '$content = "yadda yadda";';
my $content;
eval;
}
This *should* (if I understand the documentation for eval correctly) set
the *local* variable (since that's the context in which the string is
eval'ed). But it's not: it's setting the global variable. How do I get
the string to be eval'ed in the context of the block which it's in?
Is this a bug in Perl? Or am I misunderstanding the scoping rules for
eval? (The wording in the documentation is a little ambiguous.)
-jason
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 23 Oct 1999 21:11:31 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: eval using the wrong namespace?
Message-Id: <slrn8149ct.siq.bmccoy@moebius.foiservices.com>
Also Sprach jlamport@calarts.edu <jlamport@calarts.edu>:
>Here's the deal: I've got a global variable called $content. Then,
>inside a block, I've created a local variable (using my) also called
>$content. Inside this block, I eval a string which contains code that
>sets $content. In other words, here's the gist of the program (much,
>much simplified):
>
>my $content;
>{
> $_ = '$content = "yadda yadda";';
> my $content;
> eval;
>}
>
>This *should* (if I understand the documentation for eval correctly) set
>the *local* variable (since that's the context in which the string is
>eval'ed). But it's not: it's setting the global variable. How do I get
>the string to be eval'ed in the context of the block which it's in?
If you want the $content variable to be private (local) inside the block,
use the local keyword instead -- it creates a dynamically scoped variable
that is only accessible inside the block and in subs called within the
block. This can be dangerous if subroutines inside the block want to use
the global $content.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Sat, 23 Oct 1999 14:53:12 -0700
From: seether <seetherNOseSPAM@bellsouth.net.invalid>
Subject: hashes of hashes to/from DBM files...
Message-Id: <11f733ec.31a32faa@usw-ex0102-016.remarq.com>
Help. I'm having a problem either a. writing a hash table of hashes to
a dbm or b. reading ... or of course both.
here is my write code:
dbmopen ( %OUTFILE, $FILENAME, 0666 ) || die "\nCannot open file
$!\n";
foreach $PageKey ( keys %hash_table ){
$OUTFILE{$PageKey} = $hash_table{$PageKey};
foreach $NameKey ( keys %{ $hash_table{$PageKey} } ){
$OUTFILE{$PageKey}{$NameKey} = $hash_table{$PageKey}{$NameKey};}}
dbmclose ( %OUTFILE );
any help would be GREATLY appreciated.
Thanks
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Sat, 23 Oct 1999 20:32:17 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help................
Message-Id: <s146qh7e85987@corp.supernews.com>
Fleet Admiral Peter Hodder (peterh@vk2kcf.stealth.com.au) wrote:
: I need help. What I need is, to be able to let users on a Linux
: Server run Perl/CGI scripts for web pages.
Okay. By the power and authority vested in me, I hereby grant you
permission to let your Linux server users run Perl CGI scripts for web
pages.
Seriously: What are you asking? And why here? Sounds like an issue with
Linux, or your web server.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Sat, 23 Oct 1999 16:28:41 -0500
From: Stacy Doss <stacy.doss@amd.com>
Subject: Long menus -- any solutions?
Message-Id: <38122889.99150B6C@amd.com>
Is there any way to have a menu widget display in multiple columns?
Background info:
I have a dynamic menu that can disply from 1 to a 100 or so items. The
screen resolution limits the number of items actually displayed. I'd
like for the menu to wrap and start a new column at the screen boundry.
Can I do this without creating several arbitrary cascades?
--
_______ : Stacy Doss
\____ | Advanced : Product Development Engineering
/| | | Micro : Stacy.Doss@amd.com
| |___| | Devices : Voice: (512) 602-2324
|____/ \| : FAX: (512) 602-6970
: Wats Line: 1-800-538-8450 x52324
------------------------------
Date: Sat, 23 Oct 1999 21:20:50 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Mac text files vs PC text files -- How are they different?
Message-Id: <Pine.HPP.3.95a.991023190800.18075H-100000@hpplus01.cern.ch>
You now put me in a dilemma, as you have emailed me with further
interesting details, but you do not appear to have posted same to
usenet. With respect, I have to make a practice of routinely declining
emailed requests for help (I get too many, and my employer would not
like to find out I gave free personal consultancy), and what's worse,
any answer I were to give in email would not be subject to the rigours
of review by the regulars here.
I don't see anything in your mail that it would represent a breach of
confidence to quote in public, so I hope I am not doing anything
improper by bringing it into the discussion here...
On Sat, 23 Oct 1999, Alan J. Flavell wrote:
> Did you transfer then as text files (aka "ASCII" mode)? If not, why
> not, as you say they are text files?
What I am doing is saving the same file from Excel as a tab delimited
text file on both a MAC and a PC.
Fair enough. I'm going to have to assume that on both platforms this
would produce a text file that follows the usual newline conventions of
the platform on which it has been created.
Then I am trying to read in each
file via perl one line at a time.
But you are trying to read them on which platform? I understood from
your original question that you first transfer them to unix (by FTP, as
I understood you to say) and then try to run Perl against them there.
Both files have the end of line character of \r\n
We may have a terminology problem here. In Perl, \r and \n are logical
concepts, not specific binary control characters/sequences. I suspect
that you are using these notations to refer to the carriage return (\015
aka CR) and linefeed (\012 aka LF) characters; but on the Mac, a newline
(\n in Perl code) is represented internally by a carriage return (\015),
as a result of which, the linefeed (\012) is chosen to represent \r,
hence there is plenty of scope for confusion.
Having got that off my chest, I have to ask whether your assertion
referred to the files before or after they were transferred?
but when I when i try reading in each file one line at a time, the mac
file gets the whole file read in at once, while the PC file only reads
one line in at time.
This is on unix, yes? The prima facie conclusion here is that your Mac
file has arrived on the unix platform with its Mac-style binary newline
characters (i.e CR alone) intact, and no LF characters.
That is what has me confused. WHen I ftped these files to my unix
box, I did use TEXT as the transfer type
I'm sorry, but I have to say I find this hard to credit. We seem to
have here the standard symptom of a file that has been transferred
cross-platform in binary rather than in text mode.
As I said before:
> Recovering from the above error is possible, but not the way you are
> going about it. Which do you want - to do the job properly, or to
> learn how to code Perl to recover from the blunder?
I hope the regulars will step in and correct anything I get wrong
here...
The ideal answer is to always transfer text files as text files,
and always process them in Perl as text files. Then, a newline is a
newline is a newline, and everyone is happy.
But when it's not working as planned, it may be necessary, or at least
more appropriate, to read the potentially mishandled file as binary,
and get a hold of the actual control characters (\015 and \012)
directly.
So, if in fact the file (in the form in which you have it on unix)
cannot be relied on to have one unambiguous character acting as its line
ending, then the normal line-by-line reading procedure of Perl cannot be
reliably used, since one can only set the input separator $/ to one
thing or another, it cannot specify alternatives.
So if you are to code your Perl so that it can recover the situation
(modulo my separate point about the wrong 8-bit character coding), you
may need to read the file in its entirety (or in chunks if necessary)
and then go through it massaging the line endings found there, which
could be CR alone (from the Mac), CR+LF (from the PC) or LF alone (if a
text file had been _properly_ transferred in text mode to unix).
To keep a clear head, I would recommend referring to these characters in
Perl programs as \015 and \012 (or create a pair of constants with
appropriate names). I'm well aware that the unix fans regard the unix
representation of \r and \n as the canonical one, and the Mac platform
as a deviant, but it makes for more portable and harmonious code if you
can refer to a thing by its proper name in context, rather than by a
name that only happens to be correct on unix, and has to be stood on its
head for the Mac. (No, I'm not a great fan of the Mac, I just prefer to
keep a clear head about things).
Summary:
A properly formatted text file is best handled as a text file, with
the (logical) newline function \n as the input separator.
A potentially botched text file may be more controllably handled as
binary, with coding to detect the control characters (\015 and \012)
and take appropriate action. Don't forget the 8-bit character coding
issue too, unless you're sure the text is limited to 7-bit us-ascii.
good luck
------------------------------
Date: Sat, 23 Oct 1999 13:22:01 GMT
From: gsaa@mitra.cse.iitb.ernet.in (G.S. Academic Affairs)
Subject: Re: multiple SUB's reading from single Filehandle?
Message-Id: <slrn813d8f.lp6.gsaa@mitra.cse.iitb.ernet.in>
On Wed, 13 Oct 1999 13:25:35 -0400, Jeff Pinyan <jeffp@crusoe.net> wrote:
| [posted & mailed]
|
| On Oct 13, yeah@rite.net blah blah blah:
|
| > openit();
| > do_one();
| > do_two();
| > do_three();
| >
| > sub openit {
| > open(FH,"netstat -nr|");
| > }
| > sub do_one {
| > while(<FH>) {
| > print $_;
| > }
| > sub do_two {
| > while(<FH>) {
| > print $_;
| > }
| > sub do_three {
| > while(<FH>) {
| > print $_;
| > }
| >
| > whats seems to be happening is after the first sub routine FH seems to
| > be empty'd, is there a faq on this kind of filehandle manipulation?
Well, if all you want to do is to walk thru the same file content three times..
for presumably sequential operations on the data, you just need to close the
file once and open it again before calling. If you want do_twoi() to work
on the processed data of do_one() you could consider loading the file in an
array... (the standard @array=<somefilehandle>), though memory
considerations apply,
Hope that helps.
--
Mayank Jain
mayank@iportia.com
Senior Undergrad
IIT Bombay
------------------------------
Date: Sat, 23 Oct 1999 21:05:21 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: not Perl, but please read!
Message-Id: <s148ohl985980@corp.supernews.com>
Michel Dalle (michel.dalle@usa.net) wrote:
: In article <7urgip$3n1$1@nnrp1.deja.com>, yoga9900@my-deja.com wrote:
: >This is a breaking story: http://www.msnbc.com/news/323734.asp?cp1=1
: <snip>
:
: Have you tried the Meditation::Yoga module from CPAN ?
: That might help you reach the right frame of mind.
I tried it. I felt just the same, but my server seemed much calmer.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Sat, 23 Oct 1999 07:07:54 -0500
From: TK Soh <r28629@email.sps.mot.com>
To: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: passing an array as a hash value?
Message-Id: <3811A51A.2D145DE2@email.sps.mot.com>
Bob Walton wrote:
<snip>
> $hash{$word}=\@array;
<snip>
> and how to get the entire array out:
>
> $arrayout=@{$hash{$word}};
^
Oops! got the number of elements instead.
-TK
------------------------------
Date: Sat, 23 Oct 1999 13:39:00 -0700
From: "David Christensen" <dchrist@dnai.com>
Subject: Re: perl on windows ?
Message-Id: <7ut6gq$s59$1@pollux.dnai.com>
Fred:
> How can I install module into perl ?
> I can not make from windows ?
It is good to know how to find answers by yourself. Start here:
http://www.activestate.com/ActivePerl/docs/
Under the 'ActivePerl FAQ' and 'Modules & Samples' you will find:
Where do I get make for Win32?
nmake is a 'make' like program for Win32 systems by Microsoft.
It is available from
ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe
David Christensen
dchrist@dnai.com
------------------------------
Date: 23 Oct 1999 12:47:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Reference challenge
Message-Id: <m11zal7tb4.fsf@halfdome.holdit.com>
>>>>> "Sean" == Sean McAfee <mcafee@waits.facilities.med.umich.edu> writes:
Sean> Secondly, it cannot portably distinguish between a non-reference and a
Sean> reference blessed into package "0".
What are you smoking?
for ("non-reference", (bless [], 0)) {
if (length ref $_) {
print "$_ is a reference\n";
} else {
print "$_ is not a reference\n";
}
}
non-reference is not a reference
0=ARRAY(0x80c821c) is a reference
Now, blessed into the *empty-string* package, I believe you.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 23 Oct 1999 20:44:32 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Reference challenge
Message-Id: <Q6pQ3.515$4G.101736@news.itd.umich.edu>
In article <38110D10.CBEFA761@home.com>,
Rick Delaney <rick.delaney@home.com> wrote:
>In particular, I don't see any way around
> bless [], "0";
>which appears to be the point of Sean's restrictions. I can get around
>it with a relaxed condition 3 (allowing me to call eval "&\$ref") by
>removing the C<ref> test at the beginning of the sub but that's no fun.
Eep! I just realized that I spoke too soon when I said that relaxing
condition 3 would allow a solution to the challenge. This is the worst
reference expression I was able to come up with before issuing my challenge:
$ref = bless sub { &{ [] } }, "0";
If you merely test $ref as a code reference by doing something like this:
eval "&\$ref";
return "CODE" if $@ !~ /Not a CODE reference/;
...then you're catching the exception throw by the anonymous subroutine, not
by the eval. I'd originally thought you could get around this by doing
something like the following:
my $errmsg = "Not a CODE reference at ".__FILE__." line ".(__LINE__ + 1);
eval "&\$ref";
return "CODE" if $@ ne $errmsg;
...but I just now realized that $@ will NOT refer to __FILE__ and __LINE__,
but will instead look something like "Not a CODE reference at (eval 1)
line 1". Hmmmm...It seems my faulty solution can be fixed like this:
eval "&{[]}";
(my $errmsg = $@) =~ s/(?<=\(eval )(\d+)(?=\) line \d+\z)/ $1 + 1 /e;
eval "&\$ref";
return "CODE" if $@ ne $errmsg;
Okay, so it's possible to do it this way, but DAMN that's ugly code.
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Sat, 23 Oct 1999 16:51:29 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Reference challenge
Message-Id: <Pine.GSO.4.10.9910231648410.15158-100000@crusoe.crusoe.net>
On Oct 23, Randal L. Schwartz blah blah blah:
> if (length ref $_) {
This is against his policy. He says some versions of perl would return a
different kind of false. However, all perls I've seen return 0 for
package 0, and "" for non-references.
> Now, blessed into the *empty-string* package, I believe you.
That upsets me, merlyn. You didn't try it. Under Perl 5, with -w on, you
get:
Explicit blessing to '' (assuming package main) at - line 1.
when you try:
bless $a = [], "";
--
MIDN 4/C PINYAN, USNR, NROTCURPI
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
------------------------------
Date: Sat, 23 Oct 1999 20:49:30 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Reference challenge
Message-Id: <ubpQ3.516$4G.101917@news.itd.umich.edu>
In article <m11zal7tb4.fsf@halfdome.holdit.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Sean" == Sean McAfee <mcafee@waits.facilities.med.umich.edu> writes:
>Sean> Secondly, it cannot portably distinguish between a non-reference and a
>Sean> reference blessed into package "0".
> for ("non-reference", (bless [], 0)) {
> if (length ref $_) {
> print "$_ is a reference\n";
> } else {
> print "$_ is not a reference\n";
> }
> }
> non-reference is not a reference
> 0=ARRAY(0x80c821c) is a reference
perlfunc guarantees only that ref() returns FALSE if its argument is not a
reference. Sure, ref() returns "" *now* if passed a non-reference, but
suppose a future version of Perl returned 0 instead? Your code would
break.
>Now, blessed into the *empty-string* package, I believe you.
Yes, that would have enabled me to issue my challenge with fewer restrictions,
but bless() appears to treat its second argument as "main" if you actually
give it "".
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Sat, 23 Oct 1999 21:03:49 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Reference challenge
Message-Id: <VopQ3.518$4G.102047@news.itd.umich.edu>
In article <w_NP3.230$4G.62541@news.itd.umich.edu>, I wrote:
>The challenge:
>Write a 100% Perl, 100% portable, 100% bulletproof subroutine that will
>determine whether its single argument is a reference, and if so, what type
>of reference it is.
>Conditions:
[snip]
Well, I've inadvertently come up with a solution to my own challenge, using
that little-used Perl feature, *FOO{THING}.
sub reftype {
my $ref = shift;
eval { use strict; *$ref };
return "GLOB" if !$@;
return undef if $@ =~ /"strict refs" in use/;
eval { $$ref };
return "SCALAR" if !$@;
local *GLOB = $ref;
foreach (qw(ARRAY HASH CODE)) {
return $_ if defined *GLOB{$_};
}
die "Should never reach this point...";
}
I *think* this should handle all cases correctly.
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Sat, 23 Oct 1999 17:26:54 -0400
From: "Dutch McElvy" <dutch@mindspring.com>
Subject: Re: Save output from foreach loop outside loop?
Message-Id: <7ut8jc$7i3$1@nntp6.atl.mindspring.net>
Thanks
----------
In article <7use24$fm7$1@nntp1.atl.mindspring.net>, "Dutch McElvy"
<dutch@mindspring.com> wrote:
> How can I save the output generated by a foreach loop into a single variable
> so that it can be used outside the loop?
>
> Thanks,
>
> Dutch
------------------------------
Date: Sat, 23 Oct 1999 17:34:32 -0400
From: "Dutch McElvy" <dutch@mindspring.com>
Subject: uninitialized value on ftp subroutine
Message-Id: <7ut91n$7a4$1@nntp6.atl.mindspring.net>
I am using the following script to upload all files in a certain directory
and place them on the remote machine under a new name and a new directory
created from a portion of the file name. This could probably be done more
cleanly but it seems to work ok only I get an error when I use -w of
"uninitialized value" at the lines containing $newname and $newdir. What
could I do to elimante this warning?
Thanks for the help,
Dutch
#!/usr/bin/perl -w
#Main program
use Net::FTP;
$ftp = Net::FTP->new("somemachine.com.somewhere");
$ftp->login("usr",'passwd');
$ftp->binary;
$ftp->cwd("/somedir");
rename();
$ftp->quit;
sub rename {
$dir = "/somedir";
opendir(DIR, $dir ) || die "can't opendir $dir: $!";
(@filenames, $newname, $newdir) = readdir(DIR);
closedir DIR;
foreach ( @filenames ) {
$_ =~ s/(...)(.......)(.....)(....)(...........)/$1$2$3$4$5/;
$newname .= "$2$3";
$newdir = "$1";
}
$ftp->put("$newdir/$newname") or die "Could not ftp";
}
------------------------------
Date: Sat, 23 Oct 1999 20:43:24 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Unlink
Message-Id: <s147fc1385920@corp.supernews.com>
Shuba Swaminathan (sswaminathan@micron.com) wrote:
: Could you please also comment on the efficiency of if-then compared to
: eval? Which is better programming style and more efficient?
A good mnemonic is 'eval is evil'. Using eval is something you should do
only when you have no other options. It is staggeringly inefficient, and
also considered poor style for a variety of reasons.
: My code line was:
: unlink("LOCK.".$num) or eval {print ERROR "022 Could not delete lock file\n"; exit 1;};;
Why not just do
unless (unlink("LOCK$num")) {
print ERROR "022 Could not delete lock file\n";
exit 1;
}
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Sat, 23 Oct 1999 20:49:29 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Unlink
Message-Id: <tbpQ3.495$cP2.2473@news.rdc1.ct.home.com>
Craig Berry <cberry@cinenet.net> wrote:
> A good mnemonic is 'eval is evil'.
A better one is "string eval is evil". Block eval's
quite nice, and very handy. (And cheap. Can't forget
cheap)
Dan
------------------------------
Date: Sat, 23 Oct 1999 13:45:13 -0700
From: "David Christensen" <dchrist@dnai.com>
Subject: Re: Win32: Communicate w/ printer
Message-Id: <7ut7d8$s8a$1@pollux.dnai.com>
-----Original Message-----
From: Dirk Ruediger <drue@madmax.boerde.de>
To: David Christensen <dchristensen@california.com>
Date: Wednesday, October 20, 1999 12:18 PM
Subject: Re: Win32: Communicate w/ printer
>Hi David!
>
>Thanks for your reply!
>I'll answer you via email, I don't like dejanews (but im sitting
>behind a very robust firewall and have no direct news access:( ).
>
>On Mon, 18 Oct 1999, David Christensen wrote:
>
>> I have been thinking about how to pretty print forms-based
>> reports (fonts, tables, graphics, etc.) in a platform
>> independent way from a Perl console or Perl/Tk app. No answers
>> yet, just some ideas:
>>
>> 1) Perl/Tk graphics viewer and a postscript or LaserJet PCL
>> back-end (how to submit?);
>
>I dislike it, because one has to do all text formating on a canvas
>and it should be better to take an advanced program to do this job
>of rendering and take an Perl/Tk graphics viewer as one backend
>and the printer an another.
>
>> 2) postscript generator and a viewer (ghostscript) (how to
>> automate?);
>
>Item 2) is similar (except you think of latex/lout/jade as
>postscript generators). It's not so good to program postscript
>directly (these programs can do that better ;-).
>
>> 3) HTML generator (Perl/Cgi) and a browser (how to automate?).
>
>Why use a browser as backend (see item 4)? But it would be right,
>if you want to start the browser as viewer and the user has to
>press the "print button" to hand it over to printer.
>
>4) SGML/XML/HTML generator and jade/dsssl backend to ps, via
>ghostscript (as a filter) to any printer language, that's easy to
>automate.
>
>5) LaTeX generator and "latex -> dvi -> ps -> printer lang" or
> "latex -> dvi -> printer lang", that's easy too.
>
>Disadvantage of item 4) and 5) is the installation of any text
>rendering software (maybe docbook dtd+jade are not as large as
>LaTeX or lout and it supports many output formats.
>
>> As for querying printer/ queue status, I dunno. Sounds like a
>> platform-independent abstraction (Perl API) and
>> architecture-specific modules are needed (?).
>
>And that's the problem. I'd like to write a module (e.g.
>printer.pm) and encapsulate the different flavours of printer
>access. I think it's easy on platforms w/ lpr-support ... that
>should be all unixes (aix has a much more sophisticated spooling
>system, but emulates the lpr-system. I hope the other unixes do so
>too). I have BeOS installed and hope, this will play this game
>too. My largest hurdle is an access to win printers. I think,
>there should be some information in the registry, and there should
>be a program like "print" in dos. I asked Jan Dubois (Programmer
>and Maintainer of Win32::OLE), but he couldn't help me. But I
>think, it should be possible via OLE?!
>
>> Does anybody else have ideas or experience trying a solution?
>>
>> --
>> David Christensen
>> dchristensen@california.com
>
>The module "printer.pm" should detect all kinds of printer access
>during initialistion and query the state of all possible printers
>on demand. If you want to print something, there should be
>something like a filehandle and the usual print/printf/... cmds.
>No big deal at all ;-)
>
>That's my state of expierence.
>Maybe, we could get it right?
>
>Ciao for now, Dirk
>
>--
>Dirk Ruediger, Magdeburg, Germany
>
>Time goes, you say? Ah, no! Alas, Time stays, we go.
> Austin Dobson (1840-1921), The Paradox of Time
------------------------------
Date: Sat, 23 Oct 1999 13:48:09 -0700
From: "David Christensen" <dchrist@dnai.com>
Subject: Re: Win32: Communicate w/ printer
Message-Id: <7ut7d9$s8a$2@pollux.dnai.com>
Dirk:
>latex/lout/jade
>jade/dsssl
>latex -> dvi -> ps -> printer lang
>latex -> dvi -> printer lang
>docbook dtd+jade
I've heard of Latex.
ps = postscript? print spooler?
Printer lang = printer lanuage (postscript, PCL, etc.)?
What are lout, jade, dsssl, dvi, docbook, dtd?
Note that I do most of my work on a Windows 98 box, but can run
things that have been ported to DJGPP.
>And that's the problem. I'd like to write a module (e.g.
>printer.pm) and encapsulate the different flavours of printer
>access. I think it's easy on platforms w/ lpr-support ... that
>should be all unixes (aix has a much more sophisticated spooling
>system, but emulates the lpr-system. I hope the other unixes do so
>too). I have BeOS installed and hope, this will play this game
>too. My largest hurdle is an access to win printers. I think,
>there should be some information in the registry, and there should
>be a program like "print" in dos. I asked Jan Dubois (Programmer
>and Maintainer of Win32::OLE), but he couldn't help me. But I
>think, it should be possible via OLE?!
I have no idea of Win32's internal machinations when I click the
printer icon. But, I do have a good API book and Borland C++
Builder (which includes Win32 docs in the help system). I'll start
researching.
>The module "printer.pm" should detect all kinds of printer access
>during initialistion and query the state of all possible printers
>on demand. If you want to print something, there should be
>something like a filehandle and the usual print/printf/... cmds.
>No big deal at all ;-)
>That's my state of expierence.
>Maybe, we could get it right?
Maybe something like Bill Birthisel put together for serial
ports -- Device::SerialPort for Linux and Win32::SerialPort for
Win32. They share a common function call interface, so code
written for one should port to the other simply by changing the
'use' statement.
Would you care to create a draft pod for a ficticious collection of
Printer.pm modules (Device::Printer, BeOS::Printer, Win32::Printer,
etc.)?
David Christensen
dchristensen@california.com
------------------------------
Date: Sat, 23 Oct 1999 13:53:50 -0700
From: "David Christensen" <dchrist@dnai.com>
Subject: Re: Win32: Communicate w/ printer
Message-Id: <7ut7db$s8a$3@pollux.dnai.com>
-----Original Message-----
From: Dirk Ruediger <drue@madmax.boerde.de>
To: David Christensen <dchristensen@california.com>
Date: Friday, October 22, 1999 3:26 PM
Subject: Re: Win32: Communicate w/ printer
>Hi David!
>
>On Thu, 21 Oct 1999, David Christensen wrote:
>
>> Dirk:
>>
>> >latex/lout/jade
>> >jade/dsssl
>> >latex -> dvi -> ps -> printer lang
>> >latex -> dvi -> printer lang
>> >docbook dtd+jade
>>
>> I've heard of Latex.
>> ps = postscript? print spooler?
>> Printer lang = printer lanuage (postscript, PCL, etc.)?
>> What are lout, jade, dsssl, dvi, docbook, dtd?
>
>Ok.
>latex is a typesetting system, lout is it too.
>They both get an input file in their native languag, they process
>it and output an file w/ rendered data. Latex produces dvi (device
>independend format), a format, that can easily be conferted to
>pdf, PCL, ps (postscript). That's similr to HTML, where the
>browser gets only Metadata (data and commands, how these data
>should be rendered) and the browser creates the "page image". As I
>told you, latex and lout produce postscript output. And
>ghostscript (a program that transfers postscript into several
>printer languages or graphics formats) converts them. This data
>stream can be handed over to the printer device.
>
>HTML is also a language to describe the contents of a document
>(title, header(s), tables, images, ...)-- it's a markup language.
>Generally spoken it's a Document Type Definition (DTD), defined in
>SGML (look at altavista for that ;-). Docbook is another DTD, that
>defines (very detailed) the structure of documents, especially
>software docs. (Look at books from O'Reilly, they are written w/
>Docbook DTD and then processed and rendered for publishing). SGML
>Documents are high portable and platform independent (look at HTML
>and compare it w/ handling of Winword-Docs on a Sun workstation
>;-). Jade is a program (a dsssl-enging) to process SGML-Documents,
>it checks, if the document is conformant to the according DTD
>(e.g. HTML or docbooc) and produces postscript or rtf (or other)
>output.
>
>Summary:
>You can write a file that describes the contents and layout of
>your document (but you don't draw the lines and cells of the table
>yourself ;-) and you take latex, lout or jade to render it to
>postscript. Then you take ghostscript to convert ps to your
>prefered printer language. And this file has to be transfered to
>the printer device. All these programs are usable as filters or
>background processes.
>
>I hope that I could help you. I only wanted to point out, that the
>best way to create a document as output of a program is the
>generation of a file that contains the document structure and
>contents and let the dirty work be done be highly specialized
>apps.
>
>If you never used one of them, I would apperciate docbook.dtd and
>jade (it also creates rtf) and is very sophisticated. O'Reilly
>published a book about Docbook DTD currently.
>>
>> Note that I do most of my work on a Windows 98 box, but can run
>> things that have been ported to DJGPP.
>
>It's time to change ;-)
>
>> I have no idea of Win32's internal machinations when I click the
>> printer icon. But, I do have a good API book and Borland C++
>> Builder (which includes Win32 docs in the help system). I'll
>> start researching.
>
>That's a good idea. Perhaps it's a general description of device
>access. Othervice we (you, I have no Windows dev. environment)
>could program a stub for the lpr support. That mean, we have to
>create to a small program (to query the printer state, delete
>print jobs and hand over a file to the printer) and if the module
>hs to be installed on a Win32 sustem, then also this interface
>program has to be compiled w/ any C-compiler.
>
>> Maybe something like Bill Birthisel put together for serial
>> ports -- Device::SerialPort for Linux and Win32::SerialPort for
>> Win32. They share a common function call interface, so code
>> written for one should port to the other simply by changing the
>> 'use' statement.
>
>That's what I thought of. But I'd like to encapsulate the type of
>PrinterPort in the module (there you can detect the type of OS in
>perls variable $^0.
>
>> Would you care to create a draft pod for a ficticious collection
>> of Printer.pm modules (Device::Printer, BeOS::Printer,
>> Win32::Printer, etc.)?
>
>I will try to create a first (scetchy) version of printer.pm this
>weekend, but I can't promise, that I'll get ready. So we can
>disscuss it next week.
>
>Ciao for now, Dirk
>
>--
>Dirk Ruediger, Magdeburg, Germany
>
>"A computer without COBOL and Fortran is like a piece of chocolate
>cake without ketchup and mustard." -- John Krueger
------------------------------
Date: Sat, 23 Oct 1999 19:26:46 GMT
From: jimbo69@bigfoot.com
Subject: Writing to Access97 - help
Message-Id: <381a0204.4043006@news.freeuk.net>
Hello,
Can you help me.
My webserver is Unix.
I need a perl script to write to an Access97 (.mdb) Database which i
will upload to my webspace.
Can you help ?
Can this be done ??
Many thanks
Jim
jimbo69@bigfoot.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 1160
**************************************