[12052] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5652 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 13 14:07:13 1999

Date: Thu, 13 May 99 11:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 13 May 1999     Volume: 8 Number: 5652

Today's topics:
        [BUG] arguments/return values anomaly (Gustavo)
    Re: Attaching to run away perl program <pderbeko@iil.intel.com>
    Re: Attaching to run away perl program <dgris@moiraine.dimensional.com>
        bind_columns (DBD::Oracle) (Mark McArthey)
        C call perl - perl call c question <luca@mynet.it>
    Re: Can't call method "isaCGI"... with actual code. <bwlang@genome.wi.mit.edu>
    Re: Conditional search and replace within a text file <jacklam@math.uio.no>
    Re: Conditional search and replace within a text file <jacklam@math.uio.no>
    Re: Conditional search and replace within a text file (Larry Rosler)
    Re: Converting from octal to decimal (Randal L. Schwartz)
    Re: Converting from octal to decimal <anand@my-dejanews.com>
        DBD::ODBC - Please help! paul@infone.com
        Different Database Modules (GDBM) nkaiser@my-dejanews.com
        Do filehandles and fork mix? <--j.l.cummings--@lmco.com>
    Re: don't take care about the caps <jdf@pobox.com>
        Download register script (Marc)
    Re: FAQ 9.10: How do I redirect to another page? <aqumsieh@matrox.com>
        FLOCK When? <joeyandsherry@mindspring.com>
        Getting web page programmatically <reid.lee@natinst.com>
    Re: Getting web page programmatically <ebohlman@netcom.com>
    Re: How to mail html files? (MI)
    Re: Killing a Process <aqumsieh@matrox.com>
        Logic question <cp-ftp@connectexpress.com>
    Re: novice needs help--static variables <aqumsieh@matrox.com>
    Re: pattern matching ? <jshapir@uswest.com>
    Re: PERLFUNC: eval - catch exceptions or compile code (Randal L. Schwartz)
        print to STDOUT and a file at the same time? bing-du@tamu.edu
    Re: regexp ?: how to ignore escaped delimiter? <wells@cedarnet.org>
    Re: regexp ?: how to ignore escaped delimiter? (Ilya Zakharevich)
        SQL Server via TCP/IP? <Windhorn_Allen_E@cat.com>
    Re: string concatination ? <jshapir@uswest.com>
    Re: Threads: object method coderef syntax? <jdporter@min.net>
    Re: Threads: object method coderef syntax? (Jedi Master Yoda)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 13 May 1999 15:23:12 +0300
From: help@fight.spam (Gustavo)
Subject: [BUG] arguments/return values anomaly
Message-Id: <help-1305991523120001@gustavo-pm8200.weizmann.ac.il>

I noticed an apparent anomaly with how Perl handles subroutine arguments
and return values. I now wrote a script to exemplify it (appended). See
the output:

% ./fumble.pl foobar dongle
1) The arguments we got:        foobar  dongle
2)            aSet(@ARGV):      1       4       13      5       2
3) sort       aSet(@ARGV):      foobar  dongle
4) sort      &aSet(@ARGV):      1       13      2       4       5
5) sort bynum aSet(@ARGV):      1       2       4       5       13

After checking the book, I can say that 3) should have behaved exactly like 4).
Comments? Is this a bug?


The script:
>>>>>>>>>>>
% cat fumble.pl
#!/usr/local/bin/perl

print "1) The arguments we got:";
foreach $entry (@ARGV) {print "\t$entry";}
print "\n";

print "2)            aSet(\@ARGV):";
foreach $entry (aSet(@ARGV)) {print "\t$entry";}
print "\n";

print "3) sort       aSet(\@ARGV):";
foreach $entry (sort aSet(@ARGV)) {print "\t$entry";}
print "\n";

print "4) sort      &aSet(\@ARGV):";
foreach $entry (sort &aSet(@ARGV)) {print "\t$entry";}
print "\n";

print "5) sort bynum aSet(\@ARGV):";
foreach $entry (sort bynum aSet(@ARGV)) {print "\t$entry";}
print "\n";


sub aSet { return (1,4,13,5,2); }
sub bynum { $a <=> $b }
<<<<<<<<<<
--
-- Gustavo   http://bioinfo.weizmann.ac.il/Gustavo
--


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

Date: Thu, 13 May 1999 17:57:44 +0300
From: Philip Derbeko <pderbeko@iil.intel.com>
Subject: Re: Attaching to run away perl program
Message-Id: <373AE867.53B8FF52@iil.intel.com>


Daniel Grisinger wrote:

> Philip Derbeko <pderbeko@iil.intel.com> writes:
>
> > I wonder if there is a way to attach to the program and check whats
> > wrong , as can be done with pure executables.
>
> Of course you can attach a debugger to a running perl process.  It's
> no different than any other large program written in C.
>

Ok, but I want to see a Perl source and not a Perl running bytecodes of
my program.
If it can be done then how?

>
> dgris
> --
> Daniel Grisinger          dgris@moiraine.dimensional.com
> perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
> m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'

