[9100] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2718 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 25 22:07:40 1998

Date: Mon, 25 May 98 19:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 25 May 1998     Volume: 8 Number: 2718

Today's topics:
    Re: An unwelcome and undeserved slap (Thomas Bushnell, n/BSG)
    Re: An unwelcome and undeserved slap (E. Gkioulekas)
        Best way to read a binary file into a string? <su0442@studserver.uni-dortmund.de>
    Re: Best way to read a binary file into a string? (Bob Trieger)
    Re: Best way to read a binary file into a string? <danboo@negia.net>
        c.l.p.misc is `perl support' (was Re: O'Reilly has help <Russell_Schulz@locutus.ofB.ORG>
        charging for access (to FAQs, to formatted documentatio <Russell_Schulz@locutus.ofB.ORG>
        Comm.pl ? with BSD/OS 3.1 (Robert Mann)
    Re: Determining Opsys at runtime <fgrimes@hotmail.com>
    Re: GNU attacks on the open software community (Thomas Bushnell, n/BSG)
    Re: GNU attacks on the open software community (Thomas Bushnell, n/BSG)
    Re: GNU attacks on the open software community (le Fanttme)
    Re: GNU attacks on the open software community (Thomas Bushnell, n/BSG)
    Re: GPL documentation == unspeakable evil <schwartz@cs.tu-berlin.de>
    Re: More double standards out of the FSF (Thomas Bushnell, n/BSG)
    Re: Perl 5.005_xxx <webmaster@fccjmail.fccj.org>
    Re: Perl Newbie  needs help (LONG) <dspencer@accessone.com>
    Re: Perl Newbie (no nothing) needs help (LONG) <hetlet@ptialaska.net>
    Re: Problem with Renaming a file to a new name that's s <zenin@bawdycaste.org>
    Re: Q: How to recover html page(defined by URL)  using  <zenin@bawdycaste.org>
    Re: Suggestion Re: GNU attacks on the open software com (Thomas Bushnell, n/BSG)
        Writing to a file <hetlet@ptialaska.net>
    Re: Writing to a file (Mike Stok)
    Re: Zip code searching with perl <parafina@sig.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 25 May 1998 14:49:05 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: An unwelcome and undeserved slap
Message-Id: <u1hogwmb2zi.fsf@w20-575-65.MIT.EDU>

Tom Christiansen <tchrist@mox.perl.com> writes:

> Mark my words: the FSF shall never write
> anything on Perl that can even *begin* to compare with the 1,000-page
> free book which they so condescendingly disregard.

Then why are you worried?


------------------------------

Date: 26 May 1998 01:33:33 GMT
From: egkioule@u.washington.edu (E. Gkioulekas)
Subject: Re: An unwelcome and undeserved slap
Message-Id: <6kd65d$1dbm$1@nntp6.u.washington.edu>

Wolfgang Denk <wd@uebemc.siemens.de> writes:

>egkioule@u.washington.edu (E. Gkioulekas) writes:

>>>the Perl development community--a community, I shall note, in which
>>>they have never played any role.  It is not ``GNU Perl'', you know.
>>                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>>The FSF has never called Perl, the GNU Perl. I think there is some territorial
>>instict at work here. You think of the FSF as outsiders that want to come
>>in and meddle the waters. I think that if someone were to take on that task,

>Well, at least this is what they tried when they started talking about
>``GNU Linux''.

But there's a difference. I think the GNU Linux issue is valid, whereas
calling Perl, GNU Perl wouldn't make sense.

Let me explain why. When we talk of a kernel, it's called Linux. No doubt
about that. When we talk of a system, I claim we should call it GNU/Linux. 
The key is understanding what we mean when we say "system". For me
system is all the components that combined with the kernel make your
computer sufficiently usable so you can do software development
and write _applications_ that run on that system. So if you look at
the base minimal system, it is predominantly indeed composed of GNU tools,
the kernel, and some additional tools that are linux only (like the 'free'
command). So it makes sense to talk of the GNU/Linux *system*

The reason for the debate is that the Linux community perceives this as
a territorial aggression against the entire work of their community, which
is indeed very vast and greater than what is officially FSF work.
This is enhanced by the fact that when we talk of "getting Linux" we
mean grabbing one of these CDs that includes a grand part of that work.
That is really GNU/Linux + free applications (by many communities, Linux, Tcl,
Perl, X11, TeX, etc...). I am not sure if FSF really means it like this,
but that is my angle on this debate. For me the bare _system_ looks pretty
much like a GNU system. The main difference between a bare Linux system
and the GNU/Hurd system will be the kernel after all.

Unfortunately RMS was not tactful about it, and he has invalidated his
claim in the eyes of many people, but I do think he has some sort of point.
Another angle that he emphasises more in his text is that "GNU system"
is more an idea issue than an "ownership" issue. It is the idea that
software should be free, and I believe that RMS cares more about the
idea being emphasized than taking whatever credit of "ownership".

Perl on the other hand, I see it more as an application that runs on
lots of various platforms. I don't think it is appropriate to call it
GNU/Perl any more than it is appropriate to call it NT/Perl or Mac/Perl.

Elef.


------------------------------

Date: Tue, 26 May 1998 01:33:47 +0200
From: Heinz Broedner <su0442@studserver.uni-dortmund.de>
Subject: Best way to read a binary file into a string?
Message-Id: <3569FFDB.5F4424B2@gmx.de>

Hello,

I want to read a binary file into a perl-script to work with the data.
The script (see below) works, but I wonder if it is the best and fastest
way to read in the binary data. Why do I have to read the data in lines
like text-data? Is it possible to avoid the loop section and read all
the binaries at once into $data? Or has anyone a different and maybe
nicer solution?

Thanx

  Heinz



# Read binary file into a string
#
open (BIN, "test.bin");
binmode BIN;        # I am on a DOS-machine
while (<BIN>) {     # reads single line until 0D 0A
      $data.=$_
      }


------------------------------

Date: Tue, 26 May 1998 00:38:31 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Best way to read a binary file into a string?
Message-Id: <6kd30m$kb6$1@ligarius.ultra.net>

[ posted and mailed ]

Heinz Broedner <su0442@studserver.uni-dortmund.de> wrote:
-> Hello,
-> 
-> I want to read a binary file into a perl-script to work with the data.
-> The script (see below) works, but I wonder if it is the best and fastest
-> way to read in the binary data. Why do I have to read the data in lines
-> like text-data? Is it possible to avoid the loop section and read all
-> the binaries at once into $data? Or has anyone a different and maybe
-> nicer solution?
 
-> # Read binary file into a string
-> #
-> open (BIN, "test.bin");
-> binmode BIN;        # I am on a DOS-machine
-> while (<BIN>) {     # reads single line until 0D 0A
->       $data.=$_
->       }

open(BIN,"test.bin") or die "Damn BIN won't open: $!";
binmode BIN;
@data = <BIN>;
$data = "@data";

There are probably 50 other ways to do it.

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-888-821-1954
    and hang up when somebody answers "


------------------------------

Date: Mon, 25 May 1998 21:15:09 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Best way to read a binary file into a string?
Message-Id: <356A179D.25A57FB2@negia.net>

Bob Trieger wrote:
> 
[SNIP]
> 
> open(BIN,"test.bin") or die "Damn BIN won't open: $!";
> binmode BIN;
> @data = <BIN>;
> $data = "@data";
> 
> There are probably 50 other ways to do it.

and some of them may even work. :-)

don't forget about the $" special variable. my suggestion would be
to set $" to the empty string, or undef the input record separator ($/),
and read the file in at once:

open (BIN, "test.bin") || die $!;
binmode BIN;
{
  local $/;
  $data = <BIN>;
}

cheers,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


------------------------------

Date: Mon, 25 May 1998 21:18:44 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: c.l.p.misc is `perl support' (was Re: O'Reilly has helped promote the acceptance of Perl)
Message-Id: <19980525.211844.0k5.rnr.w164w_-_@locutus.ofB.ORG>

