[7303] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 928 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 26 21:17:21 1997

Date: Tue, 26 Aug 97 18:00:35 -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           Tue, 26 Aug 1997     Volume: 8 Number: 928

Today's topics:
     'abandon' hope (was: Re: Need help: how to exit a sub) <rootbeer@teleport.com>
     Re: 'abandon' hope (was: Re: Need help: how to exit a s (Daniel E. Macks)
     Re: <> operator memory leak? (Ilya Zakharevich)
     A Complex Regex Needed <mentat@mail.patterndom.com>
     Re: cardinality of an array given a reference <rootbeer@teleport.com>
     CAT in PERL <nick@wireedm.com>
     Re: CAT in PERL (Jot Powers)
     command line parameter -e yields different results? (John Erickson)
     Re: command line parameter -e yields different results? <rootbeer@teleport.com>
     Fork problem kchadha@hotmail.com
     guestbook: new entry at top && fast (Siegfried Reker)
     Re: Help on 'system' function (Charles DeRykus)
     Re: Help on Final Exam (Perl class) (Jeff Stampes)
     HELP!! Installing Perl 5.003 on DGUX <leighc@mincom.com>
     Re: HTTP Requests with PERL (Jeff Stampes)
     importing comma deliniated - I'm stuck! (Shane)
     Re: Is this a permissions problem (Eric Bohlman)
     Re: Perl for Win32 - Capturing output from backticks <rootbeer@teleport.com>
     Reading a text file from an URL (Bob Maillet)
     regex to check for valid mail adress (RFC822) (Siegfried Reker)
     Re: regex to check for valid mail adress (RFC822) (Jot Powers)
     Re: regex to check for valid mail adress (RFC822) (Daniel E. Macks)
     Re: Scrambling using tr (Josh Purinton)
     Re: Scrambling using tr (brian d foy)
     Re: spell checking (Terry Michael Fletcher - PCD ~)
     Textarea reading <nick@wireedm.com>
     Re: Textarea reading (Jot Powers)
     Re: What is ~// ? was(Re: Perl Regular Expression has a (Eric Bohlman)
     Why doesn't PERL5/EG/excel1.pl work?? <loren_j_brown@ccm.jf.intel.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 26 Aug 1997 15:43:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Benjamin Sugars <bsugars@sunpub.com>
Subject: 'abandon' hope (was: Re: Need help: how to exit a sub)
Message-Id: <Pine.GSO.3.96.970826153914.13463u-100000@julie.teleport.com>

On Tue, 26 Aug 1997, Benjamin Sugars wrote:

> I often find myself writing constructs like
> 
> open(FILE, $file) or do {
>     warn "couldn't open $file: $!\n";
>     return;
> };
> 
> It would save some typing - and also provide some syntactic closure -
> if I could write something like
> 
> open(FILE, $file) or 
>     abandon "couldn't open $file: $!\n";
> 
> What do you think?

If you can convince Larry it's a good idea, it'll probably happen. If not,
it never will. :-)

Seriously, the ability to make the sub abandon which would exit out of the
caller's subroutine might be more useful, since it's more generalized than
a new abandon built-in. Hmmm....

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 1997 00:54:44 GMT
From: dmacks@sas.upenn.edu (Daniel E. Macks)
Subject: Re: 'abandon' hope (was: Re: Need help: how to exit a sub)
Message-Id: <5tvtsk$g8p$1@netnews.upenn.edu>

Tom Phoenix (rootbeer@teleport.com) said:
: On Tue, 26 Aug 1997, Benjamin Sugars wrote:
: 
: > I often find myself writing constructs like
: > 
: > open(FILE, $file) or do {
: >     warn "couldn't open $file: $!\n";
: >     return;
: > };
: > 
: > It would save some typing - and also provide some syntactic closure -
: > if I could write something like
: > 
: > open(FILE, $file) or 
: >     abandon "couldn't open $file: $!\n";
: 
: Seriously, the ability to make the sub abandon which would exit out of the
: caller's subroutine might be more useful, since it's more generalized than
: a new abandon built-in. Hmmm....

<dreams of 6502 PLA/PLA/RTS games>Some way to pop off the top of the
caller stack</dreams> Interesting possibilities, and entirely new and
exiciting ways to shoot shoot oneself in the foot:)

