[6996] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 622 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 17 01:07:59 1997

Date: Mon, 16 Jun 97 22:01:42 -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, 16 Jun 1997     Volume: 8 Number: 622

Today's topics:
     Re: Need help with regexp in substitution (Tad McClellan)
     Newbee <ctd@red.East.Sun.com>
     Re: no output from a second perl program called? (Tad McClellan)
     Ouputting a Simple GIF Image (Bear)
     PERL5.0004 build problems on a NeXT (Ed Wright)
     reading text field input maelstrom@deathsdoor.com
     Re: RegExp Question (something stupid, I'm sure :) (J. Paul Reed)
     Repost form data? message. How to get rid of it? <bricr01@execpc.com>
     Running out of memory in recursive subroutine <s.hart@unikix.com>
     Script to verify email addresses? (Atif Ahmad Khan)
     Re: Sending e-mail using Perl for NT - don't wanna... g (Neil Briscoe)
     Re: subject within mail????? <dsonak@us.oracle.com>
     Truble installingperl5.004 on HPUX <lorenzo@informest.it>
     Re: unwanted \n's in file with wrapped lines (Tad McClellan)
     URL worthy strings in Perl <rudy@mitec.net>
     Re: What is CGI? (Tad McClellan)
     Re: What is CGI? <kperrier@Starbase.NeoSoft.COM>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Jun 1997 20:23:15 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Need help with regexp in substitution
Message-Id: <3uo4o5.8v5.ln@localhost>

Mark R. Tobias (mtobias@liberty.uc.wlu.edu) wrote:
: I am working on a perl script that will help me convert some html 
: documents.  Basically, I am looking to do two things.  The first is to 
: remove all IMG SRC tags.  The second is to remove all external HREF 
: tags.  


There is no <HREF> tag in HTML.

There is ah HREF attribute in the <A> tag though.

I 'spose that is what you are talking about...


[snip]

: This works to remove the IMG SRC tag, but there is a problem.  It also 
: removes everything past the IMG SRC tag.  For instance if the <IMG> is 
: wrapped in a link tag, it removes the IMG src tag, and then it removes 
: the </A> and it will also remove anything after that till the end of the 
: line.  What I need to do is to remove <IMG SRC> tags from anywhere 
: within the document, even mid-sentence.  If the IMG tag is wrapped in an 
: <A HREF> tag, then I need to take the text out of the ALT tag and replace 

There is no <ALT> tag either ;-)

: the IMG SRC tag with that text.  Basically, I am looking for the regexp 
: that will substitute for strings that start with <IMG and then go until 
: it sees the first >.  That will be good to remove all IMG SRC tags.  Once 


s/<IMG[^>]+>//g;


: I get that done it shouldn't be too difficult to check the IMG SRC tag if 
: it preceded by an HREF tag and if so, capture the ALT text and then 
: replace the <IMG SRC> with that captured text, but again, I'm not sure 
: how to go about it.


s/<IMG[^>]+alt="([^"]+)"[^>]*>/$1/gi; # replace <IMG...> with the value of
                                      # its ALT attribute

: Well, that is for the IMG tags, for the HREF tags, I need to remove all 
: external ones.  So, I assume I need to look in the HREF tag to see if it 
: has a # to indicate it is a link to an anchor.  However, I'm not sure how 
: to do this.


That is not a reliable way to determine what is "external".

External to that one HTML file?

External to the particular web site that the page is on?


<A HREF="www.crooksRus.com#welcome">
<A HREF="www.whitehouse.gov#welcome">

Those _may_ be references outside of the current document, or not.

Those _may_ be references to two separate web sites, or not.

What do you mean by "external"?



: I know this has gone on as a long message but I have been working on it 
: for hours and am very frustrated.  


Programming's a bitch, isn't it...


: If you can help me ASAP (I need to 
: have this done tomorrow) I would appreciate it.  


Uh oh. I don't take direction very well.

You pretty much have to take whatever is offered on Usenet.

For rush jobs, you should consider hiring a consultant to give
your job personal attention (or don't wait until the last minute
to do your homework).


: Thank you very much.

