[18421] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 589 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 29 18:16:40 2001

Date: Thu, 29 Mar 2001 15:15:56 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985907755-v10-i589@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 29 Mar 2001     Volume: 10 Number: 589

Today's topics:
        LWP & Content-Type <maestrutti@libero.it>
        LWP Timeout using get to get a webpage <marc@bookmarc.com>
    Re: LWP Timeout using get to get a webpage <webmaster@webdragon.unmunge.net>
    Re: LWP Timeout using get to get a webpage <gtoomey@usa.net>
    Re: LWP Timeout using get to get a webpage <andras@mortgagestats.com>
    Re: LWP::Simple::get don't get what I want. <jonni@ifm.liu.se>
    Re: LWP::Simple::get don't get what I want. (Logan Shaw)
        nbsp with HTTP:parser htext <jdhunter@nitace.bsd.uchicago.edu>
    Re: nbsp with HTTP:parser htext <gisle@ActiveState.com>
        net::smtp and authentication <paulthomson@hotmail.com>
        net::smtp and authentication <paulthomson@hotmail.com>
    Re: Newbie (Mark Jason Dominus)
    Re: NEWBIE: Help running Perl from Apache <clive@bromley.ac.uk>
    Re: NEWBIE: Help running Perl from Apache nobull@mail.com
    Re: Newbie: keep on matching until end of string <stephen.gray@internode.on.net>
    Re: Newbie: keep on matching until end of string <johnlin@chttl.com.tw>
    Re: Newbie: keep on matching until end of string (Tad McClellan)
    Re: Passing arguments to subroutines... <eric.kort@vai.org>
    Re: peculiar regex problem (Philip Lees)
    Re: peculiar regex problem <xris@dont.send.spam>
    Re: peculiar regex problem <ronald.fischer.gp@icn.siemens.de>
    Re: peculiar regex problem (Tad McClellan)
    Re: Perl / CGI Editors (Tim Hammerquist)
    Re: Perl / CGI Editors (Tad McClellan)
    Re: Perl / CGI Editors (---Pete---)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 29 Mar 2001 19:29:41 GMT
From: Andrea Maestrutti <maestrutti@libero.it>
Subject: LWP & Content-Type
Message-Id: <3AC39B47.724A1B0@libero.it>

Hello!

with LWP I upload some files and form fields to a remote cgi.

I'd like to change the Contet-Type for the uploaded files.

My code is:

#===================
use LWP::UserAgent;
use HTTP::Request::Common;

my $ua = LWP::UserAgent->new;

$ua->request(
        POST 'http://www.myhost.com/cgi-bin/receive.pl', 
        Content_Type => 'form-data', 
        Content => [communication => 'My documents.',
                    file1 => ["/mypath/filename1",'File1.tar'],
                    file2 => ["/mypath/filename2",'File2.doc']
                   ]
);
#===================


and the mime resulted is:


========================

--xYzZY
Content-Disposition: form-data; name="communication"

My documents.
--xYzZY
Content-Disposition: form-data; name="file1"; filename="File1.tar"
Content-Length: 33347
Content-Type: application/octet-stream

[snip]

--xYzZY
Content-Disposition: form-data; name="file2"; filename="File2.doc"
Content-Length: 47104
Content-Type: application/octet-stream

[snip]

========================

I'd like to change the "Content-Type" with another one.


Thanks in advance,

Andrea Maestrutti.


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

Date: Wed, 28 Mar 2001 21:28:21 -0800
From: "Marc Melcher" <marc@bookmarc.com>
Subject: LWP Timeout using get to get a webpage
Message-Id: <99ugr1$kr2$1@nntp.Stanford.EDU>

I using the LWP module and the get function to download urls.  Most of the
time This works smoothly.  However, some website intermittently give me a
time out error.  These website will load normally if I enter them into my
browser.

Is there a way to extend the timeout period to be a little more lenient?

-Marc




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

Date: 29 Mar 2001 19:43:26 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: LWP Timeout using get to get a webpage
Message-Id: <9a038u$fre$0@216.155.32.200>

