[21725] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3929 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 7 14:06:07 2002

Date: Mon, 7 Oct 2002 11:05:13 -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           Mon, 7 Oct 2002     Volume: 10 Number: 3929

Today's topics:
        Anyone who uses Perl on VAX <jozefn@newbolt.sonic.net>
    Re: Anyone who uses Perl on VAX <jpagnew@vcu.edu>
    Re: Anyone who uses Perl on VAX <jozefn@newbolt.sonic.net>
        appending words to a line (Bob)
    Re: appending words to a line <andrew_harton@agilent.com>
    Re: appending words to a line <jurgenex@hotmail.com>
    Re: case insensitive -f and -d (Kiyohiro Honda)
    Re: complex so-called 3 dimensional array problem <wksmith@optonline.net>
    Re: Convert Perl script to C program (and Why was this  <Cpt-n*Fredo@S.S*No*Spam>
    Re: Convert Perl script to C program (and Why was this  <flavell@mail.cern.ch>
    Re: converting a string into an array <jurgenex@hotmail.com>
        Copy and rename Directories under Window 2002 (Yang xiao)
    Re: Copy and rename Directories under Window 2002 <jurgenex@hotmail.com>
    Re: Help! How do you move one html page to another in P <jeff@vpservices.com>
    Re: Help! How do you move one html page to another in P <flavell@mail.cern.ch>
    Re: needleman-wunsch alignment ctcgag@hotmail.com
    Re: needleman-wunsch alignment ctcgag@hotmail.com
        net::pop3 problem <g-preston1@ti.com>
    Re: net::pop3 problem news@roaima.freeserve.co.uk
        Problems using Http::Date <rubberducky703@hotmail.com>
    Re: Problems using Http::Date <nobull@mail.com>
    Re: Problems using Http::Date (Helgi Briem)
        Sending HTML email in Perl (Serge)
    Re: Sending HTML email in Perl <mbudash@sonic.net>
        sendmail and perl <saketrungta@hotmail.com>
    Re: sendmail and perl (John J. Chew III)
    Re: sendmail and perl <richard@zync.co.uk>
    Re: Splitting Up A String <pinyaj@rpi.edu>
    Re: Wow! A trivial regexp I can't do! <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 07 Oct 2002 17:05:59 GMT
From: jozefn <jozefn@newbolt.sonic.net>
Subject: Anyone who uses Perl on VAX
Message-Id: <Pine.LNX.4.40.0210071000310.27518-100000@newbolt.sonic.net>


Group,

I have working with Perl/Apache/Mysql on Linux, HP, Win32 systems. Mostly
on Linux systems. I have a project which involves a Vax box ( unkown
territory for me ).  Are there any Perl Hackers out there using Perl
on Vax boxes? The project I have involves a menu system that runs
simple reports on the VAX box.  The reports are already in place - I
just want to put a front-end html based system that allows the running
of these reports using PERL/HTML/Javascript etc.


I need sites and or suggestions from anyone. I am into Perl but green
on VAX.

Thanks to all.


#Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
-68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);




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

Date: Mon, 07 Oct 2002 13:18:52 -0400
From: Jim Agnew <jpagnew@vcu.edu>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <3DA1C1FC.78D47553@vcu.edu>

What do you need to know??

jim

jozefn wrote:
> 
> Group,
> 
> I have working with Perl/Apache/Mysql on Linux, HP, Win32 systems. Mostly
> on Linux systems. I have a project which involves a Vax box ( unkown
> territory for me ).  Are there any Perl Hackers out there using Perl
> on Vax boxes? The project I have involves a menu system that runs
> simple reports on the VAX box.  The reports are already in place - I
> just want to put a front-end html based system that allows the running
> of these reports using PERL/HTML/Javascript etc.
> 
> I need sites and or suggestions from anyone. I am into Perl but green
> on VAX.
> 
> Thanks to all.
> 
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
> print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
> -68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);


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

Date: Mon, 07 Oct 2002 17:41:45 GMT
From: jozefn <jozefn@newbolt.sonic.net>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <Pine.LNX.4.40.0210071039540.4141-100000@newbolt.sonic.net>


Jim,

Thanks for the reply.

Here is where I am.

I have been working with Perl for about 5 years ( total programming experience 17 years). I have written systems in Perl on Linux/Solaris/HP(Posix)/Win32 boxes - mainly CGI based systems with Mysql backend HTML/Javascript frontend.

I now have a project on a VAX. Have not seen the box yet - don't know about the OS - as you can see - very green.

From my first paragraph I need a way to relate my current experience to the new environment. PERL is perl which is why I love it - moves from box to box and does the same fantastic work.

Are the any gotch'yas working on VAX?

What is it similar to - UNIX? MPEIX? Dos?

Do all of the parts of Perl work the same way on VAX as they do on the above mentioned platforms?

Can I use the system command to run alread resident programs and scripts in background?

Can I put a web based front-end on this box, so as to automate the current command-line entry setup that is used to run reports etc?

Thanks for any and all help, suggestions, sites etc.


#Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
-68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);


On Mon, 7 Oct 2002, Jim Agnew wrote:

> What do you need to know??
>
> jim
>
> jozefn wrote:
> >
> > Group,
> >
> > I have working with Perl/Apache/Mysql on Linux, HP, Win32 systems. Mostly
> > on Linux systems. I have a project which involves a Vax box ( unkown
> > territory for me ).  Are there any Perl Hackers out there using Perl
> > on Vax boxes? The project I have involves a menu system that runs
> > simple reports on the VAX box.  The reports are already in place - I
> > just want to put a front-end html based system that allows the running
> > of these reports using PERL/HTML/Javascript etc.
> >
> > I need sites and or suggestions from anyone. I am into Perl but green
> > on VAX.
> >
> > Thanks to all.
> >
> > #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
> > print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
> > -68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>



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

Date: 7 Oct 2002 07:41:48 -0700
From: bobx@linuxmail.org (Bob)
Subject: appending words to a line
Message-Id: <1001ff04.0210070641.4aa5c0ba@posting.google.com>

I currently have a script that looks for words and prints the lines
the words are found on along with the word to another file.

What I want to do now is to loop through the file printing the word
found plus the line and if a word was not found printing a "-" hyphen.

looking like:

word  thelinefound
- nowordfoundonline

It is actually a log I am parsing and it will help me format it later
to do it this way.  My current code is:


#!/usr/bin/perl

# pragmas
use strict;
use warnings;
 
# variables
my $word;
my $line;
my $badword;
 
#pattern matching:
my @words = qw/ bob doug george /;
 
# keep a backup of the file as xxx.bak 
$^I = ".BAK";

# do the magic!
while ($line = <>) {
    foreach $word (@words) {
        if (index ($line, $badword) > -1) {
            print ($word," ",$line);
        }
    }
}

# let me know when completed
print "The script is finished...\n";
exit (0);


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

Date: Mon, 7 Oct 2002 17:57:23 +0100
From: "Andrew Harton" <andrew_harton@agilent.com>
Subject: Re: appending words to a line
Message-Id: <1034009716.188826@cswreg.cos.agilent.com>

Bob wrote:
> I currently have a script that looks for words and prints the lines
> the words are found on along with the word to another file.
>
> What I want to do now is to loop through the file printing the word
> found plus the line and if a word was not found printing a "-" hyphen.
>
> looking like:
>
> word  thelinefound
> - nowordfoundonline
>
> It is actually a log I am parsing and it will help me format it later
> to do it this way.  My current code is:
>
>
> #!/usr/bin/perl
>
> # pragmas
> use strict;
> use warnings;
>
> # variables
> my $word;
> my $line;
> my $badword;
>
> #pattern matching:
> my @words = qw/ bob doug george /;
>
> # keep a backup of the file as xxx.bak
> $^I = ".BAK";
>
> # do the magic!
> while ($line = <>) {
>     foreach $word (@words) {
>         if (index ($line, $badword) > -1) {
>             print ($word," ",$line);
>         }
>     }
> }
How about something like this (untested);

while ($line = <>) {
    my $found = 0;
    foreach $word (@words) {
        if (index ($line,$badword) > -1) {
            print "$word $line";
            $found++;
        }
    }
    if ($found >0)
    {
        print "- $line";
    }
}

>
> # let me know when completed
> print "The script is finished...\n";
> exit (0);


Andrew

--
$s="acehJklnoPrstu ";$_="4dbce078c32ae92a6e30152a";
split//;for(0..$#_){print substr($s,hex $_[$_],1);}




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

Date: Mon, 7 Oct 2002 10:10:41 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: appending words to a line
Message-Id: <3da1c011$1@news.microsoft.com>

Bob wrote:
> I currently have a script that looks for words and prints the lines
> the words are found on along with the word to another file.
>
> What I want to do now is to loop through the file printing the word
> found plus the line and if a word was not found printing a "-" hyphen.
>
> looking like:
>
> word  thelinefound
> - nowordfoundonline
>
> It is actually a log I am parsing and it will help me format it later
> to do it this way.  My current code is:
>
>
> #!/usr/bin/perl
>
> # pragmas
> use strict;
> use warnings;
>
> # variables
> my $word;
> my $line;
> my $badword;
>
> #pattern matching:
> my @words = qw/ bob doug george /;

Make this a hash, using your words as keys

> # keep a backup of the file as xxx.bak
> $^I = ".BAK";
>
> # do the magic!
> while ($line = <>) {
>     foreach $word (@words) {

Here search in 'keys(%YourWordHash)'

>         if (index ($line, $badword) > -1) {

And here increment '$YourWordHash{$_}++;'

>             print ($word," ",$line);
>         }
>     }
> }
>
> # let me know when completed

Then here you can check the hash if there are any values still undefined.
For those keys where the value is undefined you did not find a word.

jue




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

Date: 7 Oct 2002 08:19:23 -0700
From: kiyo9876@yahoo.co.jp (Kiyohiro Honda)
Subject: Re: case insensitive -f and -d
Message-Id: <2ca34ccc.0210070719.42e07b96@posting.google.com>

Wow, glob! I never think of it.
It's a very elegant idea!

I and my friends could think of only traditional way of
recursive function call that is trivial and very slow.
I was shocked by the use of glob, very excellent way I think.
Thank you very much.