--
Thanks

Philip Derbeko




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

Date: 13 May 1999 09:19:29 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Attaching to run away perl program
Message-Id: <m3u2thatfi.fsf@moiraine.dimensional.com>

Philip Derbeko <pderbeko@iil.intel.com> writes:

> Daniel Grisinger wrote:
> 
> > Philip Derbeko <pderbeko@iil.intel.com> writes:
> >
> > > I wonder if there is a way to attach to the program and check whats
> > > wrong , as can be done with pure executables.
> >
> > Of course you can attach a debugger to a running perl process.  It's
> > no different than any other large program written in C.
> >
> 
> Ok, but I want to see a Perl source and not a Perl running bytecodes of
> my program.

Of course, I misunderstood.

I don't know of any way to attach to a running perl process
and view things from the level of the perl source.  Sorry.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Thu, 13 May 1999 17:23:48 GMT
From: mc_arthey@execpc.com (Mark McArthey)
Subject: bind_columns (DBD::Oracle)
Message-Id: <373b0a8b.6421188@news.mfa.com>

Hey all,
I am attempting to write a script that will handle differing SELECT
statements.  I am attempting to determine and print the bind variables
through the following.

my @cns = $sth->{NAME};
$sth->bind_columns( undef, @cns );      

foreach $col (@cns) {
    print $col;
}

It is currently not working.  It appears to be falling apart at the
bind_columns call.  Am I on the right track, or is there another, more
efficient, method?
Thanks much,
Mark McArthey

(remove "_" to e-mail)


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

Date: Thu, 13 May 1999 19:30:56 +0200
From: "Luca Legittimo" <luca@mynet.it>
Subject: C call perl - perl call c question
Message-Id: <7hf1o4$bso$1@fe2.cs.interbusiness.it>

When i create a perl interpreter from a C program, can I call a C function
from perl interpreter?

Thank in advance

Please cc to my e-mail

Luca Legittimo
luca@mynet.it




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

Date: Thu, 13 May 1999 09:22:53 -0400
From: "Bradley W. Langhorst" <bwlang@genome.wi.mit.edu>
Subject: Re: Can't call method "isaCGI"... with actual code.
Message-Id: <373AD22C.8B8579B0@genome.wi.mit.edu>




> You seem to be missing a semicolon at the end of the
> first line.  Did you actually cut-and-paste this from your
> actual code?  If this is what your code really looks like,
> then try adding that missing semicolon.
>

no that was not my real code but a simplified version to give you the
idea.

>
> Are you using perl -w?  Why not?  How about use strict?
> You'll be a much better programmer for it, I assure you.
>

i always use perl -w

>
> > I am passing the function ($q, $cgi_name)
>
> You are?  To what function?
>

to all the functions in my function list (actually im also passing them
T or F depending on whether
they should return hidden fields or print the HTML)

>
> > does the $q variable get unblessed when i call funcitions in a
> > perlmodule?
>
> Not unless your computer is next to a heavy neutron source.
>

well -there is an NMR nearby :) does a strong magnetic field count?

Here is the actual code  - sounds like you want to see it. I know it's
long
but my attempt to pseudoize it resulted in a distraction from the
problem.
again this code causes an error message to be printed right before i
make the first access of
$q in the called function.  I know this because i've put in a bunch of
print statements.


#!/usr/local/bin/perl5.00404 -w


BEGIN {
    $| = 1; #autoflush is now on
    use lib (getpwnam('cvar'))[7] . '/lib';
    use lib (getpwnam('cvar'))[7] . '/bin';
    if ($ENV{'CVAR_MORE_LIB'}) {
 unshift @INC, $ENV{'CVAR_MORE_LIB'};
    }
    use CGI::Carp qw(fatalsToBrowser carpout);
    $filename = (getpwnam('bwlang'))[7]
 ."/cgi_logs/add_genotype_data.log";
    open (LOG, ">>$filename") ||
      die "Unable to open log: $filename:\n $!\n";
    carpout(*LOG);
}
use diagnostics;
use strict;
use CGI qw(:standard :html3);
use common_functions;
use project;
#use locus;
#use plate;
#use experiment;

my ($q, $projids, $projlabels, $proj_id, $plate_id, %states);
my ($MajorMode, $function, $function_to_call, @order, $page_name, $tmp);

my (@hidden_fields, $field, $i);
my $CurrStep = 0;
%states = ('ask_project' => \&ask_project,
    'get_new_project' => \&get_new_project,
    'add_project' => \&add_project
    #'ask_locus' => \&ask_locus,
    #'get_new_locus' => \&get_new_locus,
    #'add_locus' => \&add_locus,
    #'ask_plate' => \&ask_plate,
    #'get_new_plate' => \&get_new_plate,
    #'add_plate' => \&add_plate,
    #'ask_exp' => \&ask_exp,
    #'get_new_exp' => \&get_new_exp,
    #'add_exp' => \&add_exp,
    #'display_exp' => \&display_exp,
    #'update_exp' => \&update_exp
   );
