[22865] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5086 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 6 21:10:36 2003

Date: Fri, 6 Jun 2003 18:10: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           Fri, 6 Jun 2003     Volume: 10 Number: 5086

Today's topics:
    Re: Loading perl modules / Caching when it shouldn't -  <nobull@mail.com>
        Managing Report File Types <goedicke@goedsole.com>
    Re: perl and surveys <noreply@gunnar.cc>
    Re: perl and surveys (Steve)
    Re: perl and surveys <emschwar@pobox.com>
    Re: Perl and Win32 OLE Excel scripting problem/question (Jay Tilton)
    Re: perl xs module <kalinabears@hdc.com.au>
    Re: perl <graham.drabble@lineone.net>
    Re: redirect location prints to screen (Harvey Siegelman)
    Re: Remove first character in a string? (Jay Tilton)
        Search and Replace in Files? (Sylvie Stone)
    Re: Search and Replace in Files? <jkeen@concentric.net>
        Strange observation (Go Perl)
    Re: Strange observation <drumspoorly@reachone.net>
    Re: Strange observation <krahnj@acm.org>
        TELNET: how to print errmsg & the command (Anand Ramamurthy)
    Re: Temporary "holding"/"Working" page - ideas? <ltierney@ltierney.demon.co.uk>
    Re: Unusual Can't load fail (web only) <drumspoorly@reachone.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 06 Jun 2003 21:46:39 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Loading perl modules / Caching when it shouldn't - HELP!
Message-Id: <u9y90f6ij4.fsf@wcl-l.bham.ac.uk>

david.gavini@digitallook.com (David Gavini) writes:

> I'm having a strange problem with perl being served through apache.
> 
> Below is an example of how to reproduce this problem.
> 
> The problem is that we cannot dynamically export between 2 modules if
> our import logic resides in a 3rd module held in modperl.
> This causes the code to appear to be cached, resulting in our scripts
> acting in an unexpected manner.

Yes - "use Digital::Test" is compile time.  I only happens when the
script is compiled.  With mod_perl the script is only compiled once.
Any statements that appear in outside of a subroutine definition in
Digital/Test.pm are _executed_ during the compilation phase of
/Digital/test.cgi so are only executed during the first execution of
/Digital/test.cgi.

> [ Introduction to problem replication]

David gives very long - but really execellent explaination of the problem.
It really is a pleasure to answer such a well asked question.

> package Digital::Test;
> use Exporter;
> @ISA = ('Exporter');
> @EXPORT = qw(&printletter);
> 
> use strict;
> use lib qw( /usr/local/etc/httpd/cgi-bin/ );

> my $type = $ENV{'QUERY_STRING'};
> 
> if ($type eq "A")
> {
>  require A::Test;
>  A::Test->import();
> }
> elsif ($type eq "B")
> {
>  require B::Test;
>  B::Test->import();
> }
> 
> 1;

Digital::Test is looking at $ENV{'QUERY_STRING'} during the compile
phase.  (Not the compile phase of the module itself, you understand,
but the compile phase of whatever's use()ing Digital::Test).

The fix is to look at run time, when &Digital::Test::printletter is
called.  Assumming there are a lot of such subroutines in the real
case I'll show this using AUTOLOAD.  (Obviously for a single
subroutine this would be overkill).

Obviously where I say "or die" you'd probably want more.

# No shebang on a module!
use strict; # It's never too soon to be strict
use warnings;
package Digital::Test;
require Exporter; # Don't use (semantics are not defined)
our @ISA = ('Exporter');
our @EXPORT = qw(&printletter);

require UNIVERSAL::require;

# This should probably go in your mod_perl startup
# That said, putting your modules in cgi-bin is bad form
use lib qw( /usr/local/etc/httpd/cgi-bin/ );

sub printletter; # Just a stub

sub AUTOLOAD {
   my $type = $ENV{QUERY_STRING} or die;
   my ($func) = our $AUTOLOAD =~ /(\w+)$/ or die;
   my $module = {
      A => 'A::Test',
      B => 'B::Test',
   }->{$type} or die;
   $module->require or die;
   no strict 'refs';
   goto &{"${module}::$func"};
}      

1;
__END__

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


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

Date: Fri, 06 Jun 2003 22:49:59 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Managing Report File Types
Message-Id: <m3el26x1m2.fsf@mail.goedsole.com>