In article <m18zloqypg.fsf@halfdome.holdit.com>,
 merlyn@stonehenge.com (Randal L. Schwartz) wrote:

 | >>>>> "Andras" == Andras Malatinszky <andras@mortgagestats.com> writes:
 | 
 | Andras> Why do we need the HTTP::Cookies module here?
 | 
 | Just trying to milk it for all its worth.
 | 
 | :-)

*groan* =8)

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Thu, 29 Mar 2001 16:30:05 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: LWP Timeout using get to get a webpage
Message-Id: <brAw6.5329$45.28902@newsfeeds.bigpond.com>

use LWP::UserAgent;
use HTTP::Cookies;

      $ua = new LWP::UserAgent;
      $ua->agent("$0/0.1 " . $ua->agent);
      $ua->timeout(30); # change your timout value as necessary
       $req = new HTTP::Request 'GET' => 'http://www.somesite.com';  #change
as apprporiate
      $req->header('Accept' => 'text/html');
      $res = $ua->request($req);

      if ($res->is_success) {
                #web page is now in the variable$res
}
---------
gtoomey
---------
"Marc Melcher" <marc@bookmarc.com> wrote in message
news:99ugr1$kr2$1@nntp.Stanford.EDU...
> I using the LWP module and the get function to download urls.  Most of the
> time This works smoothly.  However, some website intermittently give me a
> time out error.  These website will load normally if I enter them into my
> browser.
>
> Is there a way to extend the timeout period to be a little more lenient?
>
> -Marc
>
>




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

Date: Thu, 29 Mar 2001 09:21:33 -0500
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: LWP Timeout using get to get a webpage
Message-Id: <3AC344ED.8B0B3E95@mortgagestats.com>



Gregory Toomey wrote:

> use LWP::UserAgent;
> use HTTP::Cookies;
>
>       $ua = new LWP::UserAgent;
>       $ua->agent("$0/0.1 " . $ua->agent);
>       $ua->timeout(30); # change your timout value as necessary
>        $req = new HTTP::Request 'GET' => 'http://www.somesite.com';  #change
> as apprporiate
>       $req->header('Accept' => 'text/html');
>       $res = $ua->request($req);
>
>       if ($res->is_success) {
>                 #web page is now in the variable$res
> }

Why do we need the HTTP::Cookies module here?



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

Date: Thu, 29 Mar 2001 11:00:40 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: LWP::Simple::get don't get what I want.
Message-Id: <99utfh$2f6$1@newsy.ifm.liu.se>

> When you send a request for a page via HTTP, you can send a
> "User-Agent:" line to declare what browser you're using.  The web
> server is free to check this and send back a different page as its
> whim.

It seems like you are correct. Using LWP instead of LWP::Simple makes it OK
for you to use another USerAgent like this:

  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);

  # Create a request
  my $req = new HTTP::Request POST =>
'http://www.site.com/path/prog?var=val';
  $req->content_type('application/x-www-form-urlencoded');
  $req->content('match=www&errors=0');


  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

This code was copied from LWP readme. However which useragent emulates
Explorer/Netscape?
/jN

--
_______________________________
Jonas Nilsson




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

Date: 29 Mar 2001 03:34:52 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: LWP::Simple::get don't get what I want.
Message-Id: <99uvjs$k6g$1@boomer.cs.utexas.edu>

In article <99utfh$2f6$1@newsy.ifm.liu.se>,
Jonas Nilsson <jonni@ifm.liu.se> wrote:
>This code was copied from LWP readme. However which useragent emulates
>Explorer/Netscape?

It varies alot.  I just wrote a simple CGI to check on my system, and
apparently the answer for Netscape 4.76 is this:

	Mozilla/4.76 [en] (X11; U; SunOS 5.8 i86pc)

For Netscape 6 it's this:

	Mozilla/5.0 (X11; U; SunOS 5.8 i86pc; en-US; m18) Gecko/20001204 Netscape6/6.0

I had to change the output of my CGI a little bit to find that out,
because without changing it, Netscape 6 crashed.  :-)

