[18998] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1193 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 25 21:07:23 2001

Date: Mon, 25 Jun 2001 18:05:09 -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: <993517509-v10-i1193@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 25 Jun 2001     Volume: 10 Number: 1193

Today's topics:
    Re: counting matches (Jay Tilton)
    Re: counting matches <ren@tivoli.com>
    Re: counting matches (Tad McClellan)
        counting number of patterns (les ander)
    Re: counting number of patterns (Craig Berry)
    Re: E-mail help (Tad McClellan)
        Edit-In-Place? <ekdodge@plxw0541.pdx.intel.com>
    Re: Edit-In-Place? (Craig Berry)
    Re: how can i compile a perl program <EvR@compuserve.com>
    Re: How do I cope with pound (currency) sign? (isterin)
    Re: How do I cope with pound (currency) sign? <flavell@mail.cern.ch>
    Re: Perl *is* strongly typed (was Re: Perl description) <joe+usenet@sunstarsys.com>
    Re: Perl script from cron being mysteriously killed.  A (David Efflandt)
        problems with reading a file from a directory (Nina)
    Re: right symbol? (Randal L. Schwartz)
    Re: right symbol? <buggs-clpm@splashground.de>
    Re: right symbol? <ren@tivoli.com>
    Re: right symbol? <buggs-clpm@splashground.de>
    Re: right symbol? <flavell@mail.cern.ch>
    Re: right symbol? (Randal L. Schwartz)
    Re: right symbol? <buggs-clpm@splashground.de>
    Re: Script stops on multiple question marks <ren@tivoli.com>
        What is WRONG in my SCRIPT; Please Read <rig01@yahoo.com>
    Re: What is WRONG in my SCRIPT; Please Read <ren@tivoli.com>
    Re: What is WRONG in my SCRIPT; Please Read <rig01@yahoo.com>
        Where's ftp.perl.org? <tfbiv@SPAMMENOTerols.com>
    Re: Where's ftp.perl.org? (Clinton A. Pierce)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 25 Jun 2001 22:57:47 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: counting matches
Message-Id: <3b37b782.8247882@news.erols.com>

On 25 Jun 2001 15:01:11 -0700, les_ander@yahoo.com (les ander) wrote:

>I have a large string ($string) in which i have to 
>search for number of occurences of a pattern that is in a hash table. I 
>need to count the number of times this pattern occurs in the string
>but the compiler complains.

What exactly are its complaints?

>my $count;
>my $sub_string;
>my $len=length($string);
>
>#i have a hash table %patterns_tbl which has all the patterns
>
>for my $pattern(%patterns_tbl)

That will iterate over all keys and values in %patterns_tbl.
That's probably not what you want.
Assuming the patterns are only in the keys,

  for my $pattern(keys %patterns_tbl)

>{
>  for(my $i=0; $i<$len; $i++)
>  {
>     $sub_string=substr($string,$i,$len);
>     $count=$sub_string =~ tr/$pattern/$pattern/; 
>     $patterns_tbl{$pattern}=$count;
>   }
>   $count=0;
    ^ missing from your code
>}

tr/// has nothing to do with patterns.  It affects only single characters,
and variables like $pattern are not interpolated.
Manually marching through $string one character at a time is not the Perl
way.  The m// pattern-matching operator can do it for you.

  for my $pattern (keys %patterns_tbl) {
      $patterns_tbl{$pattern} = () = $string =~ m/$pattern/g;
  }

The intermediate () evaulates m//g in list context, which returns the
matched substrings.  Assigning from there to a scalar gives the number of
elements in the list.


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

Date: 25 Jun 2001 17:33:53 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: counting matches
Message-Id: <m34rt48a0e.fsf@dhcp9-173.support.tivoli.com>

On 25 Jun 2001, les_ander@yahoo.com wrote:

> Hi, I have a large string ($string) in which i have to search for
> number of occurences of a pattern that is in a hash table. I need to
> count the number of times this pattern occurs in the string but the
> compiler complains. can someone correct my code below.. thanks
> 
> my $count;
> my $sub_string;
> my $len=length($string);
> 
> #i have a hash table %patterns_tbl which has all the patterns