Dear Y'all - 

Virtually all of my code generates some sort of report.  These reports
have some file content format: HTML, wiki, RTF...  Often I provide
flags allowing the user to specify the format.

The issue is I'd like to have a scheme for storing the content like
XSLT... which I'd use for all my programs and which would easily
output to a reasonably large set of commonly desired formats.  What do
you all recommend for such a scheme and what modules do you use to
implement it?

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

Conversation: A series of digressions.

		- Kevin Montuori


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

Date: Fri, 06 Jun 2003 20:54:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: perl and surveys
Message-Id: <bbqo1d$cjlq4$1@ID-184292.news.dfncis.de>

Steve wrote:
> Gunnar Hjalmarsson wrote:
>> BitZer0 wrote:
>> 
>>> I'm trying to make site that'll display different surveys
>>> depending on the count of visitors.  Can anyone help me out?  I
>>> have 12 different surveys that needs to be properly cycled
>>> through.  The surveys also need to store the results to an
>>> appropriately named file (ie, survey1, survey2, ..., survey12).
>>> I'm not much of a perl script programmer, ...
>> 
>> Then hire somebody who is. Or learn it yourself.
> 
> Gunnar, maybe is't time for you to take a break, from the
> internet.. you sound old and tired.

Maybe it is, maybe I am. But you don't get the message, do you?

In a community around an open source program like Perl, the members
must act in a spirit of both giving and taking, not just taking.
clpmisc is intended for discussion of Perl, not for job postings:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Plain requests for programming help, without showing that you have 
tried yourself, simply don't fit here.

/ Gunnar

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



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

Date: 6 Jun 2003 16:20:35 -0700
From: techadmin@shaw.ca (Steve)
Subject: Re: perl and surveys
Message-Id: <2e27f51a.0306061520.382efebe@posting.google.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<bbqo1d$cjlq4$1@ID-184292.news.dfncis.de>...
> Steve wrote:
> > Gunnar Hjalmarsson wrote:
> >> BitZer0 wrote:
> >> 
> >>> I'm trying to make site that'll display different surveys
> >>> depending on the count of visitors.  Can anyone help me out?  I
> >>> have 12 different surveys that needs to be properly cycled
> >>> through.  The surveys also need to store the results to an
> >>> appropriately named file (ie, survey1, survey2, ..., survey12).
> >>> I'm not much of a perl script programmer, ...
> >> 
> >> Then hire somebody who is. Or learn it yourself.
> > 
> > Gunnar, maybe is't time for you to take a break, from the
> > internet.. you sound old and tired.
> 
> Maybe it is, maybe I am. But you don't get the message, do you?
> 
> In a community around an open source program like Perl, the members
> must act in a spirit of both giving and taking, not just taking.
> clpmisc is intended for discussion of Perl, not for job postings:
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
> 
> Plain requests for programming help, without showing that you have 
> tried yourself, simply don't fit here.
> 
> / Gunnar

Is this not a message board where people ask questions about perl
script? and hope that maybe someone will assist? who ever asked about
a job?


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

Date: 06 Jun 2003 17:51:50 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: perl and surveys
Message-Id: <eto3cimsr1l.fsf@wormtongue.emschwar>

techadmin@shaw.ca (Steve) writes:
> Is this not a message board where people ask questions about perl
> script?

It's a newsgroup, not a message board, and it's for discussing the
Perl language.  Often, that will happen because someone has trouble
with a script, but this is not a "write my code for me" service, it's
a group where we discuss Perl.

> and hope that maybe someone will assist?

I suggest you reread the original poster's post.  A request for
assistance looks like, "Here's what I want to do.  Here's what I've
tried.  Here's how my results differ from my expectations."  What was
posted looked more like, "Here's what I need.  Can anyone do it for
me?"  That's not what we're here for.

The OP is likely to get more, and higher-quality, responses if they
follow the posting guidelines, posted here regularly.  Among which is
the suggestion to reduce the problem to a small script (20-30 lines)
that reproduces the problem.  Often, that's enough right there to show
you where the problem is.  One is also expected to read the
documentation that comes with one's Perl distribution.

