[15513] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2923 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 2 11:05:24 2000

Date: Tue, 2 May 2000 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957279910-v9-i2923@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 2 May 2000     Volume: 9 Number: 2923

Today's topics:
    Re: Basic Exporter question (Stuart Kendrick)
    Re: Basic Exporter question poppln@my-deja.com
    Re: Basic Exporter question <iltzu@sci.invalid>
        bourne 'dot' or csh 'source behavior <shutchis@sherritt-NO_SPAM_PLEASEintl.com>
    Re: CGI.pm and -w <care227@attglobal.net>
    Re: CGI.pm and -w <care227@attglobal.net>
    Re: CGI.pm and -w (Tad McClellan)
    Re: CGI.pm and -w <jeff@vpservices.com>
    Re: confusing backtracking <rick.delaney@home.com>
    Re: convert to tab delimited file. <gary@dkstat.com>
    Re: Error Trapping (Tad McClellan)
    Re: Error Trapping <adams1015@worldnet.att.net>
        How to compare values between 2 arrays ? c_neak@my-deja.com
    Re: How to test perl CGI scripts on my computer first? <bernie@fantasyfarm.com>
    Re: I goofed (Jehsom)
    Re: I goofed (Randal L. Schwartz)
    Re: newbie Q - detecting browser version <care227@attglobal.net>
        Perl CGI Script Crashes on Win2K but not at Command <KidRockYou@yahoo.com>
    Re: perl in NT .BAT files Question <DNess@Home.Com>
    Re: Perl, limiting displayed decimal places (Tad McClellan)
    Re: Print Just Once When in (<>)? efroselli@my-deja.com
        Problem with local installation of a module <mahnke@uni-freiburg.de>
        Specifying timeout with sockets <dodd@ll.mit.edu>
    Re: using system or open to get program output <adams1015@worldnet.att.net>
        Win32 Perl Program RAM Usage (R1CH)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 2 May 2000 13:05:40 GMT
From: skendric@fhcrc.org (Stuart Kendrick)
Subject: Re: Basic Exporter question
Message-Id: <8emjr4$78g$1@pony.fhcrc.org>

Hi Uri,

OK, I've read a bit about OOP and appropriate behavior and I understand
now your point about using @EXPORT_OK over @EXPORT, to preserve my
sanity level when utilizing modules (or, more precisely, to avoid
polluting the variable name space of my primary program.)