Hope that helps.

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: 29 Mar 2001 09:47:28 -0600
From: John Hunter <jdhunter@nitace.bsd.uchicago.edu>
Subject: nbsp with HTTP:parser htext
Message-Id: <1rr8zginlb.fsf@video.bsd.uchicago.edu>

I have some html documents that I am converting to plain text with a
converter based on htext that is distributed with HTTP:Parser.  The
&nbsp html code is output as a binary character <A0>.  Can someone
advise me how to fix the converter below to take care of this?

Thanks,
John Hunter

-- modified htext --
#!/usr/bin/perl -w

# Extract all plain text from an HTML file

use strict;
use HTML::Parser 3.00 ();

my %inside;

sub tag
  {
    my($tag, $num) = @_;
    $inside{$tag} += $num;
    #print "$tag\n";  # not for all tags
  }

sub text
  {
    my $text = shift;
    return if $inside{script} || $inside{style};
    $text =~ s/\r\n/\n/g;  #fix dos like \r
    print OUTPUT $text;;
  }

my $p = HTML::Parser->new(api_version => 3,
			  handlers    => [start => [\&tag, "tagname, '+1'"],
					  end   => [\&tag, "tagname, '-1'"],
					  text  => [\&text, "dtext"],
					 ],
			  marked_sections => 1,
			 );
foreach my $file (@ARGV) {
  my $outfile = "$file.txt";
  open(OUTPUT, ">$outfile");
  print "converting $file to $outfile\n";
  $p->parse_file($file) || die "Can't open file: $!\n";
}





-- sample html text which generates the problem --
<!--Created by GeoCities Home Page Generator-->
<HTML>
<!--BODY--><center>
<!-- <SERVICE NAME="geoguide"> -->
<table bgcolor=#666666 cellpadding=1 cellspacing=0 border=0 width=468>
<tr><td><table bgcolor=#eeeeee cellpadding=2 cellspacing=0 border=0 width=100%>
<tr><td bgcolor=#FFFFFF><a href="http://geocities.yahoo.com/addons/interact/mbe.html"><IMG SRC="http://pic.geocities.com/images/mbe/mbeFFFFFF.gif" ALT="Yahoo! GeoCities Member Banner Exchange" WIDTH=335 HEIGHT=20 border=0></a></td>
<td align=right bgcolor=#FFFFFF><font face="Arial" size="-1"><a href="http://geocities.yahoo.com/addons/interact/mbe.html">Info</a></font>&nbsp;</td></tr></table></td></tr>
</table>
<table cellpadding=0 cellspacing=0 width=468 border=0>
<tr><td valign=top height=1></td></tr>
<tr><td valign=top><SCRIPT LANGUAGE="javascript" src="http://us.toto.geo.yahoo.com/toto?s=76001084&b=2"></SCRIPT></td></tr>
</table>



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

Date: Thu, 29 Mar 2001 17:40:53 GMT
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: nbsp with HTTP:parser htext
Message-Id: <m3bsqkzd26.fsf@ActiveState.com>

John Hunter <jdhunter@nitace.bsd.uchicago.edu> writes:

> I have some html documents that I am converting to plain text with a
> converter based on htext that is distributed with HTTP:Parser.  The
> &nbsp html code is output as a binary character <A0>.  Can someone
> advise me how to fix the converter below to take care of this?

Actually, <A0> is not really more binary than <20> :-)

Anyway, just add the statement shown below:

> -- modified htext --

[...]

> sub text
>   {
>     my $text = shift;
>     return if $inside{script} || $inside{style};
>     $text =~ s/\r\n/\n/g;  #fix dos like \r

      $text =~ s/\xA0/ /g;

>     print OUTPUT $text;;
>   }

-- 
Gisle Aas


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

Date: Thu, 29 Mar 2001 13:32:22 +0100
From: "paul" <paulthomson@hotmail.com>
Subject: net::smtp and authentication
Message-Id: <mn9v99.cm2.ln@cs1.moxa.com.tw>

Hi,

