[10841] in Perl-Users-Digest
Perl-Users Digest, Issue: 4442 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 16 19:07:22 1998
Date: Wed, 16 Dec 98 16:00:21 -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: 4442
Today's topics:
Re: @INC and perl (Tad McClellan)
Re: ANNOUNCE: CodeMagic Universal IDE for Win32 (Free P <newspost@morlock.net>
Re: array initialisation <aqumsieh@matrox.com>
Re: binmode (Tad McClellan)
Re: binmode (Bart Lateur)
Can this be done (Henry Lifton)
Re: Complicated sorting problem (Tim Gim Yee)
Re: delete files (Tad McClellan)
Re: First German Perl Workshop 1.0 birgitt@my-dejanews.com
Re: hashes with arrays as values? (Tad McClellan)
Re: Need some speed tips on this script.. (Tad McClellan)
Re: Need some speed tips on this script.. (Larry Rosler)
Re: need Sun Solaris 2.6 sun4u gcc binaries <uri@ibnets.com>
Re: Perl's in the dictionary <uri@ibnets.com>
Pleas help with outputting messages to an html page whi <rmurthy@plexstar.com>
Preventing 'Repost Form Data' <design@spam_raincloud-studios.com>
print one pixel gif w/ perl (Oliver Moffat)
Re: print one pixel gif w/ perl (brian d foy)
querying/updating Access db in WinPerl? (David Askov)
Re: renaming an array with a number at the end chamlin@my-dejanews.com
school me on RE please keystroke@bigfoot.com
Re: sending a query from one script to another (Tad McClellan)
Re: Sorting a Two-dimensional Numerical Array <aqumsieh@matrox.com>
Re: STDIN works too well <kprice@cardinal.co.nz>
Why doesn't setenv freeze my script (Tommy1452)
Re: Why doesn't setenv freeze my script <dgris@moiraine.dimensional.com>
Re: Why doesn't this work? (Tad McClellan)
Re: Why Is Perl not a Language? <dgris@moiraine.dimensional.com>
Re: Why Is Perl not a Language? (John Moreno)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Dec 1998 16:34:03 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: @INC and perl
Message-Id: <rgc957.slj.ln@magna.metronet.com>
Kevin R. Price (kprice@iocenter.net) wrote:
: I am trying ot get PERL to run. I have perl 5.005 01 installed on an
: AIX 4.2.1.0 box.
: When I run perl test2.pl I get:
: Can't locate IO/Socket.pm in @INC (@INC contains:
: /usr/local/lib/perl5/aix/5.004
: 63 /usr/local/lib/perl5 /usr/local/lib/perl5/site_perl/aix
: /usr/local/lib/perl5/
: site_perl .) at UPSship.pm line 7.
The 'perldiag' man page describes the error messages that perl
might issue.
For your message it says:
---------------------
=item Can't locate %s in @INC
(F) You said to do (or require, or use) a file that couldn't be found
in any of the libraries mentioned in @INC. Perhaps you need to set the
PERL5LIB or PERL5OPT environment variable to say where the extra library
is, or maybe the script needs to add the library name to @INC. Or maybe
you just misspelled the name of the file. See L<perlfunc/require>.
---------------------
: Where or what is the @INC file, and how can I edit it to put in the
: correct path to where those library modules can be found?
or, see -I in the 'perlrun' man page
or, put the correct directories in when you build the perl executable
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 17:44:36 -0500
From: "Steven Morlock" <newspost@morlock.net>
Subject: Re: ANNOUNCE: CodeMagic Universal IDE for Win32 (Free Perl IDE)
Message-Id: <fLWd2.1214$qF5.3672374@lwnws01.ne.mediaone.net>
I think you should give David a break.
I'm sure he has learned his lesson on the Job SPAM.
Steve
--
Foliage Software Systems
aka The Nerd Farm
http://www.foliage.com
Clay Irving wrote in message <755sjl$f2c@panix.com>...
>In <754c55$kt$1@nnrp1.dejanews.com> pete@davesworld.net writes:
>
>>ANNOUNCE: CodeMagic Universal IDE for Win32
>>Win32 Based FREE IDE for Perl, TclTk, Java, C, Python
>>Beta Release 1 (15 Dec, 1998)
>
>>NEVER PAY FOR FREE SOFTWARE!
>>NEVER PAY FOR PERL SOFTWARE WHEN ALL YOU WANT IS FREE!
>>NEVER PAY FOR PROPRIETARY PERL SOFTWARE!
>
>WARNING!! WARNING!
>
>"pete@davesworld.net" is the same little snot who spammed posters in the
>Perl newsgroups with a sob story about his resume last week -- This week
>it's "FREE! FREE! SOFTWARE!" posted individually to each newsgroup
>instead of cross-posting...
>
>--
>Clay Irving
>clay@panix.com
------------------------------
Date: Wed, 16 Dec 1998 13:43:34 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: array initialisation
Message-Id: <x3y1zm0ylk9.fsf@tigre.matrox.com>
jwl@worldmusic.de (Joergen W. Lang) writes:
> Maybe someday we have modules like Crystal::Ball and Read::Mind which
> suggest answers in an associative manner.
I doubt if such modules would help. There is *NO WAY* you could guess
what goes inside the minds of Perl programmers. ;-)
I was checking the entries into the 3rd Confuscated Perl Contest
.. and man .. some of those people have incredibly wicked minds!
Ala
------------------------------
Date: Wed, 16 Dec 1998 13:37:29 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: binmode
Message-Id: <p52957.tgi.ln@magna.metronet.com>
J.K. (cljlk@hotmail.com) wrote:
: Would anyone please explain about binmode function and/or provide a
: piece of example codes.
from perlfunc man page:
------------------------
=item binmode FILEHANDLE
Arranges for the file to be read or written in "binary" mode in operating
systems that distinguish between binary and text files. Files that are
not in binary mode have CR LF sequences translated to LF on input and LF
translated to CR LF on output. Binmode has no effect under Unix; in MS-DOS
and similarly archaic systems, it may be imperative--otherwise your
MS-DOS-damaged C library may mangle your file. The key distinction between
systems that need C<binmode()> and those that don't is their text file
formats. Systems like Unix, MacOS, and Plan9 that delimit lines with a single
character, and that encode that character in C as C<"\n">, do not need
C<binmode()>. The rest need it. If FILEHANDLE is an expression, the value
is taken as the name of the filehandle.
------------------------
You surely have already seen this, so please point out what part
is unclear so the docs can be fixed. Thank you.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 22:40:03 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: binmode
Message-Id: <367835a3.9518996@news.skynet.be>
Tad McClellan wrote:
>You surely have already seen this, so please point out what part
>is unclear so the docs can be fixed. Thank you.
One word: "cookbook".
If there's anything wrong with the docs, it's the lack of very simple
examples for newbies. Just to get started.
The docs don't say WHEN binmode should be called. BTW it's best right
after open.
Remember that very recently a newbie asked if "flock" needed to be
called before or after opening a file.
Bart.
------------------------------
Date: Wed, 16 Dec 1998 22:23:50 GMT
From: henlif@elsfl.com (Henry Lifton)
Subject: Can this be done
Message-Id: <759bp5$41p$1@remarQ.com>
In an effort to get around the 1024 byte record limit in dbm files, I want to
use a tab delimited text file.
While each record is large, there are only about 25 to 50 records,
I want to create an array or hash that I can use to pick the record I want
using a key that is passed from another form.
Can anyone tell me how to code this. I have the following, but it does not
work.
open(land,'/data/land.txt') || die "can't open file land"; #this is the tab
delimited text file
$key=$ENV{'PATH_INFO'};
$key =~ s|/||;
$info=$land{$key};
($id,$address,$city,$type,$imp,$desc,$terms,$comments)=split('\t',$info);
$key is a number that corresponds to the first field $id and comes from
the sending page.
In trying to debug it, I print the $key and $info variables. $key comes up
properly but $info is blank.
I need to be able to split this into the proper fields.
I would be grateful for any help
Thanks
Henry Lifton
------------------------------
Date: Wed, 16 Dec 1998 22:48:13 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: Complicated sorting problem
Message-Id: <36782f14.50975446@news.oz.net>
On 16 Dec 1998 11:52:56 -0500, Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
>
> BL> You've mentioned this OM several times in the last few days. I've never
> BL> heard of this before. (sp: Orciam, Orcian, or Orcish)
_Orcish_ Maneuver. The name is a bad pun or mnemonic or both :)
>it is defined in effective perl programming by joseph hall. its primary
>feature is it converts the sort keys to a better form (ala ST) but
>inside the sort sub, and saves the converted form in a hash indexed by
>the original key. conversions are only done once, then the hashed data
>is used. search dejanews for examples, i can't code one on the fly here
>as it is not an idiom i am fluent it. i could give some time but i do't
>have that right now.
Here's an example of the Orcish Maneuver to go along with Uri's
explanation above. This one sorts files by date:
my %age;
@sorted = sort {
($age{$a} ||= -M $a) <=>
($age{$b} ||= -M $b)
} @files;
Pronounce ||= as 'or cache' (give me the file age 'or cache' an
expensive calculation of it), and instead of calling it the 'or-cache
method'... well, at least that's the way I think it goes.
--
Tim Gim Yee
http://www.dragonfire.net/~tgy/moogle/
"Kupo! Round and round you go! Moogle!"
------------------------------
Date: Wed, 16 Dec 1998 15:18:12 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: delete files
Message-Id: <k28957.dbj.ln@magna.metronet.com>
James Ludlow (ludlow@us.ibm.com) wrote:
: John Corbin wrote:
: >
: > 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.
And on top of all of that, you can ask perl (well the "OS" actually)
to _tell_ you why it could not remove the file:
unlink('H:\$dirname\$FileName') || die "could not open $!";
^^
^^
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 20:57:10 GMT
From: birgitt@my-dejanews.com
Subject: Re: First German Perl Workshop 1.0
Message-Id: <7596r6$3vu$1@nnrp1.dejanews.com>
In article <754026$954$1@black.news.nacamar.net>,
"G.Richter" <richter@ecos.de> wrote:
> (German version below)
> ########################################
>
> German Perl Workshop 1.0
>
> In February 1999, the first German Perl Workshop will take place in
> Sankt Augustin near Bonn, Germany.
>
> After the international Perl Conferences (in San Jose, California, in
> 1997 and 1998) the intention of this German workshop is now to support
> the exchange and networking between developers of Perl modules and
> advanced users in German speaking regions.
>
> That's why the particular focus of the workshop lies on contributions
> about the practical application of Perl in different areas.
>
> Perl programmers who are interested in the workshop can find
> detailed information at http://www.gmd.de/Events/Perl-WS99/.
>
> ########################################
>
> Deutscher Perl-Workshop 1.0
>
> Im Februar 1999 findet in Sankt Augustin bei Bonn der erste deutsche
> Perl-Workshop statt.
>
> Nach den beiden ersten internationalen Perl-Konferenzen (1997 und
> 1998 in San Jose, USA) ist es Ziel dieses Workshops, den Austausch
> und die Vernetzung zwischen Entwicklern von Perl-Modulen und
> fortgeschrittenen Anwendern im deutschsprachigen Raum zu fvrdern.
>
> Besonderes Interesse besteht bei diesem Workshop daher vor allem an
> Beitrdgen |ber die Anwendung von Perl in verschiedensten
> Aufgabenbereichen.
>
> Interessierte Perl-Programmierer finden detaillierte Informationen
> unter http://www.gmd.de/Events/Perl-WS99/.
>
> ####################################
>
This announcement was NOT made in de.comp.lang.perl, nor in clpm, nor in
clp.announce. Just in clp.moderated.
Is it worth wondering why ?
birgitt
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 13:31:32 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: hashes with arrays as values?
Message-Id: <kq1957.tgi.ln@magna.metronet.com>
Urs Thuermann (thuerman@ibr.cs.tu-bs.de) wrote:
: I'd like to have hashes whose values are arrays. Before reading the
That is not possible in Perl.
It *is* possible, however, to have hashes whose values are
*references* to arrays, which is good enough.
: documentation I just tried it out and was indeed surprised to find
: that it seems to work to some extent:
: #!/usr/bin/perl
You should use -w on *all* of your Perl programs.
Really.
It spews all kinds of info for the code you included, which
may provide hints as to what is going wrong...
: $start = 10;
: for $key (apple, peach, orange) {
^^^^^^^^^^^^^^^^^^^^
Barewords are bad, -w says so.
for $key ( qw/apple peach orange/) {
or
for $key ('apple', 'peach', 'orange') {
: @hash{mango} = (9,8,7,6,5,4,3,2,1,0);
^
^ -w also complains about that.
$hash{mango} = [9,8,7,6,5,4,3,2,1,0];
^ ^
^ ^ anonymous array reference
: #printf "%d\n\n", $#hash{apple};
Now that we know that $hash{apple} is a reference to an array,
we realize that we must dereference it in order to use it:
printf "%d\n\n", $#{$hash{apple}};
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 15:02:46 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need some speed tips on this script..
Message-Id: <m57957.u7j.ln@magna.metronet.com>
Chris Beatson (cbeatson@mail.ci.lubbock.tx.us) wrote:
: Thanks for the help everyone. This is what I came up with after all the
: sugestions, it runs much faster. I learned some good lessons too.
Let's learn yet another lesson ;-)
: use strict;
: sub Main;
: sub GrabIps;
: my %ips;
: my $filename;
: Main;
: sub Main {
: unless (@ARGV) {
: print "useage -- ips2.pl <filename> ";
: exit;
: }
: $filename="@ARGV";
Try running your program with more than one argument, and put a
warn "filename '$filename'\n";
here.
Then go read up on the $" special variable in the perlvar man page.
Then change the above line to:
$filename = $ARGV[0];
or
$filename = shift @ARGV;
heh, heh...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 15:20:28 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need some speed tips on this script..
Message-Id: <MPG.10e1e014393b81c79898ce@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <x7k8zspzcc.fsf@sysarch.com> on 15 Dec 1998 21:58:27 -0500,
Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
...
> >> print RESULTS map "$_\n", sort keys %ips;
>
> i would use a join here rather than map.
>
> print RESULTS join( "\n"m sort keys %ips ), "\n";
>
> join is one of the fastest complex perl funcs and is underused by many
> folks.
I put this together with Bart Lateur's suggestion of setting the output
record separators, and benchmarked (yes, again!) these results:
#!/usr/local/bin/perl -w
use Benchmark;
@data = ('x' x 100) x 100;
open OUT, '>/dev/null' or die $!;
timethese(1 << (shift || 0), {
For0 => sub { for (@data) { print OUT "$_\n" } },
For1 => sub { for (@data) { print OUT $_, "\n" } },
Join => sub { print OUT join "\n", @data, "" },
Map0 => sub { print OUT map "$_\n", @data },
Map1 => sub { print OUT map { $_, "\n" } @data },
Seps => sub { local ($\, $,) = ("\n", "\n"); print OUT @data },
});
__END__
Benchmark: timing 4096 iterations of For0, For1, Join, Map0, Map1,
Seps...
For0: 13 secs ( 7.61 usr 0.15 sys = 7.76 cpu)
For1: 16 secs ( 7.37 usr 0.15 sys = 7.52 cpu)
Join: 4 secs ( 2.13 usr 0.10 sys = 2.23 cpu)
Map0: 19 secs ( 9.16 usr 0.17 sys = 9.33 cpu)
Map1: 26 secs (13.13 usr 0.23 sys = 13.36 cpu)
Seps: 8 secs ( 3.65 usr 0.12 sys = 3.77 cpu)
That is an eyeopener. The single print of a string of >10K characters
is the winner, *big* over multiple print arguments produced by copying
$_ and "\n" into a string, also over multiple print arguments separated
by $,. Not localizing the global variables in the last case makes it
somewhat faster (3.27 sec), but not enough to change the conclusions.
Thanks for puncturing what I thought was a good technique!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Dec 1998 16:06:54 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: need Sun Solaris 2.6 sun4u gcc binaries
Message-Id: <394sqv6bkh.fsf@ibnets.com>
since everyone else is chiming in here, check out www.sunfreeware.com.
they have precompiled versions of most gnu and many popular public
packages (including perl!). they have them for solaris 2.5, 2.6 and 7,
for both sparc and x86.
all are available in src (tar.gz) and precompiled which install in
/usr/local
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: 16 Dec 1998 16:09:54 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Perl's in the dictionary
Message-Id: <393e6f6bfh.fsf@ibnets.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
>> what is the entry? can you post it here? or is that copyrighted (even
>> for quoting only one entry)?
BL> Hmmm... "You may not use any word that is in this dictionary". We
BL> wouldn't have much to say, then.
cute. i did mean the ful entry, not the word. :-)
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Wed, 16 Dec 1998 16:58:26 -0500
From: Rama Murthy <rmurthy@plexstar.com>
Subject: Pleas help with outputting messages to an html page while the user waits.
Message-Id: <36782D02.9B24E0DA@plexstar.com>
Hi,
I am using PERL/CGI script to generate static HTML page after the
user submits the form. While the user is waiting I would like to display
messages like "please wait it is procesing etc." . How can do that in
PERL/CGI script probably using JavaScript.
Thanks
Rama
------------------------------
Date: 16 Dec 1998 21:18:56 GMT
From: "Charles R. Thompson" <design@spam_raincloud-studios.com>
Subject: Preventing 'Repost Form Data'
Message-Id: <759840$rsk@bgtnsc02.worldnet.att.net>
I realize what I am about to ask is probably the stupidist of questions.
I've been using Perl for CGI scripts for almost 4 years now I just now
realized something that I can't seem to get around. A script I'm working on
runs as follows...
Administration Page loads...
Person enters user Information.. presses OK
Now the script writes to the database and reloads the Administration page.
If you click 'refresh' it asks if I want to repost the form data, then of
course adds a duplicate record so I added a confirmation page to the system
to keep from pressing refresh on the Administration page and reposting
entries.
Administration Page loads...
Person enters user Information.. presses OK
Now the script writes to the database and presenting with confirmed
message...
Administration page is loaded.
Of course... NOW it reposts if I refresh the confirmation page.
I realize I could check for duplicates, but I would much rather eliminate
the form data from following the user to the confirmation page. I want a
rather 'seamless' feel to the online application. I've tried resetting the
form data before loading the Administration Page but of course that doesn't
work. :)
What I *really want* is to post the info, reload the administration page and
prevent the data from being reposted on a refresh.
Any way of doing this? Is there a way to keep the data from beign cached?
(For some reason I think that's what is causing it)
Thanks,
CT
------------------------------
Date: Wed, 16 Dec 1998 17:11:59 -0500
From: xcom2@popserver.panix.com (Oliver Moffat)
Subject: print one pixel gif w/ perl
Message-Id: <xcom2-1612981712000001@xcom2.dialup.access.net>
I'm building a web site access statistics script with perl. My isp dosen't
allow ssi so I'm using a single pixel trick to call the script.
I stole this sub routine from the AXS Script Set, Logging Module, Version
2.01 by Fluid Dynamics http://www.xav.com/scripts/axs, but the pixel is
NOT transparent. I don't know how it works and so don't know how to fix
it. Specificly, what I don't understand is the actual list of bytes, are
they correct? Or is there a better way to do this?
sub Print_Image
{
$| = 1;
@Binary_Code = (71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,
33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,1,1,50,0,59);
print "Pragma: no-cache\r\n";
print "Expires: Saturday, February 15, 1997 10:10:10 GMT\r\n";
print "Content-Type: image/gif\r\n\r\n";
binmode(STDOUT);
foreach (@Binary_Code)
{
$BinCode = pack("C",$_);
print $BinCode;
}
}
------------------------------
Date: Wed, 16 Dec 1998 18:21:12 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: print one pixel gif w/ perl
Message-Id: <comdog-ya02408000R1612981821120001@news.panix.com>
In article <xcom2-1612981712000001@xcom2.dialup.access.net>, xcom2@popserver.panix.com (Oliver Moffat) posted:
> I'm building a web site access statistics script with perl. My isp dosen't
> allow ssi so I'm using a single pixel trick to call the script.
>
> I stole this sub routine from the AXS Script Set, Logging Module, Version
> 2.01 by Fluid Dynamics http://www.xav.com/scripts/axs, but the pixel is
> NOT transparent. I don't know how it works and so don't know how to fix
> it. Specificly, what I don't understand is the actual list of bytes, are
> they correct? Or is there a better way to do this?
see the GIF89 spec for the interpretation of the byte order (it's
available on the web or in books on graphics file formats).
of course, instead of doing a lot of work, i'd create a one pixel
transparent image in some graphics program (perhaps Image::Magick :)
then just call that like a normal image so i don't waste cycles on
a CGI script.
so i did create such an image. here's a script which looks at it's
structure, (with some added comments by me - mostly right but i haven't
done this sort of thing in awhile).
#!/usr/bin/perl
$/ = undef;
open IMAGE, "one-pixel.gif"
or die "$!";
my $index = 0;
while( read(IMAGE, $buffer, 1) )
{
printf "%2d: %3d %s\n", $index++, ord $buffer, $buffer;
}
0: 71 G #GIF signature - (6 bytes)
1: 73 I
2: 70 F
3: 56 8 #GIF version 89a
4: 57 9
5: 97 a
6: 1 #Logical Screen Descriptor - width - 1 pixel (2 bytes)
7: 0
8: 1 # height - 1 pixel (2 bytes)
9: 0
10: 145 k # global color map (1 byte) map follows,
2 bits/pixel, ordered, map size is 12 bytes
11: 255 # background color (1 byte)
12: 0 # pixel aspect ratio (1 byte)
13: 192 ? # global color map data (12 bytes)
14: 192 ?
15: 192 ?
16: 0
17: 0
18: 0
19: 0
20: 0
21: 0
22: 0
23: 0
24: 0
25: 33 ! #Application Extension Block
26: 249
27: 4 #header size
28: 1
29: 0
30: 0
31: 0
32: 0 #block terminator
33: 44 , #Image descriptor
34: 0 #start of image from left of screen (2 bytes)
35: 0
36: 0 #start of image from left of screen (2 bytes)
37: 0
38: 1 #width (2 bytes)
39: 0
40: 1 #height (2 bytes)
41: 0
42: 64 @ #(1 byte) use global map, interlaced,
unordered, 2 bits per pixel
43: 2
44: 2 #data black size
45: 68 D #data
46: 1 #data
47: 0 #end of image sub block
48: 59 ; #Terminator byte (end of file)
--
brian d foy <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't. it doesn't matter either way.
------------------------------
Date: Wed, 16 Dec 1998 22:26:48 GMT
From: askov@news.connectnet.com (David Askov)
Subject: querying/updating Access db in WinPerl?
Message-Id: <IsWd2.18$0_1.359@news.connectnet.com>
[ Article crossposted from comp.lang.perl ]
[ Author was David Askov ]
[ Posted on Wed, 16 Dec 1998 22:26:16 GMT ]
Hi,
I'd like to be able to query, insert and update records in an MS Access
database using the Win32 version of PERL. I'm working on a Win95 system.
I'm trying to write a program that eventually could maintain an Access
database via a web interface, without having Access loaded on that
machine.
Is this possible? If so, how? As much detail as you can provide would be
really great, including snippets of code. I know basic SQL syntax & I
know PERL, but I don't know how to talk to the database or what to do
with the results once I get them.
Any other useful suggestions on how to do this are welcomed.
Thanks, will summarize,
David Askov
askov@digitalics.com
------------------------------
Date: Wed, 16 Dec 1998 20:49:38 GMT
From: chamlin@my-dejanews.com
Subject: Re: renaming an array with a number at the end
Message-Id: <7596d1$3lj$1@nnrp1.dejanews.com>
In article <3674e353.28105082@news.cyberway.com.sg>,
pigs_can_fly@mindless.com (Jason Q.) wrote:
> I have this seemingly simple task but am new to Perl so if any one
> would help...
>
> Within a while loop, I need to rename an array each time it goes
> through the loop. @array0 changes to @array1 changes to @array2...
>
> this is what I have but my syntax at @array[$y] is wrong. How should I
> 'phrase' it?
>
> *********************
>
> $y = 0;
>
> while (a certain condition)
> {
> @array[$y];
> $y++;
> }
>
> ********************
>
> Thank you.
>
> Jason Q.
>
Maybe try soft references:
@array0 = (0);
@array1 = (0, 1);
@array2 = (0, 1, 2);
for ($i = 0; $i < 3; $i++)
{ $name = "array$i";
print "@$name\n";
}
Tried it and it seems to work, though -w complains.
Guess it can't ``see'' through the use of soft
references . . . not surprising?
But, using an array of arrays is probably better,
for most things, as someone else commented.
--
--
Chris Hamlin
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 16 Dec 1998 23:18:09 GMT
From: keystroke@bigfoot.com
Subject: school me on RE please
Message-Id: <759f3h$n5j$1@tilde.csc.ti.com>
I once thought that I had a handle on Regular Expressions, but I was wrong.
I have a multi line string - an html file. I would like to match from a
'<TD>' tag to the next matching '</TD>' tag, easy.
But the problems start when I try to match the '<TD>' tag pair that
contains a certain string. I get a match from the very first '<TD>' tag
of the file to the '</TD>' tag following the string.
$HTML_FILE =~ s|<TD>(.*?STRING.*?)</TD>|<TD>whatever</TD>|im;
I understand what is happening. The RE is matching the first '<TD>' to
the string and to the next '</TD>'. But I thought that the '?'
following a quantifier makes it be non-greedy. Does that not work like
I thought it should? I know that the RE engine searches left to right
and this is the first match that it finds, but how do I do it?
I guess I could use some examples of how to match it correctly.
Do I have to start using the variables $` and $' ?
Also, I having difficulties understanding the /s and the /m differences.
/m means multi-line strings where '.' will match a newline, and ^ and $
work off of the newlines in the string, right?
/s means treat it like a single line where '.' will not match a
newline, and ^ and $ only work at the ends of the string, right?
I can't get '.' to match a newline no matter which I try.
--
Thanks for the RE lessons.
------------------------------
Date: Wed, 16 Dec 1998 13:38:51 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sending a query from one script to another
Message-Id: <b82957.tgi.ln@magna.metronet.com>
Jason Q. (pigs_can_fly@mindless.com) 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?
: If so, how is it achieved?
from the perlop man page:
=item qx/STRING/
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 13:47:03 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Sorting a Two-dimensional Numerical Array
Message-Id: <x3yzp8nyleh.fsf@tigre.matrox.com>
Tom Briles <tbriles@austin.ibm.com> writes:
>
> James Ludlow wrote:
> > This is covered in the FAQ:
> >
> > http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_sort_an_aray_by_anyth
> >
> I did read this FAQ entry (I also looked in Learning Perl and Programming Perl, as well as
> three other Perl books).
Did you check out the Perl Cookbook (The Ram book) ?
> Perhaps I'm being daft, but I still don't see how to sort a multi-dimensional array. The
> FAQ talks about single-dimensional arrays. Maybe I just need an explanation of the
> explanation...
>
> - Tom
The very last chunk of that FAQ says:
If you need to sort on several fields, the following
paradigm is useful.
@sorted = sort { field1($a) <=> field1($b) ||
field2($a) cmp field2($b) ||
field3($a) cmp field3($b)
} @data;
I believe this is precisely what you want, you just have to know which
fields to compare first.
Try it and come again if you still have problems.
Ala
------------------------------
Date: Thu, 17 Dec 1998 11:47:48 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: STDIN works too well
Message-Id: <36783894.AA60B9E5@cardinal.co.nz>
Tad McClellan wrote:
>
> Tim Cutts (timc@chiark.greenend.org.uk) wrote:
>
> : As far as I know, there is no way for a program to tell whether its
> : STDIN is a pipe or not (UNIX gurus feel free to correct me).
>
> You can use the isatty() function in C.
>
> In Perl, you use the -t filetest (see perlfunc):
>
> -t Filehandle is opened to a tty.
>
I posted a while ago that this doesn't seem to work on NT (ActiveState
506) for detecting background/foreground (it may work for deciding
whether you're in a pipeline or not). -t STDIN always returns true. I
think it is because of the virtual desktop/window thing. I really would
like for a running script to be able to tell if it is running in the
background (IE. From a service or AT job) or if it is running in the
foreground (IE. From the command prompt).
Does anyone know how to make it work or of a workaround ?
TIA
------------------------------
Date: 16 Dec 1998 22:03:25 GMT
From: tommy1452@aol.com (Tommy1452)
Subject: Why doesn't setenv freeze my script
Message-Id: <19981216170325.24449.00000181@ng-fu1.aol.com>
The following command:
setenv HTTP_USER_AGENT "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)";
stops my script dead in it's tracks, how come?
------------------------------
Date: 16 Dec 1998 15:15:00 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Why doesn't setenv freeze my script
Message-Id: <m3r9tzg2e3.fsf@moiraine.dimensional.com>
tommy1452@aol.com (Tommy1452) writes:
> The following command:
> setenv HTTP_USER_AGENT "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)";
> stops my script dead in it's tracks, how come?
Because it's not perl.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Wed, 16 Dec 1998 13:42:06 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Why doesn't this work?
Message-Id: <ee2957.tgi.ln@magna.metronet.com>
JYB (Jean-Yves.Burlett@scinfo.u-nancy.fr) wrote:
: henlif@elsfl.com (Henry Lifton) writes:
: > $info=$land{$key};
: ^^^^^^^^^
: You're calling a hash, but we can't see the declaration of it.
: %land have nothing to do with the file handle land. (correct me)
^^^^^^^^^^
Can't.
Because you are right ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Dec 1998 14:26:41 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Why Is Perl not a Language?
Message-Id: <m3vhjbg4mm.fsf@moiraine.dimensional.com>
phenix@interpath.com (John Moreno) writes:
> Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> > 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.
No, it doesn't. Unless you are saying that this isn't interactive:
[dgris@moiraine pod]$ grep hash *.pod
<snip lots of results>
[dgris@moiraine pod]$ grep hash perltrap.pod perlvar.pod
<snip lots of results>
[dgris@moiraine pod]$ grep %SIG perlvar.pod
<snip final result set>
Just because it's iterative doesn't mean that it isn't interactive.
In fact, this is exactly the execution model of an http server (make
one request, receive one reply, make another request), and I don't
hear anyone saying that the web isn't interactive.
> > 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).
No, it's not a terminology problem, and it's not better now. It's a
problem with making unsupportable assumptions about what you are
writing. `user' and `interactive' are completely meaningless terms
when it comes to interface design. At any time, your `user' could be
any or all of a human being, an intelligent agent, or another program
and you have _no_ mechanism to determine absolutely which of these is
the case.
Insisting on a difference between user and non-user, interactive or
not, gui or console, etc. etc. leads to bugs that are in the same
class as Y2K bugs; completely avoidable errors introduced by sloppy
thinking about how and when your code will be used. It may be easier
to write the code if you don't think about it, but it certainly makes
it less likely that the code will be correct. :-(
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Wed, 16 Dec 1998 18:18:13 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Why Is Perl not a Language?
Message-Id: <1dk54s4.1vbyhjaxp5st4N@roxboro0-048.dyn.interpath.net>
Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
> phenix@interpath.com (John Moreno) writes:
>
> > Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>
> > > 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.
>
> No, it doesn't. Unless you are saying that this isn't interactive:
>
> [dgris@moiraine pod]$ grep hash *.pod
> <snip lots of results>
>
> [dgris@moiraine pod]$ grep hash perltrap.pod perlvar.pod
> <snip lots of results>
>
> [dgris@moiraine pod]$ grep %SIG perlvar.pod
> <snip final result set>
The shell is interactive, grep isn't.
> Just because it's iterative doesn't mean that it isn't interactive.
> In fact, this is exactly the execution model of an http server (make
> one request, receive one reply, make another request), and I don't
> hear anyone saying that the web isn't interactive.
First off a http server isn't "the web", secondly, the server is
interactive, but the individual transactions aren't.
> > > 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).
>
> No, it's not a terminology problem, and it's not better now. It's a
> problem with making unsupportable assumptions about what you are
> writing. `user' and `interactive' are completely meaningless terms
> when it comes to interface design. At any time, your `user' could be
> any or all of a human being, an intelligent agent, or another program
> and you have _no_ mechanism to determine absolutely which of these is
> the case.
"user" may be useless, "interactive" isn't.
> Insisting on a difference between user and non-user, interactive or
> not, gui or console, etc. etc. leads to bugs that are in the same
> class as Y2K bugs; completely avoidable errors introduced by sloppy
> thinking about how and when your code will be used. It may be easier
> to write the code if you don't think about it, but it certainly makes
> it less likely that the code will be correct. :-(
Ignoring the differences that exist between things doesn't make them go
away. A programs whose correct output is determined before it is
started is not a program whose output is determined by what happens
after it is started.
--
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 4442
**************************************