PS.
please let me explain the back ground of my first question.
I'm running a perl script on my solaris box which share certain files
with windows box. And a program on the windows kicks my perl script
and give a filename,which is a shared file with my solaris box, as arguments.
But that program does not recognize upper/lower case. So my perl program
must ignore the uppuer/lower case when checking the existence of the files.

#sorry for my broken English

K

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote in message news:<Pine.A41.3.96.1021004084830.60890A-100000@vcmr-104.server.rpi.edu>...
> [posted & mailed]
> 
> On 3 Oct 2002, Kiyohiro Honda wrote:
> 
> >I want a function that is similar to -f and -d , BUT
> >which ignore lower and upper case.
> >For example, when I put "/Foo/BAR/Aaa.gif" to the function
> >and there exists "/fOO/Bar/aAa.gif", then the fucntion returns true.
> 
> I think I'd use glob():
> 
>   my @matches = find_file_ci("/Foo/BAR/Aaa.gif");
> 
>   sub find_file_ci {
>     my $f = lc shift;
>     $f =~ s/([a-z])/[$1\U$1]/g;
>     return glob $f;
>   }


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

Date: Mon, 7 Oct 2002 09:57:28 -0400
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: complex so-called 3 dimensional array problem
Message-Id: <zpgo9.31344$GF5.1894979@news4.srv.hcvlny.cv.net>


"hugo" <hugo@fractaltechnologies.com> wrote in message
news:3DA140CE.5040203@fractaltechnologies.com...
> Hi
>
> I have a very complex problem and I am not getting out of it.
>
> I want to do some calculations which previously were done on a set of
> data, but now have to be incorporated into a double nested loop. This
> ends up making use of an array which contains an array which in turn
> contains another array (if you like, a 3 dimensional array).