@order = ('ask_project',
   'ask_locus',
   'ask_plate',
   'ask_exp');
$q = new CGI;
$MajorMode = $q->param('major_mode');
#if the user last hit the continue button look at the value of
#move up one in the order array,
#otherwise the user just clicked on the add new button.
#Keep the same value of currstate and
#go the the function specified in the add new button

if (defined $q->param('continue')) {
    #delete the continue parameter for next time through
    $q->delete('continue');
    #set $function_to_call to the function to call by looking at
    #the major_mode parameter
    $function_to_call = $order[$MajorMode];
    $MajorMode++;

} elsif(!defined $q->param('continue') && !defined
$q->param('nextfunction')) {
    #this is the first time through
    $function_to_call = 'ask_project';
} else { #the user chose a get_new function
    #set $function from the parameter passed by the get_new
    $function_to_call = $q->param('nextfunction');
    $q->delete('nextfunction');
}


if (!$states{$function_to_call}) {die "$function_to_call is not a valid
page";}
#cannot make the header here since the JSCRIPT validation code changes
#for each page, call the function before printing anything
print $q->header, "\n";
print "This is before i call any functions\n<br>";
while (($page_name, $function) = each %states) {
    #passes true to the function that should be called but
    #false to all other functions.  They have the chance to
    #return hidden fields to store sticky values.
    print "Calling functions " . $i++ . "\n<br>";
    $tmp = $function->($q,
         $page_name eq $function_to_call,
         'add_genotype_data.cgi'
        );
    if (defined $tmp ) {push @hidden_fields, $tmp;}
}

foreach $field (@hidden_fields) {
    if ($field =~ m/\w/ && $field ne '1') { print $field, "\n";}
}
print $q->hidden(-name=>'major_mode', -value=>$MajorMode), "\n";
print $q->end_form(), "\n", $q->end_html(), "\n";


#-------------THIS CODE IS IN THE PERL MOD----------------------
package project;

BEGIN {
    require Exporter;
    require Key_Args;
}

@ISA = qw(Exporter);
@EXPORT = qw(ask_project
      get_new_project
      add_project
      );

use diagnostics;
use common_functions;
use strict;
use DBI;
#use CGI qw(:standard :html3);
#use CGI::Carp qw(fatalsToBrowser);
use DBinterface;

sub get_new_project { #gets information from the user about a new
project
    my ($q, $current, $callingCGI) = @_;
    if (! $current) {
 #return any values that should be kept for all pages
 return;
    }
    my ($JSCRIPT);
    $JSCRIPT=<<EOF;
    //#make sure that the user has entered the required information
    function validateForm() {
 if (document.form1.newprojname.value.length <=4) {
     //#the user did not enter a name for the project
     alert('Please enter a valid name for the project. (Name must be
longer than 4 characters.)');
     return false;
     document.form1.newprojname.focus();
     document.form1.newprojname.select();

 } else if (document.form1.newWIcontact.value.length <=4){
             alert('Please enter a valid WI contact name for the
project. (Name must be longer than 4 characters.)');
     return false;
     document.form1.newWIcontact.focus();
     document.form1.newWIcontact.select();
        } else if (document.form1.newEXTcontact.value.length <=4){
             alert('Please enter a valid external contact name for the
project. (Name must be longer than 4 characters.)');
     return false;
     document.form1.newEXTcontact.focus();
     document.form1.newEXTcontact.select();
        }


 return true;
    }
EOF
;
#-------------THIS IS WHERE THE ERROR IS GENERATED----------
    print $q->start_html(-Title=>'Add a new project to Genotyping DB',
    -Script=>$JSCRIPT,
    -bgcolor=>'#003366',
    -text=>'#FFFFF0',
    -Link=>'#3366FF',
    -vlink=>'#000000',
    -alink=>'#FF0000'), "\n";
    print $q->h3("Please add information about the new project.");
    print $q->start_multipart_form(-action=>$callingCGI,
       -name=>"form1",
       -onsubmit=>"return validateForm()"
      ) . "\n";
    print "Enter a name for the project: \n<br>";
    print $q->textfield(-name=>'newprojname',-size=>30), "\n", $q->br;
    print "Enter a description for the project: \n<br>";
    print $q->textarea(-name=>'newprojdesc', -rows=>5, -cols=>30,
-wrap=>'virtual');
    print "\n", $q->br;
    print "Enter a contact name from the Whitehead Institute: \n<br>";
    print $q->textfield(-name=>'newWIcontact',-size=>20), "\n", $q->br;
    print "Enter an external contact name: \n<br>";
    print $q->textfield(-name=>'newEXTcontact',-size=>20), "\n", $q->br;

    print "</TABLE><br>\n";
    add_new_button($q,'add_project','Submit');

}





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

Date: Thu, 13 May 1999 15:26:22 +0200
From: "Peter J. Acklam" <jacklam@math.uio.no>
Subject: Re: Conditional search and replace within a text file
Message-Id: <373AD2FE.7D591D07@math.uio.no>

Hawkwynd wrote:
> 
> After checking the manual, I think the following would be the correct
> usage, as I am looking to remove all instances of the word NOTES: that
> have no text following it on that line.

You are a bit vague.  What do you mean by "remove all instances of the
word NOTES: that have no text following it on that line"?  Firstly,
'NOTES:' is not a word.  Secondly, when you say "no text following",
do you mean following right after or following anywhere after?  Thirdly,
what do you mean by "text" when you say "no text".  Is '%$(\)!' text?

If you want people to give you the best answer I think you have to be
more specific.

> if ( $_ = ~m/NOTES:/s ) {
> 
> This would check to verify if the word NOTES: is the ONLY match on
> a single line, correct?

If you want to see if $_ is identical to the string 'NOTES:', don't
use regular expressions at all, use

   if ( $_ eq 'NOTES:' ) {

If you want to see if $_ contains the strong 'NOTES:', use

   if ( /NOTES:/ ) {

Hope this helps.

Peter

-- 
Peter J. Acklam - jacklam@math.uio.no - http://www.math.uio.no/~jacklam




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

Date: Thu, 13 May 1999 15:28:34 +0200
From: "Peter J. Acklam" <jacklam@math.uio.no>
Subject: Re: Conditional search and replace within a text file
Message-Id: <373AD382.A4F614A5@math.uio.no>

MicroChip wrote:
> 
> ## to turn a line "NOTES:" into "" use
> 
> s/^NOTES:$//;           ## is string is in $_
> $line =~ s/^NOTES:$//;  ## if string is in $line

No need for regexes here.  Simply use

   $_ = '' if $_ eq 'NOTES:';        ## if string is in $_
   $line = '' if $line eq 'NOTES:';  ## if string is in $line

Peter

-- 
Peter J. Acklam - jacklam@math.uio.no - http://www.math.uio.no/~jacklam



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

Date: Thu, 13 May 1999 07:19:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Conditional search and replace within a text file
Message-Id: <MPG.11a47f2e71eccc27989a5a@nntp.hpl.hp.com>

In article <373AD382.A4F614A5@math.uio.no> on Thu, 13 May 1999 15:28:34 
+0200, Peter J. Acklam <jacklam@math.uio.no> says...
> MicroChip wrote:
> > ## to turn a line "NOTES:" into "" use
> > 
> > s/^NOTES:$//;           ## is string is in $_
> > $line =~ s/^NOTES:$//;  ## if string is in $line
> 
> No need for regexes here.  Simply use
> 
>    $_ = '' if $_ eq 'NOTES:';        ## if string is in $_
>    $line = '' if $line eq 'NOTES:';  ## if string is in $line

A word of warning about this:

If $_ contains the string "NOTES:\n" then the regex matches but the 
direct comparison doesn't match.  ('$' in a regex matches the end of a 
string *or* before a newline that is at the end of a string.)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 13 May 1999 10:24:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Converting from octal to decimal
Message-Id: <m14slgevbu.fsf@halfdome.holdit.com>

>>>>> "Anand" == Anand  <anand@my-dejanews.com> writes:

Anand> In article <m167705l88.fsf@halfdome.holdit.com>,
Anand>   merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>> 
>> [note: comp.lang.perl is dead.  Real dead.  Stop using it to post.]

Anand> I am learning Perl now and started reading this newsgroup
Anand> (comp.lang.perl) to learn from others' posts. What do you mean by
Anand> "comp.lang.perl is dead"? If it is dead what newsgroup is being used for
Anand> general perl discussions? And why is c.l.p dead?

I mean exactly what I said.

comp.lang.perl is DEAD, for over two years.

It was replaced by the groups comp.lang.perl.{misc,modules,tk,announce},
and then later joined by comp.lang.perl.moderated.

If your news server permits you to post to comp.lang.perl (a dead
group), SHAME ON THEM.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 13 May 1999 15:15:56 GMT
From: Anand <anand@my-dejanews.com>
Subject: Re: Converting from octal to decimal
Message-Id: <7heqba$bj3$1@nnrp1.deja.com>

In article <m167705l88.fsf@halfdome.holdit.com>,
  merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
> [note: comp.lang.perl is dead.  Real dead.  Stop using it to post.]

I am learning Perl now and started reading this newsgroup
(comp.lang.perl) to learn from others' posts. What do you mean by
"comp.lang.perl is dead"? If it is dead what newsgroup is being used for
general perl discussions? And why is c.l.p dead?

Anand

P.S: BTW, Randal, I am reading your book, "Learning Perl" :-)


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Thu, 13 May 1999 13:22:24 GMT
From: paul@infone.com
Subject: DBD::ODBC - Please help!
Message-Id: <7hejme$6ft$1@nnrp1.deja.com>

I posted this question awhile back and didn't get a response from
anyone.  I apologize if I am asking a stupid question or something that
has been answered elsewhere but I failed to find a solution in the
documentation and faq for the module.  Any help or clues you guys could
provide would be extremely helpful.

I am using the DBI module with the DBD::ODBC driver to link up to a
MsSQL Server 7.0 database.  This is in an NT environment, using
ActivePerl 515.  I have successfully installed the module and have been
able to access the database.  My problem arises when I try to "nest"
fetch statements (i.e., prepare, execute, and fetch a query while
fetching another).  So something to the effect of:


   prepare & execute queryA
   while (fetch queryA)
   {
      prepare & execute queryB
      fetch queryB
   }

I have done this very thing with mySQL using the mysql DBD driver.  Do
you guys think this is a shortcoming in the odbc driver?  Am I
overlooking something obvious?  I realize that there are ways around the
problem... like perhaps saving the results of the first query to a hash
and looping on that, but this is a procedure I will be doing many times
and want to avoid such a messy workaround.

If it would help, I could post the exact code.  I've sort of hit a brick
wall on this, so your help would be greatly appreciated.

Thanks.

- Paul Singh


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Thu, 13 May 1999 13:28:51 GMT
From: nkaiser@my-dejanews.com
Subject: Different Database Modules (GDBM)
Message-Id: <7hek2h$6qk$1@nnrp1.deja.com>

I have a CGI which uses the GDBM_File module for storing data. I'm
finding that porting this program to different servers is difficult -
many do not have the GDBM_File module. Is there a different database
module I could use that most unix/NT machines always have?  I'm looking
for one that won't involve much code changing either. The way I use
GDBM is like this : tie (%
HASH,GDBM_File,"file.hash",GDBM_WRCREAT),0700);

Any suggestions for using other database modules? And how would that
effect the above code?

Also, why can't I find the GDBM_File module from the CPAN?  Is the only
way to install that module by recompiling Perl after installing the
libgdbm.a?

One last thing - Sometimes I don't have the privelege to do a "make
install" on a Perl module. Is it possible to use a module without doing
a "make install"?

Thanks!


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Thu, 13 May 1999 10:51:31 -0700
From: "J. Cummings" <--j.l.cummings--@lmco.com>
Subject: Do filehandles and fork mix?
Message-Id: <373B1123.3354@lmco.com>

I have a vexing problem with a perl program that uses an *input*
filehandle to loop through the lines of a file, in the usual fashion,

and then within the looping block, forks.



Somehow, in my perl code, when the files filehandle is open and the

fork operation takes place, an infinite loop or repeated looping through

the file develops. I've tried closing the child's copy of the
filehandle, but that didn't work. Any ideas as to why this is happening?
I'd greatly appreciate any help.



Here's my code snippet:



open(FILE, "file") or die "Couldn't open file: $!";



while (defined($line = <FILE>)) {



    chomp($line);



    unless (defined($pid = fork())) {

        die "Couldn't fork: $!";

    }

    unless($pid) {   #child code

        close(FILE) or die "Couldn't close filehandle: $!";

        $status = subroutine($line);

        exit $status;

    }

    waitpid($pid, 0);

}



close(FILE) or die "Couldn't close filehandle: $!";

exit 0;


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

Date: 13 May 1999 10:00:13 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: slegarre@ireste.fr
Subject: Re: don't take care about the caps
Message-Id: <m390atxe6q.fsf@joshua.panix.com>

slegarre@ireste.fr writes:

> I want to build a test on a variable but I don't want to take care
> about the caps.

Please see the perlop document, which explains the use of the matching
operator m//.  You want the /i modifier.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 13 May 1999 15:06:39 GMT
From: hlx@beatmaka.com (Marc)
Subject: Download register script
Message-Id: <373ae9ae.4421072@news.supernews.com>

Hi,

I'm searching a script that's able to register file downloads.
Something like a download counter. Password feature for admin and
e-mail registration of new dowloaders wouldn't be bad.

Thanks for help,
Marc
hlx@beatmaka.com


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

Date: Thu, 13 May 1999 10:05:38 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: FAQ 9.10: How do I redirect to another page?
Message-Id: <x3yvhdxnjym.fsf@tigre.matrox.com>


S Starre <sstarre@my-dejanews.com> writes:

> I've derived an algorithm to determine if a post is off-topic:
> 
> (($author ne 'TC')||($author ne 'LW'))&&($topic ~=/^perlish$/))&&
                                                  ^^
                                                  ^^
You have a syntax error in your code ;-)

> (print 'Hey thatz not perl!';) #note lim lw (as t->Y2K) = 0

Ala



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

Date: Thu, 13 May 1999 09:26:39 -0400
From: <joeyandsherry@mindspring.com>
Subject: FLOCK When?
Message-Id: <7hekck$taa$1@nntp4.atl.mindspring.net>

Thanks in anticipation.

I am newly learning Perl. I use a script to read a database file, the
process is simple Open it, read it, close it. This should only take an
instant. Should I use flock anywhere in this process? I currently use flock
when rewriting to a temp db while deleting a record, and I assume this is
all for security and the assurance of stable data integrity.

Thanks for your assitance.


--
Joey Cutchins
President
Trading Post.Com, L.L.C.
http://internettradingpost.com
ceo@internettradingpost.com




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

Date: Thu, 13 May 1999 10:09:59 -0500
From: "Reid Lee" <reid.lee@natinst.com>
Subject: Getting web page programmatically
Message-Id: <926607983.462.101@news.remarQ.com>

Hello all,

I need to be able to get the HTML from a web site through my perl script.
For example, I'd like to be able to call a function like this:

$webpage = openWebPage ("http://www.natinst.com");

and $webpage would contain the HTML in it so that I could edit/display the
contents of it.

Any ideas how to do this?

Regards,
Reid Lee
National Instruments
reid.lee@natinst.com




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

Date: Thu, 13 May 1999 15:29:32 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Getting web page programmatically
Message-Id: <ebohlmanFBoGD9.rD@netcom.com>

Reid Lee <reid.lee@natinst.com> wrote:
: I need to be able to get the HTML from a web site through my perl script.
: For example, I'd like to be able to call a function like this:

: $webpage = openWebPage ("http://www.natinst.com");

: and $webpage would contain the HTML in it so that I could edit/display the
: contents of it.

use LWP::Simple;
$webpage=get('http://www.natinst.com');

LWP comes with comprehensive documentation.



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

Date: Thu, 13 May 1999 08:03:35 GMT
From: mi @ alma.ch (MI)
Subject: Re: How to mail html files?
Message-Id: <1103_926582615@mi-note.alma.ch>

> I would like to mail an html file that can be viewed as html with my
> mailreader (MSOutlook).  I can tell that I need some Mime headers to do
> this properly.  It looks like MIME::Lite is too lite, in that I don't
> think it sends content-type=text/html.

It does if you (kindly) ask it to.

> What modules do I need to do this?  Are there any other good resources?

Look at http://alma.ch/perl/mail-sendmail-faq.htm#HTML
The example uses Mail::Sendmail, but you can easily adapt it to any mailer.

The point is: Content-Type: multipart/alternative, and 2 parts: text/plain and text/html

MIME::Lite definitely can do it.


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

Date: Thu, 13 May 1999 11:53:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Killing a Process
Message-Id: <x3ypv45neyj.fsf@tigre.matrox.com>


Todd McLaughlin <toddm@waltz.rahul.net> writes:

> I have Perl get the output from Lynx:
> 
> $data = `lynx -dump http://....`

I am not sure what the -dump option of lynx does (and it is not
installed here for me to check), but you might want to look at any of
the LWP modules if you want to retrieve data from the web
automatically.

> Sometimes Lynx hangs or has problems getting the data so my script
> hangs.  Is there anyway to have Perl kill the process if it hasn't
> finished after 30 seconds?  Or perhapes a command line option for
> Lynx that I don't know about?  Thanks!

Checkout perlfaq8:

     How do I timeout a slow event?

HTH,
Ala



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

Date: Thu, 13 May 1999 10:41:52 -0700
From: "Greg Lovitt" <cp-ftp@connectexpress.com>
Subject: Logic question
Message-Id: <373b0e8a@news.nwlink.com>

After reading countless faq's and many, many man pages, I am still having
trouble with what i feel is more of a logic question than a Perl question. I
thought I would throw it out here and see if it tickles the brain of anyone.

Here is what I am trying to accomplish.

I am creating a time clock for our company. Part of this script needs to
generate a "period" number for out payroll and record keeping. This period
number has been used for years on an old UNIX system and has been created by
a program in BASIC. Now, I want to generate this number in my Perl script. 
This may be a simple math issue, but my simple brain seems to be too
underpowered to figure it out.

The period number ranges from 1-255.
The period is assigned for days Mon - Friday.
Saturday is figured as the same period as Friday, and Sunday is not counted.
This period number starts over after the last number. Todays period number
is 232.
This script is being use as CGI to unput information via a browser, and I
would like to calculate this number each time the script is called.

Now, I have thought about making a dbm file that has all of the dates and
matching period numbers, however, I don't want to have to update this file
in the upcoming months or years. I would rather find a way of calculating
this, maybe using the year day, or month day along with the week day
numbers. But I cant seem to see the best way to do this.

Maybe, there is some wonderful Modual, or lib that is out there that I have
not yet run across, and would be most greatful if someone would point me in
the right direction.

I am not specificly looking for the code, to do this. I can figure that out
myself. However, if someone has suggestions on the logic or code to create
this, I would be very greatful. 

Thanks in advance
Greg Lovitt 


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

Date: Thu, 13 May 1999 11:06:01 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: novice needs help--static variables
Message-Id: <x3yso91nh5y.fsf@tigre.matrox.com>


qq <bulldozer_69@hotmail.com> writes:

> i'm a starting perl user.

Welcome to the family.

> I'm trying to generate a unique identification number for a web based
> reporting system.
> Each report sent must have a unique id number.
> The syntax  of the id number will be as follows:
> 1. It will have the last 2 digits of the year

Ever heard of Y2K? ;-)
I would use all four digits. (Note that this will still fail at the
end of the year 9999 when *we* will need 5 digits to represent the
year ;-)