OTOH, another approach to the original problem might be to extend
magical-goto such that it passes its own argument list like all
(most?) other &calls do. Then Benjamin would just:

  open(FILE, $file) or 
      goto &damn("couldn't open $file: $!\n");

This almost seems sorta sensiblish.

On half-the-same-topic, sometimes it'd be really nice to know the
*actual* caller of a subroutine (not hidden by magical-goto)...then a
subroutine could know if it was called directly or AUTOLOADed and
&damn in the above example could know what routine was screwy. Maybe
caller(-1) or somesuch?

dan, spouting off again

-- 
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks



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

Date: 26 Aug 1997 22:47:13 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: <> operator memory leak?
Message-Id: <5tvmdh$da5@agate.berkeley.edu>

In article <5tv74i$7g9@alvis.diku.dk>, Gargle Zndflxtzyh <joshu@diku.dk> wrote:
> that aren't deleted properly and so forth I've found 
> that this short code snippet can use up all my RAM
> in quite a short while
> (and Im working on an SGI IRIX machine with 128 megs of RAM):
> 
> =====================================
> #!/usr/bin/perl
> 
> $ROOT = "/usr/local/data/";
> 
> for (;;) {
>   opendir DIR,$ROOT;
>   for (readdir DIR) {

	Now $_ is an *alias* for the variable returned by readdir().

>     open (FIL,$ROOT.$_);
>     while (<FIL>) {

	Now $_ (i.e., the variable returned by readdir) is assigned
	the contents of the FIL (or at least the size of the IO buffer).

>     }
>     close FIL;
>   }
>   closedir DIR;
> }

Now all 20000 variables returned by readdir are reassigned the
longest-line-or-IO-buffer-whatever-is-longer for the corresponding
file. 

Try 
	for $file (readdir DIR)

Btw, does removing 
	for (;;;)
fixes situation?  If it does, then something is *strongly* broken.
Currently it is only *slightly* broken.

Ilya


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

Date: Tue, 26 Aug 1997 18:18:48 +0100
From: Christopher Stetson <mentat@mail.patterndom.com>
Subject: A Complex Regex Needed
Message-Id: <34030FDC.AB559968@mail.patterndom.com>

Hi All,

I am trying to write a match-oriented regex that is taking a tab
delimited set of fields as the target operand and trying to match it
with a regex that is looking at various fields for a matchs.

E.G.:

Fields   | Movie Name    Actor Name    Director Name     Category
Record 1 | Big        \t Tom Hanks  \t Penny Marshall \t Comedy

The regex needs to look for "Big" and "Penny" in the exact fields and no
others and the regex should do it in one fell swoop (no splitting).

Chris



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

Date: Tue, 26 Aug 1997 14:57:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: cardinality of an array given a reference
Message-Id: <Pine.GSO.3.96.970826145456.13463o-100000@julie.teleport.com>

On 26 Aug 1997, Tom Grydeland wrote:

> > > perl -le '$a=[1..100];print $#{@$a}'

[ To those reading along at home: Notice that @$a seems to be
automatically dereferenced here. Odd, isn't it? ]

> It's most probably an undocumentet feature. (I haven't gone through
> perlref with a fine-toothed comb yet.)  If you want my opinion, it's
> also a misfeature. 

Really? I don't know yet whether I like it or not. What do you have
against it? :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 26 Aug 1997 06:31:25 -0700
From: John Grimm <nick@wireedm.com>
Subject: CAT in PERL
Message-Id: <3402DAAD.3A76@wireedm.com>

How could I translate the following sentence:
cat $1 | tee /dev/port102
except /dev/port102 will be SEND in the program.  Or how could I just
send the contents of a file using print?


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

Date: 27 Aug 1997 00:27:59 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: CAT in PERL
Message-Id: <5tvsaf$4nq$1@gazette.corp.medtronic.com>

In article <3402DAAD.3A76@wireedm.com>, John Grimm wrote:
>How could I translate the following sentence:
>cat $1 | tee /dev/port102
>except /dev/port102 will be SEND in the program.  Or how could I just
>send the contents of a file using print?

