[6564] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 189 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 27 08:07:17 1997

Date: Thu, 27 Mar 97 05:00:40 -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           Thu, 27 Mar 1997     Volume: 8 Number: 189

Today's topics:
     Re: base conversion (for unix rgb/hex converter) (Eric Bohlman)
     Re: Beginner needs help <jjover@correu.andorra.ad>
     Re: converting files to html (Markus Laker)
     Re: Coverting Objects to packed strings.. how? <tibbs@hpc.uh.edu>
     Re: Help - Perl scripts cannot find cgi-lib.pl <tshell@mcs.net>
     Re: How do I ?  .. rand/srand champs read this (Brian L. Matthews)
     Re: How do I ?  .. rand/srand champs read this (Eric Bohlman)
     Re: How do I delete a line out of a text file <rob@netcentral.net.no.spam>
     Re: how to print the content of an html file? <tshell@mcs.net>
     HOW TO: Run Perl CGI Scripts on Local Windows95 PC (RGA@IO.COM)
     I.P Address Patterns <andy@wwdatalink.com>
     Re: I.P Address Patterns (A. Deckers)
     Newbie asks how do I format a numeric output? <russ@hevacomp.demon.co.uk>
     ODBC drivers for perl on UNIX zohara@bashan.co.il
     Perl script for generating a one-time password (Michael Guitton)
     Re: q <ajohnson@gpu.srv.ualberta.ca>
     Re: Regular Expresion question. (Michael Shields)
     Same syntax, different result. (Ernie Dunbar)
     Re: Same syntax, different result. (Ernie Dunbar)
     Re: Same syntax, different result. (Eric Bohlman)
     Sending Environment variables to a PERL script using Ja <alastair@redboxad.demon.co.uk>
     Re: text to HTML <ajohnson@gpu.srv.ualberta.ca>
     Re: Unix 'Cat' equivelent (Charles DeRykus)
     Re: Unix and ease of use  (WAS: Who makes more ...) <NOSPAMplas@fmi.ch>
     Re: Unpacking .gz file <eike.grote@theo.phy.uni-bayreuth.de>
     what "multi-line matching" means (was Re: text to HTML) <dbenhur@egames.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Mar 1997 08:12:59 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: base conversion (for unix rgb/hex converter)
Message-Id: <ebohlmanE7p05n.AnG@netcom.com>

David Staschover (das@panix.com) wrote:
: I want to write a unix shell command to convert from rgb to hex. Is there
: a function
: in perl to convert bases?

Not for converting arbitrary bases, but for this application take a look 
at printf, sprintf, pack and unpack.

If all you want to do is take 3 decimal numbers typed on the command line 
and convert them into a 6-character hex code, the following will do it:

printf "%02X%02X%02X\n", @ARGV[0..2];

 


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

Date: 27 Mar 1997 08:02:28 GMT
From: "Josep Jover" <jjover@correu.andorra.ad>
Subject: Re: Beginner needs help
Message-Id: <01bc3a84$9210cd40$d1419ec2@SUZUKA.andorpac.ad>

Hello Bruce,

> How do I write a program with perl. Do I just use notepad and type in
> the program? I have a cgi script but it does not work.

Yes, with only notepad you can work.

> http://www.fw.com/~bruceb/hello.htm	This is supposed to be a simple
> program, the page links to ../cgi-bin/hello.cgi    When I try to execute
> the script I get an error, malformed header from script. Can anyone help
> me?

I'll try.

hello.htm
-------------
<HTML>
<HEAD>
<TITLE>hello</TITLE>
</HEAD>
<BODY>
Hello
<HR>
<FORM ACTION="http://www.fw.com/scripts/hello.pl" METHOD="GET"
<INPUT NAME="key" VALUE="" MAXLENGTH="25" SIZE=25>
<INPUT TYPE=SUBMIT VALUE="Print key">
</FORM>
</BODY>
</HTML>


hello.pl
-----------
#! /usr/bin/perl

require"cgi-lib.pl";

print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print"<TITLE>Hello test</TITLE>\n";
print "</HEAD>\n";
print "<BODY>\n";
print "<H1>HELLO</H1>\n<HR><P>\n";