--snip--
>
> Now I want to do all this inside a double nested loop where @P is a list
> of projects and @U is a list of users for which I want to get data
> (which are tasks descriptions), WITHIN each project.
>
> 1. Get data from database:
>
> for ($p = 0; $p < @P; $p++) {
>       for ($u = 0; $u < @U; $u++) {
>       $count=0;
> $dbh = DBI->connect($connectstring,$username,$password) or die "Can't
> connect to database";
>     $sth = $dbh ->prepare ("SELECT task, add_time FROM tasks WHERE
> month=\"$current_month\" AND year=\"$year\" AND project=\"$P[$p]\" AND
> user=\"$U[$u]\" ORDER BY project, user, task, ddate, s_time_order,
> end_time_order ASC");
> $sth->execute();
>     while ($ref = $sth ->fetchrow_hashref()) {
>     $Ta[$p][$u][$count] = $ref->{'task'};
> $A_time[$p][$u][$count] = $ref->{'add_time'};
> $count++;
>          }
>
> $finalcount[$p][$u] = $count;
> $sth->finish();
> $dbh->disconnect;
>
>
> 2. Calculated the time (total number of hours as long as the task is the
> same) as above, but this time I get myself in a terrible tangle:
>
> (what follows is wrong):
>
> @ta = @Ta;
> @a_time = @A_time;
>
> foreach ($x =0; $x < @a_time; $x++) {
> print "<br>AAAA a_time is: $a_time[$x] \n";

I do not understand what you intend to print here.
$a_time[$x] is a reference to an array of references.

> }
>
>
> my ( $previous, $sum, $counting);
>        while ( @ta[$p][$u] ) {
>      ( $ch[$p][$u], $time[$p][$u] ) = ( shift @ta[$p][$u], shift
> @a_time[$p][$u]);



      while ( @{$ta[$p][$u]} ) {
     ( $ch[$p][$u], $time[$p][$u] ) = ( shift @{$ta[$p][$u]}, shift
    @{$a_time[$p][$u]});





>          if ( defined $previous and $previous ne $ch[$p][$u] ) {
>              $ta_time[$p][$u][$counting] = $sum[$p][$u];
>              print "<br>t_time is: $ta_time[$p][$u][$counting]\n";
>              $counting++;
>              $sum = 0;
>          }
>          $sum += $time[$p][$u];
>          $previous = $ch[$p][$u];
>
>      }
>      $ta_time[$p][$u][$counting] = $sum[$p][$u];
>
>   } # end second for loop
> } # end first for loop
>
>
> In other words, I only want the array values at the "third level down"
> from the three dimensional arrays @A and @A_time because that are the
> particular task entries for that particular user (at "second level" of
> array) within a project (at "first level" of array) I am after. I would
> like to store the cumulative time values in another 3D array
> $ta_time[$p][$u][$counting], to be used later on.
>
> When I do it this way, I get errors such as "must be array (not array
> element)". Obviously I am not accessing the "third level down" array
> values correctly.

--snip--

perldoc perlref
Study the first paragraph under 'Using References'.

Good Luck,
Bill



>




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

Date: Mon, 07 Oct 2002 15:39:02 GMT
From: "-F-r-e-d-o-" <Cpt-n*Fredo@S.S*No*Spam>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <qUho9.1323$u32.78055553@newssvr14.news.prodigy.com>


"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:slrnapnrfv.142.bernard.el-hagin@gdndev25.lido-tech...
> In article <g9Im9.276$3r2.2422851@newssvr21.news.prodigy.com>, .Fredo
> wrote:
> >
> > "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote
in
>
> [...]
[...]
> > No one, not even a revered book author, nor an expert programmer,
has no
> > right to display such rudeness when ever they see fit. This is what
has
> > been going on. I have been corresponding via email with various folk
> > from this group for well over a year now, and this feeling not only
felt
> > by myself.
>
>
> But what's forcing you to keep reading the group, then? Are you a
> masochist?

No, becasue I'm interested in Perl.

But sigh, I am obviously just wasting my time, as many of the people in
question will never bring them selves up to the level of admitting their
own faults. some of them have been helpful here, this I do not deny. But
when they are so quick to be rude, and then attempt to block out ANYONE
who trys to confront them with the obvious truth, then there is
something dreadfully wrong. I was only trying to help this group by
bringing this ramped problem out into the open.

But I guess no one really care about what goes on here in this group or
how the so caleld "regulars" set the tone. Being in many other groups
the past years too, I've litterally seen this group get laughed at
behind it's back so many times it's utterly rediculas. Again, if one
care what happens here or the image of this group, then so be it. I will
no longer drop to rock bottom level to deal with the few like Tad who
while being helpful every now and then soil that with arrgance and sheer
rudeness. Until people like him realize they do not own this group, but
everyone using it does, this will never be the "great" group the Perl
books trys to make it out to be.

~Fin~

-Fredo




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

Date: Mon, 7 Oct 2002 18:52:14 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <Pine.LNX.4.40.0210071851000.10879-100000@lxplus075.cern.ch>

On Oct 7, -F-r-e-d-o- inscribed on the eternal scroll:

> But sigh, I am obviously just wasting my time,

The time you're wasting isn't only your own, while we struggle to find
the common factor to put into the killfile recipe.



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

Date: Mon, 7 Oct 2002 10:12:52 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: converting a string into an array
Message-Id: <3da1c094$1@news.microsoft.com>

Vivek wrote:
> I was wondering how do you turn a string into an array?
> For example take a string $string="ABCDE" and make it an array so that
> you can work with each character separately, so that
> $s[0]=A....$s[1]=B....and so on.

'perldoc -f split', but probably there is a much easier and more perlish way
to solve your real problem.

jue




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

Date: 7 Oct 2002 08:49:27 -0700
From: yang2002_99@yahoo.com (Yang xiao)
Subject: Copy and rename Directories under Window 2002
Message-Id: <55c6e631.0210070749.402ab74a@posting.google.com>

Hi all,
I have a user who keeps a list of directory of clients as such
 ./client2002
 ./client2002/client2002Q1
 ./client2002/client2002Q1/client1Q1
 ./client2002/client2002Q1/client2Q1
 ...

there are hundreds of them. and he needs to create the directories
every quarter, not so much the files since they will be updated and
copied over individually.

I want a script that creates the directory strcuture for each quarter
depends on the previouds quarter's content. It seems simple enough,
but I just can't get it right.

Please help, thanks in advance.

Yang


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

Date: Mon, 7 Oct 2002 10:16:13 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Copy and rename Directories under Window 2002
Message-Id: <3da1c15e@news.microsoft.com>

Yang xiao wrote:
> Hi all,
> I have a user who keeps a list of directory of clients as such
> ./client2002
> ./client2002/client2002Q1
> ./client2002/client2002Q1/client1Q1
> ./client2002/client2002Q1/client2Q1
> ...
>
> there are hundreds of them. and he needs to create the directories
> every quarter, not so much the files since they will be updated and
> copied over individually.
>
> I want a script that creates the directory strcuture for each quarter
> depends on the previouds quarter's content. It seems simple enough,
> but I just can't get it right.

Should be pretty simple using File::Find to traverse the old tree, '-d' to
test for directories, s/Q1/Q2/ to get the new name (assuming that's what
indicates the quarter), and 'mkdir' to actually create the new directory.

For details please see the corresponding perldoc pages.

jue




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

Date: Mon, 07 Oct 2002 06:09:42 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help! How do you move one html page to another in Perl?
Message-Id: <3DA18796.9040702@vpservices.com>

Zordiac wrote:


> 2. Jeff, I thought CGI.pm was a specialised module which required learning
> specialised commands, and as I am new to Perl I wanted to stick to basics.


This is the Perl equivalent of saying "I thought learning to drive a car 
   requires a lot of specialized commands, so I decided to just step on 
the gas to see what happens".  If you don't know much Perl then it is 
even more important that you use CGI.pm.


The FAQ says:


   How do I decode a CGI form?

   You use a standard module, probably CGI.pm. Under no
   circumstances should you attempt to do so by hand!

   You'll see a lot of CGI programs that blindly read from STDIN
   the number of bytes equal to CONTENT_LENGTH for POSTs, or grab
   QUERY_STRING for decoding GETs. These programs are very poorly
   written. They only work sometimes.

This seems to be the approach you are currently using.  Don't let the 
fact that it's appeared to worked for you fool you.  You *really* need 
to start using CGI.pm.

BTW, what I sent you before wasn't just pseudo-code, it was a fully 
functional script.

-- 
Jeff





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

Date: Mon, 7 Oct 2002 16:23:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help! How do you move one html page to another in Perl?
Message-Id: <Pine.LNX.4.40.0210071605330.10879-100000@lxplus075.cern.ch>

On Oct 7, Zordiac inscribed on the eternal scroll:

> I thought that I could use one Perl

Presumably you mean "one CGI script, written in Perl".  There's
nothing magical about Perl in this respect: CGI scripts can be written
in many different languages, it just so happens that (for a number of
good reasons) Perl is a popular choice.  But there are far more uses
for Perl than just writing CGI scripts.

> a) generate more than one html page.