What do you want it translated into, English?

What are you sending too?

If you want to open a file and then just print it to a port, why not
something (untested) like:

#!/usr/local/bin/perl -w

open(FILE,$ARGV[0]) or die "$!\n";
open(SEND,"| /dev/port102") or die "$!\n";

while(defined(<FILE>)) {
	print SEND "$";
}

close(FILE) or die "$!\n";
close(SEND) or die "$!\n";

Of course, my question is, why?  What are you really trying to do?

-Jot
-- 
Jot Powers  news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."


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

Date: Tue, 26 Aug 1997 21:47:56 GMT
From: jderick@mail.utexas.edu (John Erickson)
Subject: command line parameter -e yields different results?
Message-Id: <34034a4f.65239279@news.cc.utexas.edu>

Using Perl 5.003_07 under WindowsNT

Perl for Win32 Build 306 - Built 17:50:28 Apr 10 1997

I've been experiencing a little wierdness lately.

I was trying to write a simple script that would replace tags like
this:

<IMG SRC="Contacts.jpg" BORDER="0">

to ones like this:

<IMG SRC="./images/Contacts.jpg" BORDER="0">

I tried using the command line: 

perl -w -i.bak -p -e "s!SRC=\"([^\"]+)\"!SRC=\"\./images/$1\"!g;"
myfile.htm

and the result is no change in the myfile.htm file.

When I move the switch to a file

rel.pl
--
s!SRC=\"([^\"]+)\"!SRC=\"\./images/$1\"!g;
--
and then run the script using:

perl -w -i.bak -p rel.pl myfile.htm

it successfully fixes all the tags.

Is there any reason why the first method didn't work?  It seems to me
that it should be identical.


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

Date: Tue, 26 Aug 1997 15:48:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Erickson <jderick@mail.utexas.edu>
Subject: Re: command line parameter -e yields different results?
Message-Id: <Pine.GSO.3.96.970826154512.13463v-100000@julie.teleport.com>

On Tue, 26 Aug 1997, John Erickson wrote something like:

> I tried using the command line: 
> 
> perl -w -i.bak -p -e "s!SRC=\"([^\"]+)\"!SRC=\"\./images/$1\"!g;"
> myfile.htm
> 
> and the result is no change in the myfile.htm file.
> 
> When I move the switch to a file and then run the script using: 
> 
> perl -w -i.bak -p rel.pl myfile.htm
> 
> it successfully fixes all the tags.
> 
> Is there any reason why the first method didn't work?  It seems to me
> that it should be identical.

Probably your COMMAND.COM is doing something interesting with those quote
marks and backslashes, or maybe with some other character. Try this
command and see what you get. 

    perl -we "print map qq#[$_]\n#, @ARGV" "s!SRC=\"([^\"]+)\"!SRC=\"\./images/$1\"!g;"

