[10839] in Perl-Users-Digest
Perl-Users Digest, Issue: 4440 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 16 14:07:31 1998
Date: Wed, 16 Dec 98 11:00:45 -0800
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, 16 Dec 1998 Volume: 8 Number: 4440
Today's topics:
(newbie) nested closure problem [long] <chrislee@lavash.ius.cs.cmu.edu>
Re: array initialisation (Craig Berry)
Re: Changing Directory Problems <nick.condon@tamesis.com>
delete files <jcorbin@apci.net>
Re: delete files <ludlow@us.ibm.com>
Re: delete files <joshb@cadence.nosp-am-please.com>
Re: Disk Free <pep_mico@hp.com>
Re: hashes with arrays as values? <jeromeo@atrieva.com>
Re: hashes with arrays as values? (Andrew M. Langmead)
Re: How to extract emails from HTML page (David Jacoby)
Re: How to extract emails from HTML page (John Stanley)
Re: How to extract emails from HTML page <jeromeo@atrieva.com>
Re: mails <joshb@cadence.nosp-am-please.com>
Module Installation <vbezard@atos-group.com>
Re: Module Installation <joshb@cadence.nosp-am-please.com>
Re: Perl - mySql and MSQL Help (John Stanley)
Posting Code for Review (Jim Seymour)
Re: previous page, perl vs asp <dan.albertsson@swipnet.se>
Re: previous page, perl vs asp <dan.albertsson@swipnet.se>
Problems with 'unpack' .. (This has to be in the FAQ so <gjw@deakin.edu.au>
Re: sending a query from one script to another dave@mag-sol.com
Re: sending a query from one script to another (Andrew M. Langmead)
Re: sort it ? (Matthew Bafford)
Re: STDIN works too well <aqumsieh@matrox.com>
Re: STDIN works too well <garethr@cre.canon.co.uk>
Re: STDIN works too well (Alan Barclay)
Template to email with file attachment features melita@my-dejanews.com
URL database <Replies@stogursey.demon.co.uk>
Re: Use Perl from C <Rick.Moroz@bluegill.com>
Re: Why doesn't this work? (Christian M. Aranda)
Re: Why Is Perl not a Language? (John Moreno)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Dec 1998 12:19:17 -0500
From: Christopher Lee <chrislee@lavash.ius.cs.cmu.edu>
Subject: (newbie) nested closure problem [long]
Message-Id: <68r9u03syy.fsf@lavash.ius.cs.cmu.edu>
Hello --
I am new to perl (I've been using it seriously for a week now) and was
converting a simple Scheme function for a topological sort to perl.
The Scheme function uses a nested closure, and I figured I could do it
in a similar manner in perl since the documentation says I can. I am
getting some bizarre behavior, however.
The problem looks like a bug in the byte-compiler to my newbie eyes --
can someone tell me if I am doing something wrong?
[NOTE: 'perl --version' -->
'This is perl, version 5.004_04 built for IP32-irix ...']
Here's the Scheme version
----------------------------------------------------------------------
;;; "tsort.scm" Topological sort
;;; Copyright (C) 1995 Mikael Djurfeldt
;
; This code is in the public domain.
;;; The algorithm is inspired by Cormen, Leiserson and Rivest (1990)
;;; "Introduction to Algorithms", chapter 23
(define (topological-sort dag pred)
(if (null? dag)
'()
(let* ((adj-table (make-hash-table
(car (primes> (length dag) 1))))
(insert (hash-associator pred))
(lookup (hash-inquirer pred))
(sorted '()))
(letrec ((visit
(lambda (u adj-list)
;; Color vertex u
(insert adj-table u 'colored)
;; Visit uncolored vertices which u connects to
(for-each (lambda (v)
(let ((val (lookup adj-table v)))
(if (not (eq? val 'colored))
(visit v (or val '())))))
adj-list)
;; Since all vertices downstream u are visited
;; by now, we can safely put u on the output list
(set! sorted (cons u sorted)))))
;; Hash adjacency lists
(for-each (lambda (def)
(insert adj-table (car def) (cdr def)))
(cdr dag))
;; Visit vertices
(visit (caar dag) (cdar dag))
(for-each (lambda (def)
(let ((val (lookup adj-table (car def))))
(if (not (eq? val 'colored))
(visit (car def) (cdr def)))))
(cdr dag)))
sorted)))
----------------------------------------------------------------------
Here's my perl translation using a nested closure. Its input is a
hash of { item => [list of dependencies] }, and it outputs a
topologically-sorted list of items.
sub tsort {
my $dag = shift;
my @sorted;
my %adj_table = %$dag; # copy the dag -- shallow copy???
sub visit {
my($u,$adj_list) = @_;
$adj_table{$u} = 'colored'; # color vertex u
map { # visit uncolored verticies to which u connects
my $val = $adj_table{$_};
visit($_, ($val || [])) unless ($val eq 'colored');
} @$adj_list;
push @sorted, ($u); # when here, all dependencies of $u are visited
}
# visit all verticies
while ( my($key, $val) = each %adj_table) {
visit($key,$val) unless ( $val eq 'colored' );
}
return \@sorted;
}
I was initially impressed -- this worked just like in Scheme. But
then I tried running it more than once, and found that on the second
run of tsort, the '$adj_table' in the inner closure seems to be
referring to the copy of '$adj_table' FROM THE FIRST RUN OF TSORT!!!!
Outside the inner closure, $adj_table seems to be OK (I put some code
it to print it out). Also, the list @sort returned from the second
run of the 'tsort' was empty, although when I printed it out before
the 'return \@sorted' statement inside the function it was non-empty!
I still am pretty clueless about perl, but this looks to me like a bug
in the byte-compiler.
----------------------------------------------------------------------
Rewriting the procedure so that the inner closure is just a separate
function gives me the correct behavior through multiple runs.
sub ts_visit {
my($u,$adj_list,$adj_table,$sorted) = @_;
$adj_table->{$u} = 'colored'; # color vertex u
map { # visit uncolored verticies to which u connects
my $val = $adj_table->{$_};
ts_visit($_, ($val || []),
$adj_table,$sorted) unless ($val eq 'colored');
} @$adj_list;
push @$sorted, ($u); # when here, all dependencies of $u are visited
}
sub tsort {
my $dag = shift;
my @sorted;
my %adj_table = %$dag;
# visit all verticies
while ( my($key, $val) = each %adj_table) {
ts_visit($key,$val,\%adj_table,\@sorted) unless ( $val eq 'colored' );
}
return \@sorted;
}
----------------------------------------------------------------------
An example use of the code (figuring-out in what order to put on my
clothes based on a list of constraints on order --- hey I'm a just
another geeky guy and these things don't come easily to me :).
----------------------------------------------------------------------
my %dag = (
'shoes' => ['socks','pants'],
'pants' => ['boxers'],
'belt' => ['pants', 'shirt'],
);
my $sorted = tsort(\%dag);
print join(" ",@$sorted), "\n";
----------------------------------------------------------------------
--> 'socks boxers pants shoes shirt belt'
--
Christopher Lee
http://www.cs.cmu.edu/~chrislee
chrislee@ri.cmu.edu
------------------------------
Date: 16 Dec 1998 18:01:22 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: array initialisation
Message-Id: <758shi$p49$1@marina.cinenet.net>
Joergen W. Lang (jwl@worldmusic.de) wrote:
: That's almost always the biggest problem in answering those questions.
: There's always a good part of guessing involved.
: Maybe someday we have modules like Crystal::Ball and Read::Mind which
: suggest answers in an associative manner.
Those names are poorly chosen. You want Ball::Crystal (in parallel with
other sorts of balls -- Ball::Onyx, Ball::Plastic), and Mind::Read (in
parallel with Mind::Control, Mind::Lose, and so forth).
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "The hills were burning, and the wind was raging; and the
clock struck midnight in the Garden of Allah."
------------------------------
Date: Wed, 16 Dec 1998 18:10:42 +0000
From: Nick Condon <nick.condon@tamesis.com>
Subject: Re: Changing Directory Problems
Message-Id: <3677F7A2.20A5C69F@tamesis.com>
Why don't you just use "du -sk $HOME"?
Ok, Ok, I know this is a perl newsgroup, so how about:
system ("du","-sk", ENV{$HOME});
How's that :-)
Tad McClellan wrote:
> chada@hotbot.com wrote:
>
> : I am having trouble with a perl script I wrote. Its purpose is to add up all
> : of the file sizes in your home directory,
--
Nick Condon
------------------------------
Date: Wed, 16 Dec 1998 11:44:45 -0000
From: "John Corbin" <jcorbin@apci.net>
Subject: delete files
Message-Id: <3677f20b.0@queeg.apci.net>
I have a script i am working on that changes to a directory, iterates thru
the files in that directory, reads the file and converts the data from all
lowercase to all uppercase and writes the data to a new file, then I need to
delete the file (with the all lowercase). Well I got everything to work
except for the delete part. I tried;
unlink("H:\\$dirname\\$FileName");
and it doesn't do anything....I have a feeling that there is a file lock on
that file for some time til it gets closed all the way, maybe?? I am on
Windows NT 4, SP4 using perl 5
.
------------------------------
Date: Wed, 16 Dec 1998 12:32:09 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: delete files
Message-Id: <3677FCA9.B4C831C0@us.ibm.com>
John Corbin wrote:
> I have a script i am working on that changes to a directory, iterates thru
> the files in that directory, reads the file and converts the data from all
> lowercase to all uppercase and writes the data to a new file, then I need to
> delete the file (with the all lowercase). Well I got everything to work
> except for the delete part. I tried;
>
> unlink("H:\\$dirname\\$FileName");
>
> and it doesn't do anything....I have a feeling that there is a file lock on
> that file for some time til it gets closed all the way, maybe?? I am on
> Windows NT 4, SP4 using perl 5
What's the value of $dirname? If it starts with a '\', then you're
trying to access h:\\directory\file, which at least on Win95 is
invalid. If it ends with a '\' then you basically have the same problem
(h:\directory\\file).
If you already changed to that directory, then you only need the
filename in the unlink command anyway.
Also, with NT and Perl in general, you can use '/' instead of '\' for
directories, which makes escape characters much easier to deal with.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 16 Dec 1998 10:43:35 -0800
From: "Josh Baudhuin" <joshb@cadence.nosp-am-please.com>
Subject: Re: delete files
Message-Id: <758v0p$s59$1@news.cadence.com>
Uh, yeah, you DO want to make sure that original file is closed. You also
want to make sure it's not read-only, e.g., something like:
my $fn = "H:\\$dirname\\$FileName";
chmod 0777, $fn and unlink $fn or warn "couldn't unlink $fn";
I think you can also rename a temp file and get rid of the existing file by:
my $tfn = "$fn.tmp";
chmod 0777, $fn and rename $tfn, $fn; # Is the order of params
correct there?
[i.e., rename should automagically delete $fn before renaming $tfn]
John Corbin wrote in message <3677f20b.0@queeg.apci.net>...
|I have a script i am working on that changes to a directory, iterates thru
|the files in that directory, reads the file and converts the data from all
|lowercase to all uppercase and writes the data to a new file, then I need
to
|delete the file (with the all lowercase). Well I got everything to work
|except for the delete part. I tried;
|
|unlink("H:\\$dirname\\$FileName");
|
|and it doesn't do anything....I have a feeling that there is a file lock on
|that file for some time til it gets closed all the way, maybe?? I am on
|Windows NT 4, SP4 using perl 5
------------------------------
Date: Wed, 16 Dec 1998 19:12:34 +0100
From: Pep Mico <pep_mico@hp.com>
To: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Disk Free
Message-Id: <3677F811.7FC41ACB@hp.com>
Hi Jaime,
Thanks for your suggestion but,
I'm using this perl release :5.005_02-Binary build 507 for windows NT,
And when I executed your script line it just outputs number "1".
Regards
pep_mico@hp.com
Jaime Metcher wrote:
> # Prints free space on C: drive
> print (`cmd /c dir c:` =~ /[\d,]+ bytes free/);
>
> __END__
>
> Tools, gentlemen, remember your tools. (1)
>
> --
> Jaime Metcher
>
> 1. Tom Christiansen, Usenet post today or yesterday.
>
> Pep Mico wrote:
> >
> > How can I get how many disk free space is available in one volume disk?
> >
> > I'm working in Windows NT environment.
> >
> > Regards
> > pep_mico@hp.com
------------------------------
Date: Wed, 16 Dec 1998 09:01:09 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Urs Thuermann <thuerman@ibr.cs.tu-bs.de>
Subject: Re: hashes with arrays as values?
Message-Id: <3677E755.8A36D15@atrieva.com>
Urs Thuermann wrote:
> So it seems I have three arrays, @hash{apple}, @hash{peach}, and
> @hash{orange}. But the assignment to @hash{mango} doesn't work.
>
> Also, the construction $#hash{apple} produces a compile time error.
>
> Is it somehow possible to use array-valued hashes? If not, what
> exactly does the above short program do?
Mixes a lovely fruit salad? A hash of lists is easily done, and the
details of it, and other complex data structures can be found in the
perl data structures cookbook, included with your documentation.
perdoc perldsc.
> I did not find an answer to this in the man pages and perlfaq.
One of the things I am in favor of is more intuitive naming of the perl
documents. It is there if you know where to look.
Good Luck!
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: Wed, 16 Dec 1998 18:02:23 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: hashes with arrays as values?
Message-Id: <F42Krz.J36@world.std.com>
Urs Thuermann <thuerman@ibr.cs.tu-bs.de> writes:
>I'd like to have hashes whose values are arrays. Before reading the
>documentation I just tried it out and was indeed surprised to find
>that it seems to work to some extent:
There are a couple of surprising gotchas in perl's implementation of
complex data structures, and the apropriate man pages (perllol and
perldsc) really are helpful.
Since a hash of arrays is implemented as a hash of references to
arrays. The line
> @hash{mango} = (9,8,7,6,5,4,3,2,1,0);
replaces the array reference held in $hash{mango} with the value
0. What you want would be
@{$hash{mango}} = (9,8,7,6,5,4,3,2,1,0);
Take the array reference found in $hash{mango}, dereference it, and
store the list of numbers into the array.
and for
> #printf "%d\n\n", $#hash{apple};
you want:
printf "%d\n\n", $#{$hash{apple}};
Take the array reference held in $hash{apple} dereference it, and return
the highest subscript.
By the way, you should probably get used to using the "-w" flag when
writing scripts. It can be put on the "#!" line so that it is
automatically invoked
#!/usr/bin/perl -w
That way, you can find out about all sorts of bugs you're program
has. (The fragility of using barewords instead of quoted strings. Your
one based access to zero based, arrays, etc.)
--
Andrew Langmead
------------------------------
Date: 16 Dec 1998 17:48:40 GMT
From: jacoby@pier.ecn.purdue.edu (David Jacoby)
Subject: Re: How to extract emails from HTML page
Message-Id: <758rpo$566@mozo.cc.purdue.edu>
In article <3677a066.938887@news.skynet.be>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>Philip Class wrote:
>
>>Contancting potential customers in a discrete way (inculding our own personal
>>address data as sender and offering a 'REMOVE ME' feature) is not what I call
>>usual cheap spam.
>
>The REMOVE ME feature should be automatic: i.e. contact people at most
>ONCE. If they're interested, they'll come to your website. If they
>aren't, you should NEVER bother them again.
>
>If you don't do it like this, it IS the "usual cheap spam".
I'd reverse this. It should be INCLUDE ME after a hit, not REMOVE ME.
The default should be "Go Away!"
--
Dave Jacoby - jacoby@ecn.purdue.edu - http://pier.ecn.purdue.edu/~jacoby/
Lamport's Law:
A distributed system is one in which the failure of a computer
you didn't even know existed can render your own computer unusable.
------------------------------
Date: 16 Dec 1998 18:13:34 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: How to extract emails from HTML page
Message-Id: <758t8e$434$1@news.NERO.NET>
In article <ebohlmanF41x4q.Ht3@netcom.com>,
Eric Bohlman <ebohlman@netcom.com> wrote:
>Try this thought experiment. Imagine that you're sending unsolicited
>mail as you describe. By itself, it doesn't really have all that much
>impact on any user; it takes them only a second or to to delete it or
>remove themselves from your list.
No, try this thought experiment. The victim you send your useless mail
to is at the other end of a long distance call and your mail costs him
money even if it is just filtered out as soon as it arrives. Or your
victim is pushed over his "free" connect time at his ISP and incurrs
eonnect time charges because of your mail.
Or, best of all, your victim lives in the state of Washington and has
registered his address with the state, and he files a lawsuit against
you for spam and POP! you owe him $500.
You know, that latter part is a good reason to help spammers harvest
addresses, as long as the harverster biases its selection to addresses
in Washington.
>The biggest problem with UCE is that it doesn't scale well,
Wrong. The biggest problem with UCE is it shifts the cost of delivery
from the sender to the victim.
------------------------------
Date: Wed, 16 Dec 1998 10:43:18 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: John Stanley <stanley@skyking.OCE.ORST.EDU>
Subject: Re: How to extract emails from HTML page
Message-Id: <3677FF46.A3BE8F0D@atrieva.com>
John Stanley wrote:
>
> In article <ebohlmanF41x4q.Ht3@netcom.com>,
> Or, best of all, your victim lives in the state of Washington and has
> registered his address with the state, and he files a lawsuit against
> you for spam and POP! you owe him $500.
Sadly, one can only collect if the spammer mungs his headers to conceal
himself. The law doesn't say "You can't spam", only "You can spam if
you send a valid email." It's a weak law.
> Wrong. The biggest problem with UCE is it shifts the cost of delivery
> from the sender to the victim.
Indeed. The real solution is when ISP's win a big class action suit
against a notorious spammer.
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: Wed, 16 Dec 1998 10:36:49 -0800
From: "Josh Baudhuin" <joshb@cadence.nosp-am-please.com>
Subject: Re: mails
Message-Id: <758uts$s0s$1@news.cadence.com>
Try putting commas between recipient names in the string, i.e.
To => 'user1@some.host.com,user2@another.host.com'
Herger Peter wrote in message <3677CBB4.CB24093A@swisslife.ch>...
|use Mail::Send;
|
|$mail=Mail::Send->new(
| Subject => "blablabla",
| To => 'user@remote.host.com',
| To => 'user2@remote.host.com');
|.....
|
|How can I add more recipients with "To=>"?
|If I do it like the example above, it is only delivered to the first
|recipient.
------------------------------
Date: Wed, 16 Dec 1998 18:11:43 +0100
From: "Vincent BEZARD" <vbezard@atos-group.com>
Subject: Module Installation
Message-Id: <758pop$h6h$1@jaydee.iway.fr>
I've downloaded a module from the WEB, and I didn't succeded in installaling
it. I've launched makefil.pl, it creates a makefile file. In the
documentation, it says that I shoud run make, or nmake. I haven't such a
file. What can I do???
Thanks
------------------------------
Date: Wed, 16 Dec 1998 10:31:41 -0800
From: "Josh Baudhuin" <joshb@cadence.nosp-am-please.com>
Subject: Re: Module Installation
Message-Id: <758uag$qs4$1@news.cadence.com>
Which version of Perl are you using? If you're using ActiveState's
distributed version, it comes with 'ppm' or Perl Package Manager. It gives
you access to ActiveState's pre-built packages. They just might have the
package you want.
If you get the from the CPAN site, you have to have some sort of compiler
(or at least a make utility) installed.
Vincent BEZARD wrote in message <758pop$h6h$1@jaydee.iway.fr>...
|I've downloaded a module from the WEB, and I didn't succeded in
installaling
|it. I've launched makefil.pl, it creates a makefile file. In the
|documentation, it says that I shoud run make, or nmake. I haven't such a
|file. What can I do???
|
|Thanks
|
|
------------------------------
Date: 16 Dec 1998 18:06:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Perl - mySql and MSQL Help
Message-Id: <758sqh$3ti$1@news.NERO.NET>
In article <3677e4ae.0@209.4.101.246>, Kim Long <kiml@worldnetla.net> wrote:
>I need to create a script that will
> a) be spawned from an entry to a MSQL database and create an entry into
>a mySQL database on a different server
> -or-
> b) query the MSQL databases for changes and reflect those changes in the
>mySQL db on diff. server.
>
This isn't a perl question, it's an MSQL one.
>Any ideas where to begin. I'm more than willing to do the research but just
>need a jumping off point. I'm at the beginner to intermediate stage.
The research you already did should have familiarized you with the
_timestamp column in each MSQL table.
------------------------------
Date: 16 Dec 1998 16:40:16 GMT
From: jseymour@jimsun.LinxNet.com (Jim Seymour)
Subject: Posting Code for Review
Message-Id: <758npg$pnm$3@jimsun.uucp>
Is it okay to post code for review here in comp.lang.perl.misc?
(Providing it's not *too* large.) I looked at the FAQs but did
not see this issue addressed. Maybe I missed it.
I'd simply like a review of one of my latest efforts to see if
I'm "on track", as it were.
Thanks,
Jim
--
Jim Seymour
jseymour@jimsun.LinxNet.com
http://home.msen.com/~jimsun
------------------------------
Date: 16 Dec 98 18:03:25 GMT
From: "Dan Albertsson" <dan.albertsson@swipnet.se>
Subject: Re: previous page, perl vs asp
Message-Id: <01be291e$63f74620$5701a8c0@dan>
I found a shopping site where .cgi files are called and it worked properly
when using the Back button in the browser. So it seems to be able to work.
Therefore I had to investigate why and how.
What I figured out is that their solution did not influence the browsers
history list when I was choosing a new link (putting a new item in my
shopping cart).
The site is built with a frameset, where you click on links to items you
want to buy in one frame, and theese items are then directly shown in a
listbox (the shopping cart) in the other frame.
When you click on the link to put an item in your shopping cart a
cgi-script is called to update the listbox (the shopping cart in the other
frame). Normally (as in my test application) that results in that every
time you click on the Back button the frame with the listbox (shopping
cart) is shown as it was before. Not good as it empties the shopping cart
every time.
But it seems that they solved it by NOT letting the called cgi-script
update the shopping cart by itself, instead is that cgi-script returning
the HTTP header "Location: some_other_script.cgi\n\n". Which instead is
updating the shopping cart. That does not influence the history list or
maybe makes it so that every time you press the Back button the cgi-script
is realy called again.
I used telnet to see what the webserver returned when you click on the link
(fill_basket.cgi?ID=1234) to put an item in the shopping cart and this is
roughly what it returned:
HTTP/1.1 302 Moved Temporarily
Date: Wed, 16 Dec 1998 16:34:32 GMT
Server: Apache/1.2.6
Set-Cookie: xxxID=Wed_Dec_16_17_34_34_1998_195_198_199_28_0_825042724609375
!; path=/;
Location: http:///cgi-bin/basket_write_cart.cgi
Connection: close
Content-Type: text/html
It seems that they are also using a cookie to handle the shopping.
Can someone explain why this work and maybe how?
Thanks
/dan
------------------------------
Date: 16 Dec 98 18:27:11 GMT
From: "Dan Albertsson" <dan.albertsson@swipnet.se>
Subject: Re: previous page, perl vs asp
Message-Id: <01be2921$b675b6e0$5701a8c0@dan>
I tried to test something like this without using cookies (because I have
never used cookies before).
First I let my cgi-script only return the HTTP header "Location" with an
absolute url to my other cgi-script that realy updated the second frame
with some HTML code. Then when I pressed the Back button in the browser,
after clicking the link in the first frame a couple of times to update the
shopping cart, I directly went to the page I was at before I made all
theese updates. So it worked.
Next I added some arguments to the url I addressed in the "Location"
header, like this, "Location:
http://192.169.1.132/cgi-bin/test/basket.cgi?PRODID=$prodid\n\n" where
$prodid changed all the time. But know it seemed that the browser thought
it was different url's all the time and put them in the history list again.
So when I pressed the Back button in the browser I came to the shopping
cart before again. Not good.
Does this mean that one have to use cookies to pass information to my
cgi-script or is there another way to pass information to the cgi-script
when using the HTTP header "Location" without updating the history list
with another entry?
Thanks
/dan
------------------------------
Date: Mon, 14 Dec 1998 18:15:55 +1100
From: Greg Wickham <gjw@deakin.edu.au>
Subject: Problems with 'unpack' .. (This has to be in the FAQ somewhere?)
Message-Id: <3674BB2B.C07466BC@deakin.edu.au>
Hi,
I'm unpacking an IP header, and am having troubles with 'unpack'.
For those that don't know, the first 32 bits of an IP header
are: 4 bits. 4bits. 8bits. 16bits.
I would have thought that:
my ( $version, $ihl, $tos, $len ) = unpack( 'H1 H1 H2 H4', $data );
would do the trick, but it doesn't.
What happens is after the first 'H1', it 8bit aligns the next match.
This means that I loose 4 bits (between the first H1 and the H2).
I must admit that I'm having trouble picking up pack/unpack,
as I keep thinking data is binary when it isn't and vice versa.
But this problem has me stumped.
I'm using perl 5.005_02 built for sun4-solaris-thread.
Any pointers gratefully appreciated,
-Greg
NOC Manager
G.Wickham@deakin.edu.au
------------------------------
Date: Wed, 16 Dec 1998 16:47:56 GMT
From: dave@mag-sol.com
Subject: Re: sending a query from one script to another
Message-Id: <758o7r$mpn$1@nnrp1.dejanews.com>
In article <3677c093.3453199@news.cyberway.com.sg>,
pigs_can_fly@mindless.com (Jason Q.) wrote:
> Is it possible to send a query from Script A to Script B and capture
> whatever is returned from Script B into a string in Script A?
Yes.
> If so, how is it achieved?
As described in perldoc perlop. Look for the bit about quoting operators
(specifically backquotes and qx).
> Thanks.
A pleasure!
Dave...
--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 17:46:33 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: sending a query from one script to another
Message-Id: <F42K1L.7C1@world.std.com>
pigs_can_fly@mindless.com (Jason Q.) writes:
>Is it possible to send a query from Script A to Script B and capture
>whatever is returned from Script B into a string in Script A?
Basically, you need to have script Script A act like an HTTP client
(web browser.) and the best way of doing that is to use the LWP
module. <URL:http://www.perl.com/cgi-bin/cpan_mod?module=LWP>
If the documentation that comes with the module is not sufficient,
then you might want to pick up the book "Web Client Programming with
Perl" <URL:http://www.oreilly.com/catalog/webclient/>
--
Andrew Langmead
------------------------------
Date: Wed, 16 Dec 1998 12:54:07 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: sort it ?
Message-Id: <MPG.10e1bdc83c32efdf989765@news.scescape.net>
In article <3677e377.0@news.cgocable.net>, jimbo@cgocable.net says...
=> hello,
=> I need to sort a tab separated text file, based on a price, for example: the
=> price1 column
=>
=> I'm hoping some kind soul will bail me out here, I've read the faq's, stayed
=> up nights drinking lots of coffee, and to no avail. the book I have (perl5
=> for dummies) doesn't seem to help either.
=>
=> text file looks like this, in the format of vendor, price 1, price2, price
=> 3, price4....etc. :
=>
=> vendor1 99.00 98.00 299.00 300.00
=> vendor2 89.00 94.00 299.00 300.00
[snip]
The answer to your question is at:
perldoc perlfaq (How do I sort an array by (anything)?)
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html
http://www.dejanews.com/getdoc.xp?AN=148002172.1
HTH!
--Matthew
------------------------------
Date: Wed, 16 Dec 1998 11:28:32 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: STDIN works too well
Message-Id: <x3y3e6gyrtb.fsf@tigre.matrox.com>
digicat@tampabay.rr.com (Kevin M. Counts) writes:
>
> #!/usr/bin/perl
> while ( $a = <STDIN> )
> {
> print "$a";
> }
>
> If I call it w/ this command line:
> echo "hello" | abc.pl
>
> It ouputs:
> hello
>
> But if I call it by itself: abc.pl
>
> It waits for me to enter input... the question is
> how do I configure it only to get data if someone
> pipes it through?
You can't!
That's not Perl's behaviour, it is your shell's. Piping something into
a command effectively passes that thing into the stdin of the
command.
I can't think of a solution for this except to implement some sort of
timeout mechanism into your little Perl snippet. If there is no data
for a long time, then die (or something of the sort).
Of course, it all depends on what you want your script to do. But why
do you want that behaviour anyway?
------------------------------
Date: Wed, 16 Dec 1998 17:29:40 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: digicat@tampabay.rr.com (Kevin M. Counts)
Subject: Re: STDIN works too well
Message-Id: <sig1agm1vf.fsf@cre.canon.co.uk>
Kevin M. Counts <digicat@tampabay.rr.com> wrote:
> how do I configure it only to get data if someone pipes it through?
The `-t' file test tells you if a filehandle is connected to a tty.
--
Gareth Rees
------------------------------
Date: 16 Dec 1998 17:51:59 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: STDIN works too well
Message-Id: <913830717.624223@elaine.drink.com>
In article <758is2$3hn$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>In article <913819358.597458@elaine.drink.com>,
>Alan Barclay <gorilla@elaine.drink.com> wrote:
>>print "input is tty\n" if($stdin & 020000);
>
>Hey, that's no good. It says that /dev/null is a tty, which it isn't.
Well, it's saying actually it's a character special device, and /dev/null
is indeed a c. If you want to know which device it is, you'd have to
look at the rdev, which isn't quite so portable.
Works easily for the original problem though, which was to id pipes.
------------------------------
Date: Wed, 16 Dec 1998 17:21:13 GMT
From: melita@my-dejanews.com
Subject: Template to email with file attachment features
Message-Id: <758q66$oi2$1@nnrp1.dejanews.com>
Hi
If you have a template for a web-based email program with file attachment
features please send it for me.
Thanks in advance
Regards
Melita
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 18:32:11 -0000
From: "James" <Replies@stogursey.demon.co.uk>
Subject: URL database
Message-Id: <913833131.26896.0.nnrp-08.d4e48203@news.demon.co.uk>
I want to create a URL database that will form a html page as well as being
searchable, does any one know of a script that will do this, please reply to
CGI@Stogursey.demon.co.uk
------------------------------
Date: Wed, 16 Dec 1998 13:47:37 -0500
From: Rick Moroz <Rick.Moroz@bluegill.com>
To: "106617,1161" <Ben_CIP@csi.com>
Subject: Re: Use Perl from C
Message-Id: <36780049.87BB9709@bluegill.com>
I have done this successfully with VC++ 5.0 on NT 4.0. I just followed the
instructions in the perlembed doc. If you think you are missing some libs (you
only need perl.lib I believe), then perhaps you should build perl yourself ...
that's what I did. I started with perl 5.005_02 from
http://language.perl.com/info/software.html, and ran nmake against the provided
makefiles. Just follow the instructions that come along with the source ...
it's easy.
106617,1161 wrote:
> Hi
>
> I try to use Perl from within Visual C++ 6.0 on Windows NT. However, all the
> examples I found (perlembed.htm, FAQ, ...) provide no sufficient
> information. I suggest that some LIBs are missing from the distribution
> (Activestate).
>
> Has anyone sufficiently created a project like the one mentioned above?
> Where can I find information on how to proceed?
>
> Thanks in advance
>
> axel.bender@cityweb.de
--
Rick Moroz BlueGill Technologies
Rick.Moroz@bluegill.com http://www.bluegill.com
------------------------------
Date: Wed, 16 Dec 1998 17:36:15 GMT
From: christian.aranda@iiginc.com (Christian M. Aranda)
Subject: Re: Why doesn't this work?
Message-Id: <758r7c$7id$1@news-1.news.gte.net>
On 16 Dec 1998 16:36:52 +0100, JYB
<Jean-Yves.Burlett@scinfo.u-nancy.fr> wrote:
>henlif@elsfl.com (Henry Lifton) writes:
>
>> I am a newbie who has been going crazy with this. Can any one tell me what is
>> wrong?
>> $key =~ s|/||;
> ^^^^^^^^^^^^^
>What did you meant to do with that?
>(I know, removing the slashes but i can't see why)
actually what he's doing is using | as the quote instead of using the
default / so he can substitite /.
Christian M. Aranda
Impact Innovations Group
------------------------
Decide what you want then decide
what you'll give up for it. Me?
I'll give up sleep.
------------------------------
Date: Wed, 16 Dec 1998 13:55:30 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Why Is Perl not a Language?
Message-Id: <1dk4sso.174i3mu1nw0e96N@roxboro0-006.dyn.interpath.net>
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> Bart Lateur <bart.lateur@skynet.be> wrote:
>
> > Daniel Grisinger wrote:
> >
> > >I suspect, however, that you are using `interactive' as a synonym for
> > >`graphical'.
> >
> > No I'm not.
> >
> > "Interactive" means that the programs stops in situations like:
> >
> > Well here's the data I've got so far, now tell me what to do with it.
> >
> > Programs without an interface don't stop and ask. They go from start to
> > finish in one go.
>
> This works for "interactive", but for "interface", this is the most
> ridiculous definition I've ever seen.
But he's not using it as a definition for "interface" but rather for an
"interactive interface". And that's a pretty fair description of what
is necessary for an interactive interface.
> How often is the program with an interface supposed to "stop and ask"?
> Every five minutes? Every time it's processed 1 kilobyte of data?
> Every time rand() returns a number less than .2?
"Interface" simply means where/how two or more things meet.
> If a program just stops once while it's executing, is that enough for an
> interface? Twice? Three times? Is it an absolute number, or is it
> relative to how long the program runs?
For it to be "interactive" then it has to be /able/ to stop at least
once.
> An "interface" is a place where two things communicate or interact with
> each other. A "user interface" is where a user interacts with a
> computer program. If a user communicates with a program by typing on
> the command line, then that is the program's user interface. It has
> absolutely nothing to do with how often the program requests
> interaction.
And he was admitting that he didn't really mean "user interface" so much
as "interactive interface" (he had his terminology a little mixed up,
but it's better now).
--
John Moreno
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4440
**************************************