The OP did nothing like that.  They said, in essence, "Write me a
script to do all this."  They showed no evidence of having done any
effort whatsoever.  They asked no specific question.  They just said,
"Here's what I want."

> who ever asked about a job?

Apparently the OP wanted someone else to do their work for them.
Generally, in a capitalist society, this is accompanied by an exchange
of funds.  Hence, a job.  If the OP wanted someone to do it for free,
they're free to ask, but they're likely to get rather negative
feedback about it.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Fri, 06 Jun 2003 23:03:14 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl and Win32 OLE Excel scripting problem/question... simple?
Message-Id: <3ee11649.258135576@news.erols.com>

jeffleary00@hotmail.com (Jeff Leary) wrote:

: The call to extract the data ( $Sheet->Cells($row,$col)->{'Value'} )
: seems to object to the $ROW,$COL assignments from an array... I keep
: getting an error message that says:
: 
: >> Win32::OLE(0.1601) error 0x800a03ec
: >> in METHOD/PROPERTYGET "Cells" at C:\perl_dev\b.pl line 18
 
[snip]

: @L = qw(4 2 5 2 3 8 2 8 13 9);
: for ($i = 0; $i <= 8; $i += 2) {
: 	$row=$L[$i];
: 	$col=$L[$i+1];					
: 	# skip empty cells, or print cells containing information	 	
: 	next unless defined $Sheet->Cells($row,$col)->{'Value'};
: 	printf "ROW %s, COL %d, VALUE %s\n",$row,$col,$Sheet->Cells($row,$col)->{'Text'};
: }

Looks like something is getting flummoxed by the distinction between
strings and numbers.  That is, the list created by qw() are strings
(with an external appearance of numbers), but they are being handed
off to the Cells() method without getting numified.

Changing it to

    $Sheet->Cells(0 + $row, 0 + $col)->{'Value'}

brings things back into line.  Or you could force numification at the
array assignment like

    @L = map $_+0, qw(4 2 5 2 3 8 2 8 13 9);

Nicely prepared test program, btw.  Not too much, not too little.
My only misgiving about it was its lack of "use strict;" .



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

Date: Sat, 7 Jun 2003 10:45:32 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: perl xs module
Message-Id: <3ee136d6$0$30699@echo-01.iinet.net.au>


"Jeff Mott" <mjeff1@twcny.rr.com> wrote in message
news:970676ed.0306060309.2148ea6e@posting.google.com...
> ...seems to come with several files (.pm .bs .dll .exp .lib). I've
> found I can get away with discluding all but .pm and .dll, but
> although I can do this I'm trying to find out if I should to this. Are
> the others necessary at any time for execution of the module?

I hope not :-)
On my mingw-built perl all that gets installed is the '.pm', the '.dll', the
(empty) '.bs' and a '.packlist'.

The inclusion of the '.exp' and the '.lib' seems to be a msvc thing.

Cheers,
Rob




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

Date: Fri, 06 Jun 2003 19:05:44 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: perl
Message-Id: <Xns9392C2406CE2Cgrahamdrabblelineone@ID-77355.user.dfncis.de>

On 06 Jun 2003 tadmc@augustmail.com (Tad McClellan) wrote in 
news:slrnbe1keg.2gk.tadmc@magna.augustmail.com:

> Graham Drabble <graham.drabble@lineone.net> wrote:
>> On 06 Jun 2003 tadmc@augustmail.com (Tad McClellan) wrote in
>> news:slrnbe154d.264.tadmc@magna.augustmail.com: 
>>> I recommend a book that isn't even really a Perl book (MRE),
>>                                                         ^^^^^
>> 
>> EXPN?
>    perldoc -q book
> 
>           Special Topics
>                   Mastering Regular Expressions

> (but get the *2nd* edition!)

Thanks. I wondered if it might be that one.


-- 
Graham Drabble
If you're interested in what goes on in other groups or want to find 
an interesting group to read then check news.groups.reviews for what 
others have to say or contribute a review for others to read.


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

Date: 6 Jun 2003 17:36:16 -0700
From: hsiegelman@mchsi.com (Harvey Siegelman)
Subject: Re: redirect location prints to screen
Message-Id: <888b276e.0306061636.3f81a82d@posting.google.com>