(I don't have a windows machine handy to try it out.) That may tell you
where COMMAND.COM is garbling things. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 26 Aug 1997 18:23:04 -0600
From: kchadha@hotmail.com
Subject: Fork problem
Message-Id: <872637575.1259@dejanews.com>

HI,

I have the following program:

&execute_sub;
print "abc\n";

sub execute_sub
{
	if $pid=fork
	{	while(1){
		sleep(4);
		if (waitpid($pid,0100))
		{
			print "completed";
			last;
		}
		print "wait";
		}
	}
	else
		{   #child does some work here }
}




Now the problem is that while executing the subroutine, the
program prints out "abc" and then prints it out again
after the message "process completed" has been issued.

Any ideas on how to solve this will be greatly appreciated !

Please e-mail replies to kchadha@hotmail.com


Thanks!
K. Chadha


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


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

Date: Tue, 26 Aug 1997 19:20:12 GMT
From: s.reker@cray.ping.de (Siegfried Reker)
Subject: guestbook: new entry at top && fast
Message-Id: <3403236a.48079926@news.ping.de>

Hi
I'm just creating a guestbook using cgi/perl. I want new entries to
appear at the top of the guestbook. Thus opening the file in append
mode does not work. So by now, I create a temporary file, write the
new entry into it, append the old guestbook entries and finally move/
rename the temporary file to replace the old guestbook. As the
guestbook grows this gets increasingly time consuming. Is there a
better way?

Siggi


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

Date: Tue, 26 Aug 1997 19:34:06 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help on 'system' function
Message-Id: <EFJD0v.MLB@bcstec.ca.boeing.com>

In article <01bcad80$7d84b700$6502a713@fce04438.jubilee.ford.com>,
John Spencer <dhayden@ford.com> wrote:
 > I would be grateful if anyone could help this problem:-
 > 
 > First Program  first.pl
 > .....
 > system("second.pl",$amount);
 > print "Amount Now =$amount";
 > ......
 > 
 > 
 > 
 > Second Program  second.pl
 > ......
 > $input=<STDIN>;
 > $amount = $amount + $input
 > ......
 > 
 > 
 > 
 > The first program "first.pl" should jump to the second program "second.pl"
 > with $amount as an arguement. It should then take an input amount and add
 > to $amount and pass back to "first.pl" upon completion of "second.pl"
 > 
 > How to I pass back the new value of $amount????
 > 
 > Or is there a better way of doing this?????
 > 
 > 

Backticks are useful. Here's a possibility which is
short (often a relief if not a virtue :) 


First program:  

 print "Amount Now = ", `/path/to/second.pl $amount`, "\n";

Second program:  

 print <STDIN> + shift;



HTH,
--
Charles DeRykus
ced@carios2.ca.knock_this_off.boeing.com


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

Date: 26 Aug 1997 23:24:39 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Help on Final Exam (Perl class)
Message-Id: <5tvojn$qaa$1@neocad.com>

Andrew Williams (andrew@spyder.manor.org) wrote:
: the one realy interesting and later usefull project I had to write in the
: perl class I took was a mail filter.  We had to put stuff in to filter based
: on a rules file (one that was parsed rather than written in perl), it had
: to deal with mail as it came in (as opposed to running through the existing
: inbox).  We had to put in forwarding to multiple e-mail addresses, forwarding
: to multiple mail folders in both standard mail format and mh.  doing the 
: project to the stated description got you a solid c for the program.  In order
: to get an A you had to add neat and usefull/clever features to it.  It was
: really a fun project.  

And a project that I took on myself to help myself learn
perl as well.  Would having added my html-stripping features
helped me on the way to a B? 

Jeff


--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 26 Aug 1997 23:38:26 GMT
From: "Leigh Carpenter" <leighc@mincom.com>
Subject: HELP!! Installing Perl 5.003 on DGUX
Message-Id: <01bcb279$0a3a2160$68b537c0@herne.mincom_oz>

I am in desperate need of help. I am trying to build perl 5.003 on a DGUX
AViion. It is running DGUX 5.3R3.10 with Oracle 7.2.3. I cannot get the
perl built. If I try building it I get the following erros on the make.
This is with dynamic and static linking. 

        Making DB_File (dynamic)                                           
    
        gcc -c  -Dflock=dg_flock -I. -I/usr/local/include -D_NO_PROTO -O2
-g    
 -DVERSION=\"1.01\"  -DXS_VERSION=\"1.01\" -fpic -I../..  DB_File.c        
    
In file included from DB_File.c:34:                                        
    
/usr/local/include/db.h:120: warning: no semicolon at end of struct or
union    
/usr/local/include/db.h:120: parse error before `__P'                      
    
/usr/local/include/db.h:121: parse error before `__P'                      
    
/usr/local/include/db.h:122: parse error before `__P'                      
    
/usr/local/include/db.h:123: parse error before `__P'                      
    
/usr/local/include/db.h:124: parse error before `__P'                      
    
/usr/local/include/db.h:125: parse error before `__P'                      
    
/usr/local/include/db.h:127: parse error before `__P'                      
    
/usr/local/include/db.h:128: warning: data definition has no type or
storage cla
ss                                                                         
    

This is the /usr/include/db.h file it is complaining about. Any advice
would be greatly appreciated. 


-- 
| | | | | |   Leigh Carpenter             | mailto:leighc@mincom.com
| | | | | |   Senior Technical Consultant | http://www.mincom.com
| | | | | |   Mincom Pty Ltd              | ph: 07-3303-3286
|M|I|N|C|O|M  Teneriffe, QLD, Aust        | 

'A common mistake that people made when trying to design something
completely foolproof was to underestimate the ingenuity of complete fools.'
 -Douglas Adams




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

Date: 26 Aug 1997 23:26:47 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: HTTP Requests with PERL
Message-Id: <5tvonn$qaa$2@neocad.com>

Thomas Whang (thomas@netpart.com) wrote:
: I have a peculiar problem when doing HTTP requests with Perl.

But I don't see a bit of perl code in your message, only HTML
tags.  Are you sure you have a perl problem?  If so, a clearer
description of the problem and the code you experience it in 
would help.

Jeff

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Tue, 26 Aug 1997 22:39:57 GMT
From: zatezalo.2@osu.edu (Shane)
Subject: importing comma deliniated - I'm stuck!
Message-Id: <340354bf.89151093@nntp.service.ohio-state.edu>

Ok, I'm stuck! I tried the code in the FAQ. I tried old code from old posts.
No luck.

I'm trying to read-in data from a comma deliniated file. Its from a huge
Access 7.0 database. I'm trying to import the data into a new
SQL database.

The file's format is as follows:

"Last","First","MI","HISusrNAME","DeptEmailAddress","Fax","Location",
"Pager","Phone","Position","B-day","HISEmailAddress","ID#"

A snippet of the file looks like this:

"Miller","John","E",mill02,"mill","688-6666",,"770-7777","293-33332","Human
Resources",6/23/71 0:00:00,"mill@bob.com","222-333-4444"
"Zatezalo","Shane","M",zate01,"Zatezalo@fam10.med","293-4444","ALL","626-4444","
293-4444","LAN-Computers",3/01/40 0:00:00,"zate@bob.com","222-333-4445"

The problem is that any variable that does NOT have quotes around it screws
the program up. And in the real database, there are quite a few of these.
There are also entries that will be blank (notices the 6666",, from the first
entry in the text file).

The code is below. I seperated the two methods I found from the faq/previous
posts into subs, to mess with both, yet be convenient while in emacs.

Any help appreciated....


#!/usr/local/bin/perl
# convert.pl
# a program to take the data list generated by MS ACCESS 6.0
# and dump into the SQL database

use Mysql;
use CGI qw(:standard);

#define needed variables
$datadir="/home/shane/sqlstuff";

# ==============================
# main program

#initsqlstuff();

open(F1,"$datadir/userdata.txt") or die "Can't open datafile";
method1();   # substitute here to try the other ones
close(F1);
exit;

sub method2 { # try the other method from the FAQ
    @new=();
    $i=0;
    while (<F1>) {
        push(@new, $+) while $text =~ m{
# groups the phrase inside the quotes
            "([^\"\\]*(?:\\.[^\"\\]*)*)",?  
                | ([^,]+),?
                    | ,
                }gx;
        push(@new, undef) if substr($text,-1,1) eq ',';
        $i++;
        foreach $n (@new) {
            print "i=$i N= $n $new[$i]\n";     
        }
        @new=();
    }
}


sub method1 { # try the first method from the old post
    while (<F1>) {
        $l=$_;
        chop $l;
        ++$id;
        $index=0;
        foreach $case (split(/(\,)/, $l))
        {
            # Remember, ()'s cause split to return all matches.

            $myfields[$id][$index] .= $case;
            $myfields[$id][$index] =~ s/^\,//;
            $index++ if ($case =~ /\"\s*$/);

        }
# pick some of the fields to see what we get
        $lname =$myfields[$id][0];
        $fname =$myfields[$id][1];
        $mi       =$myfields[$id][2];
        $his      =$myfields[$id][3];
        $bday   =$myfields[$id][11];
        $idnum =$myfields[$id][13];

        print "(#$id $index) LNAME: $lname, $fname, $mi HIS:$his ";
        print "BDAY: $bday\n";
        }
}

sub method3 { # demonstrate that we can open & read the file a-ok 
    print "USING METHOD3\n";
    while (<F1>) {
        print "Line: $_";
    }
    close(F1);
}

sub initsqlstuff {
    $host         = "localhost";    # hostname of database hostee
    $database = "database";   # database name to use (const for now)
    $table        = "users";         # table to use to lookup information
    $user         = "shane";
    $password = "password";
    $dbh = Mysql->Connect($host, $database, $password, $user);
    $dbh->SelectDB($database);  
}



--
zatezalo.2@osu.edu
http://www.ecaetc.ohio-state.edu/shane


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

Date: Tue, 26 Aug 1997 22:27:24 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Is this a permissions problem
Message-Id: <ebohlmanEFJL1p.I65@netcom.com>

Mark Worsdall (jaydee@worsdall.demon.co.uk) wrote:

: But it is not working when on the server, no errors a reported when ran
: but when run with the -w I get:-

: Read on closed filehandle <HTML> at ./jd.pl line 138.

: Which I guess means that it failed to open the file, but did it fail to
: open as it did not have access to open it?

No, that's not why.  Read on.  But first, remember that Perl is capable 
of telling you whether your script failed to open a file.  You don't have 
to guess at it.  In fact, Perl is so powerful that it can even tell you 
*why* your script couldn't open the file!  All you have to do is ask.

: # With the variable $visitorshome set to either of these:-
: # $visitorshome = 'file:C:\\Homepage\\WorsdallWEB\\startup.html';
: # $visitorshome = 'http://www.worsdall.demon.co.uk/goto-ssi.html';

Hmm, these look like URLs...

: # Open The Mail Program
: open(MAIL,"|$mailprog -t");

This isn't your problem, but this should be:

open(MAIL,"|$mailprog -t) or die "Couldn't open $mailprog: $!";

That way Perl will tell you if it couldn't start the mail program and, if 
so, why (yes, I know that when a pipe is involved, this is oversimplified 
and there are still uncaught possibilities for failure).

: # have put mail header stuff To:, From: and Subject: in here

: print MAIL "Today: $date\n\n";
: print MAIL "-" x 75 . "\n\n";

: # Put givem html file in here
: # by reading the file into a buf and out to the MAIL file handle
: # 
: open (HTML, "<$visitorshome");

I noted above that the thingies ("thingy" is a technical term in Perl
programming) that you were storing in $visitorshome looked like URLs.  Now
it looks like you're passing a URL as the filename argument to open(). 
open(), however, only knows about filenames.  It knows nothing about URLs. 
Therefore, open() fails, but you don't bother to check whether it
succeeded.  If you had written

open (HTML, "<$visitorshome") or die "Couldn't open $visitorshome: $!";

Perl would have told you what was happening, and you wouldn't have had to 
post a guess about what was happening and wait for people to figure it out.

: while (<HTML>) {

Assuming you fixed the above problems, this would read one line of the 
file each time around the loop and store it in $_.

:       $size = -s HTML;

This gets the size of the file, which doesn't change no matter how much 
you read from it, so why are you doing this inside the loop?

:       $size = 1024 if ($size < 512);

If the file is less than 512 bytes long, you're going to insist on 
reading more than that?

:       $buf = '';
:       while(defined($r = read(HTML,$buf,$size)) && $r > 0) {

This will slurp up whatever's left in the file after reading the first 
line.  The loop will only execute once.

:             if (syswrite (MAIL,$buf,$r) != $r) {
:                          close HTML;

This is the *only* place you close HTML.

:             }
:       }
: }

Since you read all of the data in your call to read(), your while() loop 
will execute only once.  Note that you've never done anything with the 
first line of the file; it certainly hasn't been written to the mail program.

: print MAIL "-" x 75 . "\n\n";
: close (MAIL);

I mentioned above that there were uncaught possibilities for failure when 
opening a pipe.  There are some error conditions that can be detected 
only when the pipe is closed.  If this is indeed the end of your script, 
there's little you can do at this point other than output a diagnostic, 
but it will still provide you some useful information.  How about 
checking whether the close() was successful?  By now you should know how 
to do it.

If you really need to be able to read in an HTML file that exists on some 
other server, go over to CPAN and get LWP.


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

Date: Tue, 26 Aug 1997 14:50:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Dumas <cdumas@ibm.net>
Subject: Re: Perl for Win32 - Capturing output from backticks
Message-Id: <Pine.GSO.3.96.970826145008.13463m-100000@julie.teleport.com>

On Tue, 26 Aug 1997, Chris Dumas wrote:

> $dir_out = 'dir';
> 
> This however fails.  Does anyone know why?????

Because you're not using backticks? :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 26 Aug 1997 20:53:23 -0500
From: bob@cafemedia.com (Bob Maillet)
Subject: Reading a text file from an URL
Message-Id: <bob-2608972053230001@apt2.tiac.net>

Has anyone been able to read the text from an external source (URL) and
write it to a buffer within perl?  

Any help or direction would be appreciated.

Bob

-- 
To get random signatures put text files into a folder called 3Random Signatures2 into your Preferences folder.


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

Date: Tue, 26 Aug 1997 19:20:10 GMT
From: s.reker@cray.ping.de (Siegfried Reker)
Subject: regex to check for valid mail adress (RFC822)
Message-Id: <3403217e.47587377@news.ping.de>

Hi
I need a regular expression to verify if a given mail adress is a
valid internet mail adress (RFC 822). Any ideas?

Siggi


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

Date: 26 Aug 1997 23:27:46 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: regex to check for valid mail adress (RFC822)
Message-Id: <5tvopi$3dc$1@gazette.corp.medtronic.com>

In article <3403217e.47587377@news.ping.de>, Siegfried Reker wrote:
>Hi
>I need a regular expression to verify if a given mail adress is a
>valid internet mail adress (RFC 822). Any ideas?

You have a number of options:

1) Check the FAQ
   a) http://www.perl.com
   b) perldoc perlfaq

2) http://www.dejanews.com to see if the question has been asked before

3) http://www.ora.com  to order Mastering Regular Expressions, which
   has the RE in it.  (Although I believe I've seen one correction that
   allows for infinte nesting of ()'s  )

-Jot

-- 
Jot Powers  news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."


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

Date: 26 Aug 1997 23:34:47 GMT
From: dmacks@sas.upenn.edu (Daniel E. Macks)
Subject: Re: regex to check for valid mail adress (RFC822)
Message-Id: <5tvp6n$76u$1@netnews.upenn.edu>

Siegfried Reker (s.reker@cray.ping.de) said:
: I need a regular expression to verify if a given mail adress is a
: valid internet mail adress (RFC 822). Any ideas?

Check DejaNews for the many previous discussions in this newsgroup.
Hint: you're likely SOL.

dan
-- 
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks



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

Date: 26 Aug 1997 15:02:20 -0700
From: joshp@silmaril.com (Josh Purinton)
Subject: Re: Scrambling using tr
Message-Id: <5tvjpc$8uf$1@shell3.ba.best.com>

[ posted and mailed ]

The one and only Justin Masters - remove "Y" to reply
<jmastYers@pcocd2.intel.com> writes:

> What's an easy method of "scrambling" a message to get past the
> casual searchers of the text which they may see displayed going by
> on the screen?

How about rot13? 

	tr/a-mn-z/n-za-m/;

The same transformation unscrambles the message.

--Josh

-- 
Josh Purinton <joshp@silmaril.com>
That which can be said to deceive can also be said to enchant. -- Plato


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

Date: Tue, 26 Aug 1997 18:15:59 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Scrambling using tr
Message-Id: <comdog-ya02408000R2608971815590001@news.walrus.com>

In article <cavd8n0aco5.fsf@fri001.fm.intel.com>, jmastYers@pcocd2.intel.com (Justin Masters - remove "Y" to reply) wrote:

>What's an easy method of "scrambling" a message to get past the casual
>searchers of the text which they may see displayed going by on the screen?
>
>I tried using tr/a-z/Z-A/g, but it doesn't like (presumably) the "backwards
>range" of Z-A. 

you could just write it out:  ZXYWV... and so forth.  or you might want
to write a little routine to do the various toy ciphers such as ROT-13 -
which would be in a cryptography or number theory book :)

-- 
brian d foy                                  <comdog@computerdog.com>


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

Date: 26 Aug 1997 21:13:25 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: spell checking
Message-Id: <5tvgtl$3tf$1@news.fm.intel.com>

Danny LaPrade (dannyl@computize.com) so eloquently and verbosely pontificated:
> Is there a way to somehow use perl to do spell checking?
> 
> or link or use an existing spell checker?

if perhaps you just want to check a word or two that is input by a user,
maybe you could use one of the unix commands:

look -- looks for words or regular expressions in the dictionary

spell -- checks a file (or STDIN) for mispelled words

ispell -- a more robust spell checker that does a lot of stuff; the one
	built into vi

you can look through the man pages on these commands, pick what is right
for you, and run them through shell calls, if you dont mind the slowdown.
if you are gonna do some *serious* spell checking, you might want to slurp
the whole dictionary (maybe /usr/share/dict or something similar) into a
hash so you can do the lookups yourself.

hope that helps!

--
print   "J"                      ."u".        #    -- Terry Fletcher
        "s"    ."t".    " A",     "n"         # tfletche@pcocd2.intel.com
   .    "o"   ,""."".   "the",    "r ","P".   #  Views expressed....not
   "e"."rl"   ." Ha",   "c",''    .""  ."".   #  INTeL's....yadda yadda
      ""            ,   "k".      "e"  ."r"  ;#          yadda....


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

Date: Tue, 26 Aug 1997 09:38:13 -0700
From: John Grimm <nick@wireedm.com>
Subject: Textarea reading
Message-Id: <34030675.7350@wireedm.com>

I have written a perl script that will save some data from a TEXTAREA to
a file but when I try to read that data back in, I don't get anything. 
I know it's there (checked the file) but it doesn't reload back into the
same form.  Heres the line:
<TEXTAREA VALUE=\"$NOTES\" NAME=\"NOTES\" ROWS=\"2\" COLS=\"31\" >
$NOTES </TEXTAREA>

I am using cgi-lib and read parsed the data (everything else in the form
is ok).


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

Date: 27 Aug 1997 00:30:18 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: Textarea reading
Message-Id: <5tvseq$4nq$2@gazette.corp.medtronic.com>

In article <34030675.7350@wireedm.com>, John Grimm wrote:
>I have written a perl script that will save some data from a TEXTAREA to
>a file but when I try to read that data back in, I don't get anything. 
>I know it's there (checked the file) but it doesn't reload back into the
>same form.  Heres the line:
><TEXTAREA VALUE=\"$NOTES\" NAME=\"NOTES\" ROWS=\"2\" COLS=\"31\" >
>$NOTES </TEXTAREA>
>
>I am using cgi-lib and read parsed the data (everything else in the form
>is ok).

use CGI;	# works for me.  ;)

Seriously, you haven't given us any code, and you're not using
CGI.pm.  You're probably not going to get much help without
either showing errors/code or switching to CGI.

-Jot
-- 
Jot Powers  news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."


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

Date: Tue, 26 Aug 1997 22:50:41 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: What is ~// ? was(Re: Perl Regular Expression has a bug?)
Message-Id: <ebohlmanEFJM4H.L1K@netcom.com>

Colin Kuskie (colink@latticesemi.com) wrote:

: Note the difference in spacing around the =~.  Your code assigns
: the return value of whatever ~/(..):(..):(..)/ to $date, overwriting
: what it used to have.  Now the interesting question that remains is:

: What in the world is ~// ?

A bare ~ gives the bitwise complement of whatever follows it.  In a 
scalar context, // returns 1 if the pattern matches and "" if it 
doesn't.  Therefore, ~// returns either the bitwise complement of 1 or 
the bitwise complement of "".  Neither value is particularly useful in 
this context.



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

Date: 26 Aug 1997 23:54:52 GMT
From: "Loren Brown" <loren_j_brown@ccm.jf.intel.com>
Subject: Why doesn't PERL5/EG/excel1.pl work??
Message-Id: <01bcb27b$534fee00$699f8686@pentii.jf.intel.com>

Notice the line that makes the chart work (the call to
ChartWizard) is rem'd out.  When you unrem it, it
doesn't work!?!?!?

The range variable doesn't even start with a '$'.  What
IS it supposed to start with?  Even putting a '$' before
the word "range" doesn't work!

Surely someone out there uses excel with perl... the
broken example ships with PERL5!

HELP!!!!!!!!!!!! AAAAUUUGGGGHHHHH.......

loren...


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

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

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