Think in terms of a script invocation producing just one result per
invocation.  That result could, of course, be a different one
depending on how the script was invoked.

> b) take user input from any page

You seem to have got this back-to-front.  A CGI script doesn't get
invoked until a user has accessed its URL.  The script doesn't go out
actively "taking input from" other pages (OK, I'm over-
simplifying[1]).

The script executes (with its input already prepared for it by the web
server) and produces a result (which might be a generated HTML page)
and exits.

The generated HTML page might e.g have a form on it which re-invokes
the same script, under different conditions - is it this that you're
asking about?  Then yes, that can be a useful technique, as it keeps
the related code together.

> c) navigate from one page to another

The result returned by the script might be a redirection rather than a
generated page.  FAQ 9 again.

> And I thought I could do this from one script

Yes; but just one outcome per invocation, even though the script has
been written to have several different possible outcomes.  Clear?

> 3. Alan, I have looked at the FAQs - doesnt mean what I wanted wasn't
> staring me in the face, just that I could not see it.

I suspect that the problem is that you're not familiar with the
terminology, so you're asking quasi-technical questions which seem to
mean one thing to you, but is being interpreted differently by others.
I interpreted your original question as wanting to perform a
redirection, and answered on that basis.  Another reader evidently
interpreted the question differently and told you how to send back a
generated HTML page.

It's often better if you put the question into context by showing a
real-world problem that you were aiming to solve.

good luck

[1] A script _could_ go and fetch the contents of other web pages
using, typically, LWP modules; but this is more in the nature of an
advanced technique, not a normal part of a regular CGI script.

-- 
       Please don't call awk from perl; it embarrasses both of them. :)
                           - Steve Grazzini on comp.lang.perl.misc



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

Date: 07 Oct 2002 17:08:47 GMT
From: ctcgag@hotmail.com
Subject: Re: needleman-wunsch alignment
Message-Id: <20021007130847.065$H3@newsreader.com>

leemur@uclink4.berkeley.edu (Stanley Lee) wrote:

use strict and enable warnings.



>         $ct = 0;

You don't my (or at least reset) @list here.  That means the 2nd time
through the loop, @list is polluted by the first time through.

Using $ct is not very perlish.  Instead push onto @list.


>         for ($a = $kk; $a <= $L1; $a += 1){   #row same, col move
>             $list[$ct] = $matrix[$ii][$a];
>             @list = sort(@list);
>             @list = reverse(@list);
>             $max_row = $list[0];

Why do you sort the list each time through the loop?  Build it up,
then sort once.  Or just use a traditional max routine without
sorting at all.  Also, you are sorting lexically.  You'll get a surprise
when your score gets above 9.

>             $ct += 1;
>         }
>
>         @list = ();

You do reset list here.  Why?  Since the want the global max, just
let it keep building.


>         $cnt = 0;
>         for ($a = $ii; $a <= $L2; $a += 1){   #col same, row move
>             $list[$cnt] = $matrix[$a][$kk];
>             @list = sort(@list);
>             @list = reverse(@list);
>             $max_col = $list[0];
>             $cnt += 1;
>         }

You don't reset @list here.  What's going to happen next time through?



Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                    Usenet Newsgroup Service


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

Date: 07 Oct 2002 17:43:14 GMT
From: ctcgag@hotmail.com
Subject: Re: needleman-wunsch alignment
Message-Id: <20021007134314.381$8Z@newsreader.com>