> 2. Then a period
> 3. and then the number returned by a counter .
> 
> This is incremented by 1 every time a new user sends the form in.
> and the counter is reset to 0 at the beginning of every year.

[snip]

> Is there something similar to the static type in perl ?
> any ideas on how to implement this?

Something like this would give you an idea:

{
	my $counter = 0;
	sub return_id {
		my $year = shift;
		return $year . '.' . $counter++;
	}
}

Note that $counter and the return_id subroutine are in the same
scope. You will also need to find a way to loop the counter back to
zero at the beginning of each year.

HTH,
Ala



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

Date: Thu, 13 May 1999 08:38:40 -0600
From: Jim Shapiro <jshapir@uswest.com>
To: tvn007@my-dejanews.com
Subject: Re: pattern matching ?
Message-Id: <373AE3F0.B2A1F567@uswest.com>

tvn007@my-dejanews.com wrote:

> Hi,
>
> Would someone help me on this ?
>
> Problem:
>
> I have to read every single line from a file and search for
> a keyword such as si1_code , si2_code, si3_code.
>
> below is a small sample of input file:
>
> si1_code = 135'b110011;
> si2_code = 2413'b11010010;
> si3_code = 2513'b0010101101;
>
> The only thing I would like to get from
> si1_code is 110011
> and si2_code is 11010010
> ....
>
> My solution on this problem require many  steps as shown below:
> while (<INFILE>) {
> chomp;
>
>      $_ =~ s/;//;  # get rid of the ;
>      $_ =~ s/'b/ /;
>      @line = split;
>
>     if ($line[0] eq "s1_code") {
>
>      "do something"
>
>      }
>   elsif ($line[0] eq "s2_code") {
>
>      "do something"
>     }
> }
>
> I really appreciate if you can give me a better solution.
>
> Thanks in advance,
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

 while(<INFILE>) {
    print "$1\n" if /^.+'b(.+);$/;
  }

