[24303] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6494 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 30 18:05:52 2004

Date: Fri, 30 Apr 2004 15: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)

Perl-Users Digest           Fri, 30 Apr 2004     Volume: 10 Number: 6494

Today's topics:
        CGI.pm Escaping query strings - ampersand issue <msalerno_rmhere_@bellsouth.net>
    Re: CGI.pm Escaping query strings - ampersand issue <msalerno_rmhere_@bellsouth.net>
    Re: CGI.pm Escaping query strings - ampersand issue <noreply@gunnar.cc>
        comparing decimal numbers <thens@NOSPAMti.com>
    Re: comparing decimal numbers (Kevin Collins)
    Re: comparing decimal numbers <dwall@fastmail.fm>
        distribute and install problem <as5yer_nh9ag@terra.es>
        First edition of _Programming perl_, how useful is it? (Alex Withers)
    Re: First edition of _Programming perl_, how useful is  <trammell+usenet@hypersloth.invalid>
        free source search engine (simple) ## comments? <webmaster @ infusedlight . net>
    Re: free source search engine (simple) ## comments? <spamtrap@dot-app.org>
    Re: free source search engine (simple) ## comments? <remorse@partners.org>
    Re: free source search engine (simple) ## comments? <xxala_qumsiehxx@xxyahooxx.com>
        How to tell Perl not to convert @mydomain.com part  ins (sams)
    Re: How to tell Perl not to convert @mydomain.com part  (Walter Roberson)
    Re: How to tell Perl not to convert @mydomain.com part  <spamtrap@dot-app.org>
    Re: How to tell Perl not to convert @mydomain.com part  (Walter Roberson)
    Re: How to tell Perl not to convert @mydomain.com part  <webmaster @ infusedlight . net>
    Re: How to tell Perl not to convert @mydomain.com part  <webmaster @ infusedlight . net>
    Re: How to tell Perl not to convert @mydomain.com part  <spamtrap@dot-app.org>
    Re: Howto: Search between 2 files <jtc@shell.dimensional.com>
    Re: I am so lost... sort and writing a shell script in  (Tsu-na-mi)
    Re: I am so lost... sort and writing a shell script in  <tore@aursand.no>
    Re: OSs with Perl installed <flavell@ph.gla.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 30 Apr 2004 16:45:24 -0400
From: "Matthew Salerno" <msalerno_rmhere_@bellsouth.net>
Subject: CGI.pm Escaping query strings - ampersand issue
Message-Id: <2Kykc.98000$UC4.69547@bignews2.bellsouth.net>


I have a cgi/mod_perl script that at one point it generates url's based on
directories:

foreach (@dirs){
    my $lnk = qq|<A HREF="index.cgi?List=$_&TestID=$testid" TARGET="$testid"
ONCLICK="window.open('index.cgi?List=$_&testid=$testid',
'$testid','toolbar=no,location=no,directories=no,status=no,menubar=no,scroll
bars=yes,resizable=yes, width=450,height=230,left=100,top=100'); return
false">|;
    print "$lnk1 here </a><br>";
}

The problem is that some of the directories contain ampersands "&".

If there is an ampersand in the directory name, the the rest of the query
string gets all messed up.

ex.
If the directory is titled:
Paperwork_&_Cover
The URL becomes
http://testserv/index.cgi?List=Paperwork_&_Cover&testID=70821

Before the print statement, I have tried the following:

escape($lnk);
Gives me:
Software error:
/TestDocs/70822/Paperwork_ No Documents in this system No such file or
directory at /docs/index.cgi line 345.

$_ =~ s/\&/\&amp\;/g;
Gives me:
Software error:
/TestDocs/70822/Paperwork_ No Documents in this system No such file or
directory at /docs/index.cgi line 345.

$_ =~ s/\&/%26/g;
Gives me:
Software error:
/TestDocs/70822/Paperwork_%26_Cover No Documents in this system No such file
or directory at /docs/index.cgi line 345.