Are the patterns the keys or the values?

> for my $pattern(%patterns_tbl)

This loops over *both* the keys and the values, which is unlikely to
be what you want.

> {
>   for(my $i=0; $i<$len; $i++)
>   {
>      $sub_string=substr($string,$i,$len);

These seems like a strange thing to do....

>      $count=$sub_string =~ tr/$pattern/$pattern/; 

tr/// is for character replacement, not pattern matching.

>      $patterns_tbl{$pattern}=$count;

Ah... so the patterns are the keys and the values are meant to be the
counts.

>    }
>    count=0;
> }

How about something like:

$patterns_tbl{$_} = () = $string =~ /$_/g for keys %patterns_tbl;

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 25 Jun 2001 19:35:47 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: counting matches
Message-Id: <slrn9jfimj.e1v.tadmc@tadmc26.august.net>

les ander <les_ander@yahoo.com> wrote:

>I have a large string ($string) in which i have to 
>search for number of occurences of a pattern that is in a hash table. 


Hashes have keys and hashes have values. What are the keys and
values in your hash? I can see that one or the other is
supposed to be a "pattern", but I can't see which...


>I 
>need to count the number of times this pattern occurs in the string
>but the compiler complains. can someone correct my code below.. thanks
>
>my $count;
>my $sub_string;
>my $len=length($string);
>
>#i have a hash table %patterns_tbl which has all the patterns
>
>for my $pattern(%patterns_tbl)


So sometimes $pattern will be a hash key and sometimes it will
be a hash value. Is that what you want it to do? Or did you
mean to call the keys() or values() function there instead?


>{
>  for(my $i=0; $i<$len; $i++)


foreach my $i ( 0 .. length($string)-1 ) {


>  {
>     $sub_string=substr($string,$i,$len);
>     $count=$sub_string =~ tr/$pattern/$pattern/; 
                               ^^^^^^^^ ^^^^^^^^

Did you know that *neither one* of those actually _is_ a pattern?

tr/// does not use regular expressions.


>     $patterns_tbl{$pattern}=$count;
>   }
>   count=0;
   ^^
   ^^ where's the dollar sign?

>}


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


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

Date: 25 Jun 2001 16:15:38 -0700
From: les_ander@yahoo.com (les ander)
Subject: counting number of patterns
Message-Id: <a2972632.0106251515.1d0a1b3a@posting.google.com>

I made some errors in my previous mail so i am writing again.





i have 2 questions:


1) how do i count the number of patterns in a string?


 for examples if i have a string such as this..
$str="thissentencemakesnosenseandandandyoushouldignoreignoreit"; #no spaces 

how can i count the number of "and" in this string?

2) say i have a string called $pattern

and i need to replace all occurences of $pattern in $str
is it legal to write a variable in the tr/// operator?

(i have a array of patterns that i would like to count the number of
each occurences in the string $str, and wanted to count the number 
of occurences of each of them.}

thanks in advance


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

Date: Tue, 26 Jun 2001 00:14:44 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: counting number of patterns
Message-Id: <tjfkvk8deh1o87@corp.supernews.com>

les ander (les_ander@yahoo.com) wrote:
: 1) how do i count the number of patterns in a string?
:  for examples if i have a string such as this..
: $str="thissentencemakesnosenseandandandyoushouldignoreignoreit"; #no spaces 
: 
: how can i count the number of "and" in this string?

Two common idioms:

  my $count = 0;
  $count++ while $str =~ /and/g;
or
  my $count = () = $str =~ /and/g;

: 2) say i have a string called $pattern
: 
: and i need to replace all occurences of $pattern in $str
: is it legal to write a variable in the tr/// operator?

If $pattern can be more than one character, you'll want to use s///, not
tr///.  It's legal to use a variable in s///, though you should think
carefully about how you want it to behave if special regex characters
(like . or *, for example) appear in $pattern.

You can't use variables in tr///, by the way.