leemur@uclink4.berkeley.edu (Stanley Lee) wrote:
> hi im very new to perl and i am trying to implement a needleman-wunsch
> alignment of two protein sequences
> (http://helix.biology.mcmaster.ca/721/outline2/node39.html)
> to align the sequences, first you construct an initial matrix of 0s
> and 1s, 1s appear wherever the sequences match (please see the URL)
> and then you iterate through this matrix a second time and add the
> largest value from the adjacent columns and rows. this part i have
> trouble on, i can get the matrix with half of the values that i need,
> but the other half is wrong. has anyone ever tried anything like this
> before?


I forgot to add, yes!

http://world.std.com/~swmcd/steven/perl/pm/xs/nw/Perl/Align/NW/NW.html





heres some code that im using:
>
> $seq1 = "AJCJNRCKCRBP";
> $seq2 = "ABCNJRQCLCRPM";
> $L1 = length($seq1);
> $L2 = length($seq2);
> @matrix = ();
> for ($i = 0; $i < $L1; $i +=1){        #sets up the 1s and 0s matrix,
> works fine
>     $aa1 = substr($seq1, $i, 1);
>     for ($k = 0; $k < $L2; $k +=1){
>         $aa2 = substr($seq2, $k, 1);
>         if ($aa1 eq $aa2){
>             $matrix[$i][$k] = 1;
>             print "$matrix[$i][$k]";
>         }else{
>             $matrix[$i][$k] = 0;
>             print "$matrix[$i][$k]";
>         }
>     }
>     print "\n";
> }
> print "\n";
>
> for ($i = $L1-2; $i >= 0; $i -=1){          #modifies matrix
>     for ($k = $L2-2; $k >= 0; $k -=1){
>         $ii = $i + 1;   #previous row
>         $kk = $k + 1;   #previous col
>
>         $ct = 0;
>         for ($a = $kk; $a <= $L1; $a += 1){   #row same, col move
>             $list[$ct] = $matrix[$ii][$a];
>             @list = sort(@list);
>             @list = reverse(@list);
>             $max_row = $list[0];
>             $ct += 1;
>         }
>
>         @list = ();
>
>         $cnt = 0;
>         for ($a = $ii; $a <= $L2; $a += 1){   #col same, row move
>             $list[$cnt] = $matrix[$a][$kk];
>             @list = sort(@list);
>             @list = reverse(@list);
>             $max_col = $list[0];
>             $cnt += 1;
>         }
>
>         @big = sort($max_row, $max_col);
>         $maxm = $big[1];
>         $matrix[$i][$k] = $matrix[$i][$k] + $maxm;
>         #print "$matrix[$i][$k]";
>     }
>     print "\n";
> }
>
> 011111111121
> 021111211112
> 113232222322
> 212333333333
> 323343333433
> 343334544444
> 334444456555
> 434444465666
> 545454456766
> 655555566677
> 666666666678
>
> this is what im getting out.
> anything would help.
> thanks! stanley.

-- 
-------------------- http://NewsReader.Com/ --------------------
                    Usenet Newsgroup Service


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

Date: Mon, 7 Oct 2002 09:07:48 -0500
From: "Jerry Preston" <g-preston1@ti.com>
Subject: net::pop3 problem
Message-Id: <ans4fl$7d4$1@tilde.itg.ti.com>

Hi!

I am having problem with this code:

#!/usr1/local/bin/perl

#!/usr/local/bin/perl

#===============================
# How to read email with Net::POP3
# Copyright 2000, Emmie P. Lewis
# Created 02/27/00
#===============================
# This script is designed to show
# how to use Net::POP3 to read your
# email from a Perl script.
#===============================

use strict;

print "Content-type: text/plain", "\n\n";

use Net::POP3;

# This debug flag will print debugging code to your browser, depending on
its value
# Set this to 1 to send debug code to your browser.  Set it to 0 to turn it
off.
my $DEBUG = 1;

if($DEBUG)
{
   $| = 1;
   open(STDERR, ">&STDOUT");
}

# Set this variable to your POP3 server name
my $ServerName = "mail.it.iz.com";

# Create a new POP3 object
my $pop3 = Net::POP3->new( $ServerName, Debug => 1 );


I get the error:

"Couldn't log on to server"

I took address right out of Outlook.

Any ideas in what I am doing wrong?

Thanks,

Jerry





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

Date: Mon, 7 Oct 2002 17:35:51 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: net::pop3 problem
Message-Id: <75dsna.5ak.ln@moldev.cmagroup.co.uk>

Jerry Preston <g-preston1@ti.com> wrote:
> Hi!

> I am having problem with this code:

[...snip...]

> I get the error:
> "Couldn't log on to server"

Not from that snippet you don't.

> Any ideas in what I am doing wrong?

Where's the call to log on to the POP3 server? You've missed that vital
part out of the quoted script.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 7 Oct 2002 17:00:19 +0100
From: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: Problems using Http::Date
Message-Id: <ansb12$gd5gt$1@ID-116287.news.dfncis.de>

Whenever i include http::date in any of my programs and then proceed to use
it I keep getting this curious error when i start my program via the command
line:

Subroutine time2str redefined at C:/Perl/lib/Exporter.pm line 57.
        Exporter::import('time2str', 'str2time') called at prog1.pl line 7
        main::BEGIN() called at C:/Perl/site/lib/HTTP/Date.pm line 7
        require 0 called at C:/Perl/site/lib/HTTP/Date.pm line 7
Prototype mismatch: sub main::time2str ($;$$) vs (;$) at
C:/Perl/lib/Exporter.pm
 line 57.
        Exporter::import('time2str', 'str2time') called at prog1.pl line 7
        main::BEGIN() called at C:/Perl/site/lib/HTTP/Date.pm line 7
        require 0 called at C:/Perl/site/lib/HTTP/Date.pm line 7

I'm running 2k and the only function of the library i am using is time2str
which i use like such

            $variable1 = time2str($variable2);

Anyone got any ideas on how to get rid of this abrupt error??

Thanks RD




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

Date: 07 Oct 2002 17:24:45 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Problems using Http::Date
Message-Id: <u9fzviw71u.fsf@wcl-l.bham.ac.uk>

"Rubber Duck" <rubberducky703@hotmail.com> writes:

> Whenever i include http::date in any of my programs and then proceed to use
> it I keep getting this curious error when i start my program via the command
> line:
> 
> Subroutine time2str redefined at C:/Perl/lib/Exporter.pm line 57.
>         Exporter::import('time2str', 'str2time') called at prog1.pl line 7
>         main::BEGIN() called at C:/Perl/site/lib/HTTP/Date.pm line 7
>         require 0 called at C:/Perl/site/lib/HTTP/Date.pm line 7
> Prototype mismatch: sub main::time2str ($;$$) vs (;$) at
> C:/Perl/lib/Exporter.pm
>  line 57.
>         Exporter::import('time2str', 'str2time') called at prog1.pl line 7
>         main::BEGIN() called at C:/Perl/site/lib/HTTP/Date.pm line 7
>         require 0 called at C:/Perl/site/lib/HTTP/Date.pm line 7
> 
> I'm running 2k and the only function of the library i am using is time2str
> which i use like such
> 
>             $variable1 = time2str($variable2);
> 
> Anyone got any ideas on how to get rid of this abrupt error??

Do not import HTTP::Date::time2str() into your main namespace, instead
call it using its fully qualified name.

Alternatively don't import the other time2str() into your main
namespace from Date::Format (or whatever other module you are
importing a function of that name from).

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


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

Date: Mon, 07 Oct 2002 16:40:15 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Problems using Http::Date
Message-Id: <3da1b65c.2448277647@news.cis.dfn.de>

On Mon, 7 Oct 2002 17:00:19 +0100, "Rubber Duck"
<rubberducky703@hotmail.com> wrote:

>Whenever i include http::date in any of my programs and then proceed to use
>it I keep getting this curious error when i start my program via the command
>line:
>
>Subroutine time2str redefined at C:/Perl/lib/Exporter.pm line 57.
>        Exporter::import('time2str', 'str2time') called at prog1.pl line 7
>        main::BEGIN() called at C:/Perl/site/lib/HTTP/Date.pm line 7
>        require 0 called at C:/Perl/site/lib/HTTP/Date.pm line 7
>Prototype mismatch: sub main::time2str ($;$$) vs (;$) at
>C:/Perl/lib/Exporter.pm
> line 57.
>        Exporter::import('time2str', 'str2time') called at prog1.pl line 7
>        main::BEGIN() called at C:/Perl/site/lib/HTTP/Date.pm line 7
>        require 0 called at C:/Perl/site/lib/HTTP/Date.pm line 7
>
>I'm running 2k and the only function of the library i am using is time2str
>which i use like such
>
>            $variable1 = time2str($variable2);
>
>Anyone got any ideas on how to get rid of this abrupt error??

You presumably have another module loaded which defines 
a function with the same name, but I am unable to
replicate your error.  

You can make it go away by calling the function with an
explicit packagename, ie:
my $variable1 = HTTP::Date::time2str($variable2);

(although I don't much like your choice of variable names.
That kind of thing will rise up and bite you on the ass in
the future).

Anyway, apart from a miniscule difference in formatting,
what does this time2str function offer you that
localtime($variable2) doesn't?


-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: 7 Oct 2002 10:36:44 -0700
From: pulsar10@email.com (Serge)
Subject: Sending HTML email in Perl
Message-Id: <2481ff4b.0210070936.399fdbe2@posting.google.com>

Hi,

 I have a Perl (CGI) script that sends out an email with a form.
However, when I use sendmail and do stuff like print sendmail "<html
tags>", all I get in the email are the actual tags. How do I make my
HTML actually decode? It is only simple HTML, no frames or anything!
Thanks in advance for your help.


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

Date: Mon, 07 Oct 2002 17:49:35 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Sending HTML email in Perl
Message-Id: <mbudash-9BA503.10493407102002@typhoon.sonic.net>

In article <2481ff4b.0210070936.399fdbe2@posting.google.com>,
 pulsar10@email.com (Serge) wrote:

> Hi,
> 
>  I have a Perl (CGI) script that sends out an email with a form.
> However, when I use sendmail and do stuff like print sendmail "<html
> tags>", all I get in the email are the actual tags. How do I make my
> HTML actually decode? It is only simple HTML, no frames or anything!
> Thanks in advance for your help.

i'm sure this is a FAQ, but essentially, all you have to do is change 
(or add) the Content-type header you're sending to the MTA to:

Content-type: text/html

hth-


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

Date: Mon, 7 Oct 2002 15:57:41 +0100
From: "Saket Rungta" <saketrungta@hotmail.com>
Subject: sendmail and perl
Message-Id: <ans7fr$pia$1@sp15at20.hursley.ibm.com>


I am trying to run a perl script whenever a user receives mail.

I modified /etc/aliases as follows:

# few comment lines in start have been removed..

# Alias for mailer daemon
MAILER-DAEMON:root

# Following alias is required by the new mail protocol, RFC 822
postmaster:root

# Aliases to handle mail to msgs and news
nobody: /dev/null
jbench: |/tmp/append.pl

--
Then do sendmail -bi

--
/tmp/append.pl is as follows:

#! /usr/bin/perl -w

open (O, ">>append.out");
print O "append.pl has been just executed...\n";

while (<STDIN>) {
 print O;
}

close O;

--

Nothing seems to happen to append.out.  Even though manual invocation of
script appends the file.  If mail is not redirected to perl script, the
jbench user gets mail. Any suggestions?
Perl 5.6.0 on AIX 5.1L

--
Thanks,
Saket

Saket Rungta1/UK/IBM@IBMGB (Office)
saket@bcs.org.uk (Personal)





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

Date: 7 Oct 2002 15:41:36 GMT
From: jjchew@coxeter.math.toronto.edu (John J. Chew III)
Subject: Re: sendmail and perl
Message-Id: <ans9vg$akk$1@news.math.toronto.edu>

In article <ans7fr$pia$1@sp15at20.hursley.ibm.com>,
Saket Rungta <saketrungta@hotmail.com> wrote:

>I am trying to run a perl script whenever a user receives mail.
>
>I modified /etc/aliases as follows:
[...]
>jbench: |/tmp/append.pl
[...]
>Then do sendmail -bi
[...]
>open (O, ">>append.out");
>print O "append.pl has been just executed...\n";

Sounds like a permissions problem.  You could confirm this by appending
an "or die" to the "open()" and looking for the message wherever sendmail
puts it, or possibly redirecting STDERR to a temporary file.

If it is, then you should adjust the permissions on append.out and its
parent directories to permit sendmail's uid to write to the file, being
careful of course to create no larger a security problem in your system
than necessary.

John
--
John Chew (poslfit on MD/WD/PD)
jjchew@math.utoronto.ca * http://www.math.utoronto.ca/jjchew


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

Date: Mon, 07 Oct 2002 18:01:38 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: sendmail and perl
Message-Id: <20021007.180138.653468858.1006@richg.richg.zync>

In article <ans7fr$pia$1@sp15at20.hursley.ibm.com>, "Saket Rungta"
<saketrungta@hotmail.com> wrote:


> I am trying to run a perl script whenever a user receives mail.  I
> modified /etc/aliases as follows:
> # few comment lines in start have been removed..  # Alias for mailer
> daemon
> MAILER-DAEMON:root
> # Following alias is required by the new mail protocol, RFC 822
> postmaster:root
> # Aliases to handle mail to msgs and news nobody: /dev/null
> jbench: |/tmp/append.pl
> --
> Then do sendmail -bi
> --
> /tmp/append.pl is as follows:
> #! /usr/bin/perl -w
> open (O, ">>append.out");
> print O "append.pl has been just executed...\n";  while (<STDIN>) {
>  print O;
> }
> close O;
> --
> Nothing seems to happen to append.out.  Even though manual invocation of
> script appends the file.  If mail is not redirected to perl script, the
> jbench user gets mail. Any suggestions? Perl 5.6.0 on AIX 5.1L
> --
> Thanks,
> Saket
> Saket Rungta1/UK/IBM@IBMGB (Office)
> saket@bcs.org.uk (Personal)
> 

I think you might be falling foul of smrsh. This isn't a James Bond
related issue ;-), it stands for SendMail Remote SHell. By default,
sendmail will only execute programs which reside in /etc/smrsh. man smrsh
for the details.