I am trying to use net::smtp to send mail but I have discovered that my
server requires authentication. Is there a way to do this with this module?

Thanks in advance,

Paul





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

Date: Thu, 29 Mar 2001 23:36:22 +0100
From: "Paul" <paulthomson@hotmail.com>
Subject: net::smtp and authentication
Message-Id: <3ac3b8a2@news1.homechoice.co.uk>

Hi,

I am trying to use net::smtp to send mail but I have discovered that my
server requires authentication. Is there a way to do this with this module?

Thanks in advance,

Paul





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

Date: Thu, 29 Mar 2001 19:18:48 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Newbie
Message-Id: <3ac38aa7.28af$33a@news.op.net>
Keywords: McCallum, calamitous, firearm, obliterate


In article <3abf9371$1@bluesky.reedtech.com>, Y <nospam@email.com> wrote:
>Here's the code:

Thanks.

You have several serious problems.

The biggest one is that you don't seem to understand how files work.
You have code that reads the file into memory:

>   open (FILE, "$file") || die $!;
>    %data = <FILE>;

(etc.)

What you get is a *copy* of the data:  It has been copied from the
disk into the computer's memory.  If you modify %data, you have
modified the copy in the computer's memory, not the copy on the disk.
Unless you then write out the data in %data, the version on the disk
will not change.

Another problem is that %data = <FILE> does not do what you think.  I
don't know just what you're thinking, but whatever it is, this isn't
doing it.  I would guess that since the cirtuser table has two
columns, you want to have the first column be keys and the second
column be values.  But %data = <FILE> doesn't do that.

Another problem is that even if you *did* read the data in the file
into the hash in the correct way, so that the left column was keys and
the right column values, your 'delete' statement makes no sense.
%data refers to an entire hash.  You want to delete only one element
from the hash.  One element is a scalar, so you need

        delete $data{whatever}

here 'whatever' is the appropriate key that you want to delete.  The
key and its value will be removed from the table.  

Another problem is that you try to read in and modify the entire file
each time you see DELETE.  This is going to be very slow.

Another problem is that your DELETE command specifies two addresses,
say 

        FORWARD user1@blg.com test@aol.com DELETE

but suppose the virtusertable contains the following:

        user1@blg.com user1@example.com

Should you delete it, or not?  It's not clear.  It would be easier to
decide what to do if the DELETE command looked like this:

        FORWARD user1@blg.com DELETE

This would mean to cancel the forwarding for user1@blg.com, regardless
of what the forwarding address is.

I suggest two things.

First, get a book about Perl and read it carefully and try the
examples.  You seem to be in way over your head.  

Second, try something like this:

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

# read the entire address file into memory
open ADDRESSFILE, "< $file" 
  or die "Couldn't open address file $file: $!";
while (<ADDRESSFILE>) {
  chomp;
  ($true, $forward) = split;
  $data{$true} = $forward;    # here we are using the hash %data
}
close ADDRESSFILE;

# Now process the commands
while (<>) {
  ($command1, $address1, $address2, $command2) = split /\t/;
  next unless $command1 eq 'FORWARD';
  if ($command2 eq 'ADD') {
    $data{$address1} = $address2;     # add new address to %data   
  } elsif ($command2 eq 'DELETE') {
    if ($data{$address1} eq $address2) {
      delete $data{$address1};
    } elsif (! exists $data{$address1}) {
      warn "Cannot delete forwarding for unknown address $address1.\n";
    } else {
      warn "$address1 is forwarded to $data{$address1}, not to $address2.\n";
    }        
  } else {
    warn "Unknown command '$command2'";
  }
}

# now write out the modified address file data
open (FILE, "> $file") || die $!;
while (($address1, $address2) = each %data) {
  print FILE "$address1\t$address2\n";
}
close FILE;


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

I hope this is helpful.


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

Date: Fri, 30 Mar 2001 02:37:46 +0100
From: "Clive Gould" <clive@bromley.ac.uk>
Subject: Re: NEWBIE: Help running Perl from Apache
Message-Id: <99vdb3$jmo$1@canard.ulcc.ac.uk>