if (&ReadParse(*input)) {}

$key=$input{'key'};

print "<P>The key is $key \n";
print "</BODY></HTML>\n";

I hope it will help you ;-)
Josep Jover
jjover@andorra.ad

 


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

Date: Thu, 27 Mar 1997 08:31:35 GMT
From: mlaker@contax.co.uk (Markus Laker)
Subject: Re: converting files to html
Message-Id: <5hdb67$bmj$1@newsserver.dircon.co.uk>

"R. Vince" <rvince@sprynet.com> wrote:

> Is anyone aware of a pd PERL script anywhere which would convert a Word Doc
> file, or an RTF, or a Wordperfect file, into an html file? Thanks, Ralph

I have a fair amount of good news and some bad.

First, the good: Microsoft gives away on its Web site
<http://www.microsoft.com> a product called Internet Assistant, which
you can use to load a document in any of the formats you mention and
save it as an HTML file.

Next, more good news: you should be able to use OLE automation to
control Word from Perl so that it does the conversion without manual
intervention if that's necessary.

Now the bad news: it's probably easier to write a Word macro or a bit
of Visual Basic than to do the job at arm's length using OLE
automation.

[Mailed and posted.]


Markus Laker



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

Date: 27 Mar 1997 02:30:09 -0600
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
To: sean@ugcs.caltech.edu (M. Sean Bennett)
Subject: Re: Coverting Objects to packed strings.. how?
Message-Id: <ufaohc5ohym.fsf@sina.hpc.uh.edu>

>>>>> "MSB" == M Sean Bennett <sean@ugcs.caltech.edu> writes:

MSB> How do I do this - which module can I use?

Depends on what "packed string" means.  Data::Dumper will probably do what
you want.
-- 
      Jason L. Tibbitts III - tibbs@uh.edu - 713/743-8684 - 221SR1
System Manager:  University of Houston High Performance Computing Center
                1994 PC800 "Kuroneko"      DoD# 1723


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

Date: Thu, 27 Mar 1997 02:08:47 -0600
From: Timothy Shell <tshell@mcs.net>
Subject: Re: Help - Perl scripts cannot find cgi-lib.pl
Message-Id: <333A2B0E.4BFA@mcs.net>

Kevin Spicer wrote:
> 
> OK...this seems like a rather basic problem, but my Perl scripts cannot seem to find
> my cgi-lib.pl file, even though it's in the same directory as the scripts
> themselves. I wrote a simple "Hello world" script, included below:
> 
> # begin
> 
> print "Content-type: text/html\n\n";
> 
> require "cgi-lib.pl";
> 
> print "Hello world.";
> 
> # end

All my require statements use single quotes, as:
require 'cgi_lib.pl';

I don't know if this will make any difference.

> 
> Any help would be appreciated.
> 
> Kevin Spicer
> kspicer@music.transy.edu
> http://spicer-k.transy.edu

-- 
Timothy Shell : tshell@mcs.net

Freedom's Nest:  http://www.bomis.com/fn


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

Date: 26 Mar 1997 22:37:41 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: How do I ?  .. rand/srand champs read this
Message-Id: <5hd4jl$24a$1@halcyon.com>