You are welcome.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 10 Jun 1997 02:23:46 -0400
From: ctd <ctd@red.East.Sun.com>
Subject: Newbee
Message-Id: <339CF2F2.3204@red.East.Sun.com>

Is this the correct place to post questions about Perl....very basic
stuff?  Thanks.


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

Date: Fri, 13 Jun 1997 06:22:37 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: no output from a second perl program called?
Message-Id: <tharn5.ai.ln@localhost>

Joshua Frigerio (joshua@uic.edu) wrote:
: I'm just a beginner, so sorry if this is simple, but I've been searching
: the faqs for a 1/2 hour and can't find the answer.

: Why is it that when my perl program calls another perl program, it
: doesn't show the standard output from the second program? What can one
: do to see it?

: E.g., 

: The first program called hello is this:

: #!/usr/bin/perl
: `hello2`;

: the second one, called 'hello2' is this:
: #!/usr/bin/perl
: print "wow \n";

: When I run 'hello', shouldn't I see "wow" ?


You are using the wrong way of calling an external program for what
you want to do.

Use system() to run a program and get the return value:

system "hello2";

Use backticks when you want to capture the _output_ of a command
into a variable in your script.


See "How can I capture STDERR from an external command?" in
the Perl FAQ for more info.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Sat, 14 Jun 1997 22:45:59 GMT
From: clary@cruzio.com (Bear)
Subject: Ouputting a Simple GIF Image
Message-Id: <33a31e13.44427503@news.ucsc.edu>

Hi, I have no idea of were to start but I want to be able to output
some farily basic GIF 87a files with Perl 5 to my web browser.  I have
Perl set up with my server and all that fine.  I just need some quick
code that outputs a gif file that, let's say, is 10x10 in size and
every other pixel is black.

Also, this is a general GIF question, do you have to use LZW
compression?

I am also interested in not-so basic (transparent BGs, LZW
compression, etc) code for outputting GIFs, but thats for the future.

Thanks for any help,

       Aran Clary
	clary@mapcruzin.com


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

Date: 16 Jun 1997 23:45:23 GMT
From: ewright@naif-sun.jpl.nasa.gov (Ed Wright)
Subject: PERL5.0004 build problems on a NeXT
Message-Id: <5o4j6j$p8l@netline.jpl.nasa.gov>
Keywords: PERL 5, NeXT, evil symbol table

I have a problem when trying to compile PERL5.0004 on a
NextStation TurboColor running NS 3.3.

This is my first try at installing a PERL distribution from
scratch.

I run configure, then the make as per instructions.  There are no
apparent problems until the Fcntl module attempts to build. At this
point I get undefined symbol problems.  The ouput is as follows


        Making Fcntl (dynamic)
Writing Makefile for Fcntl
Skip ../../lib/Fcntl.pm (unchanged)
 ../../miniperl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp -noprototypes
 -typemap ../../lib/ExtUtils/typemap Fcntl.xs >Fcntl.tc && mv Fcntl.tc Fcntl.c
cc -c  -DUSE_NEXT_CTYPE -O     -DVERSION=\"1.03\"  -DXS_VERSION=\"1.03\" 
 -I../..  Fcntl.c
Running Mkbootstrap for Fcntl ()
chmod 644 Fcntl.bs
LD_RUN_PATH="" ld -o ../../lib/auto/Fcntl/Fcntl.none   Fcntl.o     
ld: Undefined symbols:
_Perl_croak
_errno
_strncmp
_strcmp
_Perl_stack_sp
_Perl_markstack_ptr
_Perl_stack_base
_Perl_na
_Perl_sv_2pv
_Perl_sv_2iv
_Perl_sv_newmortal
_Perl_sv_setnv
_Perl_Sv
_Perl_form
_perl_get_sv
_Perl_newXS
_Perl_sv_yes
*** Exit 1
Stop.
*** Exit 1
Stop

It looks like I have left out a library somewhare.

I ran the miniperl test as described in the INSTALL doc
and everything seemed to pass.

Anyone have any ideas what I am doing wrong and how to fix the
problem?