I eventually got it working as shown below:

1) Add the following entry to the "local" section of
/etc/httpd/conf/httpd.conf

        <Directory /var/www/html/paul>
                Options +ExecCGI
        </Directory>

The above directive tells Apache to permit the execution of CGI files in
Paul's directory.

2) Add the following AddHandler directive to /etc/httpd/conf/httpd.conf to
tell the server to treat all files with the cgi or pl extension as CGI
programs:

      AddHandler cgi-script cgi pl

3) Restart Apache using the command:

 /etc/rc.d/init/d/httpd reload

and hey presto the file test.pl in Paul's directory, the source code for
which is shown below:

#!/usr/bin/perl
use CGI;
$query=new CGI;
print $query->header; print"<HEAD\n";
print"The test was OK, Perl is working";

Displays the following when viewed from IE5.5:

Just a perl test The test was OK, Perl is working

Hurrah!

Thanks for pointing us in the right direction >>>

Clive


<nobull@mail.com> wrote in message news:u9elvg4xuk.fsf@wcl-l.bham.ac.uk...
> "Clive Gould" <clive@bromley.ac.uk> writes:
>
> > We have set up an experimental Apache web server and are trying to run
Perl
> > scripts from it.
>
> Via CGI or via mod_perl?
>
> > When we try to run a script IE5 just displays the text of the .pl file
and
> > does not execute it
> >
> > We suspect it is a problem with the pathing of the perl interpreter.
>
> No, it is an problem with telling Apache that the file is to be
> handled as a CGI script (or if you are trying to use mod perl that is
> is to be handled as a perl script).
>
> Apache/CGI configuration questions are off-topic in this newsgroup as
> they are independant of the language used to implement the CGI
> scripts.  Basically you must tell Apache that either all files in a
> directory are CGI scripts, or all files with a .pl extension are CGI
> scripts.
>
> If, on the other hand, you are using mod_perl you need something like:
>
> AddHandler perl-script .pl
> PerlHandler Apache::Registry
> Options +ExecCGI
>
> > The trivial.pl script is as follows:
> >
> > #!/usr/bin/perl
> > print "Hello Perly World\n";
>
> This is not a valid CGI script (no headers).  See numerous examples of
> valid CGI scripts written in Perl all over the place.  E.g. the
> synopsis section of "perldoc CGI".
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\




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

Date: 29 Mar 2001 12:29:39 +0100
From: nobull@mail.com
Subject: Re: NEWBIE: Help running Perl from Apache
Message-Id: <u9elvg4xuk.fsf@wcl-l.bham.ac.uk>

"Clive Gould" <clive@bromley.ac.uk> writes:

> We have set up an experimental Apache web server and are trying to run Perl
> scripts from it.

Via CGI or via mod_perl?
 
> When we try to run a script IE5 just displays the text of the .pl file and
> does not execute it
> 
> We suspect it is a problem with the pathing of the perl interpreter.

No, it is an problem with telling Apache that the file is to be
handled as a CGI script (or if you are trying to use mod perl that is
is to be handled as a perl script).

Apache/CGI configuration questions are off-topic in this newsgroup as
they are independant of the language used to implement the CGI
scripts.  Basically you must tell Apache that either all files in a
directory are CGI scripts, or all files with a .pl extension are CGI
scripts.

If, on the other hand, you are using mod_perl you need something like:

AddHandler perl-script .pl
PerlHandler Apache::Registry
Options +ExecCGI

> The trivial.pl script is as follows:
> 
> #!/usr/bin/perl
> print "Hello Perly World\n";

This is not a valid CGI script (no headers).  See numerous examples of
valid CGI scripts written in Perl all over the place.  E.g. the
synopsis section of "perldoc CGI".

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 29 Mar 2001 10:46:32 +0930
From: "Stephen Gray" <stephen.gray@internode.on.net>
Subject: Re: Newbie: keep on matching until end of string
Message-Id: <3ac28ee8@duster.adelaide.on.net>