And I realize that what I really want to do is to modify the base class
of global variables (ha!  I'm learning enough about this OOP stuff to
become dangerous!  I didn't really understand that last sentence, but
hey, I'm learning.)  And you outline a way for me to do this, skipping
Exporter entirely.

So Foo.pm now looks as follows:

--------------------------
package Foo;

use strict;
use diagnostics;
use vars qw( $a $b $c $d ....);  # Thirty-some variables
use base qw( $a $b $c $d ....);  # Same list of thirty-some variables

$a = "blue";
$b = "green";
$c = "brown";
 ...

return 1;
---------------------------

Two queries:
(a) Is there a way for me to avoid maintaining *two* lists of
thirty-some variables?  I would like to define this list once.  (I
expect this list to be dynamic during development, and I can see room
for my usual fat fingers to unsync the "use vars" list and the "use
base" list.
(b)  My test program "test" doesn't know about any of my thirty-some
variables, despite the "use Foo;" statement at the front.  I tried
using your line of "use base qw( Exporter);" in place of my "use base
qw ($a $b $c ....);", but it didn't help the situation ... and I
confess that I don't understand the construct you are employing,
placing a Module name as an argument to the "use base" pragma.


Am I on the right track now, wanting to modify the base class of global
variables?  And if so, what am I missing, that my class of global
variables in my "test" program doesn't seem to get modified, despite
the "use Foo;" statement up front?

test
---------------------
#!/opt/local/bin/perl
use Foo;

print "a = $a\n";
---------------------

--sk

Stuart Kendrick
FHCRC


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

Date: Tue, 02 May 2000 13:51:41 GMT
From: poppln@my-deja.com
Subject: Re: Basic Exporter question
Message-Id: <8emmh6$8d$1@nnrp1.deja.com>

In article <8eki08$m92$1@pony.fhcrc.org>,
  skendric@fhcrc.org (Stuart Kendrick) wrote:
> uluc05{root}: perl -w test.pl
> Global symbol "@ISA" requires explicit package name at Foo.pm line 6.
> Global symbol "@EXPORT" requires explicit package name at Foo.pm line
> 7.

try
package Foo;
 use strict;
 use Exporter;
 @Foo::ISA = qw(Exporter);
 @Foo:EXPORT = qw($colour);

 use vars qw($color);
 $colour = 'octarine';


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 2 May 2000 14:16:02 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Basic Exporter question
Message-Id: <957276219.11847@itz.pp.sci.fi>

In article <8eki08$m92$1@pony.fhcrc.org>, Stuart Kendrick wrote:
>I quite specifically don't want to use the @EXPORT_OK construct.  My
>real program -- not shown here -- defines a ton of variables which I
>then want imported into other scripts.  I don't want to be updating
>this list of variables on "use Foo qw(x y z)" every time I add another
>variable to my Foo.pm file.

Ok, rethink time.  If you'd told us that at the beginning, you'd have
got much more useful advice.

You _don't_ want to be exporting "a ton of variables".  There are many
ways to do that, some better, some worse, but they're all wrong ways.

What you probably want is to export _one_ hash that contains all those
values.  That's not the only way to do it, but it's the simplest.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.




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

Date: 2 May 2000 10:01:19 -0500
From: <shutchis@sherritt-NO_SPAM_PLEASEintl.com>
Subject: bourne 'dot' or csh 'source behavior
Message-Id: <390eedbf$1@127.0.0.1>


Hello,
I suspect I've blatently missed something when looking for a solution...

I have some scripts to run non-interactively (cron) and need to establish
a specific environment. Under sh|ksh I would '. <file>'; in csh
'source <file>'. How to get the same behaviour within perl?

Unfortunately, the <file> in question is vendor supplied,
ruling out a perl re-write.

regards,
Stuart Hutchison
shutchis@sherritt-NO_SPAM_PLEASEintl.com


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Tue, 02 May 2000 09:47:14 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: CGI.pm and -w
Message-Id: <390EDC62.65C3805F@attglobal.net>

> >
> > {
> > local $^W = 0; #quiet warning that these variables only used once
> > $CGI::POST_MAX=1024 * 1000;  # max 1M posts
> > $CGI::DISABLE_UPLOADS = 1;  # no uploads
> > }
> 
> The 'used only once' message is a compile-time warning. You can't disable
> it by turning off warnings at runtime. Not your fault; you were merely
> given bad advice.

Hmm... I took that work around directly from Effective Perl 
Programming, in the debugging section.


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

Date: Tue, 02 May 2000 10:00:09 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: CGI.pm and -w
Message-Id: <390EDF69.BD82EEBA@attglobal.net>

> > I tried the following and it still prints a warning to the logs.
> > Am I missing something?
> >
> > {
> > local $^W = 0; #quiet warning that these variables only used once
> > $CGI::POST_MAX=1024 * 1000;  # max 1M posts
> > $CGI::DISABLE_UPLOADS = 1;  # no uploads
> > }
> 

(Remember, Im still learning too, be nice)

Would putting this in a BEGIN block disable warnings properly?


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

Date: Tue, 2 May 2000 09:23:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CGI.pm and -w
Message-Id: <slrn8gtlme.46i.tadmc@magna.metronet.com>

On Tue, 02 May 2000 09:47:14 -0400, Drew Simonis <care227@attglobal.net> wrote:
>> >
>> > {
>> > local $^W = 0; #quiet warning that these variables only used once
>> > $CGI::POST_MAX=1024 * 1000;  # max 1M posts
>> > $CGI::DISABLE_UPLOADS = 1;  # no uploads
>> > }
>> 
>> The 'used only once' message is a compile-time warning. You can't disable
>> it by turning off warnings at runtime. Not your fault; you were merely
>> given bad advice.
>
>Hmm... I took that work around directly from Effective Perl 
>Programming, in the debugging section.


You seem to be implying that books never give bad advice.

That is an unwarranted implication  :-)


-------------------
#!/usr/bin/perl -w

print "$foo\n";
-------------------

Name "main::foo" used only once: possible typo at ./prog line 3.
Use of uninitialized value in concatenation (.) at ./prog line 3.



-------------------
#!/usr/bin/perl -w

{  local $^W = 0;
   print "$foo\n";
}
-------------------

Name "main::foo" used only once: possible typo at ./prog line 4.



When you follow that advice, you still see the warning that
is "safely ignorable", and miss out on a warning that may
indicate a real problem with your program!


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 02 May 2000 07:44:21 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: CGI.pm and -w
Message-Id: <390EE9C5.A70EB67C@vpservices.com>

Jennifer wrote:
> 
> Jeff Zucker wrote:
> >
> > Yeah, it works for me too.  I seem to remember having had problems with
> > this in the past though so perhaps it depends on the version of CGI.pm.
> > Mine is 2.56 with activePerl build 522 on win98.
> 
> I'm using CGI version: 2.36 and perl version: 5.00404 on Solaris.
> And so far have not found a solution other than turning off -w or
> setting the variables twice.
> 
> Jennifer

The revision history in the current CGI.pm (see
http://stein.cshl.org/WWW/software/CGI/#new ) lists POST_MAX as being
added in version 2.37.  Moral of the story:  if a script does one thing
for you and another thing for other users, check the version numbers and
revision history before taking elaborate steps to "fix" something that
ends up being changed at a more basic level.  Or perhaps even better
advice: keep reasonably current copies of all important modules. 
Someday I may even follow my own advice on that :-), I am some dozen
revisions behind the current version of CGI.pm which still puts me a
dozen versions in front of you.  It looks like 2.37 was a really major
step up though so I do recommend you upgrade.  If you don't have root
privs, it is easy to install in your own directory.

This is also a nice indication that warnings are there for a reason and
that one's first impulse should be to find out why the warnings are
being produced, rather than how to circumvent them.  (At least with well
trusted and usually well-behaved modules like CGI.pm).

-- 
Jeff


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

Date: Tue, 02 May 2000 13:25:44 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: confusing backtracking
Message-Id: <390ED843.6FA19215@home.com>

fjherna@my-deja.com wrote:
> 
> In article
> <Pine.GSO.4.10.10004300848090.1278-100000@user2.teleport.com>,
>   Tom Phoenix <rootbeer@redcat.com> wrote:
> 
> > You know, it would be really cool if someone could make a program
> which
> > would trace the execution of a regular expression through a string in
> an
> > easy-to-understand visual way.
> 
> That would be a wonderfull thingĦĦĦ but ...

There is use re 'debugcolor'.  Tom might not think it an
easy-to-understand visual solution but it may help you a little.
 
> Would it work the same way when Regex
> 
> m{([^/] | [^x]/)*}
> 
> trying to match string
> 
> 'a b x//c /x e x/'    ?

Let's see.

rick $ perl -Mre=debug -e '"a b x//c /x e x/"=~m{([^/] | [^x]/)*}'
Compiling REx `([^/] | [^x]/)*'
size 35 first at 1
   1: CURLYX {0,32767}(34)
   3:   OPEN1(5)
   5:     BRANCH(17)
   6:       ANYOF[\0-.0-\377](15)
  15:       EXACT < >(31)
  17:     BRANCH(31)
  18:       EXACT < >(20)
  20:       ANYOF[\0-wy-\377](29)
  29:       EXACT </>(31)
  31:   CLOSE1(33)
  33:   WHILEM[1/1](0)
  34: NOTHING(35)
  35: END(0)
minlen 0
Omitting $` $& $' support.

EXECUTING...

Matching REx `([^/] | [^x]/)*' against `a b x//c /x e x/'
  Setting an EVAL scope, savestack=3
   0 <> <a b x//c /x >    |  1:  CURLYX {0,32767} 
   0 <> <a b x//c /x >    | 33:    WHILEM[1/1]
                              0 out of 0..32767  cc=7ffff9b8
  Setting an EVAL scope, savestack=8
   0 <> <a b x//c /x >    |  3:      OPEN1
   0 <> <a b x//c /x >    |  5:      BRANCH
  Setting an EVAL scope, savestack=8
   0 <> <a b x//c /x >    |  6:        ANYOF[\0-.0-\377]
   1 <a> < b x//c /x >    | 15:        EXACT < >
   2 <a > <b x//c /x >    | 31:        CLOSE1
   2 <a > <b x//c /x >    | 33:        WHILEM[1/1]
                                  1 out of 0..32767  cc=7ffff9b8
  Setting an EVAL scope, savestack=17
   2 <a > <b x//c /x >    |  3:          OPEN1
   2 <a > <b x//c /x >    |  5:          BRANCH
  Setting an EVAL scope, savestack=17
   2 <a > <b x//c /x >    |  6:            ANYOF[\0-.0-\377]
   3 <a b> < x//c /x >    | 15:            EXACT < >
   4 <a b > <x//c /x >    | 31:            CLOSE1
   4 <a b > <x//c /x >    | 33:            WHILEM[1/1]
                                      2 out of 0..32767  cc=7ffff9b8
  Setting an EVAL scope, savestack=26
   4 <a b > <x//c /x >    |  3:              OPEN1
   4 <a b > <x//c /x >    |  5:              BRANCH
  Setting an EVAL scope, savestack=26                
   4 <a b > <x//c /x >    |  6:                ANYOF[\0-.0-\377]
   5 <a b x> <//c /x >    | 15:                EXACT < >
                                          failed...
   4 <a b > <x//c /x >    | 18:                EXACT < >
                                          failed...
                                        failed...
     restoring \1 to 2(2)..4
                                      failed, try continuation...
   4 <a b > <x//c /x >    | 34:              NOTHING
   4 <a b > <x//c /x >    | 35:              END
Match successful!
Freeing REx: `([^/] | [^x]/)*'


Of course, you probably didn't mean to leave off the /x modifer (which
is why there are all those matches of EXACT < >, i.e. spaces) but I'll
leave it to you to try

    perl -Mre=debug -e '"a b x//c /x e x/"=~m{([^/] | [^x]/)*}x'

If you follow through that one you will really get a feel for
backtracking.

FYI, ANYOF[\0-.0-\377] means [^/] and ANYOF[\0-wy-\377] means [^x].

Also, the output is sent to stderr so if you want to save it to a file
for perusal:

    perl -Mre=debug -e '...' 2> outputfile

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 02 May 2000 07:58:50 -0700
From: Gary Artim <gary@dkstat.com>
Subject: Re: convert to tab delimited file.
Message-Id: <390EED2A.D2CD5418@dkstat.com>

Makarand Kulkarni wrote:

> > I'm writing some html/cgi/perl code and wonder if anyone has found a
> > filter program that converts native EXCEL files to tab delimited text
> > files. Any info would be greatly appreciated. I do know that EXCEL
> > provides this save option, I'm just looking for a software tool to do
> > this.
> >
>
> use OLE.pm for perl ( win32).
> Write your own programs to open the worksheets you need
> and dump the data as you want it.
> --

Thanks, but, is there a equivalent for doing this in a UNIX environment
(converting excel to tabDelimited Text).




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

Date: Tue, 2 May 2000 08:28:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Error Trapping
Message-Id: <slrn8gtift.412.tadmc@magna.metronet.com>

On Tue, 2 May 2000 06:13:17 -0400, E. Preble <preble@ipass.net> wrote:

>Is there a way to trap an
>error, and dump it to html output
 ^^^^^
 ^^^^^

   perldoc -q error


leads to:

   "How can I get better error messages from a CGI program?"


You are expected to check the Perl FAQs *before* posting
to the Perl newsgroup you know.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 02 May 2000 14:59:17 GMT
From: "Veronica Adams" <adams1015@worldnet.att.net>
Subject: Re: Error Trapping
Message-Id: <93CP4.33643$PV.2395530@bgtnsc06-news.ops.worldnet.att.net>


E. Preble <preble@ipass.net> wrote in message

> Is there a good way to trap errors that doesn't require an
> error log?

place this line after the shebang:

use CGI::Carp qw(carpout fatalsToBrowser);





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

Date: Tue, 02 May 2000 14:53:43 GMT
From: c_neak@my-deja.com
Subject: How to compare values between 2 arrays ?
Message-Id: <8emq5d$4qt$1@nnrp1.deja.com>

Hi all ,

Newbie in Perl , i don't know how to do that :
I want to perform search in a file and i want to extract only some
values which are in another array .
A first array is initializing , which contains ALL the values I want to
found , and after i open my file , read it , make a split for some
values i found , and compare that with the values in the 1rst array .


My file :

 ................................
GNSTAT 200004121600 200001122000 99 25 6 3 96 51 3 10 125
RTCNCL 0 1 3 5 5 11
RTRTRY 2 5 6 1 3 2
RTDLFL 0 1 3 5 5 11
RTALRT 2 5 6 1 3 2
 ................................
GEIINF
RTE4 0 1 0 0 1 5
RTE55 2 1 1 14 20 3
GEIINF
RTICMM 0 2 3 1 25 6
RTDLVA 0 0 0 0 0 0
 ................................
 ................................
GNSTAT 200004121600 200001122000 99 25 6 3 96 51 3 10 124
RTCNCL 0 1 3 5 5 11
RTRTRY 2 5 6 1 3 2
RTDLFL 0 1 3 5 5 11
RTALRT 2 5 6 1 3 2
 ................................
GEIINF
RTE4 0 1 0 0 1 6
RTE55 2 1 1 14 21 3
 ................................


My code in Perl :

$from_stat = "statistic.dat";
open (FILE, $from_stat) || die "Cannot open $from_stat :$!...\n";

while ($line=<FILE>){
	if ($line =~ /^RT.\d{1,3}/){
	@tosql =

(map('RTD'.$_,0..30),map('RTE'.$_,0..5,50..59),map('RTG'.
$_,0..22,50,255..258));
	chomp ($line) ;
	@valfound = split /\s/,$line;
	$line =~ s/\s//;$line =~ s/\n/;/;$line =~ s/\s/;/g;
	for ($i=0; $i<@tosql; $i++){
		if ($tosql[i] =~ /^$valfound/){
		print $valfound[3],";",$valfound[4],";",$valfound
[6],";";
		last;
}
		else{
		print ";;;";
}
}
}


The output i obtain :
"0;0;5;1;14;3;0;0;6;1;14;3;"

But i want that :
";;;;;;0;0;5;;;;;;;;;;;1;14;3;;;;;;;;;;;;;;;;;;;1;14;3;;;;;;;;;;;;;;;;;;
;;;...."
The semi-colons represent the value present in the 1st array and not
present in the 2nd array .

Scan the 1st array "@tosql" for all the values , and scan the 2nd array
"@valfound" , check if we found the values of the 1st array , if yes ,
print values nr 3 , 4 and 6 from the 2nd array , else print 3 semi-
colons ";;;" .

TIA !


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 02 May 2000 09:19:44 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: How to test perl CGI scripts on my computer first?
Message-Id: <paltgson4gka2n85nvu084vb2atmsa5a7r@news.supernews.com>

tadmc@metronet.com (Tad McClellan) wrote:

} On Sun, 30 Apr 2000 07:05:15 -0400, Ryan & Treena Carrier <ryanc@nci1.net> wrote:
} >I'm trying to figure out how to set my computer up so I can write some CGI
} >scripts in Perl and test them on my computer before posting them to my
} >internet web server.
} 
} 
} Since you are using CGI.pm, you can get one level of testing
} by running your CGI program from the command line, and entering
} form values yourself (or redirect them from a file).
} 
} To get the most realistic testing environment, you need to
} get a WWW server installed.

Actually, I've found that you don't need the server at all [at least not a
local one] --- run the CGI, feeding it the environment/form/vbl stuff it
needs, collect the output as some suitable file ['cgiout.html' or some
such].  Then you can eyeball the HTML output, or just view it locally [I
believe that all browsers allow you to view 'local' HTML files directly,
without need of an actual server.

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: 2 May 2000 13:14:18 GMT
From: jehsom@-NOSPAM-resnet.gatech.edu (Jehsom)
Subject: Re: I goofed
Message-Id: <8emkba$ps0$2@news-int.gatech.edu>

Probably the easiest way would be to parse the ls output of the
original directory, and get the date of the file from that. Then,
use the touch command to set the timestamp on the corresponding
file to the same thing.

In comp.unix.shell Tapio Luukkanen <tapio.luukkanen@vtt.fi> wrote:
> So, does anyone have or know about a script which can compare the
> contents of two directory trees, say A and B, and set the timestamps
> of files in A to those of the respective files in B, if the file
> contents are identical ?

It's probably a pretty involved script, and it's 2 hours from a final
exam for me, so I can't post you any code :).
Maybe later.

Good luck,
Moshe

-- 
jehsom(@)resnet.gatech.edu - ICQ 1900670
Geek code v3.12 (www.geekcode.com):
GCS/E d- s+:-- a-- C++$ UL++>+++$ P+>++ L+++>$ E--- W+ N++ w-- 
!O M-- V? PS+ PE Y+ !PGP t 5? X+ R- tv b- DI+ D+ G e>++ h r y


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

Date: 02 May 2000 07:33:38 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: I goofed
Message-Id: <m14s8hf2d9.fsf@halfdome.holdit.com>

>>>>> "Tapio" == Tapio Luukkanen <tapio.luukkanen@vtt.fi> writes:

Tapio> So, does anyone have or know about a script which can compare the
Tapio> contents of two directory trees, say A and B, and set the timestamps
Tapio> of files in A to those of the respective files in B, if the file
Tapio> contents are identical ?

This is a somewhat incomplete specification (like, do you really wanna
restore a-times?, and can you afford ctime updates on all the files?),
but you might want to look at the last program in:

        http://www.stonehenge.com/merlyn/UnixReview/col16.html

and then mix that with File::Compare from the CPAN to see if it's
identical, and then mix that with the stat() operator on the source
to get atime/mtime and utime() on the destination file.

Probably about 20 minutes of work (for me :).  Hope it's less than
2 hours for you. :)

print "Just another Perl hacker,"

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


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

Date: Tue, 02 May 2000 09:43:58 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: newbie Q - detecting browser version
Message-Id: <390EDB9E.43CD0CEF@attglobal.net>



"vjeran.com" wrote:
> 
> OK how would you detect older browser versions and according to version
> number send HTML that will work with that browser version?
> 
> Like I need a page for newer and page for older borwsers (w and wo CSS)
> 

This is a one or two liner in Java Script...  might be worth a look.


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

Date: Tue, 02 May 2000 14:46:57 GMT
From: "John" <KidRockYou@yahoo.com>
Subject: Perl CGI Script Crashes on Win2K but not at Command
Message-Id: <BTBP4.18452$g4.494533@newsread2.prod.itd.earthlink.net>

Hi, I have a script that I wrote that will run at the command prompt but
crash perl.exe if it's run from a browser.  Can someone please help me with
this problem?  Thanks very much.

I've attached the code and the Visual Foxpro Table.  I'm using Windows 2000
Advanced Server, Active Perl 5.6.0

On a side note, does anyone know how to set up perl for my cgi.  I use
C:\Perl\bin\Perl.exe %s %s, but I would imagine there is a better way.

Once again, thanks!!

John
use DBI;

my $dbh = DBI->connect( "dbi:ODBC:sample", {

RaiseError => 1

});

$sth = $dbh->prepare( " Select first_name, last_name FROM sample " );

$sth->execute();

$rows = $sth->dump_results();





begin 666 sample.dbf
M, `%`@0```!H`14````````````````````````#``!&25)35%].04U%`$,!
M````"@```````````````````$Q!4U1?3D%-10``0PL````*````````````
M````````#0``````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M($9R960@(" @("!,964@(" @(" @($IO:&X@(" @("!#;&%R:V4@(" @(%-T
H979E(" @("!487EL;W(@(" @($-H<FES(" @("!797-T(" @(" @&@``
`
end



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

Date: Tue, 02 May 2000 14:52:16 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: perl in NT .BAT files Question
Message-Id: <390EEBA6.F69402F3@Home.Com>

BobS wrote:
> 
> Hi David,
> 
> Thanks for the response. I appreciate your offer. I (obviously) know little
> about Perl. My real question is about the strength of Perl to do what I
> need. Since then, I've found Perl can meet most any application programming
> requirement. Initially, I got off on the wrong direction and couldn't get
> past the CGI stuff avail everywhere. CGI I don't need.
> 
> My environment is a complex 16-bit legacy application running under NTVDM.
> There are some 16-bit proprietary libraries needed for file access so am
> stuck in 16-bit land. I _think_ I can write Perl scripts to replace the
> BLAST scripts to provide high level handshaking for file queuing and FTP
> between sites. The modem driver itself to be replaced by vanilla FTP or
> similar. Perl scripts should provide a layer between my COBOL (did I say
> legacy? <g>) executables and the 16-bit file libraries. I see that Perl also
> has a FTP module that looks promising but is beyond my present
> understanding.
> 
> In theory, I think I have a plan (somewhat klunky but, hey, the whole mess
> is already a kludge). In practice, however, I need to learn Perl which I'm
> working on now. I'm trying to learn enough to determine if this is doable.
> That's why the general questions.
> 
> Again, I appreciate your response. If you don't mind, I'll probably have a
> question or two later.
> 
> Cheers,
> Bob
> 

Best of luck with your efforts. I don't know anything about BLAST, so your
words fall on deaf ears v-a-v that. However, if you are working in 16-bit
land then I have only one `early warning' for you and that deals with
file names. I found a major effort to get some of my old 16-bit code working
was to realize that in a 32-bit world the file `abc.dat' might well exist
but code that tried to search for `ABC.DAT' would not find it. I thus became a
good friend of `tr/a-z/A-Z/' on filenames before searching them, etc...


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

Date: Tue, 2 May 2000 08:21:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl, limiting displayed decimal places
Message-Id: <slrn8gti1g.412.tadmc@magna.metronet.com>

On Tue, 2 May 2000 11:37:08 +0100, Mark <KnightSky1@yahoo.com> wrote:

>Hi, i'm new to this perl thing, and i'm writing a script that
>calculates shipping weights and prices, 


You should be working with integers (cents) instead of
floating point (dollars) numbers, then convert to
dollars for output at the end of processing.

So you won't "lose stuff" and don't have to be as concerned
with accuracy and precision.


>I done this fine but the
>only problem is sometimes when it displays the total amount
>brings up loads of numbers after the decimal place, is there
>anyway to limit to 2?


   Perl FAQ, part 4:

      "Does perl have a round function?  
       What about ceil() and floor()?  
       Trig functions?"


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 02 May 2000 14:41:23 GMT
From: efroselli@my-deja.com
Subject: Re: Print Just Once When in (<>)?
Message-Id: <8empef$3kv$1@nnrp1.deja.com>

In article <morbus-69B845.09563829042000@news.totalnetnh.net>,
  Morbus Iff <morbus@disobey.com> wrote:
> In article <8ec5jp$2s7$1@wanadoo.fr>, "Elisa Roselli"
> <e.roselli@volusoft.com> wrote:
>
> > # The problem line. If I put it here, it prints to screen rather
than in
> >
> >          print "# This program has already been run on this file\n";
> >
> >          while (<>)
> >
> >          #print "# This program has already been run on this
file\n";
> >
> >
> > So my question is, where to put my problem line? After the (<>) it
prints
> > every block, before the (<>) it prints to screen.
>
> I have absolutely no clue. I know nothing abou the Korn shell. You
could
> cheat though, and do something like:
>
>    while (<>) {
>
>       unless ($printed) {
>          print "# This program has ...";
>          $printed = 1;
>       }
>
>       . . .
>
> Again, cheating, but hey <g>...
>
> Morbus Iff
> http://www.disobey.com/
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 2 May 2000 15:42:49 +0100
From: "Christian Mahnke" <mahnke@uni-freiburg.de>
Subject: Problem with local installation of a module
Message-Id: <8emlsd$fll$1@n.ruf.uni-freiburg.de>

hello,

I tried to install the Mysql-Driver locally. I used this command:

perl Makefile.PL PREFIX=/usr/local/httpd/cgi-bin/modules

It works fine when I install the prerequesites of the Mysql-Driver, that is
Data-Show-Table and DBI.
But when I try to install the MySQL Driver (Msql-MySQL-modules) it aborts
and tells me that DBI was not found in @INC.
How can I make "Makefile.PL" understand that it has to serach in
"/usr/local/httpd/cgi-bin/modules" also ????
I really appreciate your help, since I cannot post my program at my provider
without having solved this problem.
Thanks in advance,

Christian





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

Date: Tue, 02 May 2000 10:45:45 -0400
From: Stephen Dodd <dodd@ll.mit.edu>
Subject: Specifying timeout with sockets
Message-Id: <390EEA18.3E2080@ll.mit.edu>


When connecting to a terminal server using a socket object, I set the
timeout value to 10. The documention doesn't state the units of time but

I presume it's in seconds. The documents further states that the timeout

is used for "some" operations.
The problem is that if the serial device is not connected to the
terminal server the script hangs on the : "
$socket->recv($response,10);" I create the socket as listed below:

      $socket = IO::Socket::INET->new(PeerAddr => $hostname,
       PeerPort => $remote_port,
       Proto    => "tcp",
       type     => SOCK_STREAM,
       timeout  => 10);

 I send the command to the terminal server ethernet socket, the terminal

server will
send the command out the appropriate serial port. The recv command is
wait for
a response back from the serial port via network socket, but it just
hangs.

    $socket->send("@@@\n");
     print "Wait for response, command sent";
    $socket->recv($response,10);
     print "I never get to here";


dodd@ll.mit.edu



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

Date: Tue, 02 May 2000 15:02:18 GMT
From: "Veronica Adams" <adams1015@worldnet.att.net>
Subject: Re: using system or open to get program output
Message-Id: <_5CP4.33664$PV.2397895@bgtnsc06-news.ops.worldnet.att.net>


Jason Novotny <novotny@nlanr.net> wrote in message >
> Hi,
>
>     I have a program that requires a passphrase and then produces a
> result. I just simply want to do something like the following.
>
> open(MPGD, "|$program") or die "Can't open pipe to $program: $!\n";

You dont show how you get $proram here so I'm telling you this as a
precaution in case you don't know. You need to read the faq on cgi security
on cpan. (if its a cgi script) Especially the part about piping. If $program
is user submitted data this can be a security problem in your program.




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

Date: Tue, 02 May 2000 14:34:51 GMT
From: r1ch@n0sp4m.r1ch.net (R1CH)
Subject: Win32 Perl Program RAM Usage
Message-Id: <390ee6af.160998553@news.screaming.net>

Hi,
I have a Perl IRC bot that runs in Win32 using ActivePerl. Running Task
Manager shows it uses around 10mb of RAM when first started. It
basically is just one big loop with event processing in, and logfile and
stats generation. However, after about a day of uptime, the RAM usage is
around 100mb !!

The log files aer written to every time in the loop. I have set $| = 1,
so they are flushed and don't use RAM. Everything else is basically only
ever used once in a particular event, with local vars.

I have used my and local variables where I can. For the stats, I use a
big %stats hash, and things like $stats{nickname}{lines} and
$stats{nickname}{actions} etc. If I undef %stats, these "sub hashes" or
whatever they are are lost too, right?

Please help as I want to release this bot soon, but with it's currrent
RAM load this might not be possible...

Thanks,
R1CH


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 2923
**************************************


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