: (i have a array of patterns that i would like to count the number of
: each occurences in the string $str, and wanted to count the number 
: of occurences of each of them.}

  perldoc -q 'match many'

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Mon, 25 Jun 2001 17:00:55 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: E-mail help
Message-Id: <slrn9jf9k7.dvi.tadmc@tadmc26.august.net>

Blnukem <blnukem@hotmail.com> wrote:
>Hi All
>    I'm trying to send E-mail from a web form with 3 carbon copies and it
>only sends to the first one. But in the E-mail it list that copies where
>sent but there not here is my code.
>
>open (MAIL,"|/bin/sendmail -t");

You should always, yes *always*, check the return value from open()
even if it doesn't do what you really want it to do:

   open (MAIL,"|/bin/sendmail -t") or die "could not fork for sendmail $!";


See also:   perldoc -q pipe

   "Why doesn't open() return an error when a pipe open fails?"


>print MAIL "To: $FORM{'to'}\n";
>print MAIL "From: $FORM{'from'}\n;
                                ^^^
                                ^^^

Where is the closing double quote?

Are we wasting time troubleshooting code that does not even
really exist? Or does your real code have a syntax error?

Do not retype code, use copy/paste.



>print MAIL "Cc:$FORM{'cc1'}, $FORM{'cc2'}, $FORM{'cc3'}\n";
               ^^
               ^^
Where's the space?


>print MAIL "Subject: $FORM{'subject'}\n\n";
>
>print MAIL "$FORM{'body'}\n";
>
>close (MAIL);


Better check the return value from close() too when it is a pipe open:

   close (MAIL) or die "problem running sendmail";


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


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

Date: 25 Jun 2001 16:51:23 -0700
From: Edward K Dodge <ekdodge@plxw0541.pdx.intel.com>
Subject: Edit-In-Place?
Message-Id: <pgk4rt4m83o.fsf@plxw0541.pdx.intel.com>


Hi Guys,

I like to do things "old school" with shell commands because that is easier
for me to do most of what I need to do.  Unfortunately all this "power of
UNIX" has seriously degraded what few PERL skills I do have.

Anyone have some pet PERL code to edit a document in place?  In other words,
take the document and edit it without making another file, the same way a
text-editor or work-processor would do?

If I were doing this just for myself, I would normally just pipe some
text-editing commands to 'ed,' but the tool I need to make is going to be
used by other people.  Any help would be appreciated...

-- 

     ~       Edward Dodge
    . .      
   / V \     
  //   \\    
 /(     )\   