Scott Erickson <Scott.L.Erickson@HealthPartners.com> writes:

> Prior to [the ORA book], they had been opposed to the use of Perl
> because, it was free and because it was "not supported" (evidently,
> they do not understand usenet and FAQ's and documentation).

a. a book is `support'?
b. usenet is `support'?!

please clarify.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


------------------------------

Date: Mon, 25 May 1998 20:56:15 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: charging for access (to FAQs, to formatted documentation, etc.) (was Re: GNU attacks on the open software community)
Message-Id: <19980525.205615.9f8.rnr.w164w_-_@locutus.ofB.ORG>

tchrist@mox.perl.com (Tom Christiansen) writes:

> I wouldn't let you -- if it were contrary to my wishes -- make a
> changed copy (as opposed to a mirror) of my website either.  I
> certainly wouldn't let you sell access to it.

access to your website?  a lot of people charge for that.

access to a mirror of your website?  ditto.

access to a modified version of your website?  if O'Reilly editors
make changes to some perl docs that get printed (fancy formatting,
an index, who knows what) do they get to charge for that?  is that
similar, or different?

nobody thinks they should remove your name as author; this point
is lost on those who would be so ethics-free to even consider it
anyway.  but charging access is done all the time (and is the route
I have to use to get to all this good Internet stuff, personally).
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


------------------------------

Date: Tue, 26 May 1998 01:01:43 GMT
From: robert@lightspeed.net (Robert Mann)
Subject: Comm.pl ? with BSD/OS 3.1
Message-Id: <356a1324.90326427@news.lightspeed.net>

Has anyone know of a Comm.pl like or other perl script or module with
the same funtionality that works well with BSD/OS?  I need to
communicate bi-directionally with tip and would prefer not to use
expect for the task.

Robert Mann
Lightspeed Net


------------------------------

Date: Mon, 25 May 1998 16:53:40 -0700
From: "Grimes" <fgrimes@hotmail.com>
Subject: Re: Determining Opsys at runtime
Message-Id: <6kd0cm$5ji$1@nntp1.ba.best.com>

$^O  works well... returns 'MSWin32'  and 'freebsd' on my two platforms.
Much obliged... Thanks, Fergal

Mike Stok wrote in message <6kcrtg$2s@news-central.tiac.net>...
>You can check the value of $^O which ...





------------------------------

Date: 25 May 1998 14:41:19 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: GNU attacks on the open software community
Message-Id: <u1hpvh2b3cg.fsf@w20-575-65.MIT.EDU>

fantome/@/usa/./net (le Fanttme) writes:

> According to the OS class that I took when I was in school, the
> operating system was that which provided memory management, disk
> interfaces, and methods of user interface. Said jack about having a
> compiler.

"Methods of user interface".  Hmm.


------------------------------

Date: 25 May 1998 14:38:54 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: GNU attacks on the open software community
Message-Id: <u1hra1ib3gh.fsf@w20-575-65.MIT.EDU>

fantome/@/usa/./net (le Fanttme) writes:

> I've deconstructed this for you. Please read it before you continue to
> make this statement from ignorance.

Your arguments are simply legal nonsense.  A commercial company which
distributes a bundled product, and is making a profit on the sale of
the total product.  The proper way to attribute the profit is
proprortionally to the cost of the various components of the bundled
product, and since including perlfaq has a nonzero cost, it has a
nonzero profit too.

The kind of "marginal profit" calculation you were trying to do is
utterly bogus.



------------------------------

Date: Tue, 26 May 1998 01:17:14 GMT
From: fantome/@/usa/./net (le Fanttme)
Subject: Re: GNU attacks on the open software community
Message-Id: <963A20F2C46FA336.06F55A52A6961D71.E8926B4B055A26E7@library-proxy.airnews.net>

On 25 May 1998 14:41:19 -0400, tb@mit.edu (Thomas Bushnell, n/BSG)
wrote:

>fantome/@/usa/./net (le Fanttme) writes:
>
>> According to the OS class that I took when I was in school, the
>> operating system was that which provided memory management, disk
>> interfaces, and methods of user interface. Said jack about having a
>> compiler.
>
>"Methods of user interface".  Hmm.

This is not the user interface itself, Mr. Bushnell, but the methods
by which the user interface can interact with the disk, memory, and
(or course) the programs. In Unix, this is the console -- the shell
provides the actual UI. X Windows uses similar mechanisms but still
only uses the methods exposed by the kernel (and supporting programs).

In Windows, this is the GUI. 

As I said, "methods of user interface."

-f
-- 
austin ziegler * fantome*@*vnet*.*net   * http://fantome.vnet.net/
---------------* aziegler*@*vcela*.*com * -------------------------
Remove the stars to email me            * Ni bhionn an rath ach
my words my opinions my ideas           * mar a mbionn an smacht
  -- I Argue Ideas, Not Beliefs: Give Up Your Dogma --


------------------------------

Date: 25 May 1998 21:28:08 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: GNU attacks on the open software community
Message-Id: <u1h4sydes7r.fsf@biohazard-cafe.MIT.EDU>

fantome/@/usa/./net (le Fanttme) writes:

> This is not the user interface itself, Mr. Bushnell, but the methods
> by which the user interface can interact with the disk, memory, and
> (or course) the programs. In Unix, this is the console -- the shell
> provides the actual UI. X Windows uses similar mechanisms but still
> only uses the methods exposed by the kernel (and supporting programs).

Well, then you were taught wrong, I'm afraid.

Before the advent of Unix, "operating system" meant the whole shebang
of system software.  It meant command interpreters (which usually had
to run as privileged processes); it meant the main editors, it usually
meant the compilers, it meant JCL, it meant the way messages appeared
on the operator's console, it meant the way backups were done.

Unix people started using the term "operating system" to refer to the
kernel.  And they used the word "kernel" to mean "monitor", because
Unix is not a kernel-based operating system, as that word had always
been used.

Thomas


------------------------------

Date: 25 May 1998 23:55:30 GMT
From: Martin Schwartz <schwartz@cs.tu-berlin.de>
Subject: Re: GPL documentation == unspeakable evil
Message-Id: <6kd0di$bav$1@news.cs.tu-berlin.de>

Birgitt Funk <ngouah@erols.com> wrote:

>>> In my opinion the destiny of wide spread free software projects is, that
>>> they will be untied from the creators. ...

> Since when are people denied the right of recognition if they donate
> huge chuncks of their work to the public ? 

They need to and will be recognized, Birgit. They should even stay the 
main motors in developing the work. No doubt, they probably will stay 
forever connected to it. 

Martin

-- 
// Le degre zero de l'ecriture? Zero probleme!


------------------------------

Date: 25 May 1998 14:56:10 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: More double standards out of the FSF
Message-Id: <u1hk97ab2np.fsf@w20-575-65.MIT.EDU>

Anselm Lingnau <lingnau@tm.informatik.uni-frankfurt.de> writes:

> You could presumably always ask Tom to give you special permission to
> include perlfaq. If your project is commercial, he may want to have a
> cut of the profit, which under the circumstances seems only fair. If
> your project doesn't involve money, chances are he'll let you use his
> stuff even so, if you say it's his originally.

If I need to ask permission, then the manual isn't free in the FSF
sense.  Tom says he's been quite liberal in giving permission, which
is a nice thing.  But being given permission is not the same thing as
freedom, and the FSF wants free documentation--specificall
documentation free of the need to ask permission to distribute or
modify.




------------------------------

Date: Tue, 26 May 1998 01:32:30 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: Perl 5.005_xxx
Message-Id: <356A19BF.FA2F523C@fccjmail.fccj.org>

I R A Aggie wrote:
> 
> 
> Shoot, I'm reasonably well versed in perl, but even *I* don't want to
> be chasing beta's around...

I agree and I *really* wish I hadn't started this thread.  Hell, I can't
post any code to 'mend' things later.  :-(


At least, none that wouldn't be laughed at!
:-)
-Sneex- 
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster


------------------------------

Date: Mon, 25 May 1998 17:51:39 -0700
From: "Dan Spencer" <dspencer@accessone.com>
Subject: Re: Perl Newbie  needs help (LONG)
Message-Id: <6kd3q2$2nr$1@supernews.com>

Lance,

I tried uploading in ASCII and it does not work.  I took the "Dummies" book
back, BTW.  This is the script that I am having trouble with
http://www.cris.com/~kmeltz/ran_img.htm .  I have downloaded and edited it
with Notepad.  There are only two variables.  I have the first variable
($base),  set to "http://mydomain.com/".  I have the second variable
($picfile), set to "pix.txt".  This is what "pix.txt" looks like:

banners/image1.jpg
banners/image2.gif
banners/image3.gif

The path to the images is correct.  I have set the ran_img.pl and pix.txt to
the proper permissions per the "read me" file.  The page that I am trying to
display the images is http://mydomain.com/test/banner1.html .  Since I
really don't know what I am doing, I have a copy of "pix.txt" in my cgi-gin,
my main directory, and my "test" sub directory.  My best guess is that it
really belongs in the main folder only.  BTW, the path to the cgi-bin in the
HTML document is correct.

I was able to get another script working that I just uploaded to my cgi-bin
without editing.  I guess in plain English, it would be nice if someone
could explain step by step what a newbie who finds a script should do with
it.  In my case it is a script with two easily edited variables.   I have
downloaded the script and edited it with Notepad, and I have copy and pasted
the script directly into Notepad and changed the variables. It won't work
either way.  Is there a step that I am missing?  At this point, I really
have no need to learn Perl.  I would really just like to be able to edit
existing scripts for my use.

TIA,

Dan

    Lance Hetlet wrote in message <3569FD90.1E963D1D@ptialaska.net>...
    Have you made sure you're sending your files to the web server in ASCII
    mode?  That was my first problem (among many).  That's all I can think
of
    right now, being a newbie also.
    Lance

    Dan Spencer wrote:

        To summarize, this will not work:
        1) Copy and paste raw script into Notepad.

        2) Edit Perl files that have been downloaded.

        This is what works:

        1) Scripts that don't need editing.

        2) Edit script that has been looked at and probably resaved by web