I am going nuts trying to figure out how to get this to work.  Can anyone
offer up a bit of wisdom.

Thanks,

Matt




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

Date: Fri, 30 Apr 2004 16:48:20 -0400
From: "Matthew Salerno" <msalerno_rmhere_@bellsouth.net>
Subject: Re: CGI.pm Escaping query strings - ampersand issue
Message-Id: <JMykc.98015$UC4.93602@bignews2.bellsouth.net>

"Matthew Salerno" <msalerno_rmhere_@bellsouth.net> wrote in message
news:2Kykc.98000$UC4.69547@bignews2.bellsouth.net...
>
> I have a cgi/mod_perl script that at one point it generates url's based on
> directories:
>
> foreach (@dirs){
>     my $lnk = qq|<A HREF="index.cgi?List=$_&TestID=$testid"
TARGET="$testid"
> ONCLICK="window.open('index.cgi?List=$_&testid=$testid',
>
'$testid','toolbar=no,location=no,directories=no,status=no,menubar=no,scroll
> bars=yes,resizable=yes, width=450,height=230,left=100,top=100'); return
> false">|;
>     print "$lnk1 here </a><br>";
> }
>

My apologiex, obvious typo:

print "$lnk1 here </a><br>";

Should be:
print "$lnk here </a><br>";




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

Date: Fri, 30 Apr 2004 23:24:04 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm Escaping query strings - ampersand issue
Message-Id: <c6uggs$gc39g$1@ID-184292.news.uni-berlin.de>

Matthew Salerno wrote:
> I have a cgi/mod_perl script that at one point it generates url's
> based on directories:

<snip>

> The problem is that some of the directories contain ampersands "&".

<snip>

> $_ =~ s/\&/%26/g;
> Gives me:
> Software error:
> /TestDocs/70822/Paperwork_%26_Cover No Documents in this system No
> such file or directory at /docs/index.cgi line 345.

URI-escaping the directory name, i.e. converting the '&' character to
'%26', should do the trick. I don't understand what kind of test you
are doing to conclude that that does not work.

It is a URL, right? If you submit

     http://testserv/index.cgi?List=Paperwork_%26_Cover&testID=70821

with the browser, doesn't CGI.pm unescape the directory name back to
Paperwork_&_Cover?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 30 Apr 2004 23:54:08 +0530
From: Thens <thens@NOSPAMti.com>
Subject: comparing decimal numbers
Message-Id: <20040430235408.43bdb167@asiclindt001>

Hi, 

I have to compare two decimals numbers 1.5.0 and 2.1.1. The trouble is they originate from string. Hence I get warnings that say 
" Argument "1.5.0" isn't numeric in numeric ge" ...

This is my code;

 ...
( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
s/^r// for ( $rel1, $rel2 );
return $rel1 > $rel2 ? 1 : 0

Please let me know if Iam missing something here.

For the moment I did this to overcome the error message.

 ...
( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
s/^r// for ( $rel1, $rel2 );
$rel1++; $rel2++;  # to avoid the non numeric warnings
return $rel1 >= $rel2 ? 1 : 0

Thanks in advance for your help.

Regards,
Thens.



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

Date: Fri, 30 Apr 2004 19:15:19 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: comparing decimal numbers
Message-Id: <slrnc959e2.el.spamtotrash@doom.unix-guy.com>

In article <20040430235408.43bdb167@asiclindt001>, Thens wrote:
> Hi, 
> 
> I have to compare two decimals numbers 1.5.0 and 2.1.1. The trouble is they
> originate from string. Hence I get warnings that say " Argument "1.5.0" isn't
> numeric in numeric ge" ...

No, those are strings - a decimal number does not contain more than 1 decimal
point.

> 
> This is my code;
> 
> ...  ( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' ); s/^r// for ( $rel1, $rel2 );
> return $rel1 > $rel2 ? 1 : 0
> 
> Please let me know if Iam missing something here.
> 
> For the moment I did this to overcome the error message.
> 
> ...  ( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' ); s/^r// for ( $rel1, $rel2 );
> $rel1++; $rel2++;  # to avoid the non numeric warnings return $rel1 >= $rel2
> ? 1 : 0
> 

And what do the values of $rel1 and $rel2 end up being? Running a short bit of
test code:

( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
s/^r// for ( $rel1, $rel2 );
$rel1++; $rel2++;  # to avoid the non numeric warnings
print "rel1: $rel1  rel2: $rel2\n";

rel1: 2.5  rel2: 3.1

So, I seriously doubt this is remotely close to what you want to do. You need
further comparison logic to compare each part.

This seems to work for me:

print "higher: " . rev_val('r1.5.0', 'r2.1.1') . "\n";
print "higher: " . rev_val('r2.5.0', 'r2.1.1') . "\n";
print "higher: " . rev_val('r1.99.0', 'r2.1.1') . "\n";
print "higher: " . rev_val('r2.1.0', 'r2.1.1') . "\n";
print "higher: " . rev_val('r2.1.0', 'r2.1.0') . "\n";

sub rev_val
{
        my ($r1, $r2) = @_;
        $r1 =~ s/^r//g;
        $r2 =~ s/^r//g;

        print "$r1, $r2: ";
        my (@v1) = split(/\./, $r1);
        my (@v2) = split(/\./, $r2);

        my $max = ($#v1 > $#v1) ? $#v1 : $#v2;
        
        $cnt = 0;
        while ($cnt < $max)
        {
                if ($v1[$cnt] == $v2[$cnt])
                {
                        $cnt++;
                        next
                }

                return ($v1[$cnt] > $v2[$cnt]) ? $r1 : $r2;
        }

        return "equal";
}

Output:
1.5.0, 2.1.1: higher: 2.1.1
2.5.0, 2.1.1: higher: 2.5.0
1.99.0, 2.1.1: higher: 2.1.1
2.1.0, 2.1.1: higher: equal
2.1.0, 2.1.0: higher: equal

Kevin


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

Date: Fri, 30 Apr 2004 19:20:58 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: comparing decimal numbers
Message-Id: <Xns94DB9C24541D9dkwwashere@216.168.3.30>

Thens <thens@NOSPAMti.com> wrote:

> I have to compare two decimals numbers 1.5.0 and 2.1.1. The
> trouble is they originate from string. Hence I get warnings that
> say " Argument "1.5.0" isn't numeric in numeric ge" ...

Those do not look like numbers to me, nor apparently do they to perl. 
They look like sequences of numbers separated by periods.

If you remove the periods and change them to 150 and 211, will those 
numbers compare the way you want?  If so ...
 
> This is my code;
> 
> ...
> ( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
> s/^r// for ( $rel1, $rel2 );

 ... you could change the line above to 

    tr/0-9//dc for ($rel1, $rel2);

> return $rel1 > $rel2 ? 1 : 0
> 
> Please let me know if Iam missing something here.
> 
> For the moment I did this to overcome the error message.
> 
> ...
> ( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
> s/^r// for ( $rel1, $rel2 );
> $rel1++; $rel2++;  # to avoid the non numeric warnings

Try printing out the value of $rel1 and $rel here.  Is that really 
what you wanted to happen?

> return $rel1 >= $rel2 ? 1 : 0


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

Date: Fri, 30 Apr 2004 18:33:25 GMT
From: "Asier" <as5yer_nh9ag@terra.es>
Subject: distribute and install problem
Message-Id: <pan.2004.04.30.18.35.43.655393@terra.es>

Hi all;

i have realised that perl's par, is not enough for my porpuses,
due to XS modules. 

So i want to distribute my app, with the sources of the modules
i use, and compile all of them in target machines.

Ideas about how to automate this process without CPAN utilities
(i mean, i cannot download from cpan in target machines),
without having to write for every module -perl makefile.pl make make
install-

Thank you very much


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

Date: Fri, 30 Apr 2004 18:24:17 +0000 (UTC)
From: awithers@barney.gonzaga.edu (Alex Withers)
Subject: First edition of _Programming perl_, how useful is it?
Message-Id: <slrnc956ge.un6.awithers@barney.gonzaga.edu>

I have a first edition of _Programming perl_ and I am curious as to
how much of it is obsolete and/or irrelevant.

Thanks,
Alex



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

Date: Fri, 30 Apr 2004 18:53:52 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: First edition of _Programming perl_, how useful is it?
Message-Id: <slrnc95860.tt1.trammell+usenet@hypersloth.el-swifto.com.invalid>

On Fri, 30 Apr 2004 18:24:17 +0000 (UTC), Alex Withers wrote:
> I have a first edition of _Programming perl_ and I am curious as to
> how much of it is obsolete and/or irrelevant.

It's 100% obsolete and irrelevant.  Perl 4 is dead, dead, dead.

But I'll buy it from you, if it's in good shape.



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

Date: Fri, 30 Apr 2004 12:23:17 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: free source search engine (simple) ## comments?
Message-Id: <c6ucl0$c79$2@reader2.nmix.net>

This is a very a simple search engine that prints the filenames of the files
and a link to them, it's not very advanced but I used it as an excersise
into writing search engines, and I'm planning on making it into a more
advanced one in the future I am aware of the race conditions in the header
and footer subs and their suckiness and am working now to fix them, I got
some advice from someone on the perl beginners yahoo list, but to work their
code I have to understand it and I don't so once I read up I'll fix the race
condition, anyway, any comments would be nice.
-Robin

btw, unless I change newsreaders which I haven't had much success with, I've
downloaded like 5 and none seem to work for me cause they don't work with my
mail server my indenting is gonna be screwed up, so please bear with me.

#!/usr/bin/perl

use strict;
use warnings;

use Fcntl qw (:flock);

use CGI qw(:all);

$CGI::POST_MAX=1024 * 100;  # max 100K posts
$CGI::DISABLE_UPLOADS = 1;  # no uploads

$" = '';

$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';

my @directories = ("./", "../"); #change this to the directories you want to
have searched. Include the slash at the end of the directory.
my $action = url_param ('action');
my $rootfile = url (relative=>1);
my $headerfile = "searchheader.txt";
my $footerfile = "searchfooter.txt";
my $errorfile = "ERR.txt";
my @head = getheader ($headerfile);
my @foot = getfooter ($footerfile);
my $date = getdate ();
my @errors;
my @finaldirs;
checkerrors ();

if ($action eq "search")
 {
 search ();
 }

else
 {
 newsearch ();
  }

sub search
 {
 print header;
 print (@head);
 #code for parsing results
 foreach my $dir (@directories)
  {
  opendir (DIR, $dir);
  my @files_from_dir = readdir (DIR);
  closedir (DIR);
  foreach my $filefromdir (@files_from_dir)
   {
   if (! -d $filefromdir)
    {
    push (@finaldirs, "$dir$filefromdir")
    }
   }
  }
 my $query = param ('query');
 my @finalresults;
 foreach my $file (@finaldirs)
  {
  open (FILE, $file) or push (@errors, "A file open error occured on $file:
$!.");
  flock (FILE, LOCK_SH) or push (@errors, "A file lock error occured on
$file: $!.");
  checkerrors ();
  my @contents;
  my $contents;
  @contents = <FILE> if (-f $file);
  close (FILE);
  chomp (@contents);
  $contents = join ('', @contents);
  $contents =~ s/<.*>//g;
  my $result;
  if ($contents =~ m/$query/ and $query)
   {
   $result = "<a href=\"$file\">$file</a><br>";
   push (@finalresults, $result);
   }
  }
 print <<END;
 <p><strong><em>Infused Search</em></strong>
 <br>
 <br>
 Search Results:
 </p>
 END
 print @finalresults;
 print <<END;
 <hr size="1">
 </body>
 </html>
 END
 }


sub newsearch
 {
 print header;
 print (@head);
 print <<END;
<strong><em>Infused Search</em></strong>
<br>
<br>
<hr size="1">
<form name="form1" method="post" action="search.pl?action=search">
<input type="text" name="query">
<input type="submit" name="Submit" value="Submit">
</form>
<hr size="1">
END
 print (@foot);
 }

sub checkerrors
 {
 if (@errors)
  {
  print header;
  print "<html><body><center>";
  print "There were errors while trying to execute Infused Search. They are
listed as follows.<br><br>\n";
  foreach my $error (@errors)
   {
   print ($error, "<br>\n");
   }
  my $errflag = 0;
  if (! open (ERRORF, ">>$errorfile") and flock (ERRORF, LOCK_EX))
   {
   print "There was an error logging the errors: file cannot be locked or
opened.<br>";
   $errflag = 1;
   }
  else
   {
   print ERRORF ("Current date: $date", "\n");
   foreach my $error2 (@errors)
    {
    print ERRORF $error2, "\n";
    }
   }
  close (ERRORF);
  if (! $errflag)
   {
   print "<br>", "Errors have been logged in $errorfile.";
   }
  print "</body></html>";
  exit (0);
  }
 else
  {
  return;
  }
 }

sub getheader
 {
 my $header_sub = shift;
 my (@headertoret);
 if (-e $header_sub)
  {
  open (HEADERF, $header_sub) or push (@errors, "A file open error occured
on $header_sub: $!.");
  flock (HEADERF, LOCK_SH) or push (@errors, "A file lock error occured on
$header_sub: $!.");
  @headertoret = <HEADERF>;
  close (HEADERF);
  }
 else
  {
  open (HEADERF, ">$header_sub") or push (@errors, "A file open error
occured on $header_sub: $!.");
  flock (HEADERF, LOCK_EX) or push (@errors, "A file lock error occured on
$header_sub: $!.");
  @headertoret = <<END;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Infused Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
END
  print HEADERF @headertoret;
  close (HEADERF);
  }
 return (@headertoret);
 }

sub getfooter
 {
 my $footer_sub = shift;
 my (@footertoret);
 if (-e $footer_sub)
  {
  open (HEADERF, $footer_sub) or push (@errors, "A file open error occured
on $footer_sub: $!.");
  flock (HEADERF, LOCK_SH) or push (@errors, "A file lock error occured on
$footer_sub $!.");
  @footertoret = <HEADERF>;
  close (HEADERF);
  }
 else
  {
  open (HEADERF, ">$footer_sub") or push (@errors, "A file open error
occured on $footer_sub $!.");
  flock (HEADERF, LOCK_EX) or push (@errors, "A file lock error occured on
$footer_sub $!.");
  @footertoret = <<END;
</body></html>
END
  print HEADERF @footertoret;
  close (HEADERF);
  }
 return (@footertoret);
 }

sub getdate
 {
 my ($day, $mon, $year)=(localtime)[3,4,5];
 $mon++; #month is returned in a 0-11 range
 $year +=1900;
 my $date = $mon . "/" . $day . "/" . $year;
 return $date;
 }




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

Date: Fri, 30 Apr 2004 16:35:08 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <QfGdnUbstohTIA_dRVn-tw@adelphia.com>

Robin wrote:

> btw, unless I change newsreaders which I haven't had much success with,
> I've downloaded like 5 and none seem to work for me cause they don't work
> with my mail server my indenting is gonna be screwed up, so please bear
> with me.

You mentioned earlier about spaces and tabs getting screwed up. I've seen
that happen many times - the problem is that everyone has their own idea
where the "right" place to put tab stops is. Some folks put them at every 4
columns, some every 8, some every 2, etc. If you use tabs in your file, and
someone with different tab settings views the file, the formatting gets
totally hosed.

The solution is to avoid using tabs. I'm *not* saying don't indent your
code! :-) I'm just saying to use spaces to do it, instead of tabs. Most
programmer's editors have an option to insert spaces when you hit the tab
key, so you'll hardly notice a difference when typing.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 30 Apr 2004 17:07:19 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <remorse-9B1CF1.17071930042004@plato.harvard.edu>

In article <c6ucl0$c79$2@reader2.nmix.net>,
 "Robin" <webmaster @ infusedlight . net> wrote:

> btw, unless I change newsreaders which I haven't had much success with, I've
> downloaded like 5 and none seem to work for me cause they don't work with my
> mail server my indenting is gonna be screwed up, so please bear with me.

One possibility: run the following on your script file before you paste 
it into the message:

   perl -i.orig -p -e "s/\t/    /g" my_perl_script

where my_perl_script is the file with the code you want to paste.  
That's four space characters in the replacement string, although you can 
change that if you wish.

HTH,
Ricky

-- 
Pukku


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

Date: Fri, 30 Apr 2004 21:27:24 GMT
From: "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <0xzkc.43241$OO2.34404@newssvr29.news.prodigy.com>

"Robin" <webmaster @ infusedlight . net> wrote in message
news:c6ucl0$c79$2@reader2.nmix.net...

> btw, unless I change newsreaders which I haven't had much success with,
I've
> downloaded like 5 and none seem to work for me cause they don't work with
my
> mail server my indenting is gonna be screwed up, so please bear with me.

Two suggestions:

1. Download Mozilla from www.mozilla.org.

2. Please, please, please do not post your code for review on the newsgroup.
You can post asking for other people to review your code, but provide a link
of where they can download your code instead. I don't see any benefit of
posting your code as it is generally easier for other people to download it
by clicking a button than by copy/pasting it from their newsreader.

--Ala




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

Date: 30 Apr 2004 11:39:29 -0700
From: sams@freeddns.org (sams)
Subject: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <4d010e73.0404301039.2894f18b@posting.google.com>

Hi

Anyone help me how to tell perl not to convert the @MyDomain part of
the myname@mydomain.com inside a body of a mailmessage? In the
received mails I do see only myname.com the @myDomain part is missing.
Appreciate any help.

Tks

Sam.


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

Date: 30 Apr 2004 19:05:50 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <c6u82e$7sn$1@canopus.cc.umanitoba.ca>

In article <4d010e73.0404301039.2894f18b@posting.google.com>,
sams <sams@freeddns.org> wrote:
:Anyone help me how to tell perl not to convert the @MyDomain part of
:the myname@mydomain.com inside a body of a mailmessage? In the
:received mails I do see only myname.com the @myDomain part is missing.

It isn't clear what connection perl has to your email ??

For what you describe to be happening, you would have to be
effectively -executing- the body of the email rather than just
doing some kind of textual processing on it. If your script is
doing that, it shouldn't be!!! What happens if someone sends you email
that happens to include $ or % or ${} constructs?

What I would suggest is that you edit your script, and on the #! line
at the beginning, you add   -T  to turn on taint checking; and I
suggest you   use strict; use warnings;   if you are not already doing
so. If whatever problem you are seeing does have to do with your
perl script, then between -T and using strict and warnings, you
will probably find a number of places in your script that aren't
properly written.
-- 
Rome was built one paycheck at a time.      -- Walter Roberson


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

Date: Fri, 30 Apr 2004 16:16:17 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <BomdnStHruSOKQ_d4p2dnA@adelphia.com>

sams wrote:

> Anyone help me how to tell perl not to convert the @MyDomain part of
> the myname@mydomain.com inside a body of a mailmessage? In the
> received mails I do see only myname.com the @myDomain part is missing.
> Appreciate any help.

Without seeing your code, it's impossible to offer more than a guess...

As a shot in the dark though, I'd guess that the email message is in a
double-quoted string, so Perl is trying to interpolate the array @myDomain
into that string.

If you 'use strict' and 'use warnings', Perl would warn you about this and
other problems. If you 'use diagnostics', it might even suggest a solution.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 30 Apr 2004 20:28:58 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <c6ucua$edh$1@canopus.cc.umanitoba.ca>

In article <BomdnStHruSOKQ_d4p2dnA@adelphia.com>,
Sherm Pendley  <spamtrap@dot-app.org> wrote:
:Without seeing your code, it's impossible to offer more than a guess...

:As a shot in the dark though, I'd guess that the email message is in a
:double-quoted string, so Perl is trying to interpolate the array @myDomain
:into that string.

But it wouldn't try to do that unless you somehow try to execute
the string. The email message is being read as input (somehow),
and at that point perl is just going to be treating each character
literally. If string $in happens to contain an @ then
neither  my $b = $in;  nor  my $b = "$in";  are going to try to do
interpolation on the string contents.

Possibly the script tries to use the input string as a pattern, such as

s/$in/output/

"Patterns are subject to an additional level of interpretation as a
regular expression.  This is done as a second pass, after variables are
interpolated, so that regular expressions may be incorporated into the
pattern from the variables."

or perhaps the script uses the 'e' modifier on a substitute that
has the input as the replacement portion. Or perhaps any of a number
of other possibilities...
-- 
   History is a pile of debris               -- Laurie Anderson


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

Date: Fri, 30 Apr 2004 12:45:45 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: Re: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <c6udui$ci7$1@reader2.nmix.net>


"sams" <sams@freeddns.org> wrote in message
news:4d010e73.0404301039.2894f18b@posting.google.com...
> Hi
>
> Anyone help me how to tell perl not to convert the @MyDomain part of
> the myname@mydomain.com inside a body of a mailmessage? In the
> received mails I do see only myname.com the @myDomain part is missing.
> Appreciate any help.
>
> Tks
>
> Sam.

Sam, it's be nice to see your code, however I had that exact same issue with
one of my scripts... instead of using something like print MAIL
"myuser@mydomain.com";  use print MAIL "myuser\@mydomain.com"; that way it
won't try to interperate the array @mydomain -
Hope this helps.
-Robin





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

Date: Fri, 30 Apr 2004 12:48:00 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: Re: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <c6ue2t$ci9$1@reader2.nmix.net>


"Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca> wrote in message
news:c6ucua$edh$1@canopus.cc.umanitoba.ca...
> In article <BomdnStHruSOKQ_d4p2dnA@adelphia.com>,
> Sherm Pendley  <spamtrap@dot-app.org> wrote:
> :Without seeing your code, it's impossible to offer more than a guess...
>
> :As a shot in the dark though, I'd guess that the email message is in a
> :double-quoted string, so Perl is trying to interpolate the array
@myDomain
> :into that string.
>
> But it wouldn't try to do that unless you somehow try to execute
> the string. The email message is being read as input (somehow),
> and at that point perl is just going to be treating each character
> literally. If string $in happens to contain an @ then
> neither  my $b = $in;  nor  my $b = "$in";  are going to try to do
> interpolation on the string contents.
>
> Possibly the script tries to use the input string as a pattern, such as
>
> s/$in/output/
>
> "Patterns are subject to an additional level of interpretation as a
> regular expression.  This is done as a second pass, after variables are
> interpolated, so that regular expressions may be incorporated into the
> pattern from the variables."
>
> or perhaps the script uses the 'e' modifier on a substitute that
> has the input as the replacement portion. Or perhaps any of a number
> of other possibilities...

that's true...I didn't see that.
-Robin




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

Date: Fri, 30 Apr 2004 17:14:18 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to tell Perl not to convert @mydomain.com part  inside a body of message?
Message-Id: <nbSdnd1CVrYwXA_dRVn-jw@adelphia.com>

Walter Roberson wrote:

> In article <BomdnStHruSOKQ_d4p2dnA@adelphia.com>,
> Sherm Pendley  <spamtrap@dot-app.org> wrote:
> 
> :As a shot in the dark though, I'd guess that the email message is in a
> :double-quoted string, so Perl is trying to interpolate the array
> :@myDomain into that string.
> 
> But it wouldn't try to do that unless you somehow try to execute
> the string.

Not true. Try this simple example:

#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

print "@hello, world!\n";

With strict and warnings enabled, the above emits a warning about "possible
unintended interpolation." With diagnostics, the warning includes a
description of how to escape the @.

Trust me - I worked at a hosting provider for six years, helping customers
get their Perl scripts working. This is quite possibly the single most
common bug that newbies encounter when they try to print an email address.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 30 Apr 2004 16:00:06 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: Howto: Search between 2 files
Message-Id: <slrnc95j36.38s.jtc@shell.dimensional.com>

In article <158a491d.0404300103.643c25f4@posting.google.com>, josetg wrote:
> Hi,
> 
> Am a absolute newbie.
> 
> I have a list of keywords in one file, and the text to search for in 2nd file.
> I need to find lines in the 2nd file which match keywords in the 1st file.
> 
> The output should be sorted by line # in 2nd file.

It often helps to break a problem into smaller subproblems.  In your case,
the subproblems are pretty obvious - here's one way to split them up:

my @keywords = keywords_from_file('keywordfile');
my @target_lines = lines_from_file('datafile');
for my $word (@keywords) {
	# Search for $word in @target_lines, save matches, with line #
	# (This is the hardest part.  You might want to get the steps before
	# the loop working before you tackle this.  Ask here for help if you
	# need it, of course.)
}
# Sort the results from the above loop and output the result.

sub keywords_from_file {
	# implementation to be defined - ask here if you have trouble with it.
}

sub lines_from_file {
	# implementation to be defined ...
}

-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: 30 Apr 2004 12:39:03 -0700
From: tsunami@zedxinc.com (Tsu-na-mi)
Subject: Re: I am so lost... sort and writing a shell script in Perl
Message-Id: <a6b1e337.0404301139.2a209522@posting.google.com>

>   T>   $pop_density{$county} = sprintf("%.1f",$pop/$land);
>   T>   $water_pct{$county}   = sprintf(%.2f",$water/$land);
> 
> ok, you have two hashes keys by county with number values.
> 
>   T> # sort in ascending order
>   T> foreach $county (sort {$a<=>$b} values %pop_density) { 
>   T>   print "$county County : $pop_density{$county}\n"; 
> 
> hmmm, what does values %hash return? its values, which are
> numbers. great. so you loop over them and print out the numbers followed
> by the word 'County' and then the pop_density of a county named for a
> number.

oops.  should be

(sort {$hash{$a}<=>$hash{$b}} keys %hash)

That'll teach me to code off something from memory without actually
thinking about what it's doing. >_<


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

Date: Fri, 30 Apr 2004 21:58:44 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: I am so lost... sort and writing a shell script in Perl
Message-Id: <pan.2004.04.30.11.06.05.753798@aursand.no>

On Thu, 29 Apr 2004 14:26:42 -0700, Tsu-na-mi wrote:
> My solution will work for all reasonably expected values.

Rule #1 in my programming life: Never expect that your application will be
feeded with "reasonable values".  Never.  Never.  Ever!


-- 
Tore Aursand <tore@aursand.no>
"War is too serious a matter to entrust to military men." (Georges
 Clemenceau)


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

Date: Fri, 30 Apr 2004 19:29:45 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: OSs with Perl installed
Message-Id: <Pine.LNX.4.53.0404301927320.29336@ppepc56.ph.gla.ac.uk>

On Fri, 30 Apr 2004, Abigail wrote:

> I can't understand why anyone doesn't understand Microsoft doesn't
> include Perl in its OS.

Count yourselves lucky.  Digital Unix used to come with Perl 4
(presumably because it was used by some of the installation
scripts) - long after Perl 4 had passed its use-by date.


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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