Thomas Nagel <thomas.nagel@planb.de> wrote in message news:<bbpvas$13r$1@sapa.inka.de>...
> Hi,
> 
>  > What am I doing wrong?  Here is the cgi code:
> > 
> > #!/usr/bin/perl
> > $baseurl = 'http://www.economicsgroup.com/clients/';
> > $user = $ENV{'REMOTE_USER'};
> > $fullurl = $baseurl.lc($user);
> > print "Location: $fullurl/\n\n";
> 
> Works perfectly for me.
> 
> What Webserver / Browser are you using?

Thanks for all of the suggestions, but so far none of them have worked
on my site.  The mechanics of website may be responsible for the
problem.  I have a root index page that contains a 'client' link. 
That link goes to a client folder which contains several subfolders
each of which is named after a client.

Those subfolders are password protected and the username for each is
the name of their folder.  Within the client folder is also an
index.shtml page that contains the call to the CGI script.  I need to
have this call from within the client folder in order for the
username/password prompt to be executed PRIOR to calling the CGI
script.  I do that in order to record the username response as an
environment variable (REMOTE_USER).  To see how this currently works
visit my site: www.economicsgroup.com and test the client access link.
 A test username and password is ahm/ron.  What I have is a reasonable
workaround but I was hoping to find a way to avoid the intermediate
page with the hypertext that reads
'http://www.economicsgroup.com/clients/ahm/'.

BTW I am running this on a unix box.  Thanks again for your
suggestions.


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

Date: Fri, 06 Jun 2003 23:04:59 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Remove first character in a string?
Message-Id: <3ee11706.258324277@news.erols.com>

Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote:

: chip() should make a fine opposite to chop()
: I find myself removing a first char regularly.

Like others, I was chuckling at that and at the idea of also having a
simian-named function.  Yesterday I came upon a situation where a
chip() function would fit perfectly, and I realized how many times in
the past I could have used it.  Next thing I knew, I was writing it.

    sub chip {
        return chip($_) unless @_; # default to acting on $_
        my $c;
        for(@_) {
            if(defined && length) {
                ($c, $_) =
                    (
                    substr($_, 0, 1),
                    substr($_, 1)
                    );
            }
            else {
                $c = '';
            }
        }
        $c;
    }

I think that mimics[1] the documented and observable behavior of
chop() pretty well, and isn't excessively complex or golfish.
Benchmarks showed no appreciable difference in speed between using
substr and using reverse/chop/reverse.  I didn't bother benchmarking a
regex approach.

Suggestions for improvement?  Edge cases that need testing?

[1] Or, if you enjoy threads loaded with primate references, "apes."



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

Date: 6 Jun 2003 11:08:15 -0700
From: sylviestone@canada.com (Sylvie Stone)
Subject: Search and Replace in Files?
Message-Id: <181a24a8.0306061008.58b9c21f@posting.google.com>

Hi Group - my script is replacing in the first file it encounters, but
then it bails. Not sure why. WHen I'm printing my system command it is
looping through two files:

foreach $file (@list) {
  print "changing $file\n";
}

$what = $ARGV[1];
$newtext = $ARGV[3];

print "Would you like to proceed? (Y/N)";
$x = <STDIN>;
chop($x);