--
Regards,
Jim Shapiro





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

Date: 13 May 1999 08:17:20 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: PERLFUNC: eval - catch exceptions or compile code
Message-Id: <m1u2thdmnz.fsf@halfdome.holdit.com>

>>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:

Bart> Randal L. Schwartz wrote:
Bart> I feel that something is missing from this title. eval() does not only
Bart> compile code, it *executes* it too.
>> 
>> Oh yeah?
>> 
>> $coderef = eval 'sub { print "This code is not executed, merely compiled" }';
>> 
>> :-)

Bart> <PEDANTIC>"Executing" a sub definition merely defines it.</PEDANTIC>

Not at all.  You'd never need to get to that code at runtime
to get a definition.  Let me be clearer.

eval 'sub foo { "only at compile time" }';

There's no executable code in that eval.  None.  As a side effect of
compiling that code, &foo gets defined.  But that's done on the
compile pass, not the execute pass.

So, pedantic back at ya!

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 13 May 1999 14:09:25 GMT
From: bing-du@tamu.edu
Subject: print to STDOUT and a file at the same time?
Message-Id: <7hemej$8k1$1@nnrp1.deja.com>

Greetings all...

How to use 'print' statement to output to STDOUT and a file at the SAME
TIME?

print "hello world\n";  ---  STDOUT
print FILE "hello world\n";  ---- FILE