host
        admin.






------------------------------

Date: Mon, 25 May 1998 15:24:00 -0800
From: Lance Hetlet <hetlet@ptialaska.net>
To: Dan Spencer <dspencer@accessone.com>
Subject: Re: Perl Newbie (no nothing) needs help (LONG)
Message-Id: <3569FD90.1E963D1D@ptialaska.net>


--------------8A1EB6FE4BD5F486A71F8E1F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Have you made sure you're sending your files to the web server in ASCII
mode?  That was my first problem (among many).  That's all I can think of
right now, being a newbie also.

Lance

Dan Spencer wrote:

> To summarize, this will not work:
>
> 1) Copy and paste raw script into Notepad.
>
> 2) Edit Perl files that have been downloaded.
>
> This is what works:
>
> 1) Scripts that don't need editing.
>
> 2) Edit script that has been looked at and probably resaved by web host
> admin.



--------------8A1EB6FE4BD5F486A71F8E1F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Have you made sure you're sending your files to the web server in ASCII
<BR>mode?&nbsp; That was <B>my</B> first problem (among many).&nbsp; That's
all I can think of
<BR>right now, being a newbie also.

<P>Lance

<P>Dan Spencer wrote:
<BLOCKQUOTE TYPE=CITE>To summarize, this will not work:

<P>1) Copy and paste raw script into Notepad.

<P>2) Edit Perl files that have been downloaded.

<P>This is what works:

<P>1) Scripts that don't need editing.

<P>2) Edit script that has been looked at and probably resaved by web host
<BR>admin.</BLOCKQUOTE>
&nbsp;</HTML>

--------------8A1EB6FE4BD5F486A71F8E1F--



------------------------------

Date: 25 May 1998 23:03:40 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Problem with Renaming a file to a new name that's specified by a variable
Message-Id: <896137861.216747@thrush.omix.com>

Arthur Dardia <ahdiii@webspan.net> wrote:
: In my CGI problem, I have the following code:
:
: rename "../htdocs/toast/matches/temp.html",
: "../htdocs/toast/matches/'.$in{filename}.'";

	Are you sure want to embed those single quotes as part
	of the new name???

: Why doesn't that work?  I tried:
: rename "../htdocs/toast/matches/temp.html",
: '../htdocs/toast/matches/'.$in{filename}.'';

	Any particular reason you're not testing the return value and
	doing something useful with $! if it fails?

	Always, always, always test your return values of system calls....

	One more hint: Unless your CGI script does it's own chdir(), the
	exact location that it's run could be anywere.  Because of this
	relative paths such as "../somewhere" are *very* likely to fail.

	Oh, and check out the CGI::Carp module while you're at it (it comes
	with the CGI module).  It will save you tons of debug time.