In article <qum67ye9ysl.fsf@cyclone.stanford.edu>,
Russ Allbery  <rra@stanford.edu> wrote:
|> 	push @temp, splice @list, rand @list, 1 while @list;
|	push (@temp, splice (@list, rand ($#list + 1), 1)) while @list;

To each his own, but I find the first much easier to read. I get
lost trying to match up the parens.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Thu, 27 Mar 1997 08:27:27 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: How do I ?  .. rand/srand champs read this
Message-Id: <ebohlmanE7p0tr.CB8@netcom.com>

Brian L. Matthews (blm@halcyon.com) wrote:
: In article <qum67ye9ysl.fsf@cyclone.stanford.edu>,
: Russ Allbery  <rra@stanford.edu> wrote:
: |> 	push @temp, splice @list, rand @list, 1 while @list;
: |	push (@temp, splice (@list, rand ($#list + 1), 1)) while @list;

: To each his own, but I find the first much easier to read. I get
: lost trying to match up the parens.

I prefer something in between:

push @temp, splice (@list, rand @list, 1) while @list;

I guess my mental heuristic here is to use parens with operators that take 
more than two arguments; with one or two arguments it's easy to see which 
operator they're associated with, but with more than two I have to read 
the expression inside out.


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

Date: Wed, 26 Mar 1997 15:14:58 -0600
From: Rob Huffstedtler <rob@netcentral.net.no.spam>
Subject: Re: How do I delete a line out of a text file
Message-Id: <333991D2.7F2C39D1@netcentral.net.no.spam>

I never bothered to check anything other than the real time it takes to
execute, which we didn't run time on, so we only have a ballpark idea,
but it seemed to speed up the process of deleting a line from a several
thousand line file by a couple of seconds, which was important bc there
were are often several processes contesting for the file, so we wanted
to minimize the amount tof time necessary for the lock to clear.

I too, have no idea how ed does it's magic internally.  I've been
meaning to have a look at the source for it anyway, so I may download it
from the gnu site when I have an opportunity and see if I can figure out 
how it does it.  I will also try to find some time in the near future to
test the new version against the old version (which was doing exactly
what was suggested earlier, printing the entire file and skipping over
the line) to see if I can present some real data as substantiation
rather than my subjective interpretation of what is occuring.


Mike Campbell wrote:
> 
> Rob Huffstedtler <rob@netcentral.net.no.spam> writes:
> 
> > That's the inefficient way to do it.  If you are on a unix platform,
> > you can use perl to write an ed script and feed it to ed.  Thus you
> > can either dearch for particular text ro go to a particular line,
> > delete that line then do a qw to quit and write it to disk.
> 
> I have my doubts as to your efficiency claim.  time?  space?  CPU?
> Some combination thereof?
> 
> You may be correct, as I'm no 'ed' expert, but I'd like to know from a
> guts point of view how ed actually does this deletion.


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

Date: Thu, 27 Mar 1997 02:17:12 -0600
From: Timothy Shell <tshell@mcs.net>
Subject: Re: how to print the content of an html file?
Message-Id: <333A2D08.2714@mcs.net>

Sean Roehnelt wrote:
> 
> With a script I open a .html file, and make a substitution for each
> image. Now I want to print out the entire file like:
> 
> open(HTML_FILE, $html_file);
> 
> ##My substitutions happen here##
> 
> print <HTML_FILE>;
> 
> but it seems when I do this perl does not like all the quotes, and
> slashes in the html file...
> 
> any suggestions?
> 
> sean

Maybe this:

while ($_ = <HTML_FILE>) 
	{print "$_ \n";};

I use something similar to print out whole html files and perl doesn't
mind.

> 
> --
> ------------------------------------------------------------------------
> Sean Roehnelt mailto:roehnelt@csulb.edu http://www.uces.csulb.edu/~seanr
> ------------------------------------------------------------------------

-- 
Timothy Shell : tshell@mcs.net

Freedom's Nest:  http://www.bomis.com/fn


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

Date: Thu, 27 Mar 1997 12:18:56 GMT
From: rga@io.com (RGA@IO.COM)
Subject: HOW TO: Run Perl CGI Scripts on Local Windows95 PC
Message-Id: <3339a42e.12851071@news.io.com>

Here's a very easy way to set up a local 
Windows95 PC to run or test perl CGI scripts.

You need two things:
===============
1. Perl for Win32s installed on your machine
2. Some kind of server software w/ CGI support installed on your
machine

Go get the files:
===========
1. Perl for Win32 v5.003k_07 (build 304) 
    the current stable version, dated 3/22/97
    Get it w/ your browser at
     http://www.ActiveWare.com/
    Get it w/ your FTP at
     ftp.epix.net/pub/languages/perl/ports/win32/perl5/Release

Here are the files you want:
Install them in this order !!!
Pw32i304.exe
PlSEi304.exe
PllSi304.exe

These files are self-extracting and will install Perl5 on
your machine. Let it install under all the defaults.

2. Omnicron Technologies has a FREE 
Web Server for Windows 95.
OmniHTTPd Web Server for Windows 95
The latest release is Version 1.0b4 (Beta 4)
for Windows 95, dated 11/17/96
Get the file w/ your browser at:
http://www.fas.harvard.edu/~glau/httpd/

This version file name is <oh104b4.exe>
It is self extracting, self installing, and will
install a Web Server on your machine. 
let it install w/ all the defaults.

Note: TCP/IP must be installed on your Win95
for OmniHTTPd to work, but I assume this is 
already done else you wouldn't be downloading
the files :-)

Summary
========
You should now have both the Perl5 interpreter and 
a Web Server installed on your machine.

Load up the Web Server, right click on tray icon,
choose properties, advanced.
Then make sure CGI is enabled with the correct
pathway to <perl.exe>
Put in "C:\perl\bin\perl.exe"

Now, load up your browser, open a location,
enter "http://127.0.0.1/"
This should take you to the root directory of
the HTTPd Server, which has several HTML
files in it already for your testing pleasure.
Click on <test.shtml> and see if the SSI, CGI 
stuff works.

The <sample.html> has a link to 
offline documentation bundled with the server,
which has some good information on CGI, etc.


Things to Check, Double check, and Triple Check
=============
If you're importing perl scripts from a network 
server (online) you will likely have to change 
pathways in the script to fit the local set up.

Omni HTTPd looks for perl in 
#!/usr/local/bin/perl 
You'll need to change this if different than
your online server.

You'll need to change any <filename.cgi> extensions
to <filename.pl> to run locally.

Absolute pathways would be
"c:/HTTPd/subdirectory/filename.html"
This needs to be right if your perl script
is writing to an html file.

Relative pathways would be
"/filename.html" or
"/cgi-bin/filename.pl"

HTTP pathways would be
"http://127.0.0.1/filename.html" or
"http://127.0.0.1/subdirectory/filename.html"
Anything in the Root Directory would be
"http://127.0.0.1/filename.html"

Call your CGI scripts from
"http://127.0.0.1/cgi-bin/filename.pl"
Use this address if calling from an HTML Form Post
or use a relative pathway
"/cgi-bin/filename.pl"

If you transferred files from your online server, make
sure you did it in ASCII not Binary modes.

Note:
When I can't get something to work, that was 
already working on my online server, I invariably
have the pathways wrong.  At least there are
no permissions to worry about locally.

Happy Testing !
And Remember to change things back to fit your
online server when you're ready to put your files
back on the Real WEB :-)

Disclaimer: this is intended as an easy, affordable
way for getting Per5 and a Web Server on Win95.
There are, of course, other Web Servers than OmniHTTPd

Sincerely, RGA

=============== Home Pages
http://www.io.com/~rga
=============== The Rainbow Garden
http://www.io.com/~rga/rainbow.html
Stories, Parables, Metaphor, Poetry, Quotes.





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

Date: Wed, 26 Mar 1997 15:37:38 -0700
From: Andrew Koons <andy@wwdatalink.com>
Subject: I.P Address Patterns
Message-Id: <3339A532.3E72@wwdatalink.com>

Does anyone know if there is a pattern in a ip address that tells you in
what country the dial up server is located.  I noticed that most of
Europes I.P. address start with 193. 194. or 195..  I need to be able to
detect specific countries and that is too broad.

Andrew Koons
andy@wwdatalink.com


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

Date: 27 Mar 1997 12:20:18 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: I.P Address Patterns
Message-Id: <slrn5jkpg3.kjd.Alain.Deckers@nessie.mcc.ac.uk>

In <3339A532.3E72@wwdatalink.com>,
	Andrew Koons <andy@wwdatalink.com> wrote:
>Does anyone know if there is a pattern in a ip address that tells you in
>what country the dial up server is located.  I noticed that most of
>Europes I.P. address start with 193. 194. or 195..  I need to be able to
>detect specific countries and that is too broad.

I don't think this is possible, since RIPE assigns netblocks as and when
the need arises. They may be able to provide a list of netblocks in some
sort of useable form, but this could be an expensive way of getting at
the information you require.

Could you not use `whois` to whois -h whois.ripe.net?

[followup set]

>Andrew Koons
>andy@wwdatalink.com

Cheers,
-- 
Alain.Deckers@man.ac.uk          <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
   Perl software: <URL:http://www.perl.com/CPAN/>


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

Date: Thu, 27 Mar 1997 09:36:59 GMT
From: "Russ" <russ@hevacomp.demon.co.uk>
Subject: Newbie asks how do I format a numeric output?
Message-Id: <01bc3a92$6b4a5100$d011dec2@hevacomp.demon.co.uk>

Hi,

I'm sure the solution to this is very simple but I can't find out how to
format the result of a calculation.   I using a perl script to multiply say
7.99 by 2 and I am getting a result of  15.980000000000000426.   How can I
limit this to 2 decimal places?

Thanks

Russ Walton


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

Date: Thu, 27 Mar 1997 02:21:15 -0600
From: zohara@bashan.co.il
Subject: ODBC drivers for perl on UNIX
Message-Id: <859450409.19902@dejanews.com>

Are there any ODBC drivers for perl running on a UNIX box ?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Thu, 27 Mar 1997 11:58:24 +0200
From: webmaster@cardshow.com (Michael Guitton)
Subject: Perl script for generating a one-time password
Message-Id: <webmaster-2703971158250001@paris25-049.paris.worldnet.fr>

I just read RFC #1750 and I wonder if someone has ever wrote a Perl
password generating facility based on this RFC. I checked out CPAN but to
no avail. BTW, a C -- comprehensive? :) -- PAN dedicated search engine is
welcome.

-- 
Michael Guitton
webmaster@cardshow.com

"Learn as if you would live forever, Live as if you would die tomorrow."
-- Mahatma Gandhi


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

Date: Thu, 27 Mar 1997 00:57:48 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: q
Message-Id: <333A1A6C.1E21F410@gpu.srv.ualberta.ca>

Tom Phoenix wrote:
! 
! On 26 Mar 1997, Anthony Mulligan wrote:
! 
! > Subject: q
! 
! a
! 

        || ! 2 q?

andrew


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

Date: 27 Mar 1997 08:17:57 -0000
From: shields@crosslink.net (Michael Shields)
Subject: Re: Regular Expresion question.
Message-Id: <5hdafl$hmc$1@daedalus.crosslink.net>

In article <5h94ka$oof$2@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>     http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/ckaddr.gz ,
>     which actually checks against the full RFC spec (except for nested

I am going to have to buy Jeffrey's book just to understand that regexp.
Amazing.

Maybe regexps are not good for everything.
-- 
Shields, CrossLink.


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

Date: 27 Mar 1997 08:25:35 GMT
From: grimm@vortex.netbistro.com (Ernie Dunbar)
Subject: Same syntax, different result.
Message-Id: <5hdatv$jp8@usenet85.supernews.com>

Ok. This is starting to get on my nerves. What happens is I create two
different scripts, to do slightly different jobs, using a snippet of code
that is identical, or virtually so. (but still syntactically (sp?) 
correct) What will happen sometimes is that one script will work, and the
other will not.

Of course, it could all be in my head. I'm just starting to learn all
this. (Almost done the Llama book!) But in any case, this is the code I am
working on to filter mail, and another program to forward it to a list of
addresses. Be aware that there _are_ obscenities in the code, since it's
fitting to my mood.

This one works:

#!/usr/bin/perl
open (LETTER,"greeting.txt") || die "Oh shit. The greeting file isn't
there.";
@letter = <LETTER>;
close (LETTER);
open (THING);
@thing = <STDIN>;
close (THING);
foreach $line (@thing) {
        if ($line =~ /^from:/i) {
                ($stuff,$address) = split (/:/,$line);
                last;
        }
}
foreach $line (@thing) {
        if ($line =~ /^subject:/i) {
                if ($line =~ /subscribe/i) {
                        &newguy;
                        &add2list
                }
        }
}
### Here is the code I made originally, and stole for the second program. 
sub newguy { 
        open (MAILTO,"|mail -s Subscription $address") || die "Uhm, mail
doesn't work."
        print MAILTO @letter;
        close (MAILTO); 
}
### End of stolen code.

sub add2list {
        open (ADDRESSLIST,">>addresslist") || die "Can't read
addresslist.";
        print ADDRESSLIST $address;
        close (ADDRESSLIST);
}

This program doesn't:

#!/usr/bin/perl
open(ADDRESSLIST,"test.txt");
@addresslist = <ADDRESSLIST>;
chop (@addresslist);
foreach $thing (@addresslist) {
        $addresslist = "$thing, $addresslist";
}
close(ADDRESSLIST);
@message = <STDIN>;

### Begin Stolen Code.
#open(MAILTO,"|mail -s Test grimm@netbistro.com -b $addresses") || die
#"oops. Mail doesn't work.";
open (MAILIT,"|mail -s Test grimm@netbistro.com -b $addresses") || die
"Shit.";
print MAILIT @message;
close (MAILIT);

### End stolen code.

In the second program, what happens is mail barfs back a message that says
I didn't use it right. (Your regular USAGE: message) I tested it at the
bash$ prompt, and sure enough, it works as promised. I suspected
$addresses wasn't what it was supposed to be, so I printed it out before
the filehandle. It was what it was supposed to be. Now I think that perl
isn't interpolating $addresses in the open () statement. This doesn't make
sense however, because it most certainly is interpolating the variable in
the first program.

If it really matters, the program is being run under BSDI BSD/386 1.1,
with perl V4.0, Revision 1.2.

----------------------------- IXTJ at large ------------------------------
         De Iesus domine           | grimm@netbistro.com - BOFH in 
       Dom a Hades requiem         | training and voted by my co-workers 
                                   | "Most Likely to Go Postal"
-If you send me spam, I will decimate your account. Resistence is futile.-



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

Date: 27 Mar 1997 08:58:59 GMT
From: grimm@vortex.netbistro.com (Ernie Dunbar)
Subject: Re: Same syntax, different result.
Message-Id: <5hdcsj$k19@usenet85.supernews.com>

Ernie Dunbar (grimm@vortex.netbistro.com) wrote:

[stuff about a real simple problem. Did you spot it?]

And the stupid newbie of the week award goes to: 

Me!

Guy Decoux was nice enough to point it out to me, and MAN do I feel
stupid. You can stop sending me flame mail now. ;)

----------------------------- IXTJ at large ------------------------------
         De Iesus domine           | grimm@netbistro.com - BOFH in 
       Dom a Hades requiem         | training and voted by my co-workers 
                                   | "Most Likely to Go Postal"
-If you send me spam, I will decimate your account. Resistence is futile.-



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

Date: Thu, 27 Mar 1997 09:02:38 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Same syntax, different result.
Message-Id: <ebohlmanE7p2GE.FsM@netcom.com>

Ernie Dunbar (grimm@vortex.netbistro.com) wrote:

: This program doesn't:

: #!/usr/bin/perl

If you had put "-w" on the end of that line, you'd have found out long 
ago what your problem was.

: open(ADDRESSLIST,"test.txt");

One variable assigned: the filehandle ADDRESSLIST

: @addresslist = <ADDRESSLIST>;

Another variable assigned: the array @addresslist

: chop (@addresslist);
: foreach $thing (@addresslist) {

Now $thing gets assigned, but it's local to the loop.

:         $addresslist = "$thing, $addresslist";
: }
: close(ADDRESSLIST);
: @message = <STDIN>;

@message just got assigned

: ### Begin Stolen Code.
: #open(MAILTO,"|mail -s Test grimm@netbistro.com -b $addresses") || die
: #"oops. Mail doesn't work.";
: open (MAILIT,"|mail -s Test grimm@netbistro.com -b $addresses") || die
: "Shit.";

Let's see.  We've previously assigned ADDRESSLIST, @addresslist and
@message and we just assigned MAILTO.  Funny how that list of variables
doesn't include $addresses, wouldn't you say? 

: print MAILIT @message;
: close (MAILIT);

: ### End stolen code.

: In the second program, what happens is mail barfs back a message that says
: I didn't use it right. (Your regular USAGE: message) I tested it at the
: bash$ prompt, and sure enough, it works as promised. I suspected
: $addresses wasn't what it was supposed to be, so I printed it out before
: the filehandle. It was what it was supposed to be. Now I think that perl

Are you sure you didn't try to print out $addresslist instead?

: isn't interpolating $addresses in the open () statement. This doesn't make
: sense however, because it most certainly is interpolating the variable in
: the first program.

There's a well known phenomenon in perceptual psychology called "set."  
Basically it means that if you're expecting to see something, you'll see 
it even if it isn't there.  You were probably staring at "$addresses" and 
reading "$addresslist" all along.  That's why perl has a -w switch.

: If it really matters, the program is being run under BSDI BSD/386 1.1,
: with perl V4.0, Revision 1.2.

Have you thought about calling the admissions office at the Old 
Interpreters' Home to see if they can take a new resident?



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

Date: Thu, 27 Mar 1997 12:29:16 +0000
From: alastair brown <alastair@redboxad.demon.co.uk>
Subject: Sending Environment variables to a PERL script using JavaScript
Message-Id: <333A681C.4F22@redboxad.demon.co.uk>

Hi All

I'm am just learning programming using PERL. The script I want to write
needs to pass client environment variables to my perl script. can this
be done using javaScript the following way?

window.location = "http://www.mydomain.com/cgi-bin/links.pl?day=" +
now.getDay() + "&hour=" + now.getHours());

Thanks in advance for any help

Alastair Brown


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

Date: Thu, 27 Mar 1997 00:48:16 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: text to HTML
Message-Id: <333A1830.61B140E3@gpu.srv.ualberta.ca>

Laurence Molloy wrote:
!
! Lewis Taylor wrote:
! >
! > I am currently writing a primative text to HTML routine. I want to
! > replace all instances of double carriage return (\n\n) with a paragraph
! > tag. But this :
! >
! > $big_string =~ s/\n\n/<P>/g;
! >
! > does'nt seem to do anything. I have also tried the two \n's in a
! > variable to no avail. Other printable chars in place of \n\n work. Can
! > someone please help?
! >
! 
! Perl has a special variable $* which you can set to 1 if you wish to
! <quote>do multiline matching within a string</unquote>. However, I can
! never get it to match more than 1 "\n". Can someone explain to me
! exactly what "$*=1" can and cannot do?
! 

setting $* affects the interpretation of ^ and $, though it
is deprecated and now one should use the /m modifier (maybe /s too)...


! Alternatively, how about s/^$/<P>/g?
! 
! The ^ equates to line start
! and $ equates to line end
! 
! thus, ^$ implies an empty line (same as \n\n).
! 
! I've tested the above substitution command and it seems to do the job
! you require.
! 

however, one can always explicitly match newlines...to match
two in a row you would need to suck in more than one line at
a time from the file by setting $/ to something appropriate:

$/="";  #set record separator to 'paragraph-mode'
$file="file.txt";
open(FILE,$file)||die "can't open $file: $!";
while (<FILE>) {
   s/\n\n/\n<P>\n/;
   print;
}

assumes you want the <P> tag on the line by itself between
paragraphs.

regards
andrew


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

Date: Wed, 26 Mar 1997 23:42:21 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Unix 'Cat' equivelent
Message-Id: <E7oCIL.20w@bcstec.ca.boeing.com>

In article <Pine.GSO.3.96.970325164753.27841H-100000@kelly.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>On 25 Mar 1997, Mike Campbell wrote:
>
>> bill@sover.net.no.junkmail (Bill) writes:
  >> 
  >> >    Here's a quick and easy cat clone:
  >> > 
  >>  perl -e 'print while (<>);'
  >
>perl -pe0
>

and for the sake of completeness :) 

  perl -pet 
  perl -petcat 

--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: Thu, 27 Mar 1997 08:03:09 GMT
From: Stephane Plattner <NOSPAMplas@fmi.ch>
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <333A29BD.7DAD@fmi.ch>

> It is openness that allows differences to exist. Look at the history of
> PC hardware. The original IBM PC was open. 

What do you mean by that? The IBM PC was open? Was it possible to
install any kind of hardware and software? Motorola processors, Amiga
Operating system, etc? Probably not, the IBM PC was a closed solution,
which became a de-facto standard. IEEE gave it the rest, so now every
idiot is able to produce pieces and parts for the IBM/Intel machine.

> Competition in today's
> hardware market for the descendants of the PC is fierce, and the state
> of the art is always moving. 

Sure, but not because the PC is open, but because it has become a
de-facto standard. Except the CD-ROM there was not a real innovation on
the PC market in the last two three/years. Sure, processors got faster,
memory modules became smaller but more powerfull, screens became bigger,
etc., and surprisingly you still have to pay 4000-5000 bucks for a
"good" PC nowadays, as you had to pay two/three years ago.

> By contrast, the PS/2 was closed, and it is now dead. 

The PS/2 is not dead, because it was closed, but because of the bad
maketing of IBM (same as OS/2). If Bill Gates would have taken care of
the PS/2, then believe me most people would use microchannel
architecture PC's. 

> In software, compare Unix to DOS/Windows. DOS was closed for
> the most part (in the sense that much of its internals were undocumented
> or otherwise hidden, and that source was not available), and only
> advanced when it had competition from the likes of DR-DOS. 

Or the hardware develeopment required it (necessity and possibility to
access memory above the magic 640kb border, when 386 processors came up.

> Unix, on the
> other hand, was and is much more open (not entirely, of course, but
> today with FreeBSD, Linux, and the like it is very open).

And which owns the bigger market share? DOS/Windows you find EVERYWHERE,
for UNIX you need to go into an academic environment or some highly
IT-specialized companies doing highly IT specialized stuff.
-- 
Best
Stephane Plattner
DMS - Digitale Medien Systeme AG / Digital Media Systems Inc.
CEO Broadcast Communication Technologies

For reply remove NOSPAM!


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

Date: Thu, 27 Mar 1997 11:07:58 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Unpacking .gz file
Message-Id: <333A46FE.41C6@theo.phy.uni-bayreuth.de>

Hi,

sundance@pacbell.net wrote:
> 
> Does anybody here know how to unpack a .gz file under UNIX?

I hope so ...  ;-)

Try "gunzip file.gz"


Note: This newsgroup is about the programming language Perl, not
      about UNIX - maybe you should choose a more appropriate place
      to post articles regarding UNIX (e.g. 'comp.unix.questions')


Bye, Eike

=====================================================================
 Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
            e-mail : eike.grote@theo.phy.uni-bayreuth.de
           URL : http://www.phy.uni-bayreuth.de/~btpa25/ 
=====================================================================


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

Date: Thu, 27 Mar 1997 00:02:00 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Laurence Molloy <lauriem@cstr.ed.ac.uk>
Subject: what "multi-line matching" means (was Re: text to HTML)
Message-Id: <333A2978.574C@egames.com>

Laurence Molloy wrote:
> Perl has a special variable $* which you can set to 1 if you wish to
> <quote>do multiline matching within a string</unquote>. However, I can
> never get it to match more than 1 "\n". Can someone explain to me
> exactly what "$*=1" can and cannot do?

It's somewhat of a misnomer, actually.
It should probably be called something like
"embedded newline sensitivity mode"

First of all, $*'s use is deprecated and it's functionality 
is supported with the /s & /m suffixes (though lacking
/s /m RE modifiers, $*'s value will be honored)

$*, /s, /m will in no way effect how /\n\n/ is
matched.  They only effect how the RE metacharacters
'.', '^', and '$' are interpreted.

Here's a little table:
             /./        /^/         /$/
normal,
$*=0         [^\n]      beg-string  end-string
$*=1         [^\n]      beg-line    end-line
/s           [\0-\xFF]  beg-string  end-string
/m           [^\n]      beg-line    end-line
/sm          [\0-\xFF]  beg-line    end-line

beg-string means matches only before first char in string
beg-line means matches at beg-string or after any \n
end-string means matches only after last char in string or
    before the last char in string if that last char is \n
end-line means match at end-string or before any \n

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"It's better to be lucky than good."  -- Elizabeth Bourne



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

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 189
*************************************

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