As always
Ed Wright NAIF Group
ewright@cardamon.jpl.nasa.gov

Wild nights are my glory..



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

Date: Sat, 14 Jun 1997 17:41:09 -0600
From: maelstrom@deathsdoor.com
Subject: reading text field input
Message-Id: <866327755.4147@dejanews.com>

Hi. Does anyone know how to manipulate the text in a text box in form
submission script? So for example I couldput a border around the text
like----------------------| comments  || in here 
|----------------------I'd also like to keep the format of the space bars
and carriage returns.At the moment everything is run together as a big
string.I'm fairly new to Perl but I'm guessing you'd parse a string for
some sort of carriage return character. Does anyone have any sample
functionor code on how to do this? Thanks--Maelstrom

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


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

Date: 17 Jun 1997 02:19:00 GMT
From: preed@psd.k12.co.us (J. Paul Reed)
Subject: Re: RegExp Question (something stupid, I'm sure :)
Message-Id: <5o4s6k$43c$1@mercury.psd.k12.co.us>

Tom Fawcett (fawcett@mailsvr.nynexst.com) wrote:
: preed@psd.k12.co.us (J. Paul Reed) writes:
: > When I run the following, I don't get any output? Can anyone tell me why?
: >[clip]
: > if ($blah =~ /^EP = [\w*\d*]\;$/) {
: 
: Square brackets denote a character class.  You can't use stars inside (you
: can, but they don't mean what you want them to mean).  You probably mean
: [\w\d]* instead.  Or [\w\d]+ in this case.

Ah hah...D'OH!

Thanks!

Later,
Paul
   -------------------------------------------------------------------
   J. Paul Reed                 preed@psd.k12.co.us || paul@619pro.com
   Such a noble creature; a quality we sometimes lack...
   				--Borg Queen; Star Trek: First Contact
   Geek Code and various other frivolities at www.psd.k12.co.us/~preed


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

Date: Sat, 14 Jun 1997 22:15:35 -0500
From: Colleen <bricr01@execpc.com>
Subject: Repost form data? message. How to get rid of it?
Message-Id: <33A35E56.7976@execpc.com>

I have a perl cgi script that at the end calls another html document.
The second document comes up fine, however, I am getting "Repost form
data?" from Netscape. If I answer "yes", my cgi script is re-executed by
the server resulting in a error message as the script was designed to
do. If I reply no, everything seems to be alright. Question: how can I
get rid of the "Repost" message without using expire or pragma headers
which I understand some browsers do not handle correctly. 

Thank-you, colleen

PS I have looked at the FAQS and have looked at several books to find
the answer.  No luck.


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

Date: Mon, 16 Jun 1997 20:02:59 -0700
From: Steve Hart <s.hart@unikix.com>
Subject: Running out of memory in recursive subroutine
Message-Id: <33A5FE63.48A4@unikix.com>

I have written a perl subroutine that reads a text file, and whenever
a file name is encountered in the text file, appends the file's
contents to the text file.

The files that are appended to my text file may also contain files
that I need to append to my text file, so I made the subroutine
call itself whenever this hapens.

I need entire text file to be kept in memory as a string until all
files have been appended to it.

My problem is that memory allocated for the string that is used to
store the text file does not seem to be released each time the
subroutine finishes.

Here is part of my program showing the recursive subroutine:

undef $/;

foreach $arg (@ARGV) {
   open (TEXTFILE, "<$arg");
   $expanded_file = &expand (<TEXTFILE>);
}

sub expand {
   my ($text) = @_;
   foreach $line (split (/\n/, $text)) {
      if ($line =~ /^EXPAND:(.+?)\s/) {
         $expfile = $1;
         open (EXPFILE, "<$expfile");
         $text .= &expand (<EXPFILE>);   # Recursive call
         close EXPFILE;
      }
   }
   return ($text);
}

What happens is that every time the program expands a text file,
more memory is used up, which will eventually casuse my machine to
run out of memory.

Is there any way I can free up the memory used for $text in this
example.

Or should this not cause a problem (meaning I'm doing something
wrong elsewhere)?


Steve Hart
s.hart@unikix.com


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

Date: 17 Jun 1997 02:15:15 GMT
From: aak2@Ra.MsState.Edu (Atif Ahmad Khan)
Subject: Script to verify email addresses?
Message-Id: <5o4rvj$sb2$1@NNTP.MsState.Edu>


I know from searching the dejanews archive and altavista that this
is a rather frequently asked question.  However I have not been able
to find a good solution to the problem yet.

I know that I can telnet to port 25 on a sever and verify the email
address of (most users) and if the server isn't the mail handler then
find the mail handler and telnet there.  I would like to automate this
process so that I can use it a cgi script.

If my perl was any good I would write the script myself but it isn't
so I ask for help.

Thanks a million.

Atif Khan
aak2@ra.msstate.edu


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

Date: 17 Jun 1997 04:19:15 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: Sending e-mail using Perl for NT - don't wanna... gotta
Message-Id: <memo.19970617051914.36713B@skep.compulink.co.uk.cix.co.uk>

In article <866481687.19948@dejanews.com>, x@apocalypse.org () wrote:

> I'm being "forced" (no gun to my head... at least not literally)
> to port some perl CGI scripts from Unix to NT. Sending e-mail
> with perl on Unix is easy enough... open a pipe to sendmail... but
> how would I send e-mail from perl on NT? Thanks.
> P.S. Thanks to those who responded to my other recent post.

Well, either you can get a sendmail for NT - there is one - but its
commercial - see www.metainfo.com - it supports the sendmail -t switch.

Alternatively, you can talk native SMTP.  I have a perl routine to do that
- not very pretty but functional.  Mail me and I'll send you smtp.zip by
return.

Regards
Neil



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

Date: Fri, 13 Jun 1997 10:49:49 -0700
From: "Dipti V. Sonak" <dsonak@us.oracle.com>
To: patton@micro.ti.com
Subject: Re: subject within mail?????
Message-Id: <33A1883D.712A@us.oracle.com>

This is a routine that I have used : 

# Subject line for the mail
# File that need to be mailed to the user
sub sendMail
{
   local( $message, $fileName ) = @_;
 
   `$MAIL -s $message $mailRecipients < $fileName `;
   $return = $?;
   if( $return != 0 )
   {
       printf "Error Sending Mail to : $mailRecipients\n";
   }
   else
   {
        printf "Mail sent to : $mailRecipients\n";
   }
}
1;


My $MAIL is initialized to the mail program. There are two mail programs
on my system - one does not accept the header [ subject line ] - make
sure that you are using the correct program incase you have multiple
mail programs. 

Thanks, 
Dipti 



James D. Patton Jr. wrote:
> 
> How would I go about putting a subject on a mail message using the PERL
> open(MAIL "|mail YOUR_ADDRESS_HERE");
>          print MAIL "BODY_OF_MESSAGE\n";
>          close(MAIL);
> 
> ???????????????????????????????????????????
>         Texas Instruments Inc.
> James Patoon    Novice System Administrator
>          patton@micro.ti.com
> ???????????????????????????????????????????


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

Date: 10 Jun 1997 09:32:00 GMT
From: "Feurra" <lorenzo@informest.it>
Subject: Truble installingperl5.004 on HPUX
Message-Id: <01bc7580$3e1a35a0$1a90f3c2@antonio.informest.it>

I have downloaded Perl5.004 and I need to install it on my HPUX. I run "sh
Configure -d" and everything seems to go right. If i run "make " it gives
me errors:
/usr/include/math.h: 367 : too much defining - use -H options
 ./perl.h: 1246 :too much defining - use -H options
 ./perl.h: 1577 :no space

Has anybody an idea? All the partitions on my system have almost 30Mb of
free space available. The direnctory in which I want to install Perl has
about 300Mb of available space.

Thanks in advance

Lorenzo Feurra


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

Date: Sat, 14 Jun 1997 23:23:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: unwanted \n's in file with wrapped lines
Message-Id: <unqvn5.rp.ln@localhost>

WillSextonsextw@ils.unc.edu wrote:
: I'm trying to get a perl script to read in a file with some very
: long lines.  
  ^^^^^^^^^^

How long is that for you?

1000 chars on a line?  1,000,000 ? ...


: The problem is, the file wraps some of these long lines so
                      ^^^^^^^^^^

Who "wraps" it? (ie. what program does the wrapping?)


: that perl sees newline characters where there should be none.  Needless to
: say, this is messing me up.  So I have a question about how to deal with
: this, but I'm not really sure what the question is.  It might be:

: Is it possible to store text files with unlimited line lengths?

No.

"unlimited" is pretty ambitious  ;-)


If you change the "unlimited" to "really really long", then

Yes  ;-)