Thanks in advance,

Bing


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Thu, 13 May 1999 17:29:28 +0000
From: Steve Wells <wells@cedarnet.org>
Subject: Re: regexp ?: how to ignore escaped delimiter?
Message-Id: <373B0BF8.1A6E064C@cedarnet.org>

I hope I don't scare you away from PERL altogether with this.

If you want a detailed explaination of why this works then
please review the book:

"Mastering Regular Expressions" by Jeffrey E. F. Friedl

specifically page 205 as this is a modification of his
work.

Here's what I came up with:
  while (<RESULTS>) {
        push (@entry, defined($1) ? $1 : $3)
             while (m/([^\|\\]*(\\.[^\|\\]*)*)\|?|\|/g);
  }

This will find the Mastering Regular Expressions book for
you:

http://expert.cc.purdue.edu/~bgannon/booksearch/bottom.cgi?isbn=1565922573

Hope that helps,
STEVE

Spica wrote:
> 
> I hope that I don't make any major faux pas in this, my first post.
> I'm just getting started here and I've run into a snag. I've got a
> text file that is delimited with the vertical bar:  |. However, there
> are a few fields that have an excaped vertical bar: \|. I would like
> to ignore these. So, here is what my script looks like so far:
> 
> $ErrorCount = 0;
> $TotalErrorCount = 0;
> open (RESULTS, $newfile);
> while (<RESULTS>) {
>         # split the record into fields
>         ($TestPlan, $Script, $TestCase, $TestData, $ErrorCount,
> $ErrorText, $WarningCount, $WarningText, $DateTime, $Elapsed) = split
> (/\|/,$_);
> 
>         # Calculate error total
>         $TotalErrorCount += $ErrorCount;
> }
> print "Total error count: ",$TotalErrorCount;
> 
> and an example of a record where it doesn't work is:
> 
> master.pln|Unit_Testing\Scripts\LogicalView\LV_DataObject.t|ModifyObjectName|5,
> "\|MyTable", 3|0||0||1999-05-11 18.23.49|0:00:09
> 
> I'll get the error:
> 
> Argument "MyTable", 3" isn't numeric in add at filetest.pl line 13,
> <RESULTS> chunk 22.
> 
> How can I skip occurences of \|? I tried:
> 
>         ($TestPlan, $Script, $TestCase, $TestData, $ErrorCount,
> $ErrorText, $WarningCount, $WarningText, $DateTime, $Elapsed) = split
> (/[^\\]\|/,$_);
> 
> but that was worse than before.
> 
> Any help for a newbie is much appreciated.
> 
> TIA, Spica

