[16316] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3728 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 11:03:13 2000

Date: Tue, 18 Jul 2000 08:03:03 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963932583-v9-i3728@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3728

Today's topics:
    Re: reg expression not working. WHY??? (Drew Simonis)
    Re: reg expression not working. WHY??? (Pasquale)
    Re: reg expression not working. WHY??? (Godzilla!)
    Re: Regex Never satisfied (Bernard El-Hagin)
        regular expression - html tag-esque pattern (Blair Heuer)
    Re: regular expression - html tag-esque pattern (Bart Lateur)
        Renaming files trough Perl? <trondage@langtind.no>
    Re: Renaming files trough Perl? <cal@iamcal.com>
    Re: Renaming files trough Perl? <mike.solomon@eps.ltd.uk>
        scripting question (TT)
        Search a string for &lt; and replace it with < (Raphael Pirker)
    Re: Search a string for &lt; and replace it with < (Ecco)
    Re: Search a string for &lt; and replace it with < (jason)
    Re: Search a string for &lt; and replace it with < (Raphael Pirker)
    Re: Search a string for &lt; and replace it with < (NightWish)
    Re: Search a string for &lt; and replace it with < (Alan J. Flavell)
    Re: Search a string for &lt; and replace it with < (Tony Curtis)
    Re: Search a string for &lt; and replace it with < (Steven Smolinski)
    Re: Search a string for &lt; and replace it with < (Raphael Pirker)
    Re: Search a string for &lt; and replace it with < (jason)
    Re: Search a string for &lt; and replace it with < (jason)
        searching for a # within a range ()
    Re: Sending data to a web server. (Bob Walton)
    Re: sending mail from perl (Alex T.)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 12 Jul 2000 20:00:08 GMT
From: care227@attglobal.net.bbs@openbazaar.net (Drew Simonis)
Subject: Re: reg expression not working. WHY???
Message-Id: <3bNSC9$Wzx@openbazaar.net>

Pasquale wrote:
>
> The conditional statement
> does not seem to be matching/working??  Thanks in advance!!
> Pasquale
>
> $address = $formdata{'address'};
> $price = $formdata{'price'};