"lines" are just a concept to help people deal with data. To an
OS or program, a "line" is just another character like any other
character.


Anyway, the length is not limited by perl, only by the amount
of memory available on your machine.


: Or, can I make perl unwrap the text when reading it in, or otherwise
: ignore these \n's?
         ^^^^^

Does that mean these \n's, but not those \n's?

How could you tell the difference between newlines that were there
originally and the ones added by some facist program.


If you want to delete all newlines:  s/\n//g;

: Or, do I just have to make the lines shorter?


No, you shouldn't have to do that (not on Perl's account anyway).

: Or something else, even.  If you know the answer, or even the question,
: please let me know.


Since the problem is some program that is changing your file without
your permission, I would want to know which program that is...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 13 Jun 1997 00:18:36 -0500
From: Rudy Richter <rudy@mitec.net>
Subject: URL worthy strings in Perl
Message-Id: <33A0D82C.34B@mitec.net>

We've all seen this...

@cgiPairs = split("&",$ENV{'QUERY_STRING'});
foreach $pair ( @cgiPairs ) {
    ($var,$val) = split("=",$pair);
    $val =~ s/\+/ /g;
    $val =~ s/%(..)/pack("c",hex($1))/ge;
    $cgiVals{"$var"} = "$val";
}

Now, does anyone know an easy way to reverse this?  I have come up with
this clumsy code...

