[23959] in Perl-Users-Digest
Perl-Users Digest, Issue: 6160 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 18 21:10:40 2004
Date: Wed, 18 Feb 2004 18:10:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 18 Feb 2004 Volume: 10 Number: 6160
Today's topics:
Re: OPEN( , Get , or slurping problem <dha@panix.com>
Re: OPEN( , Get , or slurping problem <noreply@gunnar.cc>
Re: Posting Usenet News Messages SOLVED <ignoromnibus@cochon.fr>
Re: Posting Usenet News Messages <ignoromnibus@cochon.fr>
Re: Posting Usenet News Messages <ignoromnibus@cochon.fr>
Re: Posting Usenet News Messages <ignoromnibus@cochon.fr>
Re: Posting Usenet News Messages <usenet@morrow.me.uk>
Re: Posting Usenet News Messages <ignoromnibus@cochon.fr>
Re: Posting Usenet News Messages <ignoromnibus@cochon.fr>
Re: Sybperl - how to specify my own interfaces file <mpeppler@peppler.org>
Re: Sybperl - how to specify my own interfaces file <mpeppler@peppler.org>
testing for directories/files fails <parimi@none.nowhere.com>
Re: testing for directories/files fails <parimi@none.nowhere.com>
Re: testing for directories/files fails <gnari@simnet.is>
Re: Why is Perl losing ground? <spamtrap@dot-app.org>
Re: Why is Perl losing ground? <spamtrap@dot-app.org>
Re: Why is Perl losing ground? <uri@stemsystems.com>
Win32::Clipboard() and Excel <mikeflan@earthlink.net>
Re: win9x - how to test if a file is open? <perlcdr@mail.rumania>
Re: XML::DOM Encoding UTF-8 and ISO-8859-1 <flavell@ph.gla.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Feb 2004 23:16:49 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <slrnc37sj1.6p8.dha@panix2.panix.com>
In article <c0vtj9$1cqoqv$1@ID-184292.news.uni-berlin.de>, Gunnar
Hjalmarsson wrote:
> Yeah, I do know that Perl == CGI returns false (or doesn't
> compile...). ;-)
Ahem.
~ 18:13:43% perl -e 'print "yikes!\n" if Perl == CGI';
yikes!
eq, however, is a different matter entirely... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
... we didn't know what the hell we were doing, but we did it loud.
- Andy Partidge on early XTC
------------------------------
Date: Thu, 19 Feb 2004 00:47:51 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <c10ud1$1dgan2$1@ID-184292.news.uni-berlin.de>
David H. Adler wrote:
> In article <c0vtj9$1cqoqv$1@ID-184292.news.uni-berlin.de>, Gunnar
> Hjalmarsson wrote:
>
>>Yeah, I do know that Perl == CGI returns false (or doesn't
>>compile...). ;-)
>
> Ahem.
>
> ~ 18:13:43% perl -e 'print "yikes!\n" if Perl == CGI';
> yikes!
>
> eq, however, is a different matter entirely... :-)
Ouch! What can I say.. Maybe: You should have enabled strictures! ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 18 Feb 2004 19:09:32 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages SOLVED
Message-Id: <c112j6024al@enews1.newsguy.com>
Steve May wrote:
> What part of "a line with a space in it is not a blank line" is so hard to
> grasp?
>
Probably the same part of "it depends on context" that you don't grasp. ;)
Besides, once I got it to work ( see below ) it appears that in fact it IS
a blank line (either that, or datasend() is smart enough or dumb enough to
strip the leading spaces before sending it...).
> Sheesh! :-)
>
> Now a cursory search on Google turned up this page:
>
> http://freebooks.by.ru/view/RedHatLinux6Unleashed/rhl6u320.htm
>
> and this sample (which I take no credit/blame for):
>
> LISTING 31.8 Posting an Article to Usenet
>
> #!/usr/bin/perl
> open (POST, "post.file");
> @post = <POST>;
> close POST;
> use Net::NNTP;
> $NNTPhost = 'news';
> $nntp = Net::NNTP->new($NNTPhost)
> or die "Cannot contact $NNTPhost: $!";
> # $nntp->debug(1);
> $nntp->post()
> or die "Could not post article: $!";
> $nntp->datasend("Newsgroups: news.announce\n");
> $nntp->datasend("Subject: FAQ - Frequently Asked Questions\n");
> $nntp->datasend("From: ADMIN <root\@rcbowen.com>\n");
> $nntp->datasend("\n\n");
> for (@post) {
> $nntp->datasend($_);
> } # End for
> $nntp->quit;
>
> *NOTE* the double new lines with no space between separating
> the header and the body.
NOTED! ;) But not necessary. I tried it with these two, then with one (as
well as with eight), and all worked. It just threw the excess lines into
the body.
>
> The above is not production quality, IMHO, as it is not
> scoped, does not use warnings nor strict,
> nor is it error trapped properly.
>
> Bt it should get the point across....
>
My reading of RFC 1036 seems to indicate that the required header lines for
date, message-id, and path are missing, so I'm a bit puzzled as to why it
works... but it does, and I don't really care about those one way or the
other, as long as the host adds them (which it apparently does).
Now, here's the part that's really bothering me: I dredged up an example
my @Message = ( "Newsgroups: alt.test\015\012",
"From: nospam\@some-domain.tld\015\012",
"Reply-To: trash\@some-domain.tld\015\012",
"Subject: Teste Net::NNTP\015\012",
"Organisation: Someone\015\012",
"Content-Type: text/plain; charset=ISO-8859-1\015\012",
"Content-Transfer-Encoding: 8bit\015\012",
"X-No-Archive: yes\015\012",
"\015\012", # Leerzeile zwischen Header und Body
"Erste Zeile\015\012",
"Zweite Zeile\015\012"
);
# Das Gefuckel mit \015\012 lässt sich meist in einem Rutsch erledigen
# @message = map { "$_" . "\015\012" } (0..$#message);
my $OK = $server->post(\@Message);
Which seems to be not drastically different from what I was trying to do...
and it DOESN'T WORK (even when I added multiple CR/LF's on the "blank"
line). It finally dawned on me that Net::NNTP has a debug() method, so I
turned it on, and it says, guess what...
441 - Article has no body, just headers.
Huh? The output from debug, right up to that point, looks absolutely the
same as the output from the datasend() example you found, as far as I can
see, and if we change these lines to datasend() calls, it seems to work
just fine.
Boy, I dunno... I'm going to do what I was planning to do but
using the straight datasend() calls, but I still want to know why the
post([@message]) form doesn't work...
And, you know what? All the blather about what constitutes a "blank" line
didn't have diddley-squat to do with it, because I tried every combination
of them I could think of, including the CR/LF that turned out to work...
The only reason I put spaces in was to see if it for some reason just HAD
to have at least one character on the line to declare it a "line" (hey, you
never know until you try... ).
and
either NNTP doesn't effing care about the space, or datasend() strips it,
because I changed
> $nntp->datasend("\n\n");
to
> $nntp->datasend(" \n");
just for the hell of it... and... IT... WORKS.
So there. ;p
Thanks for the example - I was so intent on finding out why post() wasn't
working that I blew off other datasend() examples several times, looking
for a workiong post() one.
So... we still don't know why post() doesn't work, but at least we have
code that DOES work!
Thanks again!
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Wed, 18 Feb 2004 16:44:03 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages
Message-Id: <c10q2b21pae@enews1.newsguy.com>
gnari wrote:
> "Camelback Jones" <ignoromnibus@cochon.fr> wrote in message
> news:c105v92kpq@enews2.newsguy.com...
>> Steve May wrote:
>>
>>
>> That depends on what you mean by "blank", and on what Perl interprets as
>> "blank".
> actually it depends mostly on what NNTP considers blank, and I can tell
> you for sure that NNTP does not consider a line with space to be empty.
Okaaaay... that's two for two on managing to miss the reference a few lines
down to how NNTP interprets it, as well as the more specific statement in
another message in the same thread. In any event, the specific response was
to his question "I don't see any blank lines =here=, do you?"
>> However, that's not the point I was making there, which was: "lie" and
>> "incorrect" are not the same thing. What I said was not a "lie", it was -
>> in terms of what NNTP apparently wants - "incorrect".
>
> look back at the original context:
>
> a) the statement was followed by a smilie
> b) the joke was that the text 'This is the body of this message'
> ended up in the headers because of the extra space. so it
> was a counterfactual selfreferencial sentence. in other words, a lie
> of the most entertaining sort. thus the smilie
>
> gnari
Yes, and no. Whether the self-reference is - or was - contrafactual is
conditional upon circumstances outside of itself; that is, if the header of
the message were formatted properly, then it would be factual, but it has
no control over that.
The truly funny thing is that in the original version of the code, it was
"This is not the body", along the lines of Magritte's famous "Ceci n'est
pas une pipe".
Thanks for the response.
------------------------------
Date: Wed, 18 Feb 2004 16:43:57 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages
Message-Id: <c10q2601pae@enews1.newsguy.com>
Ben Morrow wrote:
>
> Camelback Jones <ignoromnibus@cochon.fr> wrote:
>> Steve May wrote:
>> >
>> > Consider: "Text\n \n"
>> >
>> > Note the constructon: text and a newline, a space and a newline.
>> > The first line holds text, the second line holds a space.
>> > I don't see any blank lines there, do you?
>> >
>>
>> That depends on what you mean by "blank", and on what Perl interprets as
>> "blank".
>
> ...and what NNTP interprets as blank.
... Oh, actually it's probably a lot MORE important what NNTP thinks, as I
tried to indicate a few lines after that, which you snipped.
>> I understand that what you are trying to say here is that a "blank" line
>> is one that consists of nothing but a single ascii character 10 - which
>> is not necessarily the case for every language and every piece of
>> software.
>
> As a general rule, Unix software (and descendants, such as Perl)
> consider a line blank iff it has nothing on it.
>
Okay, as a GENERAL rule.
>> For all I know, NNTP is perfectly happy to consider a line as "blank" if
>> there's nothing on it but spaces
>
> Well, you don't know much then, do you?
Well, let's see... no, that's not true: actually I know plenty. I happen to
not know a lot about Perl and *n*x; certainly not enough, at any rate. But
I'm trying to learn.
How about you? Quick, without looking 'em up, what's the average weight of
an adult bald eagle, who used "graxaflexaflugula" as a spelling bee word,
and who originated the worlds' most widely known equation, e = m c^2?
>Try reading the relevant RFC
I read 1036 and 822. I've no doubt I missed plenty in those. If neither of
those is the relevant one, what is?
> before writing a newsreader:
Ahhhh, no, that would be "newsposter", not "newsreader". Reading works,
this is about "posting" - see the subject? ;)
>NNTP considers a blank line to be exactly
>
> "\015\012\015\012"
>
> , ie. ASCII CR LF CR LF.
>
I'm gruntled to know that. If you'll tell me where this is documented, I'd
love to read it and see what other nuggets are to be found. This seems to
be a difference from the general rule that LF's end a line and CR's cause
problems.
>> However, that's not the point I was making there, which was: "lie" and
>> "incorrect" are not the same thing. What I said was not a "lie", it was -
>> in terms of what NNTP apparently wants - "incorrect".
>
> Oh, FFS, get a life.
Gander sauce, bucko. I appreciate the help, but I can do without the petty
insults. ;)
>The only thing that matters is whether what you
> said was correct or not: getting on your high horse about the fact that
> you didn't mean it to be false helps noone.
It's not about being on a high horse, old son, it's about the difference
between "lie" and "mistake". I don't have any problem at all saying "I
don't know" and "I screwed up" - but I have a big problem with any
intimation of untruthfulness, smiley or no smiley. If you don't understand
that, that says something about you, not about me. Now, as far as I'm
concerned, that part is over, but if you want to keep harping on it, you'll
get a response. 'Nuff said.
>> > Take a look at the documentation (pod) for NET::NNTP and see what
>> > it says.
>>
>> Really, though, I did look at both pod and man for Net::NNTP. I didn't
>> see much, if any, difference between them. Is there something specific in
>> the pod thant's not in the man pages? What is it you think I'm missing?
>
> There is no difference.
That's what I thought, too... by golly, that might not be much, but at
least it shows I know =something=, huh? ;)
So, how about it - do YOU have a working example of what I'm trying to do?
I could sure enough use the help, and telling me I don't know much isn't
telling me anything I don't already know.
Thanks, again.
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Wed, 18 Feb 2004 16:44:01 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages
Message-Id: <c10q2911pae@enews1.newsguy.com>
Ron Parker wrote:
> On Wed, 18 Feb 2004 11:00:54 -0600, Camelback Jones wrote:
>> This depends on how the NNTP server interprets it. Many pieces of
>> software do in fact interpret a line as "blank" if there are no
>> "printable" characters on it, and an ascii 32 is not considered
>> "printable".
>
> [ron@mail ron]$ cat >foodle.c
> int main() {printf("%s", isprint(' ')?"printable":"not printable");}
> [ron@mail ron]$ gcc foodle.c -o foodle
> [ron@mail ron]$ ./foodle
> printable
>
Sez C. Presumably isprint() returns a true for any character thing over 31,
or perhaps just the non-control characters of the 7-bit set... Or 32-255?
Is a DEL printable? Does your printer actually have a space character on it
(or in it) or does it just index the print "head" and skip a little bit?
Can a space really be "printed"? If you have three sheets of paper and one
of them was "printed" by sending a page eject, the second was printed by
sending 60 (or 66) line feeds, and the third by sending five or six
thousand spaces, can you tell which is which?
Bottom line: the only meaningful test is "what does THIS piece of software
want"?
> That said, I think your real problem might be that Net::NNTP 'post' is
> morally equivalent to Net::Cmd 'datasend' and neither of them makes any
> assumptions about where you wanted newlines. That is, just calling your
> array 'lines' doesn't make it actual lines; you should put a newline at
> the end of each line.
>
> As evidence, here's a couple of lines from the top of Net::Cmd:
>
> my $arr = @_ == 1 && ref($_[0]) ? $_[0] : \@_;
> my $line = join("" ,@$arr);
>
> The first line sets $arr equal to a reference to the array you passed,
> whether or not what you passed was a reference. The next line joins the
> whole array into one long scalar. Note the lack of newlines in the first
> parameter to join.
>
> So, to make the smallest possible change to your program, try replacing
> the not-really-blank lines with an empty string, and then replacing
> [@lines] with [join("\n", @lines)] in your call to nntp->post.
>
> Alternatively, you can just put the necessary newlines at the end of every
> element in @lines.
>
As I thought I'd said, I've been back and forth with newlines (as well as
with spaces and no spaces on the "blank" line(s)), and it didn't work
either way. Someone else has indicated that NNTP specifically demands a
CR/LF pair as a "blank" line, so I've tried combinations of LF and CR/LF to
end each line of @lines with LF and CR/LF as the "blank" line(s).
Here's the current version:
#!/usr/bin/perl
use Net::NNTP;
$service="enews.newsguy.com"; $user="bolivar"; $password="124c41";
srand(time);
$server = Net::NNTP->new($service)
or die "Can't connect to news server $service\n";
$thegroup="alt.test";
$something = $server->authinfo($user,$password);
($narticles, $first, $last, $name) = $server->group( $thegroup )
or die "Can't select $thegroup\n";
$randid = int(rand(999999));
$server->postok() or die "Server didn't tell me I could post.\n";
print "Apparently we're ALLOWED to post to $name\n";
$crlf = "\015\012"; # try various versions of cr/lf
$eol = "\012"; # and eol
@lines = ("From: Norbo Quantitator <aintg\@noemail.com>$eol",
"Date: Fri, Feb 13 2004 15:14:13 PST$eol",
"Newsgroups: $thegroup$eol",
"Subject: \"There is no subject\"$eol",
"Message-ID: <$randid\@noemail.com>$eol",
"Path: aintg$eol",
"$crlf",
"$crlf",
"This might be the body of this message.$crlf",
"Say, who DOES shave the barber, anyway???$eol",
"There may be any number of body lines. Or not.$crlf",
"$crlf"
);
if ($server->post( [ @lines ] ))
{print "Might've posted THIS time... check $thegroup";}
else
{warn "Can't post: $!";}
open HANDLE, ">np.txt";
print HANDLE @lines;
close HANDLE;
I think I've tried all the permutations for $crlf and $eol, and still no
luck, but maybe I've missed some...
The output file (np.txt) looks reasonable, in that there ARE lf's after
each line and cr/lf's where indicated (for this particular version) - and
yes, the mixture in the body of eol's and crlf's is intentional, although
I've tried both ways.
I've also tried typing the header and body from RFC 1036 into files and
using datasend() to send those lines and a couple of cr/lf's between. There
doesn't seem to be any response other that "1" from datasend(), though, so
we just have to wait a bit and see if the message shows up... which it
hasn't yet.
If you've got a working example, or have any idea where I can find one, I'd
love to see it. I've been googling the snot out of various search strings
and haven't found anything workable yet... but I'll get there, one of these
days!
Thanks for the ideas!
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Wed, 18 Feb 2004 23:29:06 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Posting Usenet News Messages
Message-Id: <c10sg2$kot$1@wisteria.csv.warwick.ac.uk>
Camelback Jones <ignoromnibus@cochon.fr> wrote:
> Ben Morrow wrote:
>
> >Try reading the relevant RFC
>
> I read 1036 and 822. I've no doubt I missed plenty in those. If neither of
> those is the relevant one, what is?
They'll do... 822 is obsoleted by 2822, but that doesn't matter for
these purposes.
> >NNTP considers a blank line to be exactly
> >
> > "\015\012\015\012"
> >
> > , ie. ASCII CR LF CR LF.
>
> I'm gruntled to know that. If you'll tell me where this is documented, I'd
> love to read it and see what other nuggets are to be found. This seems to
> be a difference from the general rule that LF's end a line and CR's cause
> problems.
RFC822, section 3.2:
field = field-name ":" [ field-body ] CRLF
section 4.1:
message = fields *( CRLF *text )
As another general rule, Internet protocols (including
Usenet-over-Internet :), use CRLF as the end-of-line sequence and
big-endian number representations.
> So, how about it - do YOU have a working example of what I'm trying to do?
> I could sure enough use the help, and telling me I don't know much isn't
> telling me anything I don't already know.
No I don't, sorry. As someone else said, you perhaps need to put the
newlines on the end of you lines before passing them to post.
Ben
--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: ben@morrow.me.uk
------------------------------
Date: Wed, 18 Feb 2004 19:24:34 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages
Message-Id: <c113fc023sb@enews2.newsguy.com>
gnari wrote:
> "Camelback Jones" <ignoromnibus@cochon.fr> wrote in message
> news:c105uu0kpq@enews2.newsguy.com...
>> Tad McClellan wrote:
>>
>> > Camelback Jones <ignoromnibus@cochon.fr> wrote:
>> >> Tad McClellan wrote:
>> >
>> > Because then you will make the 3-char sequence "\n \n" when
>> > you are supposed to be making the 2-char sequence "\n\n".
>> >
>> >
>> >> The spec calls for a blank line. What DO you want there?
>> >
>> >
>> > A blank line.
>> >
>> > A line with a space character on it is not blank,
>> > it has a space character on it.
>> >
>>
>> This depends on how the NNTP server interprets it. Many pieces of
>> software do in fact interpret a line as "blank" if there are no
>> "printable" characters on it, and an ascii 32 is not considered
>> "printable". I don't know whether NNTP considers it to be a "blank" line
>> if it has one or more spaces, but I do know that at least this particular
>> part of it - so far - hasn't seemed to make the slightest difference
>> whether it's accepted for posting or not.
>
> listen, you have an attitude problem.
>
> Tad is trying to help you. he is
> pointing
> out that you should not have a space at that position, and you start
> nitpicking
> about it, without any knowledge, when Tad most definitively has.
>
Actually, as it turns out, Tad - whatever his knowledge may or may not be -
is wrong about that. Now that I finally have it working, it doesn't matter
whether there's a space there or not, which is exactly what I thought in
the first place.
> the fact that his help was not enough for you to make your program work
> is not good reason to slap him.
I'm not slapping him, or you, or anybody else. I'm stating what I believe
to be facts. I'm sorry if you don't like the way I state them, and I'm
sorry if you don't like the fact that I state my opinions freely.
>> Thank you for trying, anyway. I'll let you know when I do get this
> working,
>> and then you'll know, too.
>
> we wait in anticipation
>
Your wait is ended: See my response with the word SOLVED appended to the
subject line.
You're welcome. ;)
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Wed, 18 Feb 2004 19:24:38 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages
Message-Id: <c113ff123sb@enews2.newsguy.com>
Ben Morrow wrote:
>
> Camelback Jones <ignoromnibus@cochon.fr> wrote:
>> Ben Morrow wrote:
>>
>> >Try reading the relevant RFC
>>
>> I read 1036 and 822. I've no doubt I missed plenty in those. If neither
>> of those is the relevant one, what is?
>
> They'll do... 822 is obsoleted by 2822, but that doesn't matter for
> these purposes.
>
>> >NNTP considers a blank line to be exactly
>> >
>> > "\015\012\015\012"
>> >
>> > , ie. ASCII CR LF CR LF.
>>
>> I'm gruntled to know that. If you'll tell me where this is documented,
>> I'd love to read it and see what other nuggets are to be found. This
>> seems to be a difference from the general rule that LF's end a line and
>> CR's cause problems.
>
> RFC822, section 3.2:
>
> field = field-name ":" [ field-body ] CRLF
>
> section 4.1:
>
> message = fields *( CRLF *text )
>
> As another general rule, Internet protocols (including
> Usenet-over-Internet :), use CRLF as the end-of-line sequence and
> big-endian number representations.
>
>> So, how about it - do YOU have a working example of what I'm trying to
>> do? I could sure enough use the help, and telling me I don't know much
>> isn't telling me anything I don't already know.
>
> No I don't, sorry. As someone else said, you perhaps need to put the
> newlines on the end of you lines before passing them to post.
>
As I thought I'd said (several times, but maybe it only SEEMED that way ;)
I tried that, too.
As it turns out, apparently the post() method just flat doesn't work, or
there's something mysterious about it...
Anyway, the datasend() method works, and as it turns out, either NNTP is
perfectly happy to consider " \015\013" as a "blank line" or datasend()
strips leading spaces, because it works just fine either way. See my
response with the word SOLVED appended to the subject line for details.
Thanks for the help!
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Wed, 18 Feb 2004 16:58:37 -0800
From: Michael Peppler <mpeppler@peppler.org>
Subject: Re: Sybperl - how to specify my own interfaces file
Message-Id: <pan.2004.02.19.00.58.37.28785@peppler.org>
On Wed, 18 Feb 2004 11:17:03 -0800, Sudip wrote:
> Hi,
> I want to specify my own interfaces file - instead of the default
> $SYBASE/interfaces - to my sybperl program ( I am using CTlib).
> I am finding a place to mention additional parameters in a hash as
> additional attributes.
> But neither I am being able to find what exactly ( I mean - a list )
> can be specified in there nor I am sure whether that is the place to
> override default $SYBASE/interfaces.
> I guess it has already been done many times by many people.
This is actually documented in the manual. You need to call
ct_config(CS_SET, CS_IFILE, $filename, CS_CHAR_TYPE);
before attempting to connect - this will set the interfaces file to
$filename.
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html
------------------------------
Date: Wed, 18 Feb 2004 17:00:49 -0800
From: Michael Peppler <mpeppler@peppler.org>
Subject: Re: Sybperl - how to specify my own interfaces file
Message-Id: <pan.2004.02.19.01.00.49.764501@peppler.org>
On Wed, 18 Feb 2004 19:23:31 +0000, Uri Guttman wrote:
>>>>>> "S" == Sudip <sudip@ureach.com> writes:
>
> S> I want to specify my own interfaces file - instead of the default
> S> $SYBASE/interfaces - to my sybperl program ( I am using CTlib).
>
> are you really using sybperl? that is based on perl4 and way way way
> obsolete and has security holes and all sorts of other problems.
sybperl is the collective name of 5 modules in the Sybase:: namespace,
namely Sybase::CTlib, Sybase::DBlib, Sybase::BLK, Sybase::BCP and
Sybase::Sybperl (this last one being an emulation layer for perl 4
scripts).
See http://search.cpan.org/dist/sybperl/
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html
------------------------------
Date: Wed, 18 Feb 2004 16:26:04 -0700
From: Ravi Parimi <parimi@none.nowhere.com>
Subject: testing for directories/files fails
Message-Id: <Pine.GSO.4.58.0402181614400.20663@shelltoe.ece.arizona.edu>
Hi,
I am trying to print the list of files(excluding directories) in a
directory with a Perl/CGI script:
#!/usr/bin/perl -w
print "Content-type:text/html\n\n";
print "<pre>\n";
opendir DH,"/var/www/cgi-bin/results" or die "$!";
foreach my $ls (readdir DH) {
next if -d $ls;
print "$ls\n";
}
print "</pre>\n";
The above script gives the correct output(i.e. does not print directories)
when I run it from the command line. However, when run as a CGI, it even
prints the directory names as files. Is this normal behaviour? Any help is
appreciated.
Thanks,
--ravi
------------------------------
Date: Wed, 18 Feb 2004 16:35:07 -0700
From: Ravi Parimi <parimi@none.nowhere.com>
Subject: Re: testing for directories/files fails
Message-Id: <Pine.GSO.4.58.0402181630380.20663@shelltoe.ece.arizona.edu>
>
> I am trying to print the list of files(excluding directories) in a
> directory with a Perl/CGI script:
>
> #!/usr/bin/perl -w
>
> print "Content-type:text/html\n\n";
> print "<pre>\n";
>
> opendir DH,"/var/www/cgi-bin/results" or die "$!";
> foreach my $ls (readdir DH) {
> next if -d $ls;
> print "$ls\n";
> }
> print "</pre>\n";
>
> The above script gives the correct output(i.e. does not print directories)
> when I run it from the command line. However, when run as a CGI, it even
> prints the directory names as files. Is this normal behaviour? Any help is
> appreciated.
I just realized that the CGI script wouldn't know the absolute path of
each of the directory entries (and interprets all entries as files?).
Upon adding:
use File::Spec;
.
<remaining lines>
.
foreach my $ls (readdir DH) {
my $abs_file = File::Spec::Unix->rel2abs($ls,"/var/www/cgi-bin/results");
.
.
}
works as expected. Can anyone explain why all entries are interpreted as
files?
Thanks,
--ravi
------------------------------
Date: Thu, 19 Feb 2004 00:09:46 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: testing for directories/files fails
Message-Id: <c10uqk$703$1@news.simnet.is>
"Ravi Parimi" <parimi@none.nowhere.com> wrote in message
news:Pine.GSO.4.58.0402181630380.20663@shelltoe.ece.arizona.edu...
> >
> > I am trying to print the list of files(excluding directories) in a
> > directory with a Perl/CGI script:
> > opendir DH,"/var/www/cgi-bin/results" or die "$!";
> > foreach my $ls (readdir DH) {
> > next if -d $ls;
> > print "$ls\n";
> > }
> > The above script gives the correct output(i.e. does not print
directories)
> > when I run it from the command line. However, when run as a CGI, it even
> > prints the directory names as files. Is this normal behaviour? Any help
is
> > appreciated.
>
> ... Can anyone explain why all entries are interpreted as
> files?
you assume too much.
just because -d $some_ramdom_string fails does
not mean that -f some_ramdom_string will not
hint: what is the current directory?
hint2: FAQ
gnari
------------------------------
Date: Wed, 18 Feb 2004 18:23:12 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Why is Perl losing ground?
Message-Id: <hO-dnZA6lo9-bq7dRVn-uw@adelphia.com>
Uri Guttman wrote:
> SP> It's subjective.
>
> no it isn't.
Sure it is. It's a matter of style and opinion, not one of substance. The
fact that many people share the same opinion doesn't make it any less
subjective.
> larry actually picke nmemonic chars for them as well.
Larry also coined the term "TMTOWTDI", and chose to include the English
module in support of that philosophy. It would seem that Larry has a much
better understanding of the term "subjective opinion" than you do.
sherm--
------------------------------
Date: Wed, 18 Feb 2004 18:27:19 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Why is Perl losing ground?
Message-Id: <hO-dnZM6lo9Kaa7dRVn-uw@adelphia.com>
David K. Wall wrote:
> Sherm Pendley <spamtrap@dot-app.org> wrote:
>
>> $! : $OS_ERROR
>
> What the hell was that?!
I once used a database library where every error function was prefixed with
"wtf_". I didn't get it at first, but my reaction to the first error I ran
into brought immediate understanding. ;-)
>> $| : $OUTPUT_AUTOFLUSH
>
> Flush that crap down the pipe.
LOL! I've always thought of it as "piping hot output."
But I like your version better.
sherm--
------------------------------
Date: Wed, 18 Feb 2004 23:39:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why is Perl losing ground?
Message-Id: <x7brnwrm8h.fsf@mail.sysarch.com>
>>>>> "SP" == Sherm Pendley <spamtrap@dot-app.org> writes:
SP> Uri Guttman wrote:
SP> It's subjective.
>>
>> no it isn't.
SP> Sure it is. It's a matter of style and opinion, not one of substance. The
SP> fact that many people share the same opinion doesn't make it any less
SP> subjective.
it is not subjective. no one uses it and no one recommends it
(regardless of the slowdown bug). it is there for show and not use.
>> larry actually picke nmemonic chars for them as well.
SP> Larry also coined the term "TMTOWTDI", and chose to include the English
SP> module in support of that philosophy. It would seem that Larry has a much
SP> better understanding of the term "subjective opinion" than you do.
you quote larry like you know him which i don't think you do. he picked
the special chars with nmenonics in mind. he didn't expect english to be
needed or he would have made those names aliased by default. note that
they are in a separate module and not in the core language. perlvar
covers their names.
the worst thing is seeing english in use and it never seems to help at
all. users of it usually have way more problems with perl than just the
names of special vars. they need more help than english could provide.
and here is another little tidbit, perl is used internationally and note
how no one has ever come up with a french.pm or italian.pm? why not?
because having non-words for the special vars is more portable across
human languages. that alone should show you that english is a wasted
module.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 19 Feb 2004 01:53:48 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Win32::Clipboard() and Excel
Message-Id: <4034173A.F22C98FF@earthlink.net>
I'm trying to use Win32::Clipboard() to get data from the
clipboard. The text I am copying to the clipboard is in
an Excel file. Here is the code I use:
$clip = Win32::Clipboard();
$text = $clip->Get();
It works fine if I swipe the formula bar in Excel, hit
ctrl C, and then run the program. But if I just highlight
the cell I want and hit ctrl C, and then run the Perl
script I get a bunch of garbage like this:
6 ( ² ø à
ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ
Apparently this is some kind of metacharacters or something
that contains cell formatting (and other things?) along with the
text I want. Does anybody know how to extract the root
text from this gobley gook?
Mike Flannigan
------------------------------
Date: Thu, 19 Feb 2004 00:48:16 GMT
From: perl coder <perlcdr@mail.rumania>
Subject: Re: win9x - how to test if a file is open?
Message-Id: <kJTYb.9771$c14.3058@bignews6.bellsouth.net>
Matt Garrish said:
> How's that going to help you, though? There is no file locking capability in
> the win9x versions, so waiting until one process is finished with the file
> will do nothing to prevent another from accessing it at the same time as
> your script.
There's no working flock(), but I found a way to lock files using the
Win32::API::Prototype module and the win32 CreateFile() function. This
method works on win98 (it also should on NT/2K/XP, but I didn't try):
# lockfile.pl
use strict;
use Win32::API::Prototype;
my $file = 'c:/autoexec.bat';
# accessMode flags
my $GENERIC_READ = 0x80000000;
my $GENERIC_WRITE = 0x40000000;
# shareMode flags
my $FILE_SHARE_READ = 0x00000001; # or just use 0 for exclusive lock
# create flags
my $OPEN_EXISTING = 3;
ApiLink( 'kernel32.dll', 'HANDLE CreateFile(
LPCTSTR name,
DWORD accessMode,
DWORD shareMode,
LPSECURITY_ATTRIBUTES securityAttributes,
DWORD create,
DWORD attributes,
HANDLE templateFile)'
) or die $^E;
print "Calling CreateFile to lock $file ... \n";
CreateFile($file, $GENERIC_READ|$GENERIC_WRITE, 0, 0, $OPEN_EXISTING, 0, 0)
or die $^E;
sleep 9999;
# now try:
# 1. "type c:\autoexec.bat" -> it works
# 2. "echo test >> c:\autoexec.bat" -> it fails
Is there any disadvantage to this method? It seems to allow any
combination of shared/exclusive read/write locking at the kernel level.
So if I lock a file with shareMode FILE_SHARED_READ, I can be certain no
other process can write to the file. For my purposes, this is better
protection than flock() offers (which is purely advisory in nature).
There's one thing missing though: I still need to be able to tell if a
file is already open by another process before I try to lock it. I
wouldn't want to (for example) get an exclusive lock on a file someone
is in the process of downloading with I.E. or some FTP program... And
although you might think that's not possible, I trid this:
1. vim c:\autoexec.bat
2. perl lockfile.pl
3. (vim) append a line at the end of the file, and try to save
Step 3 fails, and Vim gives me an error ("Can't open file for writing").
And that's right. But I don't want to lock the file if Vim already has
it open. :-)
--
No crazy stuff in my email. ;-)
------------------------------
Date: Wed, 18 Feb 2004 22:55:45 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: XML::DOM Encoding UTF-8 and ISO-8859-1
Message-Id: <Pine.LNX.4.53.0402182252470.29985@ppepc56.ph.gla.ac.uk>
On Wed, 18 Feb 2004, Addy wrote:
> However, when I traverse through the XML and print out the above
> "string" element, I see grabled text like "Sécurité"
My hunch is that you're using Perl 5.8.0 under RedHat9 - or some
similar environment where the locale setting implies utf-8.
A search for those key points in previous discussions should get
you on the way to understanding the problem.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 6160
***************************************