---------------
Stephen D. Wells
http://www.iren.net/wellss/
http://expert.cc.purdue.edu/~bgannon/booksearch/


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

Date: 13 May 1999 17:44:19 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regexp ?: how to ignore escaped delimiter?
Message-Id: <7hf31j$ccq$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Steve Wells 
<wells@cedarnet.org>],
who wrote in article <373B0BF8.1A6E064C@cedarnet.org>:
> I hope I don't scare you away from PERL altogether with this.
> 
> If you want a detailed explaination of why this works then
> please review the book:
> 
> "Mastering Regular Expressions" by Jeffrey E. F. Friedl
> 
> specifically page 205 as this is a modification of his
> work.
> 
> Here's what I came up with:
>   while (<RESULTS>) {
>         push (@entry, defined($1) ? $1 : $3)
>              while (m/([^\|\\]*(\\.[^\|\\]*)*)\|?|\|/g);
>   }

Yet another example of not trusting this book for best advice.

    /(?<! \\ ) \| /x

starting from 5.005 (It does not handle \\|, but this was not requested.)

Ilya


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

Date: 13 May 1999 09:59:56 -0500
From: Allen Windhorn <Windhorn_Allen_E@cat.com>
Subject: SQL Server via TCP/IP?
Message-Id: <uemklauc3.fsf@cat.com>