$URLval = $val;
$URLval =~ s/%/%25/g;
$URLval =~ s/\+/%2B/g;
$URLval =~ s/ /\+/g;
$URLval =~ s/&/%26/g;
$URLval =~ s/"/%22/g;
$URLval =~ s/=/%3D/g;
$URLval =~ s/\?/%3F/g;
$URLfilterby =~ s/#/%23/g;

This sucks, IMHO, and I would love to see something better..

TIA
Rudy


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

Date: Mon, 16 Jun 1997 20:26:48 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: What is CGI?
Message-Id: <o4p4o5.8v5.ln@localhost>

Mr Mah Hang Chin (esupu@warwick.ac.uk) wrote:
: 	I am a novice. Can anyone tell me what is CGI pls and what is so
: good about it?


No.

Nobody here will tell you about the CGI protocol.

This is the Perl newsgroup. We discuss Perl here.

CGI is not Perl, so we do not discuss it here. That would be off-topic
clutter that would be likely to annoy the people who came here to
read about Perl.


Try a radical approach to getting your CGI question answered, and
ask in it the CGI newsgroup:

comp.infosystems.www.authoring.cgi


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 16 Jun 1997 22:00:58 -0500
From: Kent Perrier <kperrier@Starbase.NeoSoft.COM>
Subject: Re: What is CGI?
Message-Id: <cs3eqiue51.fsf@Starbase.NeoSoft.COM>

Mr Mah Hang Chin <esupu@warwick.ac.uk> writes:

> 	I am a novice. Can anyone tell me what is CGI pls and what is so
> good about it?
> 	Cheers.
> 

Well, a quick grep of the active newsgroups for the string "cgi" returns the
following:

	comp.infosystems.www.authoring.cgi

When you read the newsgroup for the first time pay attention to any 
articles that are called FAQs.  Also read the newsgroup for at least a
week before you post anything.  Its also a good idea to browse the 
archives at www.dejanews.com before you post.

Kent
-- 
Kent Perrier                             kperrier@neosoft.com 
Corporations don't have opinions, people do.  These are mine.


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

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

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