You aren't using CGI.pm, are you?  Thats likely your third mistake.
(I assume you haven't used -w or strict pragma either)



> open(LOGFILE, "test.log");

Should read: open LOGFILE, "test.log" or die "Can't open: $!\n";

> @entries = <LOGFILE>;
> close(LOGFILE);
>
> foreach $line(@entries) {
>   chomp($line);
>   @cells = split(/::/, $line);
>        if ($address eq $cells[3]) {
>        $cells[0] = $price;
>         last;
>      }
> }

Try this, its easier to type, but a little more cloudy.  I'll also
added some print statments that should make debugging easier.  You'll
remove them when you've seen the problem.

 for(@entries) {                # work with the default $_ varible
   chomp;                       # works on $_ by default
   @cells = split /::/;         # also works on $_ by default
        if ($address eq $cells[3]) {
        $cells[0] = $price;
         last;
      }
 }


So, for a completed snippet (sans the CGI.pm way of getting data), we
have:

my $address = $formdata{'address'};
my $price = $formdata{'price'};

print $address, "\n";
print $price, "\n";

open LOGFILE, "test.log" or die "Can't open logfile: $!\n";
chomp(@entries = <LOGFILE>); #nasty newlines
close(LOGFILE);

for(@entries)
{
   @cells = split /::/;
   print $cells[3], "\n";
   if ($address eq $cells[3])
   {
       $cells[0] = $price;
       last;
   }
}

But you are aware that they array is being clobbered with
each iteration.  I'm sure thats why you've included the last
command, but I just wanted to make sure.


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

Date: 12 Jul 2000 23:00:02 GMT
From: pdmos23@geocities.com.bbs@openbazaar.net (Pasquale)
Subject: Re: reg expression not working. WHY???
Message-Id: <3bNWj4$XPi@openbazaar.net>

Thanks, but it still is not working.  Do I really need to use CGI.pm to
get this to work?  I'm not too familiar with linking to that module.  I
never have had to.  The variables you suggested to be printed are
printing OK.  It happen to be something I was trying previously to "see"
things.
This is the rest of the code following what I previously sent. I don't
know if it has anything to do with the problem.  I don't think it would,
but....who knows.  Thanks again!!

open(LOGFILE, "> test.tmp") || die "Can't open logfileB $!\n";
foreach $row(@entries) {
print LOGFILE "$row\n";
}
close(LOGFILE);
rename("test.tmp", "test.log") || die "Can't rename $!\n";

open(LOGFILE, "test.log") || die "Can't open logfileC $!\n";
@entry = <LOGFILE>;
close(LOGFILE);

print "Content-type: text/html\n\n";
print "<body>\n";
print "<table>\n";

foreach $line(@entry) {
@field = split(/::/, $line);
print "<tr><td>$field[2]&nbsp;<td>$field[3]<td>$field[1]<td>$field[0]\n";

}

print "</table>\n";
1;





Drew Simonis wrote:

> Pasquale wrote:
> >
> > The conditional statement
> > does not seem to be matching/working??  Thanks in advance!!
> > Pasquale
> >
> > $address = $formdata{'address'};
> > $price = $formdata{'price'};
>
> You aren't using CGI.pm, are you?  Thats likely your third mistake.
> (I assume you haven't used -w or strict pragma either)
>
> > open(LOGFILE, "test.log");
>
> Should read: open LOGFILE, "test.log" or die "Can't open: $!\n";
>
> > @entries = <LOGFILE>;
> > close(LOGFILE);
> >
> > foreach $line(@entries) {
> >   chomp($line);
> >   @cells = split(/::/, $line);
> >        if ($address eq $cells[3]) {
> >        $cells[0] = $price;
> >         last;
> >      }
> > }
>
> Try this, its easier to type, but a little more cloudy.  I'll also
> added some print statments that should make debugging easier.  You'll
> remove them when you've seen the problem.
>
>  for(@entries) {                # work with the default $_ varible
>    chomp;                       # works on $_ by default
>    @cells = split /::/;         # also works on $_ by default
>         if ($address eq $cells[3]) {
>         $cells[0] = $price;
>          last;
>       }
>  }
>
> So, for a completed snippet (sans the CGI.pm way of getting data), we
> have:
>
> my $address = $formdata{'address'};
> my $price = $formdata{'price'};
>
> print $address, "\n";
> print $price, "\n";
>
> open LOGFILE, "test.log" or die "Can't open logfile: $!\n";
> chomp(@entries = <LOGFILE>); #nasty newlines
> close(LOGFILE);
>
> for(@entries)
> {
>    @cells = split /::/;
>    print $cells[3], "\n";
>    if ($address eq $cells[3])
>    {
>        $cells[0] = $price;
>        last;
>    }
> }
>
> But you are aware that they array is being clobbered with
> each iteration.  I'm sure thats why you've included the last
> command, but I just wanted to make sure.


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

Date: 14 Jul 2000 02:00:01 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: reg expression not working. WHY???
Message-Id: <3bOR61$VmM@openbazaar.net>

Pasquale wrote:
 
> Can someone please help me "see the light" as to where the
> problem is with this snippet of code?

(snip)

Only you can open your eyes and truly see the light.

I can help you see your problem first time you
run your program. Copy and paste this code into
your script as a replacement for this code snippet
you posted with your article.

Sound thinking and good logic both dictate you
make a visual comparison of your input data and
your data arrays. In this sense, perhaps you will
see the light, right off.

I've included some better error checking methods
for file opening and array creation than the usual
cargo cult crud people around here demand and
command everyone use. Look it over; it is more
logical than the ho-hum usual strict thinking
of Perl 5 Cargo Cultists.

If you still have a problem, equally sound
thinking and good logic dictate you look close
at your read and parse routine; what is it
passing through which may be invisible?

I am curious what relationship there is between
an address and a price along with being curious
why you need to change your input price.

This snippet has been exhaustively tested under
realistic internet working conditions and works
perfect. Do not respond with "This doesn't work."


Godzilla!



$address = $formdata{'address'};
$price = $formdata{'price'};

open(LOGFILE, "test.log");
@entries = <LOGFILE>;
close(LOGFILE);

if (!(@entries))
 { print "File Open And Array Creation Failed."; exit; }
else
 { chomp (@entries); }

foreach $line(@entries)
 {
  print "Entries Line Is: $line \n";

  @cells = split(/::/, $line);

  if (!(@cells))
   { print "\n\nCells Array Creation Failed."; exit; }

  print "Cells 0 Is: $cells[0]\n",
        "Cells 1 Is: $cells[1]\n",
        "Cells 2 Is: $cells[2]\n",
        "Cells 3 Is: $cells[3]\n",
        "Address Is: $address\n\n";

  if ($address eq $cells[3])
   {
    $cells[0] = $price;
    last;
   }
 }

 print "Final Results Are:\n\n",
       "Cells 0 Is: $cells[0]\n",
       "Cells 1 Is: $cells[1]\n",
       "Cells 2 Is: $cells[2]\n",
       "Cells 3 Is: $cells[3]\n",
       "Address Is: $address\n",
       "Price Is:   $price";

exit;


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

Date: 12 Jul 2000 14:00:04 GMT
From: bernard.el-hagin@lido-tech.net.bbs@openbazaar.net (Bernard El-Hagin)
Subject: Re: Regex Never satisfied
Message-Id: <3bNIg7$XHw@openbazaar.net>

On Wed, 12 Jul 2000 14:38:24 +0100, John <john@nomailplease> wrote:
>
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
>news:slrn8moi52.9rf.bernard.el-hagin@gdndev25.lido-tech...
>> On Wed, 12 Jul 2000 10:40:39 +0100, John <john@nomailplease> wrote:
>> >At last I feel the arcane mystery of regex starting to reveal itself to
>me !
>> >
>> >However chuffed I am that my code below works I would appreciate it if
>> >someone would show me how it could be done a bit better.
>> >I'm sure it could be done in two lines by not destroying the RHS but am
>> >stumped.
>> >
>> >Thanks, JohnShep
>> >
>> >  $alpha = $numeric = $string_in;
>> >  $alpha =~ s/[\W]|[\d]//g; # remove any non letters
>> >  $numeric =~ s/[\D]//g; # remove any non digits
>>
>> If you want these in two different variables (as you seem to ) then the
>> only improvements and/or simplifications I can think of are:
>>
>> $alpha =~ s/[\W\d]//g;
>>
>> and
>>
>> $numeric =~ s/\D//g;
>>
>Yes that's what I need, I was imagining a regex that was something like
>$alpha = extract_alpha_from $string_in;
>$numeric = extract_numeric_from $string_in;
>thanks John

You mean something like this:

($some_variable) = $string_to_search =~ m/some(.*)regex/;

which would put $1 into $some_variable if there's a match in
$string_to_search.

But I don't know if that's possible in your case since you haven't
provided an input string. If, for example, your input is...

$string_in = "aaa999bbb";

 ...and you want just the numbers you can use:

($nums) = $string_in =~ m/(d\+)/;

But if...

$string_in = "a8d8w7823y34uwierwe87234";

 ...and you still want just the numbers, you have to use s/// or some
other way (a map, possibly). Of course there could be a way to use the
($a) = $b =~ /(.*)/ form, but I don't know how.  You can be sure,
though, that if it's possible someone here will post it. :-)

Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#


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

Date: 17 Jul 2000 22:00:02 GMT
From: ab@cd.com.bbs@openbazaar.net (Blair Heuer)
Subject: regular expression - html tag-esque pattern
Message-Id: <3bRQg1$T9Y@openbazaar.net>

I am writing a message board script that uses templates for the layout of
the output page. In the templates are custom tags which need to be found and
replaced. I originally used the tag format, [out author], to set where and
what was replaced. I was able to use the following code to do what I wanted:

    $template =~ s/\Q[\E(\w+)\s(\w+\.*\w*\.*\w*)\Q]\E/&process($1,$2)/gie;
        # \Q[\E could probably just have been \[, but I was being verbose
        # &process takes the found string, processes it, and returns the
apropriate value
        # (\w+\.*\w*\.*\w*) is how it is, since some tags could be [in
text.author.post] or whatever

That worked, but was limited, since I had to remember what word.word.word
orders were for each tag and this is for a service to offer, so I wanted a
simpler format. What I want to be able to do is use a format of: [out
name="author"] that can have more than one attribute as well as qouted and
unqouted values such as: [out name=author value="Not Here"].

The problem is, I cannot figure out how to search/replace to get the values.
What I have come up with so far is:

    $template =~ s/\[(\w+)\s*(.*)\]/&process($1,$2)/gie;

    sub process() {

            my %tag;
            foreach $each ( split(/\s+/, $_[1]) ) {
            my @tag = split( /\=/, $each );
                    $tag{ $tag[0] } = $tag[1];
            }
    ...
    }

That takes the tag puts the type (such as 'out' used above) into $1 and the
rest of the tag into $2. Then it splits it into values, or at least should.
the way it goes something like name="Blair Heuer" would be split and
everything would be messed up.

So how would I have it split the tag apart without spliting the spaces
within qoutes?
Aso,the code above does not work even with no spaces in the values, any
ideas why?
Also, if two tags are next to each other, it puts them all as one, any way
to fix that?
        ([out author][out email] would be read from the first [ to the
last ] )
Finally, if anyone knows a better way to do this, please tell me.

Thanks for any help,
Blair Heuer


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

Date: 17 Jul 2000 23:40:04 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: regular expression - html tag-esque pattern
Message-Id: <3bRTN4$UqP@openbazaar.net>

Blair Heuer wrote:

>What I want to be able to do is use a format of: [out
>name="author"] that can have more than one attribute as well as qouted and
>unqouted values such as: [out name=author value="Not Here"].

>The problem is, I cannot figure out how to search/replace to get the values.
>What I have come up with so far is:
>
>    $template =~ s/\[(\w+)\s*(.*)\]/&process($1,$2)/gie;

>Also, if two tags are next to each other, it puts them all as one, any way
>to fix that?
>        ([out author][out email] would be read from the first [ to the
>last ] )

Greediness. Replace "(.*)" with "(.*?)".

>Finally, if anyone knows a better way to do this, please tell me.

I would go for a more specific parserlike thingie. For example, you can
check for:

	$_ = q[name=author value="Not Here"];
	@attributepairs = /(\w+\s*=\s*(?:"[^"]*"|'[^']*'|\w+))/g;
	foreach (@attributepairs) {
	    my($key, $value) = split /\s*=\s*/, $_, 2;
	    # do something with each $key and $value:
	    print "$key -> $value\n";
	}

You might have to replace the '\w's with a custom, better adapted
character class.

--
	Bart.


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

Date: Tue, 18 Jul 2000 11:06:29 GMT
From: "Trond Aage Langtind" <trondage@langtind.no>
Subject: Renaming files trough Perl?
Message-Id: <VSWc5.3103$Dxe.185918464@news.telia.no>

How do I make a perl script that rename a file. I'm running UNIX.


Trond Aage







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

Date: Tue, 18 Jul 2000 12:18:17 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Renaming files trough Perl?
Message-Id: <F1Xc5.265$uY6.5238@news6-win.server.ntlworld.com>

"Trond Aage Langtind" <trondage@langtind.no> wrote...
:
: How do I make a perl script that rename a file. I'm running UNIX.
:

rename "oldfile", "newfile";

you really didn't read the FAQs did you?


--
Cal Henderson

sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);




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

Date: Tue, 18 Jul 2000 12:57:05 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: Renaming files trough Perl?
Message-Id: <8l1gpe$3eaje$1@ID-36965.news.cis.dfn.de>

try

perldoc -f rename

Regards

Mike Solomon

Trond Aage Langtind <trondage@langtind.no> wrote in message
news:VSWc5.3103$Dxe.185918464@news.telia.no...
> How do I make a perl script that rename a file. I'm running UNIX.
>
>
> Trond Aage
>
>
>
>
>




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

Date: 11 Jul 2000 20:50:02 GMT
From: tjturner@chpc.utah.edu.bbs@openbazaar.net (TT)
Subject: scripting question
Message-Id: <3bMe2V$Vm8@openbazaar.net>

Hello;

Please help me get the elseif statement at the bottom which I commented
to work.

I'm getting the error tailing the apache log file:

disconnect(DBI::db=HASH(0x81d5c90)) invalidates 1 active statement.
Either destroy statement handles or call finish on them before
disconnecting. at /usr/local/apache/cgi-bin/piinfo.pl line 68.

All I want is that if no value exists in my database, the elseif of user
not found html/cgi web content would be returned.

Thank you for your time.


#!/usr/bin/perl

use CGI qw(param);
use DBI;

$usrvar = param("Query");

$userfile='/usr/local/apache/cgi-bin/usernames';

open(USERS, "<$userfile") or die "could not open file userfile";

$dbh = DBI->connect("dbi:Pg:dbname=newqbank", "postgres");

if ( !defined $dbh ) {
die "Cannot connect to database!\n";
}

if ($usrvar ne undef) {
$sth = $dbh->prepare("select username, realname from userinfo where
username='$usrvar'");
$sth->execute;

while(@row = $sth->fetchrow()) {
    if (@row ne undef) {
 ($realname, $realname2, $username, $username2)=(split, @row);

#{ print USERS "@row\n"; }

print "Content-type: text/html

<html>
<title>Account Allocation Form</title>

<body bgcolor=#ffffff text=#000000 link=#3333ff vlink=#ff3333
alink=#33ff33>
<td align=left><font face=\"Arial,Helvetica\" color=black><b>
<table>
<tr>  <font size=+1><b>QBank PI INFO:</b><br></font>
<td align=left><font
face=\"Arial,Helvetica\"><B>USERID:</B>&nbsp;&nbsp;$realname&nbsp;</font></td>

<td align=left><font
face=\"Arial,Helvetica\">&nbsp;&nbsp;&nbsp;</font></td>
<td align=left><font
face=\"Arial,Helvetica\"><B>NAME:</B>&nbsp;&nbsp;&nbsp;$realname2&nbsp;</font></td>

<td align=left><font
face=\"Arial,Helvetica\">&nbsp;&nbsp;&nbsp;</font></td>
<td align=left><font
face=\"Arial,Helvetica\"><B>SU's:</B>&nbsp;&nbsp;test&nbsp;</font></td>
<td align=left><font
face=\"Arial,Helvetica\">&nbsp;&nbsp;&nbsp;</font></td>
<td align=left><font
face=\"Arial,Helvetica\"><B>CONSUMED:</B></font></td>
<td align=left><font
face=\"Arial,Helvetica\">&nbsp;&nbsp;test&nbsp;</font></td>
<td align=left><font
face=\"Arial,Helvetica\"><B>PERCENTAGE:</B></font></td>
<td align=left><font
face=\"Arial,Helvetica\">&nbsp;&nbsp;test&nbsp;</font></td>
</table>
</body>
</html>";
}

# Can't get this  else if to return

elsif ($sth->rows == 0) {

print "Content-type: text/html

<html>
<title>CHPC Account Allocation Form</title>

<body bgcolor=#ffffff text=#000000 link=#3333ff vlink=#ff3333
alink=#33ff33>

<h2>This PI wasn't found</h2>

</body>
</html>";

}

$dbh->disconnect;

}
}
close(USERS);


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

Date: 16 Jul 2000 22:30:03 GMT
From: raphaelp@nr1webresource.com.bbs@openbazaar.net (Raphael Pirker)
Subject: Search a string for &lt; and replace it with <
Message-Id: <3bQc7R$W1o@openbazaar.net>

Hi guys,

Ok, I have no Idea with this but what I want to do is search the variable
$html_code for possible &lt; codes (the string is about 10k in size) and
replace all the &lt; with <. How do I do that in Perl?

Thanks in advance,

Raphael


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

Date: 16 Jul 2000 23:10:01 GMT
From: ecco64@chello.nl.bbs@openbazaar.net (Ecco)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQd9R$USL@openbazaar.net>

$html_code =~ s/&lt/</g;

Just a wild guess, i'm a newbie... but this should do the trick I think...
--
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/free_video/

"Raphael Pirker" <raphaelp@nr1webresource.com> wrote in message
news:8ktd3n$u7r$17$1@news.t-online.com...
> Hi guys,
>
> Ok, I have no Idea with this but what I want to do is search the variable
> $html_code for possible &lt; codes (the string is about 10k in size) and
> replace all the &lt; with <. How do I do that in Perl?
>
> Thanks in advance,
>
> Raphael
>
>


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

Date: 16 Jul 2000 23:10:01 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQd9S$UWK@openbazaar.net>

Raphael Pirker wrote ..
>Ok, I have no Idea with this but what I want to do is search the variable
>$html_code for possible &lt; codes (the string is about 10k in size) and
>replace all the &lt; with <. How do I do that in Perl?

from the command line run

  perldoc perlop

and scroll down to "Regexp Quote-Like Operators"

--
  jason -- elephant@squirrelgroup.com --


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

Date: 16 Jul 2000 23:30:00 GMT
From: raphaelp@nr1webresource.com.bbs@openbazaar.net (Raphael Pirker)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQdYO$W5Z@openbazaar.net>

> >$html_code =~ s/&lt/</g;
>                  ^^^
>
> This won't replace a single occurrence of '&lt;' with anything.
Actually it did...

Only that there was the ; missing:

$html_code =~ s/&lt;/</g;

> Testing would have let you know for sure.  It's not nice to make
> people waste their time running down your wild guesses.
Well, it wasted 5 seconds... :-) Not knowing it at all would have wasted a
lot more!


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

Date: 17 Jul 2000 00:00:01 GMT
From: ?@?.?.bbs@openbazaar.net (NightWish)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQeO0$TPe@openbazaar.net>

Backoff Jason, he was just trying to help, and he did a hell of a lot more
than you did, so go bother your mom!


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

Date: 17 Jul 2000 00:10:01 GMT
From: flavell@mail.cern.ch.bbs@openbazaar.net (Alan J. Flavell)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQeaP$Wzn@openbazaar.net>

On Sun, 16 Jul 2000, Ecco wrote:

> Just a wild guess,

Please don't: there's more than enough mess around here that the
regulars feel they have to clean up (and thus waste time where they
could otherwise be helping us).

> i'm a newbie...

gosh, as if that hadn't been obvious.

Stick around, keep reading.  Just reading, for the time being.


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

Date: 16 Jul 2000 23:50:02 GMT
From: tony_curtis32@yahoo.com.bbs@openbazaar.net (Tony Curtis)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQeBR$Vjb@openbazaar.net>

>> On Sun, 16 Jul 2000 23:32:38 GMT,
>> elephant@squirrelgroup.com (jason) said:

> Steven Smolinski wrote ..
>> Ecco <ecco64@chello.nl> wrote:
>>
>>>  $html_code =~ s/&lt/</g;
>>
>> This won't replace a single occurrence of '&lt;' with
>> anything.

> actually - it will replace all occurences of '&lt;' with
> '<;' ..  certainly not what the originator wanted (but
> that's nothing new for Ecco)

Yes, but that's an incomplete description, as it will also
replace a terminal "&lt" with "<".

    http://search.cpan.org/search?dist=HTML-Parser

might be a good thing to try (HTML::Entities)

> Ecco is quickly gaining the reputation for posting
> completely out of place responses that have either
> entirely missed the point - or produce more errors that
> they're worth .. or both

Getting to be a trend round these parts...

hth
t
--
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: 16 Jul 2000 23:20:02 GMT
From: sjs@yorku.ca.bbs@openbazaar.net (Steven Smolinski)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQdM3$V82@openbazaar.net>

Ecco <ecco64@chello.nl> wrote:

[...jeopardectomy...]

>"Raphael Pirker" <raphaelp@nr1webresource.com> wrote:
>> Ok, I have no Idea with this but what I want to do is search the variable
>> $html_code for possible &lt; codes (the string is about 10k in size) and
>> replace all the &lt; with <. How do I do that in Perl?
>
>$html_code =~ s/&lt/</g;
                 ^^^

This won't replace a single occurrence of '&lt;' with anything.

>Just a wild guess, i'm a newbie... but this should do the trick I think...

Testing would have let you know for sure.  It's not nice to make
people waste their time running down your wild guesses.

Steve


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

Date: 16 Jul 2000 23:50:02 GMT
From: raphaelp@nr1webresource.com.bbs@openbazaar.net (Raphael Pirker)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQeBQ$Vfc@openbazaar.net>

> there's a time to teach and a time to learn
I'd say it's the will that counts, too! If the code would have been 100%
wrong, I would complain as well, but since there was only that one little
mistake... (which was probably a typo?)


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

Date: 16 Jul 2000 23:30:01 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQdYP$W9y@openbazaar.net>

Steven Smolinski wrote ..
>Ecco <ecco64@chello.nl> wrote:
>
>[...jeopardectomy...]
>
>>"Raphael Pirker" <raphaelp@nr1webresource.com> wrote:
>>> Ok, I have no Idea with this but what I want to do is search the variable
>>> $html_code for possible &lt; codes (the string is about 10k in size) and
>>> replace all the &lt; with <. How do I do that in Perl?
>>
>>$html_code =~ s/&lt/</g;
>                 ^^^
>
>This won't replace a single occurrence of '&lt;' with anything.

actually - it will replace all occurences of '&lt;' with '<;' ..
certainly not what the originator wanted (but that's nothing new for
Ecco)

>>Just a wild guess, i'm a newbie... but this should do the trick I think...
>
>Testing would have let you know for sure.  It's not nice to make
>people waste their time running down your wild guesses.

Ecco is quickly gaining the reputation for posting completely out of
place responses that have either entirely missed the point - or produce
more errors that they're worth .. or both

there's a time to teach and a time to learn

--
  jason -- elephant@squirrelgroup.com --


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

Date: 17 Jul 2000 02:40:13 GMT
From: elephant@squirrelgroup.com.bbs@openbazaar.net (jason)
Subject: Re: Search a string for &lt; and replace it with <
Message-Id: <3bQiWD$WPs@openbazaar.net>

Raphael Pirker wrote ..
>> there's a time to teach and a time to learn
>
>I'd say it's the will that counts, too! If the code would have been 100%
>wrong, I would complain as well, but since there was only that one little
>mistake... (which was probably a typo?)

yeah .. but nothing is done in isolation .. this response from Ecco to
your issue here was one of a number of incorrect posts by Ecco .. just
because Ecco's incomplete guess here happened to lead you to the correct
answer doesn't make it any less dangerous in the bigger picture

did the responses that you received in your "communicating through the
location bar" thread from Ecco lead you to similar realisations ?

anyone who confesses to hating the FAQs isn't going to do much good in
the long run

to your original query .. you really will do your Perl understanding a
favour by following my (and others') advice and checking out the "Regexp
Quote-Like Operators" documentation in the perlop manual

  perldoc perlop

from the command line

--
  jason -- elephant@squirrelgroup.com --


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

Date: 18 Jul 2000 06:50:01 GMT
From: padme67@my-deja.com.bbs@openbazaar.net ()
Subject: searching for a # within a range
Message-Id: <3bReWP$XXa@openbazaar.net>

I am new to Perl, cgi and coding...
That said I am trying to do a search on a database that will determine
if any value in the database falls into a user defined range.
1)I have a drop-down menu that a user can choose a price range(i.e.
$150,000-200,000 etc.)
2)When submitted my program looks through the db to find any values
that fall into the range chosen.

I can pattern match with words or phrases but finding a # in a range
has me stumped.  If someone could just push me in the right direction I
would be eternally grateful!

Thanks,
padme67


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Jul 2000 12:40:01 GMT
From: bwalton@rochester.rr.com.bbs@openbazaar.net (Bob Walton)
Subject: Re: Sending data to a web server.
Message-Id: <3bQMc1$TDh@openbazaar.net>

Guy wrote:
>
> Does anybody know how I can send data to a web server using a perl script.
> (like submitting a form but without using HTML forms on the client side)
> For example: instead of logging in manually to my web-mail account (using
> their HTML forms: name, password) I would like to run a perl script that
> knows my login name and password, and submits this information to the
> original form action URL. That way instead of going to let's say
> www.hotmail.com and logging in there, I just run my perl script and it
> automatically logs-in for me. (without using a browser during the procedure)
> If this sounds complicated, tell me and I'll try to explain it better.
 ...
> Guy
Take a look at the LWP module.  I think it might do what you want.
--
Bob Walton


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

Date: 12 Jul 2000 19:40:08 GMT
From: samara_biz@hotmail.com.bbs@openbazaar.net (Alex T.)
Subject: Re: sending mail from perl
Message-Id: <3bNRZ9$XyR@openbazaar.net>

Hey!

Yes, of course, there is. Here's how you do it:

You have your global variables which don't change:

#e-mail variables
$mailsender = 'your_e-mail@domain.com';
$mailserver = 'mail.domain.edu';

Then you have a subroutine: (You have to have libnet module installed,
ask again if you need directions on how to install this module)

####################################################################
#sends an e-mail
#input: subject, mailto, mailbody
#output: e-mail
####################################################################
sub Email{

  #passing the parameters
  my( $subject, $mailto, $mailbody) = @_;

  use Net::SMTP;

  $smtp = Net::SMTP->new($mailserver);

  $smtp->mail($mailsender);
  $smtp->to($mailto);

  $smtp->data();
  $smtp->datasend("Subject: $subject\n");
  $smtp->datasend("To: $mailto\n");
  $smtp->datasend("From: $mailsender\n\n");
  $smtp->datasend($mailbody);

  $smtp->datasend();
  $smtp->quit;
} #Email

So, then to send an e-mail all you have to do is to call this subroutine

like:

&Email('You subject goes here',
'the-person-you-want-to-email@somewhere.com', 'Hey there! This is a
short e-mail');



Hope that helps!

Alex

Benjamin David Garrison wrote:

> is there a way to send mail from perl from a windows platform?
>
> and, what are the modules that would be required for that?
>
> --
> Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
>  - There's a fine line between sitting through a calculus leture and
> sleeping -- Oh wait!  No there isn't.


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

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 V9 Issue 3728
**************************************


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