[18665] in Perl-Users-Digest
Perl-Users Digest, Issue: 833 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 4 11:06:13 2001
Date: Fri, 4 May 2001 08:05:19 -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: <988988718-v10-i833@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 4 May 2001 Volume: 10 Number: 833
Today's topics:
Re: a few quick questions <bart.lateur@skynet.be>
Active perl problem <DieSpamDieLisaandsi@btinternet.com>
Re: Allocating people like in a cinema (J.C.Posey)
Re: Allocating people like in a cinema (Mark Jason Dominus)
Re: Allocating people like in a cinema (Abigail)
Re: Allocating people like in a cinema (Greg Bacon)
Re: Any tip on accessing DB2 from NT (DBD::DB2 is not p <fortinj@attglobal.net>
Compare 2 arrays <dwb1@home.com>
Re: Compare 2 arrays <hillr@ugs.com>
connect timeouts <paul.brown@ukinternetsites.com>
Re: connect timeouts <hillr@ugs.com>
Re: cookie expiry (Randal L. Schwartz)
Re: DNS Lookups <hillr@ugs.com>
Re: Downloading images with HTTP/LWP libraries (Abigail)
Re: Downloading images with HTTP/LWP libraries (Randal L. Schwartz)
Re: Downloading images with HTTP/LWP libraries (Randal L. Schwartz)
Re: Downloading images with HTTP/LWP libraries <bart.lateur@skynet.be>
Re: Downloading images with HTTP/LWP libraries <bart.lateur@skynet.be>
Re: efficient <flavell@mail.cern.ch>
Re: evil eval in BEGIN (Tramm Hudson)
Re: execution of perl script <andrew@mvt.ie>
Re: Familiar with this perl fix permission script <jfreeman@tassie.net.au>
Re: Familiar with this perl fix permission script <arr@oceanwave.com>
Re: general Perl question <temp1@williamc.com>
Re: general Perl question <temp1@williamc.com>
Re: general Perl question (Abigail)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 04 May 2001 12:03:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: a few quick questions
Message-Id: <ii65ft8d6o3nag56se87sus4jjigc45esd@4ax.com>
Joseph N Ross wrote:
>1. Can anyone recommend a good book to learn perl for someone with
>significant programming experience? preferably a book that is more of a
>reference (function definitions with examples, or something like that)?
You're practically describing the camel book, officially entitled
"Programming Perl". But I warn you: by perusing a reference alone, you
won't learn much of the Perl idioms. Or, at least, you won't learn them
fast. The Llama book ("Learning Perl") is a good book to quickly get up
to speed.
--
Bart.
------------------------------
Date: Fri, 4 May 2001 15:31:44 +0100
From: "Si" <DieSpamDieLisaandsi@btinternet.com>
Subject: Active perl problem
Message-Id: <9cuejm$9m0$1@neptunium.btinternet.com>
Hi,
I am currently in the process of learning Perl, and installed Active
perl on my lan, also set up a small web server that supports cgi, mapped
all
the relevant extensions so I have basic scripts working, but when playing
around with a simple self-referential script I came across the following
problem, an elsif (expression) doesn't evaluate the way it should
..basically the script reads input from a form and echoes the input back to
the user in a table of key/value pairs, but after prompting for name,email,
it's supposed to call itself and then ask for the phone number, after that
it calls itself again and outputs the info, I've pasted the script below,
it
works fine when I run it via one of my isp's on their server but when I run
it on mine it reads in the first batch of info, but then defaults to the
final cover all else statement block.. Other scripts I have written/used on
my server work without problems so I know the setup is all ok, if anyone
has
any ideas I would really appreciate a nod in the right direction ...
btw when it does print out the values it has submit equal to submit so I
can't
understand why the elsif block doesnt execute..
#!/usr/local/bin/perl
require "cgi-lib.pl";
&ReadParse(*form_data);
print "Content-type: text/html\n\n";
if ($form_data{'submit'} eq "")
{
print qq!
<HTML>
<HEAD>
<TITLE>Testing Form Input</TITLE>
</HEAD>
<BODY>
<FORM METHOD = "POST"
ACTION = "self-refer.cgi">
<CENTER>
<TABLE BORDER = "1">
<TR>
<TH>First Name</TH>
<TD><INPUT TYPE = "text"
NAME = "f_name"></TD>
</TR>
<TR>
<TH>Last Name</TH>
<TD><INPUT TYPE = "text"
NAME = "l_name"></TD>
</TR>
<TR>
<TH>Email</TH>
<TD><INPUT TYPE = "text"
NAME = "email"></TD>
</TR>
</TABLE>
<P>
<INPUT TYPE = "SUBMIT" NAME = "submit"
VALUE = "submit">
</CENTER>
</FORM>
</BODY>
</HTML>!;
exit;
}
#******** The statement block below never executes ???***************
elsif ($form_data{'submit'} eq "submit")
{
print qq!
<HTML>
<HEAD>
<TITLE>Get More Data While
Remembering Old</TITLE>
</HEAD>
<BODY>
You submitted the following information:
<P>
<TABLE BORDER = "1">!;
foreach $key (keys(%form_data))
{
print qq!
<TR>
<TD>$key</TD>
<TD>$form_data{$key}</TD>
</TR>!;
}
print qq!
</TABLE>
<P>
Thank you very much. However, we need
one more bit of information.
Please input your phone number below:
<P>
<FORM METHOD = "POST" ACTION = "self-refer.cgi">
<INPUT TYPE = "TEXT" NAME = "phone">!;
foreach $key (keys(%form_data))
{
if ($key ne "submit")
{
print qq!
<INPUT TYPE = "HIDDEN" NAME = "$key"
VALUE = "$form_data{$key}">!;
}
}
print qq!
<INPUT TYPE = "SUBMIT" NAME = "submit"
VALUE = "Final Submit">
</FORM>
</BODY>
</HTML>!;
}
# *****************It always defaults to this block on the second pass
****************
else
{
print qq!
<HTML>
<HEAD>
<TITLE>Testing Form Input</TITLE>
</HEAD>
<BODY>
<TABLE>!;
foreach $key (keys(%form_data))
{
print qq!
<TR>
<TD>$key</TD>
<TD>$form_data{$key}</TD>
</TR>!;
}
print qq!
</TABLE>
</BODY>
</HTML>!;
}
Any help gratefully recieved...Running Active Perl v5.6.0 built for
MSWin32-x86-multi-thread
Si.
------------------------------
Date: 04 May 2001 11:49:03 +0100
From: jcp@myrtle.ukc.ac.uk (J.C.Posey)
Subject: Re: Allocating people like in a cinema
Message-Id: <jkou231pexs.fsf@myrtle.ukc.ac.uk>
"Tim Lauterborn" <Tim.Lauterborn@gmx.de> writes:
>
> Does someone know a module or a freeware program which can handle this
> problem?
>
> Greetings,
> Tim
Watch out! Here it comes...you should probably do your own homework. Good
luck with that.
Jake
--
Afraid of clpm
------------------------------
Date: Fri, 04 May 2001 11:07:35 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Allocating people like in a cinema
Message-Id: <3af28d76.ebe$329@news.op.net>
In article <9cttvf$pnd$1@nets3.rz.RWTH-Aachen.DE>,
Tim Lauterborn <Tim.Lauterborn@gmx.de> wrote:
>I have a list of people in groups (1 to 3 people in one group). I want to
>allocate these people to a set of chairs like in a cinema making sure that
>groups are not broken in two 'subgroups' at the end of a row.
>
>Does someone know a module or a freeware program which can handle this
>problem?
The problem is so simple that it is unlikely that anyone would write a
module or a program to solve it. Little would be gained by doing so.
For example, you might use the following code:
$seats_per_row = 10;
$rows = 12;
@groups = split //, "222131233131323121312211122331221322232321131311332122233112";
$_ = (("." x $seats_per_row) . "_") x $rows;
@c = (0..9, 'A' .. 'Z', 'a'..'z', );
while (@groups) {
$pat = "\\W" x (my $n = shift @groups);
s/$pat/(pop @c) x $n/e;
}
tr/_/\n/;
print;
Hope this helps.
--
@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: Fri, 4 May 2001 13:30:07 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Allocating people like in a cinema
Message-Id: <slrn9f5bmv.7cj.abigail@tsathoggua.rlyeh.net>
J.C.Posey (jcp@myrtle.ukc.ac.uk) wrote on MMDCCCIII September MCMXCIII in
<URL:news:jkou231pexs.fsf@myrtle.ukc.ac.uk>:
@@ "Tim Lauterborn" <Tim.Lauterborn@gmx.de> writes:
@@
@@ >
@@ > Does someone know a module or a freeware program which can handle this
@@ > problem?
@@ >
@@ > Greetings,
@@ > Tim
@@
@@ Watch out! Here it comes...you should probably do your own homework. Good
@@ luck with that.
Well, there are several ways to handle this.
- The US way:
$count = number_of_people_fitting_in_cinema;
while ($count--) {
wait_for_customer;
sell_ticket;
}
- Tickets have a row number and you want to be able to group
block sales. Again, there are two ways to do that. First
is to sell tickets as soon as it's been asked for. That's
a standard greedy algorithm. If there's a request for N tickets,
sell N tickets in the lowest row that has N or more places still
available. If no such row exists, let the customer decide how to
divide N.
The second way first collects all demands for tickets, and then
assigns all seats. This leads to an optimal placement; if such
a placement exists. However, this is NP-complete, so it will run
for a while.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Fri, 04 May 2001 14:11:24 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Allocating people like in a cinema
Message-Id: <tf5e4c1e4bj35a@corp.supernews.com>
In article <slrn9f5bmv.7cj.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
: The second way first collects all demands for tickets, and then
: assigns all seats. This leads to an optimal placement; if such
: a placement exists. However, this is NP-complete, so it will run
: for a while.
Not if you happen to have a non-deterministic Turing machine on hand.
Greg, can't seem to find one from any of the major vendors
--
The depths of idiocy are as yet unplumbed.
-- Larry Wall in <199612181938.LAA10214@wall.org>
------------------------------
Date: Fri, 4 May 2001 09:46:45 -0400
From: "John Fortin" <fortinj@attglobal.net>
Subject: Re: Any tip on accessing DB2 from NT (DBD::DB2 is not provided) ?
Message-Id: <9cubp5$drg$1@news.btv.ibm.com>
> The problem is that this is possible from db2cmd window.
> I could execute a program using system this way:
> $RC = system("db2cmd runqueries.pl");
>
> but I need the return code from the program, and this call
> always return me zero.
>
my $rc = system("db2cmd -c -w -i runqueries.pl")>>8;
print $rc;
From the db2 reference:
Command Parameters
-c
Execute the command, and then terminate. For example, "db2cmd /c dir" causes
the "dir" command to be invoked in a command window, and then the command
window closes.
-w
Wait until the cmd.exe process ends. For example, "db2cmd /c /w dir" invokes
the "dir" command, and db2cmd.exe does not end until the command window
closes.
-i
Run the command window, sharing the same console and inheriting file
handles. For example, "db2cmd /c /w /i db2 get dbm cfg > myoutput" invokes
cmd.exe to run the db2 command and to wait for its completion. A new console
is not assigned, and stdout is piped to file "myoutput".
-t
Instead of using "DB2 CLP" as the title of the command window, inherit the
title from the invoking window. This is useful if one wants, for example, to
set up an icon with a different title that invokes "db2cmd /t".
Note: All switches must appear before any commands to be executed. For
example: db2cmd /t db2.
------------------------------
Date: Fri, 04 May 2001 14:23:06 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Compare 2 arrays
Message-Id: <Pine.LNX.4.20.0105041020240.4345-100000@ethyl.addictmud.org>
Hello,
I have an irritating problem... I'm trying to come up with an efficient
way to sync 2 tables, in different databases, that have become horrible
un-sync'd :(
So far, I've pulled the id's into 2 different files created by the
Storable module, but now I need to figure out how to sync the id's...
Is there any "easy" or fast way to compare the 2 lists? I want to
get the extra id's from list A, and add those records to list B, but
at the same time get the extra id's from list B and delete those
records from list A. (I hope I'm explaining myself clearly).
Right now I stored the lists as arrays, but I could re-get the data
and store them into hashes if that is easier to manipulate...
FYI- there's over 600000 id's in each list.
Any help would be great!
Dan.
------------------------------
Date: Fri, 04 May 2001 07:54:22 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: Compare 2 arrays
Message-Id: <3AF2C29E.61BB4FFC@ugs.com>
"Daniel W. Burke" wrote:
>
> Hello,
>
> I have an irritating problem... I'm trying to come up with an efficient
> way to sync 2 tables, in different databases, that have become horrible
> un-sync'd :(
annoying isnt it? I have the same problems keeping 2 directories in sync
> So far, I've pulled the id's into 2 different files created by the
> Storable module, but now I need to figure out how to sync the id's...
good
> Is there any "easy" or fast way to compare the 2 lists? I want to
> get the extra id's from list A, and add those records to list B, but
> at the same time get the extra id's from list B and delete those
> records from list A. (I hope I'm explaining myself clearly).
I think what you are asking is: you would like to know which
items are in both lists? If this is the case try something like this
foreach $e (@a) { $union{$e} = 1 }
foreach $e (@b) {
if ( $union{$e} ) { $isect{$e} = 1 }
}
@isect = keys %isect;
The @isect array now contains what was in both @a and @b
I hope this helps
> Any help would be great!
------------------------------
Date: Fri, 4 May 2001 13:09:58 +0100
From: "Paul Brown" <paul.brown@ukinternetsites.com>
Subject: connect timeouts
Message-Id: <m_wI6.29949$PP3.2354819@nnrp3.clara.net>
Hi,
I am trying to write a client script in Perl to connect to a server I wrote
(also in perl). I have came to a little problem.....
I use connect(S, $serverhostname) to connect to the other server, however if
the server is down and not responding very fast, then it can sit there for a
long time. I want to setup some kind of timeout, so it trys to connect and
if it hasn't connected in 30 seconds (for example), it exits.
Any solutions to create a timeout? Thanks in advance!
Paul
------------------------------
Date: Fri, 04 May 2001 06:22:18 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: connect timeouts
Message-Id: <3AF2AD0A.4459E740@ugs.com>
Paul Brown wrote:
> I use connect(S, $serverhostname) to connect to the other server, however if
> the server is down and not responding very fast, then it can sit there for a
> long time. I want to setup some kind of timeout, so it trys to connect and
> if it hasn't connected in 30 seconds (for example), it exits.
>
> Any solutions to create a timeout? Thanks in advance!
>
Try something like this
$SIG{ALRM} = sub {die "timeout"};
eval {
alarm(5);
connect(S,$severhostname);
alarm(0);
};
if ($@) {
if ($@ =~ /timeout/) {
#it timed out do something
}else {
alarm(0); #clear the alarm
die;
}
}
I hope this helps
Ron
------------------------------
Date: 04 May 2001 07:27:26 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: cookie expiry
Message-Id: <m1wv7xchpt.fsf@halfdome.holdit.com>
>>>>> "Troy" == Troy Boy <troyr@vicnet.net.au> writes:
Troy> Time passes..........The user hits on a log out button and the
Troy> same code is called..but the expires variable gets reset to '1s'
Troy> .My problem is...that it doesn't take this into account..and
Troy> keeps the cookie active till the 2 minutes have passed.
Troy> Has anyone come across this problem..?
It is not safe to rely on "removing a cookie" as a "logout mechanism".
The browser is free to ignore your removal attempts, since setting or
clearing a cookie is just a suggestion, not a demand.
The cookie should be merely a key to a server-side database that has
the real "logged in" state. Set your server-side database to "logged
out", and ignore the cookie after that.
I have a good article on how to do that, including timing out a login,
at <http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 04 May 2001 06:24:10 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: DNS Lookups
Message-Id: <3AF2AD7A.69A73D95@ugs.com>
Mike Myers wrote:
[snipped]
>
> Is there a method to implement a simple timeout feature to improve
> efficiency without resorting to NET::DNS?
>
See my post on connection timeouts
Ron
------------------------------
Date: Fri, 4 May 2001 13:33:50 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Downloading images with HTTP/LWP libraries
Message-Id: <slrn9f5btu.7cj.abigail@tsathoggua.rlyeh.net>
Rafael Garcia-Suarez (rgarciasuarez@free.fr) wrote on MMDCCCIII September
MCMXCIII in <URL:news:slrn9f4l2k.mvk.rgarciasuarez@rafael.kazibao.net>:
{} Bob Walton wrote in comp.lang.perl.misc:
{} }
{} } As for getting HTML back when fetching an image file, that sounds like a
{} } mis-configured web server to me. Does the web page which references
{} } these images work OK in your browser? If so, is the web page actually
{} } pointing to those image files, or perhaps to other image files
{} } somewhere? Maybe the web server is trying to be too smart by paying
{} } attention to what kind of brower you say you are when giving the
{} } request. If so, you could pretend to be whatever brower it is that
{} } works with the web server (by using $ua->agent('whatever');). Who knows
{} } what the server thinks you are if you don't say? Maybe it assumes
{} } text-only?
{}
{} Another guess : the web server issues a redirect from the JPEG file to
{} an HTML file when some header is not present (probably User-Agent or
{} Referer). Try to use $ua->simple_request instead of $ua->request to
{} avoid being redirected and investigate the status code of the response :
{} is it 200 ? Try to add headers to the original request.
Of course, people could make the false assumption that when a URL ends
in '.jpg', it will return a JPEG image.
On the HTTP level, there is no relationship between the URL and the
content/type.
Abigail
--
BEGIN {my $x = "Knuth heals rare project\n";
$^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
$y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;
------------------------------
Date: 04 May 2001 07:20:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Downloading images with HTTP/LWP libraries
Message-Id: <m18zkddwlg.fsf@halfdome.holdit.com>
>>>>> "Robert" == Robert Hughes <rhughes@fas.harvard.edu> writes:
Robert> I'm trying to figure out how to download an embedded image
Robert> in a web page using the HTTP/LWP libraries. Right now,
Robert> I'm resorting to submitting a request with the image's URL.
Robert> This creates two problems:
Robert> 1) The image I get when I save $request->content to a
Robert> file is very distorted.
Robert> 2) In response to a request like http://www.foo.com/bar.jpg
Robert> some websites give an html page with bar.jpg embedded.
Robert> In this case, all I get in $request->content is the HTML code.
Robert> Here's the code I'm using now:
Robert> use HTTP::Request;
Robert> use LWP::UserAgent;
Robert> $ua = LWP::UserAgent->new;
Robert> $request = HTTP::Request->new('GET',
Robert> 'http://www.foo.com/bar.jpg');
Robert> $request->header(Accept => "image/*");
Robert> $response = $ua->request($request);
Robert> open (OUTPUT, ">result.jpg");
Robert> print OUTPUT $response->content;
Robert> close OUTPUT;
Robert> Any suggestions on how to do this better?
Yes, stop typing so much:
use LWP::Simple;
mirror("http://www.foo.com/bar.jpg", "result.jpg");
First most important advice:
read "perldoc lwpcook" from beginning to end, ONCE.
Shall I repeat that?
read "perldoc lwpcook" from beginning to end, ONCE.
There are far too many tips on higher-level interfaces in that
document to not be aware of them. It's a false Laziness not
to read it.
print "Just another Perl hacker,";
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 04 May 2001 07:22:33 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Downloading images with HTTP/LWP libraries
Message-Id: <m11yq5dwie.fsf@halfdome.holdit.com>
>>>>> "Godzilla!" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
Godzilla!> use LWP::Simple;
Godzilla!> $image = get ("url/path/to/image.jpg");
Godzilla!> binmode STDOUT;
Of course, binmode on STDOUT has nothing to do with the following
code. It's a red herring. Waste of characters. Distracting.
Vestigial no doubt.
Godzilla!> open (FILEHANDLE, ">image.jpg");
You need to insert binmode FILEHANDLE in here.
Godzilla!> print FILEHANDLE $image;
Godzilla!> close (FILEHANDLE);
The rest of Kira's advice is sound, however.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 04 May 2001 15:02:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Downloading images with HTTP/LWP libraries
Message-Id: <71h5fto99hb2996cc6ucmpsins26t9678b@4ax.com>
Robert Hughes wrote:
>Is it possible to retrieve an html file and the embedded images with a
>single HTTP request?
No, each URL has to be retrieved independantly. But HTML::LinkExtor
(part of the HTML::Parser package) can extract embedded URL's in a page,
and convert relative URL's to absolute ones.
--
Bart.
------------------------------
Date: Fri, 04 May 2001 15:03:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Downloading images with HTTP/LWP libraries
Message-Id: <a7h5ftcmv3p928rm5n2idq9arobvv6njq1@4ax.com>
Godzilla! wrote:
>binmode STDOUT;
>open (FILEHANDLE, ">image.jpg");
>print FILEHANDLE $image;
Whoops, wrong filehandle. And use binmode() after the file has been
opened.
--
Bart.
------------------------------
Date: Fri, 4 May 2001 13:19:09 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: efficient
Message-Id: <Pine.LNX.4.30.0105041317210.13142-100000@lxplus003.cern.ch>
On Fri, 4 May 2001, John Hall wrote:
> just when i thought i was writing good code, i revisited a subroutine...
>
> and shortened it from 15 lines to 3.
This might or might not actually be more efficient.
One day I might tell about the program that ran faster by adding a
NOP instruction. (But it's OT for Perl).
cheers
------------------------------
Date: 4 May 2001 14:09:07 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: evil eval in BEGIN
Message-Id: <9cud63$f93$1@sloth.swcp.com>
[ Posted and cc'd to cited author ]
Daniel Heiserer <daniel.heiserer@bmw.de> wrote:
> ...
> 3) I have to substitute the directory .../bin/... in $0 with /moduls
> and push that to @INC.
Why not use FindBin and the lib pragma?
#!/usr/bin/perl -w
use strict;
use FindBin;
use lib "$FindBin::Bin/../modules";
__END__
Do you really want 'moduls' or is that a typo?
> Pleas remember the only way i can do something is
> BEGIN { push(@INC, HERE) }
The "only way"? This is Perl. There are an unbounded number of ways
to do it.
Tramm
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
Date: Fri, 4 May 2001 15:56:36 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: execution of perl script
Message-Id: <9cug26$12i$1@kermit.esat.net>
> C:\TEMP>C:\WINDOWS\COMMAND.COM /C ""C:\perl\bin\perl test.pl
> text.txt""
> Can't open perl script "test.pl": No such file or directory
>
> Obviously, I am missing something, but what?
>
> <Gleason>
>
What's wrong is that you haven't specified the full path to test.pl. What
happens is
that the perl interpreter looks in whatever directory you run the batch file
from
hoping to find test.pl and complains when it's not found.
using "c:\perl\bin\perl c:\perl\bin\test.pl" should work.
On another note, since you're running under windows, the more recent
active-state
installations of perl allow you to run scripts by just typing their name in
at the
command prompt. Regarding your example, assuming test.pl is in a directory
that's
covered by your PATH environment variable, you would be able to run it by
typing
"test.pl" all by itself. This should mean that you wouldn't even need the
batch file.
Andrew
------------------------------
Date: Fri, 04 May 2001 23:37:02 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Familiar with this perl fix permission script
Message-Id: <3AF2B07E.72D49964@tassie.net.au>
Serge wrote:
> Hello,
>
> why not try
>
> system("chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null");
You should probably add a shebang line to give this huge script.
#!/usr/bin/perl
system("chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null");
__END__
The /usr/bin/perl bit refers to the location of the perl executable. Type 'which
perl' at the command line to get this. It will probably be as shown. If system
does not work you can try:
#!/usr/bin/perl
`chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null`;
__END__
James
>
>
> newuser wrote:
> >
> > Hello,
> > Every once in awhile my shell account goes crazy and it never puts the
> > correct permission as I ask for. The tech from my isp always has to do a
> > ls -lag which he
> > says that only techs can do. He mentioned that there is a work around to
> > this if I know how to write a perl script that runs the following command
> > "chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null
> > Have anyone seen a script that can do this and if so can they post it
> > here. I would also like if someone can explain to me how this works.
> > thanks a lot for your help
>
> --
> CGI Scripts and Services
> http://bestwebscripts.com
------------------------------
Date: 04 May 2001 10:33:57 -0400
From: <arr@oceanwave.com>
Subject: Re: Familiar with this perl fix permission script
Message-Id: <861yq5chey.fsf@sekrit.office.oceanwave.com>
newuser> Hello, Every once in awhile my shell account goes crazy and
newuser> it never puts the correct permission as I ask for. The tech
newuser> from my isp always has to do a ls -lag which he says that
newuser> only techs can do.
Your tech is alost definitely incorrect. All an ls does is show the
permissions on the files. You can do an ls just as well as he (read
the man page for ls).
newuser> He mentioned that there is a work around to this if I know
newuser> how to write a perl script that runs the following command
newuser> "chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null
You don't need a perl script, this is a simple shell command. See the
man page for chmod. Why he's making all of the files in
1/u3/r/t/trrttt/public/test/test2/ would readable, executable, AND
writiable is anyone's guess (perhaps some web server or something is
writing to them as nobody). In any case, I'd suggest picking up a
general UNIX book like UNIX in a Nutshell and learning how to use your
shell.
------------------------------
Date: Fri, 04 May 2001 11:11:39 GMT
From: PropART <temp1@williamc.com>
Subject: Re: general Perl question
Message-Id: <3AF28D1A.F6A4574F@williamc.com>
Yuriy Tenenbaum wrote:
>
> Hi. I am working on a Perl-CGI-HTML system where a lot of text files
> are being modified through web user's input. I heard from many people
> that developing such a system in Perl/CGI is not a good idea... that it
> has to be done in JavaScript. If this is true, can anyone tell me the
> exact reasons why? And what are the downfalls of that kind of system
> developed through Perl/CGI?
>
> thanks,
>
> sergey
This is not really appropriate for this ng - try...
comp.infosystems.www.authoring.cgi
Those people would be wrong. Perl is an excellent choice for handling
text and files. JavaScript, unless you're talking about Server-side
JS, which I doubt, is client-side, in the browser, scripting and not
really relevant to munging files on the server.
It all depends on what your setup is. If you have a Unix server and a
solid Perl programmer then Perl/CGI is a great way to go. The downfall
is that you need a solid Perl programmer who understands security as
well as CGI.
But there are various other ways to go, too. ASP/components. PHP.
JSP/Servlets. To me your question implies that you're over your head
and need some help even at this stage. No offense.
--williamc
------------------------------
Date: Fri, 04 May 2001 11:17:28 GMT
From: PropART <temp1@williamc.com>
Subject: Re: general Perl question
Message-Id: <3AF28E7E.159AF8A5@williamc.com>
Yuriy Tenenbaum wrote:
>
> Hi. I am working on a Perl-CGI-HTML system where a lot of text files
> are being modified through web user's input. I heard from many people
> that developing such a system in Perl/CGI is not a good idea... that it
> has to be done in JavaScript. If this is true, can anyone tell me the
> exact reasons why? And what are the downfalls of that kind of system
> developed through Perl/CGI?
>
> thanks,
>
> sergey
One thing that I forgot to add. Thinking of Perl and client-side
JavaScript as in any way incompatible, or as alternative ways to go,
is 100% wrong. No gray area at all. Your CGI program can write
JavaScript just as easily as it can write HTML...
--wmc
------------------------------
Date: Fri, 4 May 2001 13:38:05 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: general Perl question
Message-Id: <slrn9f5c5t.7cj.abigail@tsathoggua.rlyeh.net>
Yuriy Tenenbaum (yuriyt@ix.netcom.com) wrote on MMDCCCIII September
MCMXCIII in <URL:news:3AF23675.D4C9113D@ix.netcom.com>:
// Hi. I am working on a Perl-CGI-HTML system where a lot of text files
// are being modified through web user's input. I heard from many people
// that developing such a system in Perl/CGI is not a good idea... that it
// has to be done in JavaScript. If this is true, can anyone tell me the
// exact reasons why? And what are the downfalls of that kind of system
// developed through Perl/CGI?
I think that asking why Perl would not be a good choice in a field Perl
is used a lot is better done someplace other than a Perl language group.
If you think Javascript is better (and you believe that there's no
difference between client-side and server-side), by all means, go ask in
a group dealing with Javascript.
I think your problem is solvable with about 98% of the computer languages
out there. I think Javascript is in the remaining 2%. But again, this is
not the right place.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
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 833
**************************************