if ($x eq "Y") {

   foreach $file (@list) {
    $cc = "";
    $file2 = $file;
    open (test, "<$file");
    # $file =~s /^*.html*//;

    while ($ct = <test>) {
      chomp $ct;
      if ($ct =~ /$ARGV[1]/) {#need to replace that line with ww2
          system "perl -pi -e 's/$ARGV[1]/$ARGV[3]/g' $file";
          print "system = perl -pi -e 's/$ARGV[1]/$ARGV[3]/g'
$file\n";
      }
    $cc .= $ct."\n";
    }

  }

close (test);
open(NEW,">$file2");
print NEW $cc;
close(NEW);

} else {

< snip >

Output:
# ./replacemany.cgi -w 1 -n david
changing david.html
changing lynda.html
Would you like to proceed? (Y/N)Y
system = perl -pi -e 's/1/david/g' david.html
system = perl -pi -e 's/1/david/g' david.html
system = perl -pi -e 's/1/david/g' lynda.html
system = perl -pi -e 's/1/david/g' lynda.html


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

Date: 06 Jun 2003 23:28:39 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Search and Replace in Files?
Message-Id: <bbr837$9s2@dispatch.concentric.net>


"Sylvie Stone" <sylviestone@canada.com> wrote in message
news:181a24a8.0306061008.58b9c21f@posting.google.com...
> Hi Group - my script is replacing in the first file it encounters, but
> then it bails. Not sure why.

I'm not sure why either; your code is very difficult to follow and
unnecessarily roundabout.

1.  Did you call 'use strict;' at the top of this script.  Given that you
have no scoping of variables indicated, I suspect you didn't.
2.  Did you call 'use warnings;' or call the '-w' flag on the shebang line?
Again, I suspect not.

> WHen I'm printing my system command it is
> looping through two files:
>
> foreach $file (@list) {
>   print "changing $file\n";
> }
>
> $what = $ARGV[1];
> $newtext = $ARGV[3];
>
You assign to $what and $newtext and never call them hereafter.

> print "Would you like to proceed? (Y/N)";
> $x = <STDIN>;
> chop($x);
>
Poor style.  What you want is:   chomp($x = <STDIN>);

> if ($x eq "Y") {
>
>    foreach $file (@list) {
>     $cc = "";
>     $file2 = $file;
>     open (test, "<$file");
>     # $file =~s /^*.html*//;
>
>     while ($ct = <test>) {
>       chomp $ct;
>       if ($ct =~ /$ARGV[1]/) {#need to replace that line with ww2
>           system "perl -pi -e 's/$ARGV[1]/$ARGV[3]/g' $file";
>           print "system = perl -pi -e 's/$ARGV[1]/$ARGV[3]/g'
> $file\n";

Why do a system call ... and a system call to perl's own command-line
interpreter to boot ... when you can do it all inside Perl?

>       }
>     $cc .= $ct."\n";
>     }
>
>   }
>
> close (test);
> open(NEW,">$file2");
> print NEW $cc;
> close(NEW);
>

I suspect that what you're trying to accomplish is to change particular
lines in a number of files.  These days the best way to do that is with the
'Tie::File' module by Mark Jason Dominus, available from CPAN and standard
with Perl 5.8.




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

Date: 6 Jun 2003 14:46:37 -0700
From: puissant00@yahoo.com (Go Perl)
Subject: Strange observation
Message-Id: <d3825316.0306061346.2f9c12d5@posting.google.com>

This is working
elsif ($read[7] == 70) { 
           $read[0]=$REAL_VALUE[$i][14];   # save
REAL_VALUE[14]..REAL_VALUE[19].
           $read[1]=$REAL_VALUE[$i][15];             
           $read[2]=$REAL_VALUE[$i][16]; 
           $read[3]=$REAL_VALUE[$i][17];             
           $read[4]=$REAL_VALUE[$i][18]; 
           $read[5]=$REAL_VALUE[$i][19];
	   $read[6]=$REAL_VALUE[$i][20];             
           $read[15]=$REAL_VALUE[$i][21]; 
           $read[8]=$REAL_VALUE[$i][22];             
           $read[9]=$REAL_VALUE[$i][23]; 
           $read[10]=$REAL_VALUE[$i][24];             
	   $read[11]=$REAL_VALUE[$i][25];             
           $read[12]=$REAL_VALUE[$i][26]; 
           $read[13]=$REAL_VALUE[$i][27];             
           $read[14]=$REAL_VALUE[$i][28]; 
                      
           printf TEMP_FILE
("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n", 
$read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[15],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[7]);
and this is not how come ??
elsif ($read[16] == 70) { 
           $read[0]=$REAL_VALUE[$i][14];   # save
REAL_VALUE[14]..REAL_VALUE[19].
           $read[1]=$REAL_VALUE[$i][15];             
           $read[2]=$REAL_VALUE[$i][16]; 
           $read[3]=$REAL_VALUE[$i][17];             
           $read[4]=$REAL_VALUE[$i][18]; 
           $read[5]=$REAL_VALUE[$i][19];
	    $read[6]=$REAL_VALUE[$i][20];             
           $read[7]=$REAL_VALUE[$i][21]; 
           $read[8]=$REAL_VALUE[$i][22];             
           $read[9]=$REAL_VALUE[$i][23]; 
           $read[10]=$REAL_VALUE[$i][24];             
	     $read[11]=$REAL_VALUE[$i][25];             
           $read[12]=$REAL_VALUE[$i][26]; 
           $read[13]=$REAL_VALUE[$i][27];             
           $read[14]=$REAL_VALUE[$i][28]; 
                      
           printf TEMP_FILE
("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n", 
$read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[7],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[16]);

i am trying to read the following line:
12 12 23 34 54 56 67 87 89 90 90 97 12 14 15                  7
0
forget about the spaces in the input line why is this happening


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

Date: Fri, 06 Jun 2003 16:24:06 -0700
From: Steve May <drumspoorly@reachone.net>
Subject: Re: Strange observation
Message-Id: <ve2876ci5bm86d@corp.supernews.com>

Go Perl wrote:
> This is working
> elsif ($read[7] == 70) { 
>            $read[0]=$REAL_VALUE[$i][14];   # save
> REAL_VALUE[14]..REAL_VALUE[19].
>            $read[1]=$REAL_VALUE[$i][15];             
>            $read[2]=$REAL_VALUE[$i][16]; 
>            $read[3]=$REAL_VALUE[$i][17];             
>            $read[4]=$REAL_VALUE[$i][18]; 
>            $read[5]=$REAL_VALUE[$i][19];
> 	   $read[6]=$REAL_VALUE[$i][20];             
>            $read[15]=$REAL_VALUE[$i][21]; 
>            $read[8]=$REAL_VALUE[$i][22];             
>            $read[9]=$REAL_VALUE[$i][23]; 
>            $read[10]=$REAL_VALUE[$i][24];             
> 	   $read[11]=$REAL_VALUE[$i][25];             
>            $read[12]=$REAL_VALUE[$i][26]; 
>            $read[13]=$REAL_VALUE[$i][27];             
>            $read[14]=$REAL_VALUE[$i][28]; 
>                       
>            printf TEMP_FILE
> ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n", 
> $read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[15],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[7]);
> and this is not how come ??
> elsif ($read[16] == 70) { 
>            $read[0]=$REAL_VALUE[$i][14];   # save
> REAL_VALUE[14]..REAL_VALUE[19].
>            $read[1]=$REAL_VALUE[$i][15];             
>            $read[2]=$REAL_VALUE[$i][16]; 
>            $read[3]=$REAL_VALUE[$i][17];             
>            $read[4]=$REAL_VALUE[$i][18]; 
>            $read[5]=$REAL_VALUE[$i][19];
> 	    $read[6]=$REAL_VALUE[$i][20];             
>            $read[7]=$REAL_VALUE[$i][21]; 
>            $read[8]=$REAL_VALUE[$i][22];             
>            $read[9]=$REAL_VALUE[$i][23]; 
>            $read[10]=$REAL_VALUE[$i][24];             
> 	     $read[11]=$REAL_VALUE[$i][25];             
>            $read[12]=$REAL_VALUE[$i][26]; 
>            $read[13]=$REAL_VALUE[$i][27];             
>            $read[14]=$REAL_VALUE[$i][28]; 
>                       
>            printf TEMP_FILE
> ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n", 
> $read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[7],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[16]);
> 
> i am trying to read the following line:
> 12 12 23 34 54 56 67 87 89 90 90 97 12 14 15                  7
> 0
> forget about the spaces in the input line why is this happening

Sheesh!

Slices are your friend for this sort of thing:

if( $read[7] == 70 ){
     @read[0..14] = @{$REAL_VALUE[$i]}[14..28];
}


As to why the second elsif is not working:  there appear to be only
16 fields in your input data yet you are trying an equality on the
17th element ( $read[16] ).  Is this what you want to do?

s.



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

Date: Sat, 07 Jun 2003 00:13:29 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Strange observation
Message-Id: <3EE12E16.972F71A4@acm.org>

Go Perl wrote:
> 
> This is working
> elsif ($read[7] == 70) {
>            $read[0]=$REAL_VALUE[$i][14];   # save
> REAL_VALUE[14]..REAL_VALUE[19].
>            $read[1]=$REAL_VALUE[$i][15];
>            $read[2]=$REAL_VALUE[$i][16];
>            $read[3]=$REAL_VALUE[$i][17];
>            $read[4]=$REAL_VALUE[$i][18];
>            $read[5]=$REAL_VALUE[$i][19];
>            $read[6]=$REAL_VALUE[$i][20];
>            $read[15]=$REAL_VALUE[$i][21];
>            $read[8]=$REAL_VALUE[$i][22];
>            $read[9]=$REAL_VALUE[$i][23];
>            $read[10]=$REAL_VALUE[$i][24];
>            $read[11]=$REAL_VALUE[$i][25];
>            $read[12]=$REAL_VALUE[$i][26];
>            $read[13]=$REAL_VALUE[$i][27];
>            $read[14]=$REAL_VALUE[$i][28];
> 
>            printf TEMP_FILE
> ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
> $read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[15],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[7]);

You can simplify that code a bit:

elsif ( $read[ 7 ] == 70 ) {
    @read[ 0 .. 6, 15, 8 .. 14 ] = @{$REAL_VALUE[ $i ]}[ 14 .. 28 ];
    printf TEMP_FILE '%4d' x 15 . "%20d\n", @read[ 0 .. 6, 15, 8 .. 14
];
    }



> and this is not how come ??
> elsif ($read[16] == 70) {

Perhaps the value in $read[16] is not equal to 70?


John
-- 
use Perl;
program
fulfillment


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

Date: 6 Jun 2003 14:10:23 -0700
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: TELNET: how to print errmsg & the command
Message-Id: <761041e6.0306061310.54fb1371@posting.google.com>

I have a errormode similar to this in a sub called openTelnet
which returns a Net::Telnet object :

$s->errmode(sub
           {
              ($s->timed_out) {
                     warn "$host busy: ", $s->errmsg, "\n";
              }
              elsif ($s->eof) {
                    warn "$host offline: ", $s->errmsg, "\n";
              }
              else {
                    warn $s->errmsg, "\n";
              }
           });

using the object returned I execute a command using $s->cmd($command)
in another sub. When an error is generated, one of the above
error warn messages is displayed. How can I display the command
($command) that generated the error in the $s->errmode.

Do I still have access to the command that was passed to
$s->cmd within $s. If yes, what is the variable name?
$s->errmode will not what command caused $s to generate error.

Thank you,

-anand


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

Date: Fri, 6 Jun 2003 21:18:23 +0100
From: "Lawrence Tierney" <ltierney@ltierney.demon.co.uk>
Subject: Re: Temporary "holding"/"Working" page - ideas?
Message-Id: <bbqsul$aat$1$8300dec7@news.demon.co.uk>

Cheers mate that's absolutely perfect!

--
ltierney@ltierney.demon.co.uk

"J. Gleixner" <glex_nospam@qwest.net> wrote in message
news:oH3Ea.756$md3.33711@news.uswest.net...
> Lawrence Tierney wrote:
> > Hi there,
> >
> > Looking for some ideas.
> >
> > Got a script which runs a sql search. This search can take anything up
to 60
> > secs - quite a long time. What I'd like to do is while the mySQL is
> > doing its stuff display a page like "Hold on - searching".
>
> See Randal's column at:
> http://www.stonehenge.com/merlyn/WebTechniques/col20.html
>




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

Date: Fri, 06 Jun 2003 12:28:18 -0700
From: Steve May <drumspoorly@reachone.net>
Subject: Re: Unusual Can't load fail (web only)
Message-Id: <ve1qd7c363pef3@corp.supernews.com>

Mike Bobbitt wrote:
> Hi all,
> 
> I've got an odd problem, that doesn't seem to be covered by any of the
> exisiting threads. When I run a simple DB perl script through the
> command line, it fetches the info and works fine. However, if I run it
> via the web, I get the following error:
> 
> install_driver(mysql) failed: Can't load
> '/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBD/mysql/mysql.so'
> for module DBD::mysql:
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBD/mysql/mysql.so:
> undefined symbol: PL_perl_destruct_level at
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 229.
> 
> I've re-installed DBD::mysql using perl -MCPAN -e shell; and manually,
> and there's no change. The fact that it runs via command line seems to
> indicate permissions, but I ran "chmod -R o+r /usr/lib/perl5" and no
> change.
> 
> Any help would be appreciated.
> 
> Thanks!

Just a thought, double check the shebang line at the top of the perl
main executable.

#! /usr/bin/perl

And then run perl -v from the command line to make sure everything is
pointing to the same place.


hth,

s.



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

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


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