Can I use perl to connect to a SQL Server 7 database via TCP/IP?  If
so, where would I get more information?  I want to do this from a
Windows NT system, and the database is on NT Server.

Thanks,
Allen
-- 
Allen Windhorn, P.E.	(507) 345-2782 	FAX 507.345.2805
Kato Engineering (now part of Emerson)
2075 Howard Drive, P.O. Box 8447, N. Mankato, MN  56002
Windhorn_Allen_E@cat.com or a.windhorn@ieee.org


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

Date: Thu, 13 May 1999 08:53:22 -0600
From: Jim Shapiro <jshapir@uswest.com>
To: tvn007@my-dejanews.com
Subject: Re: string concatination ?
Message-Id: <373AE762.D192BCBB@uswest.com>

tvn007@my-dejanews.com wrote:

> Hi,
>
> Would someone help me with this problem ?
>
> Problem:
>
> $line[1] = 010;
>
> Want the output to be:
>
> $line[1] = xxx010;
>
> My solution:
>
> for ($i = 0 ; $i < $number_of_x ; $i++){
>    $line[1] = x.$line[1]
> }
>
> ------------------------------------
>
> since $number_of_x could be thousand and I do not want goes
> through the for loop thousand of times.
>
> Would someone give be a better or more elegant solution ?
>
> Thanks in advance,
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---

If I understand your question, you want to prepend as many x's onto the
value of a variable as the variable is long.   Try this:

  my($short, $long) = ('010', '234820948092840');
  $short = 'x' x length($short) .  $short;
  $long   = 'x' x length($long)  .   $long;

--
Regards,
Jim Shapiro





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

Date: Thu, 13 May 1999 13:38:00 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Threads: object method coderef syntax?
Message-Id: <7hekjo$769$1@nnrp1.deja.com>

In article <slrn7jlhlm.66v.yoda@dagoba.org>,
  yoda@dagoba.org wrote:
> I have a $foo->bar() method call which I want to run as a Thread. Now
> the Thread constructor takes a coderef, but I can't for the life of me
> figure out the right syntax to get this. The obvious
>
> $t = new Thread(\&foo->bar());
>
> doesn't work (perl just replies 'Not a CODE reference' . I think I
must
> have tried every possible random combination of brackets, backslashes
> and braces without much joy. Help please!

I bet you didn't try this:

  $t = new Thread( sub { $foo->bar() } );

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 13 May 99 15:21:03 GMT
From: yoda@dagoba.org (Jedi Master Yoda)
Subject: Re: Threads: object method coderef syntax?
Message-Id: <slrn7jlu14.69u.yoda@dagoba.org>

On Thu, 13 May 1999 13:38:00 GMT, John Porter <jdporter@min.net> saw
fit to expound:
>
>  $t = new Thread( sub { $foo->bar() } );

FX: lightbulb goes on over head

Thanks ;)

JMY


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5652
**************************************

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