> > David Wake <dwake@Turing.Stanford.EDU> wrote in message

> > use g for "global"
> > (@results)=($string_you_search_in =~ m/INTERESTING_SUBSTRING/g);
> > will copy the first occurrence of INTERESTING_SUBSTRING into
$results[0],
> > the second into $results[1], the third into $results[2] and so on.
>
> Many thanks for replies.  What do I do if the string has a
> non-repeated introduction?  Say, for example, that I want to search
> for the string "START" and then copy every subsequent word into an array.

You could just split at the introduction, eg:

$string = "kslzfjd  kfhdfh START lksj sj sdjf sfdfj";
($loseit, $string) = split(/START/, $string);

Then if the string contains "word delimiters" (eg spaces) you can use
split() again (@result = split(" ", $string;) or use the above method if you
need to do something more complicated.

Steve




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

Date: Thu, 29 Mar 2001 11:59:05 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Newbie: keep on matching until end of string
Message-Id: <99ubr2$if4@netnews.hinet.net>

"Stephen Gray" wote
> > > David Wake wrote
> > > (@results)=($string_you_search_in =~ m/INTERESTING_SUBSTRING/g);
> > What do I do if the string has a non-repeated introduction?
> >  Say, for example, that I want to search
> > for the string "START" and then copy every subsequent word into an array.
>
> $string = "kslzfjd  kfhdfh START lksj sj sdjf sfdfj";
> ($loseit, $string) = split(/START/, $string);
>
> Then if the string contains "word delimiters" (eg spaces) you can use
> split() again (@result = split(" ", $string;) or use the above method if you
> need to do something more complicated.

I wonder can we use just regular expressions to do it?  For example,

$_ = 'trash garbabe START some interested words';
@results = /START/ ? /\G\s*(\w+)/g : ();    # hoping \G starts from last match
print map {"[$_]"} @results;

__END__
[trash][garbage][START][some][interested][words]

Of course it is not the correct answer. (We want  [some][interested][words])

Will Perl consider to enable \G to be used across several regular expressions?
That would generally solve this kind of problems.
And \G becomes more useful.

What do you think about it?  Thank you.

John Lin





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

Date: Wed, 28 Mar 2001 22:35:42 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie: keep on matching until end of string
Message-Id: <slrn9c5bce.jrh.tadmc@tadmc26.august.net>

David Wake <dwake@Turing.Stanford.EDU> wrote:

>I guess my initial query was a bit too general -- apologies. 

>So you could imagine the string


Why imagine? Can't you just show us one?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 23 Mar 2001 10:20:07 -0500
From: "Eric" <eric.kort@vai.org>
Subject: Re: Passing arguments to subroutines...
Message-Id: <99vgme$2uio$2@msunews.cl.msu.edu>

"Naran Hirani" <N.Hirani@hgmp.mrc.ac.uk> wrote in message
news:3ABB6746.CDCFEB76@hgmp.mrc.ac.uk...
> Hi All,
>
> I have this piece of noddy  code in perl  which works but I was
> wondering if some one
> could tell me how I can modify it so that arguments can be passed to my
> little
> subroutine.
>

all arguments are passed in through @_, like this:

$greeting=Hello('world');
exit;

sub Hello
{
  $audience = shift;
  # $audience = $_[0] would also work
  # the next argument, if it existed, would be $_[1], etc.
  return "Hello $audience";
}




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

Date: Thu, 29 Mar 2001 08:21:55 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: peculiar regex problem
Message-Id: <3ac2f022.67341862@news.grnet.gr>

On Thu, 29 Mar 2001 10:55:35 +0930, "Wyzelli" <wyzelli@yahoo.com>
wrote:

>"Kevin Connor Arpe" <kca@po.cwru.edu> wrote in message
>news:3AC28827.10AA@po.cwru.edu...
>> I'm having a problem with what should be the simplest regex.
>> I want to remove (from a string) all instances of useless HTML tags,
>> i.e., <tag>whitespace</tag>.
>
>$data =~ s/<[^>]+>\s*<\/[^>]+>//g;
>

Or, assuming you only want to remove _matching_ tags, i.e. not
<tag1></tag2>:

s/<([^>]+)>\s*<\/\1>//g;

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: Thu, 29 Mar 2001 13:57:01 -0600
From: xris <xris@dont.send.spam>
Subject: Re: peculiar regex problem
Message-Id: <xris-D02B62.13570129032001@newsrump.sjc.telocity.net>

In article <slrn9c69rn.la5.tadmc@tadmc26.august.net>,
 tadmc@augustmail.com (Tad McClellan) wrote:

> >s/<([^>]+)>\s*<\/\1>//g;
> which will fail for something like:
>    <tag attr="value">   </tag>

try:

   s/<(\w+)[^>]*>\s*<\/\1>//g;

or if you're still concerned about missing certain (very nonstandard?) 
tags:

  s/<([^>\s]+)[^>]*>\s*<\/\1>//g;

> and both approaches fail for:
>    <tag attr=">>value<<">   </tag>

well, technically this is bad html and will break some browsers, too...  
if at all possible, you should use &lt; and &gt; instead of those other 
values.   I'm still curious if someone else can find another workaround, 
though.


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

Date: Thu, 29 Mar 2001 10:34:17 +0200
From: Ronald Fischer <ronald.fischer.gp@icn.siemens.de>
Subject: Re: peculiar regex problem
Message-Id: <3AC2F389.2FA8E0B6@icn.siemens.de>

Kevin Connor Arpe wrote:
> 
> I'm having a problem with what should be the simplest regex.
> I want to remove (from a string) all instances of useless HTML tags,
> i.e., <tag>whitespace</tag>.
> 
> This should be as easy as:
> 
> $data =~ s/<[^>]>\s*<\/[^]>//g ;
> 
> But it won't work.

The sub-expression <[^>]> looks for a tag consisting of exactly one
character, so it would not match, for instance, <frame> or <title>. You
probably meant <[^/>]+> for the start of your regexp, and I guess you
don't expect nested tags in your string either?

Ronald
-- 
Ronald Otto Valentin Fischer <rovf@earthling.net>
[now at: Siemens ICM N MR UR DE 6, phone: +49(Germany)+89-722-23368]
http://profiles.yahoo.com/ronny_fischer/
http://fusshuhn.ourfamily.com/cppincomp.html


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

Date: Thu, 29 Mar 2001 07:15:51 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: peculiar regex problem
Message-Id: <slrn9c69rn.la5.tadmc@tadmc26.august.net>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>On Thu, 29 Mar 2001 10:55:35 +0930, "Wyzelli" <wyzelli@yahoo.com>
>wrote:
>
>>"Kevin Connor Arpe" <kca@po.cwru.edu> wrote in message
>>news:3AC28827.10AA@po.cwru.edu...
>>> I'm having a problem with what should be the simplest regex.
                                                 ^^^^^^^^^^^^^^

A simpleminded approach will be a simple regex.

It will also be incorrect in some cases though...


>>> I want to remove (from a string) all instances of useless HTML tags,
>>> i.e., <tag>whitespace</tag>.
>>
>>$data =~ s/<[^>]+>\s*<\/[^>]+>//g;
>>
>
>Or, assuming you only want to remove _matching_ tags, i.e. not
><tag1></tag2>:
>
>s/<([^>]+)>\s*<\/\1>//g;


which will fail for something like:

   <tag attr="value">   </tag>

and both approaches fail for:

   <tag attr=">>value<<">   </tag>


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Mar 2001 02:11:24 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Perl / CGI Editors
Message-Id: <slrn9c56nh.iai.tim@vegeta.ath.cx>

Ntl World <Sh0t2bts@hotmail.com> wrote:
> I currently do quite a bit of CGI scripting for web pages, I am using a
> Program called PFE "I'm sure you would have heard of it"
> This is a great program for small scripts where it is easy to keep track but
> I am after some thing that will highlight Vars, Sub routines & comments Etc.

Vim is freely available on almost every OS.  It is extremely powerful,
and comes with 215 syntax definitions out-of-the-box, for everything
from DOS .BAT files to *nix shell scripts to Modula3 to Perl to Python
to Rexx and Ruby.  Find out more at http://www.vim.org/

BTW, comp.lang.editors might be a better place to find a good editor for
any platform or language.  If you had posted this there, you would've
had at least 3 people recommending Vim and several more endorsing Emacs,
along with some other more Win-centric editors.

HTH
-- 
-Tim Hammerquist <timmy@cpan.org>

I know I can quit smoking because I've done it a thousand times.
	-- Mark Twain


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

Date: Wed, 28 Mar 2001 22:19:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl / CGI Editors
Message-Id: <slrn9c5adp.jla.tadmc@tadmc26.august.net>

Ntl World <Sh0t2bts@hotmail.com> wrote:

>Subject: Perl / CGI Editors
                 ^^^^^^^^^^^

I doubt that you would want to edit an interface. 

You probably want to edit programs.


>I am sure this has been asked loads of times.


Yes, you might say that your Question is Asked Frequently
(which should be a hint as to where to look for an answer).


>I have looked in this news group for answers bit could not find any...


Have you looked at the Perl FAQs?

You must have, since you're posting here and you have to do that
before posting. You must have missed it...


>Anyway my question.

>I am after some thing that will highlight Vars, Sub routines & comments Etc.


Perl FAQ, part 3:

   "Is there an IDE or Windows Perl Editor?"


>Could anyone recommend a program which would do this???


vi or emacs.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 29 Mar 2001 22:51:03 GMT
From: bogus@erol.com (---Pete---)
Subject: Re: Perl / CGI Editors
Message-Id: <3ac3b603.363775052@news.earthlink.net>

>I currently do quite a bit of CGI scripting for web pages, I am using a
>Program called PFE "I'm sure you would have heard of it"
>This is a great program for small scripts where it is easy to keep track but
>I am after some thing that will highlight Vars, Sub routines & comments Etc.
-------
Mark & everyone, there is a new/first release of .... Visual Perl IDE,
an integrated development environment for writing and debugging
perl scripts under Windows.

This program is written with Delphi 5 and Perl, and it is OpenSource,
distributed under Mozilla Public License !  

And here are the key features:

-Perl Syntax Coloring

-Script lines with syntax errors will be highlighted in editor window.

-Insertion and deletion of breakpoints with one mouse click.

-View and edit of variables in a hierarchical watch tree.

-Hint evaluation: Variables under the mouse cursor will be evaluated
and shown as hint.

So, if you want to download or get further information about Visual
Perl IDE, or if you just want to see some screenshots, please visit
http://www.lost-sunglasses.de or http://visual-perl.sourceforge.net


PS: I found the basic message above at... comp.lang.perl.announce
Just a few days ago (~3/27/01),  I downloaded and installed a copy
and tried it on my PC. I loaded a simple HELLO_WORLD PERL script
and tried the RUN function -- Nothing happened so I went looking for
the DOCS for Visual Perl IDE but could not locate any. I contacted the

author and he replied that there are no DOCs released yet and that
he'd have something in a few days.

Anyway, I tried using it just for the basic edit functions where it
displays different colors for variables, functions, etc., and that
works ok with a few minor bugs but it is certainly usable for editing
PERL code. Then I click save, and simply open a DOS window 
to test my code while leaving the editor window open too.

I would recommend it but I think we will need to support the author
by reporting and bugs found or by making suggestions as to 
features we would like to see incorporated.

BTW: I'm a Visual Basic progammer too. The following comment
 is for other VB/PERL programmers.  This Visual Perl IDE app
works similar to the VB IDE editor except it's in in infantcy phase.
I think that the VB IDE should be the basic model for functionality.
Visual Perl IDE has good potential but currently only does a fraction
of what the VB IDE can do.  So, it's gonna take all of us contributing
with feedback to the author.. that is if he is open to suggestions and
will actually implement them.

---pete---



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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V10 Issue 589
**************************************


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