HTH
Rich


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

Date: Mon, 7 Oct 2002 11:43:10 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Vivek <vgtek@yahoo.com>
Subject: Re: Splitting Up A String
Message-Id: <Pine.A41.3.96.1021007113455.33296A-100000@cortez.sss.rpi.edu>

[posted & mailed]

On 4 Oct 2002, Vivek wrote:

>I've just started learning perl, and i was working on a problem which
>deals with cutting up a protein sequence.  I'm supposed to create a
>'cut' subroutine which cuts up a protein sequence according to a
>specified regular expression and location.
>For example if my protein sequence was:
>'QWGCSDLPFGERTYWGGP'
>And the regular expression I gave was FGER  and position was 1
>I should get the two subsequences:
>'QWGCSDLPF'  and 'GERTYWGGP'

If you have to use a regex, I'd do the following:

  sub protein_split {
    my ($seq, $rx, $pos) = @_;
    $seq =~ $rx or return;
    return (
      substr($seq, 0, $-[0] + $pos),
      substr($seq, $-[0] + $pos),
    );
  }

-- 
Jeff "japhy" Pinyan      RPI Acacia Brother #734      2002 Acacia Senior Dean
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 07 Oct 2002 17:25:38 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Wow! A trivial regexp I can't do!
Message-Id: <u9elb2w70d.fsf@wcl-l.bham.ac.uk>

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> writes:

> Whenever you use parens for bundling characters and you don't want
> anything captured, make them non-capturing by using ?:. This will make
> the whole operation slightly quicker.

That's probably untrue.  

The "whole operation" has to include the time taken to think about and
type the extra two keystrokes (call that 1s).  It also includes the
time taken to read and understand the extra two characters every time
someone looks at the code (call that 0.1s).

Now (on a moderate CPU), the time taken to perform the capturing is in
the order of 1 microsecond.

This means that it is unlikely that the _whole_ operation will be
quicker unless most of your regexs are evaluated millions of times.

Obviously you could decide just use the (?:) in situation where the
regex was going to be evaluated a millions of times.  But this
increases the thinking time to several seconds so actually makes it
_less_ likely you'll make an overall saving.

Of course, all the times involved are probably small compared to the
time we just spent discussing this matter!

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


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

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


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