-  ^`~'^ - - 


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

Date: Tue, 26 Jun 2001 00:34:07 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Edit-In-Place?
Message-Id: <tjfm3v8fv3131a@corp.supernews.com>

Edward K Dodge (ekdodge@plxw0541.pdx.intel.com) wrote:
: I like to do things "old school" with shell commands because that is easier
: for me to do most of what I need to do.  Unfortunately all this "power of
: UNIX" has seriously degraded what few PERL skills I do have.

Considering that Perl was conceived as (in effect) a big load of Unix
shell tools all in one convenient jumbled pile, this is tough to
understand.  Unix shell expertise typically makes Perl seem more natural.

: Anyone have some pet PERL code to edit a document in place?  In other words,
: take the document and edit it without making another file, the same way a
: text-editor or work-processor would do?

You can do 'true' in-place editing by opening the file for read-and-update
('+<'), but typically that's both harder and more annoying than it needs
to be.  The more typical course for simple apps is to use the -i switch
and operate on files in the @ARGV array using the simple diamond <>
operator.  This will apply the script on the files 'in place' (really
optionally renaming away the original and rewriting a new version under
the original's name, but it amounts to the same thing for simple cases.) 
See 'perldoc perlrun' for details.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Mon, 25 Jun 2001 18:58:48 -0600
From: "Richard A. Evans" <EvR@compuserve.com>
Subject: Re: how can i compile a perl program
Message-Id: <9h8mms$f7r$1@sshuraaa-i-1.production.compuserve.com>

Try perl2exe -- the site is http://www.indigostar.com/perl2exe.htm

I have only experimented a bit, but it looks like it will do the job.

Regards,

Rick Evans

"Suraj Siddique" <surajsid@sharbatlyvillage.com.sa> wrote in message
news:993386227.563610@news...
> how can i compile a perl program to make an excecutable
>
>




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

Date: 25 Jun 2001 15:18:09 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: How do I cope with pound (currency) sign?
Message-Id: <db67a7f3.0106251418.7ced82ad@posting.google.com>

You would use it's hexidecimal equivalent.

Ilya


David Wake <dn131@yahoo.com> wrote in message news:<m1lmmgh391.fsf@da-nu.com>...
> I'm parsing some raw HTML from some British websites, and some of them
> contain the British pound (currency) sign in their raw HTML.  Can
> anyone tell me how I could parse this symbol in a regular expression?
> 
> Thanks,
> 
> David


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

Date: Tue, 26 Jun 2001 01:09:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do I cope with pound (currency) sign?
Message-Id: <Pine.LNX.4.30.0106260107380.29639-100000@lxplus003.cern.ch>

On 25 Jun 2001, isterin jeopardized:

> You would use it's hexidecimal equivalent.

If you want to make it unnecessarily non-portable between
different coding systems, you'd probably do that.




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

Date: 25 Jun 2001 18:23:28 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Perl *is* strongly typed (was Re: Perl description)
Message-Id: <m3d77sryfz.fsf@mumonkan.sunstarsys.com>

Buggs <buggs-clpm@splashground.de> writes:

> Joe Schaefer wrote:
> 
> > David Coppit <newspost@coppit.org> writes:
> > 
> >> The code I posted illustrates this. Two ostensibly equivalent scalars
> >> behaved differently under the same "closure of operations" on scalars.
> >> e.g. " 3 . '' " is a different scalar subtype than " 3 ".
> > 
> > I doubt you can find any Perl that treats ("3") different than (3).
> > Your prior code shows that (1/3 . '') is slightly different from (1/3),
> > but not in any meaningful sense:
> >
> 
> On initialization there is a difference between "3" and 3.
> 
> perl -MO=Terse -e '$foo = 3; $bar = "3";'
> 
> LISTOP (0x804ea80) leave [1]
>     OP (0x80baec8) enter
>     COP (0x805a280) nextstate
>     BINOP (0x804eac0) sassign
>         SVOP (0x804eae0) const  IV (0x804c218) 3
>         UNOP (0x804eb20) null [15]
>             SVOP (0x804eb00) gvsv  GV (0x805bd9c) *foo
>     COP (0x805a300) nextstate
>     BINOP (0x804e9e0) sassign
>         SVOP (0x804ea20) const  PV (0x805bdc0) "3"
>         UNOP (0x804ea00) null [15]
>             SVOP (0x804ea60) gvsv  GV (0x805bd30) *bar
> 
> 
> I'm not sure if this qualifies as "treat", but I'd say so.

I'd say no- you're peeking at perl's internals which does not count.
Neither does relying on any XS code, nor on perl bugs like

  % perl -e 'print $]'
  5.006001
  % perl -wle '$a=3; print ++$count for $a .. "0"'
  Name "main::count" used only once: possible typo at -e line 1.
  % perl -wle '$a=3; print ++$count for "$a" .. "0"' 
  Name "main::count" used only once: possible typo at -e line 1.
  1
  2
  3
  4
  5
  6
  7
  %  perl5.00503 -wle '$a=3;print ++$count for "$a" .. "0"'
  Name "main::count" used only once: possible typo at -e line 1.
  %

-- 
Joe Schaefer     "Never put off until tomorrow that which can be done the day
                                       after tomorrow."
                                               --Mark Twain



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

Date: Tue, 26 Jun 2001 00:56:19 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Perl script from cron being mysteriously killed.  Any ideas?
Message-Id: <slrn9jfndj.h2e.see-sig@typhoon.xnet.com>

On 25 Jun 2001 06:32:44 -0700, Frank <thoennes@pingsite.com> wrote:
> Hi all,
> 
> We have a cron that executes a shell script that executes a perl
> script every hour.  There are times when the perl script may take over
> an hour to complete processing (it does lots of DB queries and also
> sends out emails via sendmail).  We've noticed that if the script
> can't complete by the time the cron fires for the next hourly run, the
> script is "killed" and the new instance started. (This is verified
> through a log file).
> 
> When we simulate all this through an interactive login in a
> development server, everything seems to work fine.  In production
> however, no dice.  Both devel and prod are running Linux RedHat 6.2 (I
> believe).
> 
> Any ideas?  I would have thought the cron would just start a new
> instance of the script.  BY the way - the shell script does nothing
> more than a CD to the perl script directory and then launches said
> script.

Maybe it does, but maybe each instance steps on the other if you do not
properly flock files.  Rather than have a new instance go through its
paces when one is already running, have the script first check if more
than one instance of itself is running (grep ps) and have the new instance
exit gracefully if it is.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 25 Jun 2001 17:02:49 -0700
From: nina_samimi@yahoo.com.au (Nina)
Subject: problems with reading a file from a directory
Message-Id: <52fb0298.0106251602.351b1e84@posting.google.com>

Hi,
I am trying to open a directory and read a file which is compressed(.Z). 
I am getting an error "Use of uninitialized value at qf_system_blast.pl line 179."
what am I doing wrong?
can I read a compressed file? or should it be uncompressed first?
Here is the code I am using, please advise.


my @tempdir;
opendir(DIR, $mns_dir) || die("Cannot open directory");
print "$DIR is my directory!!!!!!!!";
while (my $tempfiles = readdir DIR) {
  print $tempfiles  if $tempfiles =~ /RPTPRINT.MNS206AR.24Jun01_13.37.48.Z/;}
closedir DIR;


Nina


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

Date: 25 Jun 2001 15:12:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: right symbol?
Message-Id: <m17ky043a9.fsf@halfdome.holdit.com>

>>>>> "Buggs" == Buggs  <buggs-clpm@splashground.de> writes:

Buggs> print   q(http://somewhere/abc.asp?param1=), $var1,
Buggs>         q(&param2=),format_string($var2);

Buggs> print "http://bla/foo.asp\?param1=$var1\&param2=${&format_string($var2)}";

Still wrong.  "&" needs to be written "&amp;" if you're sending it as
part of an <A HREF="...">.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 26 Jun 2001 00:25:46 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: right symbol?
Message-Id: <9h8dj1$t37$07$1@news.t-online.com>

Randal L. Schwartz wrote:

>>>>>> "Buggs" == Buggs  <buggs-clpm@splashground.de> writes:
> 
> Buggs> print   q(http://somewhere/abc.asp?param1=), $var1,
> Buggs>         q(&param2=),format_string($var2);
> 
> Buggs> print
> "http://bla/foo.asp\?param1=$var1\&param2=${&format_string($var2)}";
> 
> Still wrong.  "&" needs to be written "&amp;" if you're sending it as
> part of an <A HREF="...">.
> 


Yadda, yadda, yadda not wrong.
But I respect your concern for better HTML.
What about the questionmark?

Buggs


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

Date: 25 Jun 2001 16:50:37 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: right symbol?
Message-Id: <m3ofrc8c0i.fsf@dhcp9-173.support.tivoli.com>

On Mon, 25 Jun 2001, min_c_lee@yahoo.com wrote:

> Trying to print out the following query string:
> http://somewhere/abc.asp?param1=$var1&param2=$var2
> 
> it should be like:
> print "http://somewhere/abc.asp\?param1=$var1\&param2=$var2";
> 
> However, $var2 needs to be formatted using a subroutine:
> $var2 = &format_string($var2)";
> 
> How can I combine these two commands in one line (as follow) without
> confusing the ampersand sign as the start of the next parameter?
> 
> print
> "http://somewhere/abc.asp\?param1=$var1\&param2=&format_string($var2)";

print "http://somewhere/abc.asp?param1=$var1&param2=",
  format_string($var2);

("?" and "&" are not special in a string)

or, if you *really* want to embed the call in the string:

print "http://somewhere/abc.asp?param1=$var1&param2=${\format_string($var2)}";

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 26 Jun 2001 01:32:14 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: right symbol?
Message-Id: <9h8hfk$pd4$01$1@news.t-online.com>

Buggs wrote:

> Randal L. Schwartz wrote:
> 
>>>>>>> "Buggs" == Buggs  <buggs-clpm@splashground.de> writes:
>> 
>> Buggs> print   q(http://somewhere/abc.asp?param1=), $var1,
>> Buggs>         q(&param2=),format_string($var2);
>> 
>> Buggs> print
>> "http://bla/foo.asp\?param1=$var1\&param2=${&format_string($var2)}";
>> 
>> Still wrong.  "&" needs to be written "&amp;" if you're sending it as
>> part of an <A HREF="...">.
>> 
> 
> 
> Yadda, yadda, yadda not wrong.
> But I respect your concern for better HTML.
> What about the questionmark?
> 
> Buggs

Ren is right
print "... ${\format_string($var2)}";

and I like the combination most
print "... ${\&format_string($var2)}";

But the "\" is a must have unless your sub returns a reference
( and you don't want symbolic dereference, I'd guess ).


Have fun,
Buggs


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

Date: Tue, 26 Jun 2001 01:33:53 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: right symbol?
Message-Id: <Pine.LNX.4.30.0106260126170.29639-100000@lxplus003.cern.ch>

On Tue, 26 Jun 2001, Buggs wrote:

> Randal L. Schwartz wrote:
>
> > Still wrong.  "&" needs to be written "&amp;" if you're sending it as
> > part of an <A HREF="...">.

Sure.  Even if you're sending it as normal HTML text, you need to do
that.

The amusing feature of getting it wrong is that if it validates then
it'll cause trouble, whereas if it doesn't validate you'll probably
get away with it.  Consider ?print=yes&copy=5&lang=english , it
validates fine, but very few browsers do with it what the author
likely intended.  (Hint: copy and lang are HTML4 entity names).

> Yadda, yadda, yadda not wrong.
> But I respect your concern for better HTML.
> What about the questionmark?

You seem to have chosen rather an obtuse way of letting the hon.
Usenaut know that this part of the discussion is off topic here and
they'd get better answers by RTFFAQ or consulting a group that
specialises in the WWW aspects of this issue.

The rules for composing URLs (well, URIs) are clearly set out in the
RFC; how to express those URIs in HTML is clearly set out in the
relevant HTML specs.  There's no need to ask one-off questions here
about each individual character.

-- 

  "There is no actual [127.0.0.2] host and if there were it probably
   would not spam you."   - MAPS database entry



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

Date: 25 Jun 2001 16:57:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: right symbol?
Message-Id: <m1u2142juw.fsf@halfdome.holdit.com>

>>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:

Ren> print "http://somewhere/abc.asp?param1=$var1&param2=",
Ren>   format_string($var2);

Ren> ("?" and "&" are not special in a string)

But the ampersand is special to HTML.  You need to code it
as &amp; or the day you have a parameter called "copy", you'll
be unexpectedly surprised with a copyright symbol showing up.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 26 Jun 2001 02:02:49 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: right symbol?
Message-Id: <9h8j90$qla$03$1@news.t-online.com>

Alan J. Flavell wrote:

> On Tue, 26 Jun 2001, Buggs wrote:
> 
>> Randal L. Schwartz wrote:
>>
>> > Still wrong.  "&" needs to be written "&amp;" if you're sending it as
>> > part of an <A HREF="...">.
> 
> Sure.  Even if you're sending it as normal HTML text, you need to do
> that.
> 
> The amusing feature of getting it wrong is that if it validates then
> it'll cause trouble, whereas if it doesn't validate you'll probably
> get away with it.  Consider ?print=yes&copy=5&lang=english , it
> validates fine, but very few browsers do with it what the author
> likely intended.  (Hint: copy and lang are HTML4 entity names).
> 
>> Yadda, yadda, yadda not wrong.
>> But I respect your concern for better HTML.
>> What about the questionmark?
> 
> You seem to have chosen rather an obtuse way of letting the hon.
> Usenaut know that this part of the discussion is off topic here and
> they'd get better answers by RTFFAQ or consulting a group that
> specialises in the WWW aspects of this issue.
> 
> The rules for composing URLs (well, URIs) are clearly set out in the
> RFC; how to express those URIs in HTML is clearly set out in the
> relevant HTML specs.  There's no need to ask one-off questions here
> about each individual character.
> 

;-)

Reread the thread.
I may have an "obtuse way of letting the hon",
whatever that means - the word hon seems to be
nonexisting, but it was not about HTML.
And I didn't expect an answer to my question.


Buggs


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

Date: 25 Jun 2001 16:34:57 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Script stops on multiple question marks
Message-Id: <m3sngo8cqm.fsf@dhcp9-173.support.tivoli.com>

On 25 Jun 2001, dspidell@mta.ca wrote:

[snip]
> The problem is: If a response contains a string of 3 or more
> question marks, the script simply stops. The section of code is
> below.
> 
> if (($i > $start_value+$part_1_num)&($i <= $start_value+$part_2_num))
> #Checks to see which part of the assessment the current question is in
>   {
>     print "$response[$i], ";
>     my $temp_answer = $answers[$i-$start_value];
>     $temp_response = $response[$i];
>     if ($temp_answer =~ /< *$temp_response *>/)
>     {
>       $part_2++;
>     }
>   }
> 
> If the response is "etre???", the script prints "etre???," then
> quits.  It seems to stop when it hits the regular expression.

Are you intending the pattern to allow special regex characters?  Or
should that pattern match three literal "?"-s?  Or are you using a
wildcard-style pattern where "?" represents any character?

As you've written it, the response is treated as a regex, and "?" is
special there.  If you don't want it to be special, use quotemeta() or
"\Q".  If you *do* want the regex behavior, then realize that "???" is
not valid regex syntax.  Finally, if you want wildcard behavior, then
you need to preprocess the response:

$temp_response =~ s/\*/.*/g;
$temp_response =~ tr/?/./;

Unfortunately, this makes it difficult to handle other special regex
characters.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 25 Jun 2001 18:52:18 -0700
From: Peter <rig01@yahoo.com>
Subject: What is WRONG in my SCRIPT; Please Read
Message-Id: <2hpfjt4bu1vudjsuikio6g58ln6b38v1ir@4ax.com>


What is wrong ???

I am trying to transalte  all non printable characters  with blanks
but doesn't work .

This is my script : (I am using Octal repesentation)

perl -i.bak -p -e 'tr/\000-\007\013-\037\177-\377//'  myfile



I create a test file and I put a non printable char (Ctrl Z) in the
midle of the file.
 (Note :  Ctrl Z is equal to 032 in Octal and 1A in Hex)

myfile :

AAAAAAAAAAA
BBBBBBBBBBB
CCCCC   DDDD 
EEEEEEEEEEE
FFFFFFFFFFFFF

The RESULT after running the script is this  : (Removed all lines
after the non printable char )

 AAAAAAAAAAA
BBBBBBBBBBB
CCCCC




WAHT IS WRONG ????





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

Date: 25 Jun 2001 17:55:51 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: What is WRONG in my SCRIPT; Please Read
Message-Id: <m3zoaw6ufc.fsf@dhcp9-173.support.tivoli.com>

On Mon, 25 Jun 2001, rig01@yahoo.com wrote:

> 
> What is wrong ???
> 
> I am trying to transalte  all non printable characters  with blanks
> but doesn't work .
> 
> This is my script : (I am using Octal repesentation)
> 
> perl -i.bak -p -e 'tr/\000-\007\013-\037\177-\377//'  myfile

This doesn't translate them to anything.  You need to include a space
in the replacement section, or add a "d" modifier if you just want to
delete them.

> I create a test file and I put a non printable char (Ctrl Z) in the
> midle of the file.
>  (Note :  Ctrl Z is equal to 032 in Octal and 1A in Hex)
> 
> myfile :
> 
> AAAAAAAAAAA
> BBBBBBBBBBB
> CCCCC   DDDD 
> EEEEEEEEEEE
> FFFFFFFFFFFFF
> 
> The RESULT after running the script is this  : (Removed all lines
> after the non printable char )
> 
>  AAAAAAAAAAA
> BBBBBBBBBBB
> CCCCC

Is this on a DOS/Windows platform by any chance?  If so, Ctrl-Z is the
end-of-file indicator and you will need to put the filehandle in
binmode() to handle this issue.  Probably:

perl -i.bak -pe 'BEGIN{binmode(... uh-oh... I don't remember what the
default FILEHANDLE used by "-p" is... maybe F?  Oh well, the point is
that you need to call binmode().

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 25 Jun 2001 19:21:01 -0700
From: Peter <rig01@yahoo.com>
Subject: Re: What is WRONG in my SCRIPT; Please Read
Message-Id: <s6sfjt4rrhu5j98fn1sjeb8ige87uri0p5@4ax.com>


Hi   Ren :
 
Right!! Im using active perl in Win 2000 , and the script finished
in a premature way because of CTL  Z (eof file).

I will try BIMODE.

Thanks a lot REN .  	  



On 25 Jun 2001 17:55:51 -0500, Ren Maddox <ren@tivoli.com> wrote:

>On Mon, 25 Jun 2001, rig01@yahoo.com wrote:
>
>> 
>> What is wrong ???
>> 
>> I am trying to transalte  all non printable characters  with blanks
>> but doesn't work .
>> 
>> This is my script : (I am using Octal repesentation)
>> 
>> perl -i.bak -p -e 'tr/\000-\007\013-\037\177-\377//'  myfile
>
>This doesn't translate them to anything.  You need to include a space
>in the replacement section, or add a "d" modifier if you just want to
>delete them.
>
>> I create a test file and I put a non printable char (Ctrl Z) in the
>> midle of the file.
>>  (Note :  Ctrl Z is equal to 032 in Octal and 1A in Hex)
>> 
>> myfile :
>> 
>> AAAAAAAAAAA
>> BBBBBBBBBBB
>> CCCCC   DDDD 
>> EEEEEEEEEEE
>> FFFFFFFFFFFFF
>> 
>> The RESULT after running the script is this  : (Removed all lines
>> after the non printable char )
>> 
>>  AAAAAAAAAAA
>> BBBBBBBBBBB
>> CCCCC
>
>Is this on a DOS/Windows platform by any chance?  If so, Ctrl-Z is the
>end-of-file indicator and you will need to put the filehandle in
>binmode() to handle this issue.  Probably:
>
>perl -i.bak -pe 'BEGIN{binmode(... uh-oh... I don't remember what the
>default FILEHANDLE used by "-p" is... maybe F?  Oh well, the point is
>that you need to call binmode().



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

Date: Mon, 25 Jun 2001 18:36:11 -0400
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: Where's ftp.perl.org?
Message-Id: <e4ffjt498v91i2v4abjevkdn4206n360mc@4ax.com>

Trying to install modules on a new Red Hat 7.1 installation. I've used
PPM on Windows, but this is my first foray into the Linux world of
perl installation. The CPAN module is looking for files at
ftp.perl.org, which seems to be down? or gone?

TIA


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

Date: Tue, 26 Jun 2001 00:24:41 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Where's ftp.perl.org?
Message-Id: <dDQZ6.125765$DG1.20931814@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <e4ffjt498v91i2v4abjevkdn4206n360mc@4ax.com>,
	Tom Bates <tfbiv@SPAMMENOTerols.com> writes:
> Trying to install modules on a new Red Hat 7.1 installation. I've used
> PPM on Windows, but this is my first foray into the Linux world of
> perl installation. The CPAN module is looking for files at
> ftp.perl.org, which seems to be down? or gone?

<rumor>
The *.perl.org domains were having some DNS issues today (25th).
</rumor>

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 1193
***************************************


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