[19814] in Perl-Users-Digest
Perl-Users Digest, Issue: 2009 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 25 14:06:09 2001
Date: Thu, 25 Oct 2001 11: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)
Message-Id: <1004033112-v10-i2009@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 25 Oct 2001 Volume: 10 Number: 2009
Today's topics:
Automated html index ? <Leary@foad.org>
Re: Automated html index ? <please@no.spam>
Re: Automated html index ? <jurgenex@hotmail.com>
Difference between " and ' <lmoran@wtsg.com>
Re: Difference between " and ' <whatever@nevermind.invalid>
Re: Difference between " and ' <lmoran@wtsg.com>
how can I do: if (x isnot , x bigger, x smaller){} <mto@kabelfoon.nl>
Re: how can I do: if (x isnot , x bigger, x smaller){} <rsherman@ce.gatech.edu>
Re: how can I do: if (x isnot , x bigger, x smaller){} <Tassilo.Parseval@post.rwth-aachen.de>
How to replace char in string?... <mto@kabelfoon.nl>
Re: How to replace char in string?... <spam@thecouch.homeip.net>
Re: https and writing files <spam@thecouch.homeip.net>
Re: I am Adam H. Kerman your new god <kima@newmail.net>
implicit split to @_ (Andrew J. Perrin)
Re: implicit split to @_ <Tassilo.Parseval@post.rwth-aachen.de>
Re: lookingglass.pl (Mark Jason Dominus)
Re: matching (Tad McClellan)
Re: NEWBIE: double sort on a string <please@no.spam>
Ordering pairs of links [a bit long] <jeff@vpservices.com>
Re: Perl, MySQL, MS Access, Windows AND Linux (Stephen Patterson)
Ping Script Help Needed <alexd@NOSPAMsynergycsi.com>
Printing Images in a Web browser <peterd@physik.uni-augsburg.de>
Re: Printing Images in a Web browser <spam@thecouch.homeip.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 Oct 2001 10:10:07 -0500
From: "Leary" <Leary@foad.org>
Subject: Automated html index ?
Message-Id: <mVVB7.54935$B3.1504170@e3500-atl2.usenetserver.com>
Is it feasible to use perl to create an index of html docs in a given dir? I
need to include info from the title field and an updated field within each
html doc in the index.
TIA
------------------------------
Date: Thu, 25 Oct 2001 15:36:42 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Automated html index ?
Message-Id: <87669320p8.fsf@homer.cghm>
"Leary" <Leary@foad.org> writes:
> Is it feasible to use perl to create an index of html docs in a
> given dir? I need to include info from the title field and an
> updated field within each html doc in the index.
Yes, and it shouldn't be hard. See HTML::HeadParser, HTML::Parser,
etc. If you want to be recursive about it, see File::Find as well.
------------------------------
Date: Thu, 25 Oct 2001 08:56:40 -0700
From: "JЭrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Automated html index ?
Message-Id: <3bd8363c@news.microsoft.com>
"Leary" <Leary@foad.org> wrote in message
news:mVVB7.54935$B3.1504170@e3500-atl2.usenetserver.com...
> Is it feasible to use perl to create an index of html docs in a given dir?
I
> need to include info from the title field and an updated field within each
> html doc in the index.
Should be pretty simple.
HTML::Parser will do most of the parsing job for free.
And adding the found title fields to a list shouldn't be a problem.
jue
------------------------------
Date: Thu, 25 Oct 2001 13:08:27 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Difference between " and '
Message-Id: <0fhgttgoq9sgv66khnnv0i15kcgb1si21m@4ax.com>
I looked up quote in perldoc and read the FAQs that came up but I just
don't understand what the difference is between " " and ' '.
print "Test\n" ;
print 'Test\n' ;
I see that these print out:
Test
Test\n
but I don't know why.
Where should I be looking?
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Thu, 25 Oct 2001 13:19:20 -0400
From: asif <whatever@nevermind.invalid>
Subject: Re: Difference between " and '
Message-Id: <3BD84998.6090908@nevermind.invalid>
Lou Moran wrote:
> I looked up quote in perldoc and read the FAQs that came up but I just
> don't understand what the difference is between " " and ' '.
>
> print "Test\n" ;
> print 'Test\n' ;
>
> I see that these print out:
>
> Test
> Test\n
>
> but I don't know why.
>
> Where should I be looking?
>
> --
> TMTOWTDI: My way tends to be wrong...
> lmoran@wtsg.com
>
Try reversing the two print commands, if the \n in the output above
didn't give the answer away. Hint: think interpolation.
/whatever
------------------------------
Date: Thu, 25 Oct 2001 13:43:19 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Difference between " and '
Message-Id: <j9jgttc97a92af97hcq75i1n150og2749e@4ax.com>
On Thu, 25 Oct 2001 13:19:20 -0400, asif <whatever@nevermind.invalid>
wrote wonderful things about sparkplugs:
>Lou Moran wrote:
SNIP
>>
>> Test
>> Test\n
>>
SNIP
>
>Try reversing the two print commands, if the \n in the output above
>didn't give the answer away. Hint: think interpolation.
>
$Test\nTest
$
So the difference is that "" replace the variable with its value but
'' is literal?
Example
$x=1 ;
$y=2 ;
print '$x + $y' ;
print "$x + $y: ;
$x + $y1 + 2
Thanks I think I get that.
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Thu, 25 Oct 2001 19:27:01 +0200
From: "MAGiC MANiAC^mTo" <mto@kabelfoon.nl>
Subject: how can I do: if (x isnot , x bigger, x smaller){}
Message-Id: <9r9i97$23fj$1@news.kabelfoon.nl>
$status="1";
if ($status isnot 1){
}
how can I do this?...
----
and how can I do this?
$status="1";
if ($status isnot 1 and $status isbigger 2){
}
----
and how can I do this?
$status="1";
if ($status isnot 3 and $status issmaller 2){
}
thanks for the explain! :)
------------------------------
Date: Thu, 25 Oct 2001 17:53:37 +0000 (UTC)
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: how can I do: if (x isnot , x bigger, x smaller){}
Message-Id: <9r9jj1$fnj$1@news-int.gatech.edu>
In article <9r9i97$23fj$1@news.kabelfoon.nl>, MAGiC MANiAC^mTo wrote:
>
> $status="1";
> if ($status isnot 1){
> }
>
> how can I do this?...
>
if($status != 1){}
> ----
>
> and how can I do this?
>
> $status="1";
> if ($status isnot 1 and $status isbigger 2){
> }
>
if(($status != 1) && ($status > 2)){}
> ----
>
> and how can I do this?
>
> $status="1";
> if ($status isnot 3 and $status issmaller 2){
> }
>
if(($status != 3) && ($status < 2)){}
>
> thanks for the explain! :)
>
also try:
perldoc perlop
for more explanation...
--
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa
------------------------------
Date: Thu, 25 Oct 2001 19:55:45 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: how can I do: if (x isnot , x bigger, x smaller){}
Message-Id: <3BD85221.8010401@post.rwth-aachen.de>
MAGiC MANiAC^mTo wrote:
> $status="1";
> if ($status isnot 1){
> }
if ($status != 1)
> how can I do this?...
> $status="1";
> if ($status isnot 1 and $status isbigger 2){
if ($status > 2)
[isbigger 2 implies isnot 1]
> $status="1";
> if ($status isnot 3 and $status issmaller 2){
if ($status < 2)
[same applies here]
But for the record:
if ($status != 3 && $status < 2)
> thanks for the explain! :)
More to that, you should do a 'perldoc perlsyn' to read a little bit on
syntax.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 25 Oct 2001 17:53:11 +0200
From: "MAGiC MANiAC^mTo" <mto@kabelfoon.nl>
Subject: How to replace char in string?...
Message-Id: <9r9cpa$1sem$1@news.kabelfoon.nl>
How to replace char in string...
var $tmp1="hello' th'ere";
how can I replace the ' chars into \'
result :
hello\' th\'ere
------------------------------
Date: Thu, 25 Oct 2001 12:08:19 -0400
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: How to replace char in string?...
Message-Id: <iNWB7.3503$cE2.160876@weber.videotron.net>
"MAGiC MANiAC^mTo" <mto@kabelfoon.nl> wrote in message
news:9r9cpa$1sem$1@news.kabelfoon.nl...
> How to replace char in string...
>
> var $tmp1="hello' th'ere";
$tmp1 =~ s/'/\\'/g;
>
> how can I replace the ' chars into \'
>
> result :
>
> hello\' th\'ere
>
>
>
------------------------------
Date: Thu, 25 Oct 2001 12:11:50 -0400
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: https and writing files
Message-Id: <BQWB7.3519$cE2.162075@weber.videotron.net>
"Ted Apke" <tedapke@apkesoftware.com> wrote in message
news:5EVB7.20414$IR4.11759583@news1.denver1.co.home.com...
> I'm having a problem writing to a file when the perl CGI script is
accessed
> via a secure connection. The script works fine when the connection is via
> http, but when run from https it fails. I'm not 100% sure of the host
> environment but I'd say it is Solaris.
>
> I've done a number of searches, including Google groups, and found nothing
> similar. I'd appreciate any suggestions.
I also got into my car a few days ago but it didn't take me to work. Can you
tell me why ?
Seriously, you provide no details at all. Help us out here. What exactly is
the error message, if any.. ?
>
> Thanks in advance.
>
> Ted Apke
>
>
>
------------------------------
Date: Sat, 20 Oct 2001 09:52:18 +0200
From: "Alex" <kima@newmail.net>
Subject: Re: I am Adam H. Kerman your new god
Message-Id: <9qrkea$4s1$1@news.inter.net.il>
u just sending those posts to have fun or u really idiot?
"Paul" <whamera@home.com> сообщил/сообщила в новостях следующее:
news:kSWo7.5$oD.23182@news1.rsm1.occa.home.com...
> Fuck You...
>
>
>
> "Adam H. Kerman" <ahk@chinet.chinet.com> wrote in message
> news:5c517d5a.b1ced549@webty.sd.us...
> > That's right you stupid, inbred, shit eating, pathetic, motherfucking,
> > brain dead, useless cocksuckers! I'm taking over all of Usenet! There
> > isn't a fucking thing you can do about it either! You're all a bunch
> > of worthless scumbags, and now you will all answer to me! If you don't
> > like this fact TOO FUCKING BAD! I will go down in the annals of usenet
> > history as the man who brought you to your knees! Now get down on your
> > knees and pay proper tribute to my glorious self!
> >
> > I AM ADAM H. KERMAN LORD AND HIGH MASTER OF USENET!
> >
> > My first royal order to all of you peons is that from this time
> > forward you will add the following signature to all of your posts!
> >
> >
> > ***** This was posted with the express permission of *****
> > **********************************************************
> > ** HIS HIGHNESS ADAM H KERMAN LORD AND MASTER OF USENET **
> > **********************************************************
> > *********** We are simple servants of his will ***********
> >
> >
> > This will be appended to the bottom of all your posts with absolutely
> > NO EXCEPTIONS! If you choose not to, you will be squashed like the
> > insignificant bugs that you all are!
> >
> > I am running Usenet now! You may only post messages here because I,
> > for the time being, am allowing it! Do you scumbags understand me!
> >
> > THIS IS THE DAWNING OF THE AGE OF KERMAN!
> >
> > ALL HAIL ADAM H. KERMAN LORD AND HIGH MASTER OF USENET!
> >
> >
> > We moan them, then we nearly close Toni and Jim's orthodox
> > sattelite phone. It's very usable today, I'll type
> > smartly or Henry will contradict the governments. Let's
> > prepare outside the pathetic websites, but don't eliminate the
> > loud gorillas. Ophelia doesn't engulf weak pointers, do you
> > start them? My actual stack won't place before I propagate it.
> > Don't try to pump a rumour! Excelsior sadly reboots
> > untouched and locates our disgusting, sly hackers with a
> > cyphertext. She wants to contribute moronic analysts
> > to Alice's window. While investigators finally generate
> > ideas, the discs often learn beneath the violent firewalls.
> > There Francoise will outwit the error, and if Madeleine
> > badly creates it too, the protocol will substantiate
> > about the tall haven. The mixmasters, programmers, and
> > ROMs are all minor and bright. If you will corrupt
> > Gregory's database around FORTRANs, it will strongly
> > load the iteration. They are opening behind lost,
> > over root, around powerful users. Why did Mel vexate
> > without all the trackballs? We can't spool cowboys unless
> > Vance will actually disrupt afterwards. You won't
> > transport me disappearing to your strange sneaker. Other
> > bizarre plastic postmasters will reload weekly without
> > admins. She'd rather slump crudely than twist with
> > Marian's veggie robot. The CDROM against the stuck
> > web page is the modem that excludes weakly. Ratana wants to
> > insulate simply, unless Jimmy manages newsgroups over
> > Jonathan's PGP. They are deleting around the data center now, won't
> > dream backups later.
> >
> >
> >
>
>
------------------------------
Date: 25 Oct 2001 13:41:47 -0400
From: aperrin@email.unc.edu (Andrew J. Perrin)
Subject: implicit split to @_
Message-Id: <87snc7boro.fsf@hm269-26876.socsci.unc.edu>
Greetings-
I need to count the number of words, separated by /\s+/, in a
string. I assumed (apparently correctly) that
my $length = scalar split(/\s+/,$string);
would do the trick, but in the process I get:
Use of implicit split to @_ is deprecated at html2pg.pl line 183.
perldiag suggests that it's "better" to split to an explicit array or
list and then count that; but this string has the potential to be
rather large, and it seems a poor use of memory to store the entire
array of words in order to count them. Is there another avenue I
should be taking?
Thanks.
--
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin@unc.edu - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA
------------------------------
Date: Thu, 25 Oct 2001 19:59:39 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: implicit split to @_
Message-Id: <3BD8530B.5040604@post.rwth-aachen.de>
Andrew J. Perrin wrote:
> Greetings-
>
> I need to count the number of words, separated by /\s+/, in a
> string. I assumed (apparently correctly) that
>
> my $length = scalar split(/\s+/,$string);
>
> would do the trick, but in the process I get:
> Use of implicit split to @_ is deprecated at html2pg.pl line 183.
>
> perldiag suggests that it's "better" to split to an explicit array or
> list and then count that; but this string has the potential to be
> rather large, and it seems a poor use of memory to store the entire
> array of words in order to count them. Is there another avenue I
> should be taking?
Better use the tr/// operator for that:
$length = ($string =~ tr / //) + 1;
This counts the number of whitespaces and adds 1 to that, hence should
result in the number of words.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 25 Oct 2001 15:36:54 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: lookingglass.pl
Message-Id: <3bd83196.27db$2@news.op.net>
In article <3BD7A98B.2B1BCDB6@earthlink.net>,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>> # create an array of indices into the list of questions
>> @q_index = (0 .. @questions-1);
>> # scramble it, using the method outlined in perlfaq4
>> fisher_yates_shuffle( \@q_index );
>> # then ask the questions in the shuffled order we just created
>> ask_question($questions[$_]) foreach @q_index;
>>
>> @questions-1 should evidently have been $#questions.
>
>ISTM that the code above could have been better done as:
>
>@q_shuffled = @questions;
>fisher_yates_shuffle( \@q_shuffled );
>ask_question($_) foreach @q_shuffled;
It depends. If @questions contains many large items, you might not
want to make a copy. The original code might be much cheaper.
I agree with your main point, however.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Thu, 25 Oct 2001 15:52:41 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: matching
Message-Id: <slrn9tg1f1.r6n.tadmc@tadmc26.august.net>
Lex Thoonen <lex@nospam.peng.nl> wrote:
>Then, completely unexpected, on Wed, 24 Oct 2001 15:25:29 GMT,
>tadmc@augustmail.com (Tad McClellan) turned around and said:
>>>$key can be a number,
>> ^^^^^^^^
>>
>>12.45
>>
>>1e10
>>
>>5+5
>>
>>Those are all "numbers" too. I will assume you mean "all digit characters"
>>instead of "number".
>>
>
>I mean: only (whole) numbers (english is not my 1st language)
Yes, I figured that, but I don't think that is what caused the confusion.
>like 1 2
>3 etc. not: -1 or 1.5 or 1,5 or 0,3 or 0
You are doing pattern matching. Pattern matching works on _strings_,
not numbers.
So $key isn't a "number", it is a "series of digit characters".
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 25 Oct 2001 15:59:53 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <87zo6fzp98.fsf@homer.cghm>
"Jippie@yahoo.com" <jippie@yahoo.com> writes:
> Hi,
>
> What I'm trying to do is to sort of on two columns.
> The the first column is an argument and the second in always column 1.
>
> This is what I have done but my logic is wrong.
> I thought it would be just an extra check if both are the same then check if
> column 1 are the same.
>
> Jippie
>
> sub by_string
> {
> @parts_a=split(/[|]/,$a);
> @parts_b=split(/[|]/,$b);
>
> $retval = (lc($parts_a[$sortfield])) cmp (lc($parts_b[$sortfield]));
> if( $retval == 0 && $sortfield !=1 ) # they are the same
> {
> # then sort by title next. Always nice to have the title in order
> $retval = (lc($parts_a[1])) cmp (lc($parts_b[1]));
> }
> }
This is a slow way to sort. You shouldn't do processing (such as
split, lc) on the elements in the sort sub, because elements get
compared more than once. Do the processing once, save it, and then
refer to the saved copy later.
Here's a replacement for your code. There are three steps. First, do
the processing. What you want are anonymous arrays of (field1,
field2, value), where the fields can be compared with a simple cmp:
map { [ (split '|', lc)[0,1], $_ ] } @array_to_sort;
As you see, I used fields 0 and 1 here. You can, of course, put
variables in there and choose the fields at run-time.
The second step is to do the sort:
sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] }
map { [ (split '|', lc)[0,1], $_ ] } @array_to_sort;
Note the ||. If the first cmp returns -1 or 1, the result of the
entire expression will be that result. If the first cmp returns 0,
i.e. if the first fields are the same, then the result of the
exression will be the result of the second cmp.
The final step is to extract the values from the anonymous array you
created in the first step:
@sorted_array = map { $_->[2] }
sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] }
map { [ (split '|', lc)[0,1], $_ ] } @array_to_sort;
Tada. It's faster, yet still easier to write, easier to understand,
and idiomatic.
------------------------------
Date: Thu, 25 Oct 2001 09:08:28 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Ordering pairs of links [a bit long]
Message-Id: <3BD838FC.626A33E@vpservices.com>
Sorry, this is a bit long, but perhaps it's a "problem of interest" to
borrow a particulary disgusting phrase from law enforecement. First
some explanation, then some code.
I have lists of pairs of linked items like this (link represented by a
colon)
qw( a:b c:d a:d e:f );
The list can theoretically contain any number of pairs but isn't likely
to have more than a half dozen. There is no restriction on what items
are linked to other items, including items linked to themselves.
I want to return undef if there are any pairs in which neither item is
linked to items outside that pair (e:f in this example). And I want to
end up with an ordered list such that every item (except the first) has
a link to at least one of the items on its left. Which in this case
would be: abdc (the d comes before the c because it is linked to one of
a b while c is not). This is not a linked list, or if it is, it is a
special case, since items do not have to be linked to the item
immediately to their left but rather to any item to their left.
Some context not needed for the code below but which might make more
sense than the above: I am optimizing the order of tables for executing
SQL equijoins (actually executing them, not preparing them for passing
to an rdbms). I want to be able to join the tables in such an order that
every table except the first is being joined with a table it has a link
(equijoin) to. So if I join a:b first I can't join c:d to it
immediately, but if I first join a:d to a:b, I can then join c:d to that
joined table. The solution will need to cover all possible relations --
one-to-many, many-to-many, etc.
Ok, my code is below and my main questions are whether it handles all
cases and whether it works, and if there's a way to do it less
wastefully than my admitedly crude first pass :-). I will suffer
graciously any attempts at golf but my preferences run towards
legibility so I am more interested in comments that improve efficiency
rather than those which simply shorten the code.
#!/usr/local/bin/perl -w
use strict;
my $order = order_links( qw( a:b c:d a:d ) );
print "@$order\n" if $order;
sub order_links {
my @links = @_;
my @all_tables;
my %relations;
my %is_table;
for my $rel(@links) {
my($t1,$t2) = split /:/,$rel;
return undef unless defined $t1 and defined $t2;
push @all_tables, $t1 unless $is_table{$t1}++;
push @all_tables, $t2 unless $is_table{$t2}++;
$relations{$t1}{$t2}++;
$relations{$t2}{$t1}++;
}
my @tables = @all_tables;
my @order = shift @tables;
my %is_ordered = ( $order[0] => 1 );
my %visited;
while(@tables) {
my $t = shift @tables;
my @rels = keys %{$relations{$t}};
for my $t2(@rels) {
next unless $is_ordered{$t2};
push @order, $t;
$is_ordered{$t}++;
last;
}
if (!$is_ordered{$t}) {
# yeah ok, a kludge, but better than just using 17
# and i ain't smart enough to know what else to use
#
push @tables, $t if $visited{$t}++ < @all_tables;
}
}
return undef if @order < @all_tables;
return \@order;
}
__END__
Thanks! (and not TIA, since you already deserve thanks if you've
bothered to read this far)
--
Jeff
------------------------------
Date: Thu, 25 Oct 2001 18:57:23 BST
From: spam@freeuk.com (Stephen Patterson)
Subject: Re: Perl, MySQL, MS Access, Windows AND Linux
Message-Id: <slrn9tgkln.7sm.spam@localhost.localdomain>
On Thu, 25 Oct 2001 08:34:02 GMT, Bart Lateur wrote:
> [comp.lang.perl snipped, as it is dead -- and supposed to stay that
> way.]
>
> Rubber Ducky wrote:
>
>>Is it possible to interact with both MySQL AND MS Access at the same time
>>with Perl? I want it to run on both on windows and on linux. Could you
>>please provide SOME details of how I can acomplish such a thing!
>
> Yes it's possible, at least on Windows, with DBI and DBD::ODBC for
> Access, DBD::mysql for MySQL. Take any standard DBI sample program, and
> provide two database handles, each connecting to a different database.
> There. You have access to two different databases in one program, at the
> same time.
>
> For Linux, in addition, you have the problem of connecting to an Access
> database. There's no program in the world (that I know of) that can
> directly manipulate an Access database file on Linux. It is possible, in
> several ways, to connect to a Windows machine which contains, and
> connects to the database. For example, DBD::Proxy is one way you can do
> it (which I still haven't tested, I must say). See that link on the DBI
> homepage: <http://dbi.symbolstone.org>
I've noticed that access SQL is subtly different from MySQL SQL. So
watch out for that if things start going pear shaped.
--
Stephen Patterson http://home.freeuk.net/s.patterson/
s.patterson@SPAM.freeuk.com (remove spam to reply)
ICBM address 54-22-0N 0-28-0W
------------------------------
Date: 25 Oct 2001 15:36:06 GMT
From: "Alex Davidson" <alexd@NOSPAMsynergycsi.com>
Subject: Ping Script Help Needed
Message-Id: <9r9bh6$id3@dispatch.concentric.net>
I have the following script in a page in order for me to determine an IP
being available so I can use an alternate site if necessary:
<SCRIPT LANGUAGE="PerlScript" RUNAT="Server">
use Net::Ping;
$host = "216.98.200.32";
$p = Net::Ping->new();
$retval = $p->ping($host,1);
$p->close();
if ($retval = 0) {
$Response->Redirect("pingresult.asp?Error=Yes");
} else {
$Response->Redirect("pingresult.asp?Error=No");
}
</SCRIPT>
216.98.200.32 comes back as "Destination specified is invalid" when I PING
it yet this script returns no error.
I have tried:
if ($retval = "0") {
if ($retval == "0") {
if ($retval == 0) {
with similar results (bad and good IPs both show either good or bad) - I
can't find the syntax to discriminate correctly between reachable and
unreachable IPs.
As you can tell I am a complete neophyte and not sure of the syntax to use.
Can someone correct it for me?
Thanks.
------------------------------
Date: Thu, 25 Oct 2001 17:37:52 +0200
From: Peter Drechsler <peterd@physik.uni-augsburg.de>
Subject: Printing Images in a Web browser
Message-Id: <3BD831D0.17086495@physik.uni-augsburg.de>
# Hi,
# I have images (gifs) in a mysql-database running under linux 2.4.0.
# I want to print them via the CGI module of Perl (v5.6.1) in netscape.
#
# What I got from the the db is the images in a scalar.
# Above here is all the db stuff, connection etc: works
# In column pict defined as blob is the gif
# After SQL.... I got my image in a scalar.
my $ref = $sth->fetchrow_hashref();
my $image = $ref->{'pict'};
# So far, so good.
# I can write them in a file and the file is
# ok and show it in netscape.
# A temp-file doesn't work
# and I don't wan't to have a permant (say: redundant) file.
my $anz = CGI->new();
print $anz->header(), $anz->start_html();
print img{src => $image}; # <--- NOT WORKING
print $anz->end_html;
# Any Ideas?
# Peter.
------------------------------
Date: Thu, 25 Oct 2001 12:10:26 -0400
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: Printing Images in a Web browser
Message-Id: <hPWB7.3512$cE2.161514@weber.videotron.net>
"Peter Drechsler" <peterd@physik.uni-augsburg.de> wrote in message
news:3BD831D0.17086495@physik.uni-augsburg.de...
> # Hi,
>
> # I have images (gifs) in a mysql-database running under linux 2.4.0.
> # I want to print them via the CGI module of Perl (v5.6.1) in netscape.
> #
> # What I got from the the db is the images in a scalar.
>
> # Above here is all the db stuff, connection etc: works
> # In column pict defined as blob is the gif
> # After SQL.... I got my image in a scalar.
>
> my $ref = $sth->fetchrow_hashref();
> my $image = $ref->{'pict'};
>
> # So far, so good.
>
> # I can write them in a file and the file is
> # ok and show it in netscape.
> # A temp-file doesn't work
> # and I don't wan't to have a permant (say: redundant) file.
I don't use CGI.pm often, although I'm sure you can tell it what
content-type you're output will be.
However for a quick fix to see if that IS your problem, try this:
print "Content-type: image/gif\n\n";
print img{src => $image};
>
> my $anz = CGI->new();
> print $anz->header(), $anz->start_html();
>
> print img{src => $image}; # <--- NOT WORKING
>
> print $anz->end_html;
>
>
> # Any Ideas?
> # Peter.
------------------------------
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.
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 2009
***************************************