-- 
-Zenin
 zenin@archive.rhps.org


------------------------------

Date: 25 May 1998 22:58:49 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Q: How to recover html page(defined by URL)  using perl ?.
Message-Id: <896137569.787929@thrush.omix.com>

KRIS VAN LIER <kvanlier@club-internet.fr> wrote:
: How can I copy a html page given an URL using perl.
: Any reference to handle this would be appreciated.

	Look for the libwww/LWP modules at your local CPAN.

-- 
-Zenin
 zenin@archive.rhps.org


------------------------------

Date: 25 May 1998 14:50:50 -0400
From: tb@mit.edu (Thomas Bushnell, n/BSG)
Subject: Re: Suggestion Re: GNU attacks on the open software community
Message-Id: <u1hlnrqb2wl.fsf@w20-575-65.MIT.EDU>

David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> writes:

> tb@mit.edu (Thomas Bushnell, n/BSG) writes:
> 
> > tzs@halcyon.com (Tim Smith) writes:
> > 
> > > The courtesy copies he sends have the same notice on them, so that's not
> > > really a problem.
> > 
> > Being an out gay Christian on Usenet exposes one to a fair amount of
> > hate mail, so I was well prepared for Tom's email.  It's a shame he's
> > do fond of the tactics of Jesse Helms and his ilk.
> 
> Please don't use your presumed attacked-minority status for explaining
> any dissension or aggressiveness towards you.  That is cheap.  Tom is
> perfectly able to be rude on his own without needing a presumed victim
> with special status.  In fact, I'm pretty sure he would have not
> noticed (and probably still hasn't) without you bringing up that cheap
> pseudo-defense.

Oh, Tom's gay too.  He's attacking me because of my arguments, which
he doesn't like, and the forcefulness with which I advocate them,
which he likes even less.

My point is that the tone of his attacks are strikingly similar to
those of the hate-mongers I more usually deal with.













------------------------------

Date: Mon, 25 May 1998 15:18:47 -0800
From: Lance Hetlet <hetlet@ptialaska.net>
Subject: Writing to a file
Message-Id: <3569FC57.477DEB54@ptialaska.net>


--------------39E51C783E8D2723ECC6271B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm just learning Perl and have run into a problem with writing to a
file.
The book I'm working from shows two examples, one which doesn't
work, and the other is confusing.

The example that I'm trying is:

open(DATABASE, ">>/data/records.dat");
select (DATABASE);
print $_;
print "\n";
select (STDOUT);

The above does not work for me.  Any hints?
The example that confuses me is:

format printf(FILE-TO-WRITE-TO FORMAT-STATEMENTS, DATA);

I am unsure of the "Format-Statements" paramater.  There is no example
in
the book, and I don't know what the format-statements might be.

Any help would be greatly appreciated.
TIA

Lance Hetlet
http://www.ptialaska.net/~hetlet


--------------39E51C783E8D2723ECC6271B
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
I'm just learning Perl and have run into a problem with <I>writing to a
file.</I>
<BR>The book I'm working from shows two examples, one which doesn't
<BR>work, and the other is confusing.

<P>The example that I'm trying is:

<P><B><FONT COLOR="#000099"><FONT SIZE=-1>open(DATABASE, ">>/data/records.dat");</FONT></FONT></B>
<BR><B><FONT COLOR="#000099"><FONT SIZE=-1>select (DATABASE);</FONT></FONT></B>
<BR><B><FONT COLOR="#000099"><FONT SIZE=-1>print $_;</FONT></FONT></B>
<BR><B><FONT COLOR="#000099"><FONT SIZE=-1>print "\n";</FONT></FONT></B>
<BR><B><FONT COLOR="#000099"><FONT SIZE=-1>select (STDOUT);</FONT></FONT></B>

<P>The above does not work for me.&nbsp; Any hints?
<BR>The example that confuses me is:

<P><B><FONT COLOR="#000099"><FONT SIZE=-1>format printf(FILE-TO-WRITE-TO
FORMAT-STATEMENTS, DATA);</FONT></FONT></B>

<P>I am unsure of the "Format-Statements" paramater.&nbsp; There is no
example in
<BR>the book, and I don't know what the format-statements might be.

<P>Any help would be greatly appreciated.
<BR>TIA

<P><I><FONT COLOR="#990000"><FONT SIZE=-1>Lance Hetlet</FONT></FONT></I>
<BR><FONT SIZE=-1><A HREF="http://www.ptialaska.net/~hetlet">http://www.ptialaska.net/~hetlet</A></FONT>
<BR>&nbsp;</HTML>

--------------39E51C783E8D2723ECC6271B--



------------------------------

Date: 26 May 1998 00:15:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Writing to a file
Message-Id: <6kd1ig$3gs@news-central.tiac.net>

In article <3569FC57.477DEB54@ptialaska.net>,
Lance Hetlet  <hetlet@ptialaska.net> wrote:
>-=-=-=-=-=-
>
>I'm just learning Perl and have run into a problem with writing to a
>file.
>The book I'm working from shows two examples, one which doesn't
>work, and the other is confusing.
>
>The example that I'm trying is:
>
>open(DATABASE, ">>/data/records.dat");
>select (DATABASE);
>print $_;
>print "\n";
>select (STDOUT);
>
>The above does not work for me.  Any hints?
>The example that confuses me is:

You shpuld check whether the open succeeds, if it fails the perl variable
$! should contain some useful information, so

  $database = "/data/records.dat";
  open (DATABASE, ">>$database") || die "$0: open $database failed ($!)\n"; 

  ...

will report errors opening the database file.

It's possible to specify the filehandle per print dtatement by saying

  print DATABASE $_, "\n";

if you don't want to do the selects (and you might consider saying 

  $oldFH = select (DATABASE);
  ...
  ...
  select ($oldFH);

just in case STDOUT wasn't the selected file handle...)

>format printf(FILE-TO-WRITE-TO FORMAT-STATEMENTS, DATA);
>
>I am unsure of the "Format-Statements" paramater.  There is no example
>in
>the book, and I don't know what the format-statements might be.

In recent perl distributions

  perldoc -f sprintf | more

should describe some of the formatting options - they're the same for
printf and sprintf.  They allow you to specify field wisth and precision
and representation of data.

Failing that,

  perldoc perlfunc

or

  man perlfunc

should get you documentation on perl's built in functions.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


------------------------------

Date: Mon, 25 May 1998 20:41:00 -0500
From: sonny <parafina@sig.net>
Subject: Re: Zip code searching with perl
Message-Id: <356A1DAC.B8C89BAC@sig.net>

If you want a geographical search, then you need the latitude and longitude of
the zipcode polygon centroid.  You can use perl to search and sort for the
closest z ipcodes.  The data is freely available for 3 and 5 digit zips.
Email me if you want the URL for the data.

sonny


Jake Baillie wrote:

> Good Day,
>
> I am a relatively new perl programmer looking for some help. Right now, I
> have written a perl script that will post a flatfile database to a web
> page.
>
> I would like to insitute a function where it would be able to search by
> zip code, i.e., if I gave it a zip code of 56049 it would find the nearest
> zip code up or down. I can't seem to find out how to do this. Does anybody
> have any ideas on a search routine for this?
>
> If so, could you do me a big favor and drop me a line at jake@marinar.com
>
> Thank you,
> Jake Baillie
> Marinar Communications





------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2718
**************************************

home help back first fref pref prev next nref lref last post