[13636] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1046 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 12 02:05:29 1999

Date: Mon, 11 Oct 1999 23:05:08 -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: <939708308-v9-i1046@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 11 Oct 1999     Volume: 9 Number: 1046

Today's topics:
    Re: Case Question. (Craig Berry)
        CGI.pm background graphics <pmm@saf.com>
    Re: CGI.pm background graphics <dtbaker_@busprod.com>
    Re: CGI.pm background graphics <srmalloy@home.com>
    Re: Dedicated Server (David Efflandt)
        harder questions was [Re: CGI and perl question] <ltl@rgsun40.viasystems.com>
    Re: harder questions was [Re: CGI and perl question] (Bill Moseley)
    Re: hidden field displays old value (David Efflandt)
    Re: Is there an easy Perl equivalent to SSIs including  (David Efflandt)
        move files in directories recusively in Windows using P <bennycc@pacific.net.sg>
        Net::FTP + mput? <dutch@mindspring.com>
        Output time based on TimeZone <scott_beck@my-deja.com>
    Re: Passing unknown filenames as arguments to another p (Randal L. Schwartz)
    Re: Perl Interview Question: (Randal L. Schwartz)
    Re: Perl lite <uri@sysarch.com>
        perl want load mysql DBD steve1430@my-deja.com
        Question about tr/srch/repl (Ghost)
    Re: Question about tr/srch/repl (Larry Rosler)
    Re: Spreadsheets. <bennycc@pacific.net.sg>
        Standard Error and NT <akmink@worldnet.att.net>
    Re: Standard Error and NT (Bill Moseley)
        taint-safe way of getting cwd? (David Wall)
    Re: use strict problem (Martien Verbruggen)
        Using Perl to add line nums? KernelKlink@webtv.net
    Re: Using Perl to add line nums? (Martien Verbruggen)
    Re: Using Perl to add line nums? (Larry Rosler)
    Re: Using Perl to add line nums? (Matthew Bafford)
    Re: Using Perl to add line nums? KernelKlink@webtv.net
    Re: Using Perl to add line nums? (Peter J. Kernan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 12 Oct 1999 05:43:59 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Case Question.
Message-Id: <s05ikvk9h1s48@corp.supernews.com>

Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote:
: On Mon, 11 Oct 1999 22:16:35 GMT, Craig Berry <cberry@cinenet.net> wrote:
: >Larry Rosler (lr@hpl.hp.com) wrote:
: >: > This argument goes away if you lc @keywords once outside the subroutine
: >: > (and the keyword list is fixed), of course.
: >: 
: >: That is what I meant (and what I thought I said -- see the word 'once' 
: >: in the sentence quoted above).
: >
: >The ambiguity was whether your 'once' was subroutine-block-scope or
: >program-scope. :)  Thanks for the confirming clarification.
: 
: The phrase 'once *outside* the subroutine' is a pretty unambiguous way of 
: meaning the second option I think. ;)

*bonk* You'd think, wouldn't you?  Sorry, I'm using a loaner brain today.
Just ignore me, tomorrow I should be totally piano again.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "There it is; take it."  - William Mulholland


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

Date: Tue, 12 Oct 1999 02:13:50 GMT
From: Penn McClatchey <pmm@saf.com>
Subject: CGI.pm background graphics
Message-Id: <38029990.354C22E5@saf.com>

I am trying to use a background graphic, not a color.
The file is called "back.gif"  Anyone know how to get
it to serve from a Perl file using CGI.pm?  The beginning of my
script looks like:

#!/usr/local/bin/perl                                                     
use CGI
qw(:standard);                                                    
$query =
CGI->new();                                                      
print
"BACKGROUND=\"bakc.gif\"";                                          
$TITLE="Paint Code
Search";                                               
print header, start_html($TITLE),
h1($TITLE);                             
# print
"BACKGROUND=\"bakc.gif\"";                                        
print "<p> What is pattern you wish to search for? Hit Back to
exit</p>"; 

As you can see, I've tried putting the BACKGROUND statement in several
places, all to no avail.

Any help will be much appreciated!!

Best Regards,

Penn
-- 
Penn McClatchey


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

Date: Mon, 11 Oct 1999 22:29:19 -0500
From: Dan Baker <dtbaker_@busprod.com>
Subject: Re: CGI.pm background graphics
Message-Id: <3802AB0F.66A51F94@busprod.com>



Penn McClatchey wrote:
> 
> I am trying to use a background graphic, not a color.
> The file is called "back.gif"  Anyone know how to get
> it to serve from a Perl file using CGI.pm?  The beginning of my
> script looks like:
--------------

your perl script has several problems. try adding the -w option to the
first line to get your warnings. read the doc for CGI.pm to see what it
can/cant do...

eventually, you need to construct valid HTML to get it to work. Try
constructing a hardcoded HTML page that looks the way you want with
whatever tool you are used to, and look at the source. Then create a
script that prints out the exact same thing, then work in your
variables.

there is another newsgroup that is intended more for cgi issues at
comp.infosystems.www.authoring.cgi that you might want to search with
dejanews for future problems.

Dan


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

Date: Tue, 12 Oct 1999 04:00:42 GMT
From: Sean Malloy <srmalloy@home.com>
Subject: Re: CGI.pm background graphics
Message-Id: <P7ICOLfYMm99Gs25hlLont07XSc5@4ax.com>

Penn McClatchey <pmm@saf.com> wrote:

>I am trying to use a background graphic, not a color.
>The file is called "back.gif"  Anyone know how to get
>it to serve from a Perl file using CGI.pm?

Try this:

print $query->start_html(-title=>'Page Title',
                           -BACKGROUND=>'background.gif',
                           -BGCOLOR=>'FFFFFF');

-- 
Sean R. Malloy               | American Non Sequitur
    Naval Medical Center     |       Society
    San Diego, CA 92134-5000 |
srmalloy@home.net            | "We may not make sense,
srmalloy@nmcsd.med.navy.mil  |  but we do like pizza"
FORMAL NOTICE: unsolicited commercial email will be read
at a charge of $500 per item. Receipt of such email shall
be considered to constitute acceptance of contract, and 
will be billed immediately.


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

Date: 12 Oct 1999 05:49:39 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Dedicated Server
Message-Id: <slrn805j0c.98.efflandt@efflandt.xnet.com>

On Mon, 11 Oct 1999 12:56:00 +0200, John <irishcream@iname.com> wrote:
>
>Does anybody know a good company that offers
>reliable Linux dedicated servers ? DN offers this
>at 300 dollars a month, which I think is a little
>bit expensive. Any Help would be highly appreciated.
>Thank you,
>
>John

www.rapidot.com		$175/mo	1G bandwidth ($12.50/G above that)
www.superuser.net	$225/mo	15G bandwidth

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: 12 Oct 1999 01:58:25 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: harder questions was [Re: CGI and perl question]
Message-Id: <7tu4k1$j7t$1@rguxd.viasystems.com>

Bill Moseley <moseley@best.com> wrote:
:>How come you can post a completely off-topic question and get an answer, 
:>and I post a _perl_ question and it just gets lost in the noise?

Because you no longer ask questions with easy answers.  :-)

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Mon, 11 Oct 1999 22:46:35 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: harder questions was [Re: CGI and perl question]
Message-Id: <MPG.126c6b122adfc9f49897f7@nntp1.ba.best.com>

lt lindley (ltl@rgsun40.viasystems.com) seems to say...
> Bill Moseley <moseley@best.com> wrote:
> :>How come you can post a completely off-topic question and get an answer, 
> :>and I post a _perl_ question and it just gets lost in the noise?
> 
> Because you no longer ask questions with easy answers.  :-)

Well then, there needs to be more answers in the FAQ, so my questions 
can be answered with RTFFAQ ;)

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: 12 Oct 1999 05:57:23 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: hidden field displays old value
Message-Id: <slrn805jet.98.efflandt@efflandt.xnet.com>

On Mon, 11 Oct 1999 22:33:41 +0200, Antoine
<paranoid_of_spam_antoine@nospam_natuur.org> wrote:
>I' ve written a perl cgi script to select a location on the web server to
>create a new folder in. I call this scipt several times to enter deeper in
>the tree structure. A hidden field contains the current dir but when i call
>the script for the second time it will not refresh the value of the hidden
>field.  What goes wrong. Are the values in hidden fields cached? how to
>resolve this?

In your shell or console type and read: perldoc CGI
Fields inherit previously submitted values unless you reasign a value to
the param or use -override=>1 in the field.  The default value for a field
is only used if the variable does not already have a value.

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: 12 Oct 1999 06:03:45 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <slrn805jqp.98.efflandt@efflandt.xnet.com>

On Mon, 11 Oct 1999 13:15:05 -0400, David Wozmak <dwozmak@rational.com> wrote:
>
>
>Stuart Wright wrote:
>> 
>> Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
>> > Yes it usually involves opening the file and printing its contents.
>> >
>> In my original post I wrote that I had considered this - but not being a
>> Perl expert (actually it baffles me - I tend to copy existing Perl and hope
>> it works without knowing how), opening a file and printing it's contents is
>> not *necessarily* a quick solution for some people.
>> But thanks anyway.
>
>well...what do you think happens when you do an Server-Side-Include? 
>The file is opened and read, and it's contents(or results) are printed. 
>This is a trivial operation.  in fact, it is a simple four liner
>(although it could have even been done in two):
>
>#---------------------------------------------
>#code snippet:
>#
>sub include_this_file {
>	my $include_file = @_;    # get the name of the file
>	open (INCLUDE, "$include_file") or print "couldn't open $include_file,
>error: $!\n"; 
>	while (<INCLUDE>) {print;}   # read each line from the file and print
>it.

Or instead of the above while loop, simply print the whole file at once:
	print <INCLUDE>;

>	close (INCLUDE);  # be nice and close the file yourself, 
>                          #even though perl will eventually do it for
>you
>}
>#---------------------------------------------
>
>This code snippet is called a "subroutine". You cut and paste this into
>your script at the end, and in the main body of your code, any time you
>want to include a file, you put this line in your code:
>
>&include_this_file("somePath/myfile.htm");
>
>where you change "somePath/myfile.htm" to be the name of the file you
>want to include.
>
>so, in the main body of your script, it reduces to a single simple line
>of code, just as simple as any server-side-include!
>
>The main body of your code could look like this:
>
>
>____________________________________________
>#! usr/bin/perl
>
>use Strict;
>{
>&include_this_file("header.htm");
>&include_this_file("top_navbar.htm");
>&include_this_file("body.htm");
>&include_this_file("footer.htm");
>1
>}
>#---------------------------------------------
>sub include_this_file {
>	my $include_file = @_;    # get the name of the file
>	open (INCLUDE, "$include_file") or print "couldn't open $include_file,
>error: $!"; 
>	while (<INCLUDE>) {print;}   # read each line from the file and print
>it.
>	close (INCLUDE);  # be nice and close the file yourself, 
>                          #even though perl will eventually do it for
>you
>}
>#---------------------------------------------
>____________________________________________
>
>So...if you considered this and decided not to do it, what other options
>do you have?  I'm curious, because there really isn't any simpler way to
>do it in PERL.  
>
>I'm also curious about your other statement...that you "hope it works,
>without knowing how..."  Does that mean you really could give a rat's
>a** about learning perl, and just want someone to do the real work for
>you?  If this is for a company website, I must ask how you can sleep at
>night, not really knowing what all that code you use does.  Do you just
>blindingly trust that the code is doing what you want it to do, and
>nothing more? People like you build websites that are known as
>"cracker's delights", because they're so full of bugs and backdoors.  
>
>Think of that.  I could have "given" you a twenty-line code snip that
>opened a file and printed it, and also sent me all your customer
>information, set up any subsequent page to redirect through my server so
>I could steal your form data, wipe out your filesystem, give myself
>remote access to your server, and lots of other really fun stuff.
>
>I, of course, have no need for your information, so the code above is
>probably safe to use.  But there's lots of bored young programmers that
>would do malicious things just for a lark.
>
>How would you know?
>
>If this is something you might have to do *several times* in the future,
>wouldn't it be *quicker* to spend an hour learning it the first time, so
>that it becomes a quick little 5 minute thing NEXT time and the NEXT
>NEXT time?
>
>Perhaps you're better suited to using VBscript, a Microsoft scripting
>language in which difficult things are sometimes easy to do, and simple
>things are seldom easy to do. VBscript has a command that works just
>like SSI "include", in fact it's called "include".  Imagine that. 
>
>dwoz
>
>hope this helped.


-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Tue, 12 Oct 1999 10:24:54 +0800
From: Benny Chee <bennycc@pacific.net.sg>
Subject: move files in directories recusively in Windows using Perl
Message-Id: <38029BF6.EC76BF1E@pacific.net.sg>

Hi,

    Is there a method to move files + directories (recursively) to
another directory
    using Perl for Win32 (AcitvePerl) ?

    Other than excuting DOS commands (move.exe), is there a Perl way of
doing it?

Benny
bennycc@pacific.net.sg



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

Date: Tue, 12 Oct 1999 00:02:59 -0400
From: "Dutch McElvy" <dutch@mindspring.com>
Subject: Net::FTP + mput?
Message-Id: <7tubfb$nv0$1@nntp5.atl.mindspring.net>

I am trying to setup an automated hotfolder which a perl script can look at
and ftp any files landing in this folder to another server on my network.

Is there anyway to use the mput command with net::ftp? If not can anyone
offer any suggestions for ftping multiple files from a hotfolder on one
server to a location on another server using perl?

Also is there a way to tell $ftp to "put" any files in the specified
directory, not knowing their actual names by using a wild card like *?

This is on unix

Thanks for any help,

Dutch


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

Date: Tue, 12 Oct 1999 02:33:44 GMT
From: Scott Beck <scott_beck@my-deja.com>
Subject: Output time based on TimeZone
Message-Id: <7tu6m8$t49$1@nnrp1.deja.com>

I just want to make sure I didn't miss something that I wouldn't
catch till like the year 2034 ;)
Please eval this, thanks.

#!/usr/bin/perl -w

use strict;
use Time::ParseDate;

# Constant #
use vars qw/ %Zone /;



#***********************************************#
#%Zone comes from Graham Barr <bodg@tiuk.ti.com>#
#***********Originaly in Timezone.pm************#

%Zone = (
    "gmt"   =>   0,  	# Greenwich Mean
    "ut"    =>   0,  	# Universal (Coordinated)
    "utc"   =>   0,	# UTC
    "wet"   =>   0,  	# Western European
    "wat"   =>  -1*3600,# West Africa
    "at"    =>  -2*3600,# Azores
    "ast"   =>  -4*3600,# Atlantic Standard
    "est"   =>  -5*3600,# Eastern Standard
    "cst"   =>  -6*3600,# Central Standard
    "mst"   =>  -7*3600,# Mountain Standard
    "pst"   =>  -8*3600,# Pacific Standard
    "yst"   =>  -9*3600,# Yukon Standard
    "hst"   => -10*3600,# Hawaii Standard
    "cat"   => -10*3600,# Central Alaska
    "ahst"  => -10*3600,# Alaska-Hawaii Standard
    "nt"    => -11*3600,# Nome
    "idlw"  => -12*3600,# International Date Line West
    "cet"   =>  +1*3600,# Central European
    "met"   =>  +1*3600,# Middle European
    "mewt"  =>  +1*3600,# Middle European Winter
    "swt"   =>  +1*3600,# Swedish Winter
    "fwt"   =>  +1*3600,# French Winter
    "eet"   =>  +2*3600,# Eastern Europe, USSR Zone 1
    "bt"    =>  +3*3600,# Baghdad, USSR Zone 2
    "zp4"   =>  +4*3600,# USSR Zone 3
    "zp5"   =>  +5*3600,# USSR Zone 4
    "zp6"   =>  +6*3600,# USSR Zone 5
    "wast"  =>  +7*3600,# West Australian Standard
    "cct"   =>  +8*3600,# China Coast, USSR Zone 7
    "jst"   =>  +9*3600,# Japan Standard, USSR Zone 8
    "east"  => +10*3600,# Eastern Australian Standard
    "gst"   => +10*3600,# Guam Standard, USSR Zone 9
    "nzt"   => +12*3600,# New Zealand
    "nzst"  => +12*3600,# New Zealand Standard
    "idle"  => +12*3600,# International Date Line East
);

# Normaly this would be required by anouther Script #
# Test Run #
print &get_time('EST'),"\n";

sub get_time {

	my $tzone = shift;

	# Get GMT time as seconds sence the epoch
	my $gmtsec = parsedate(scalar gmtime);

	# Check input. If not recognized default to GMT
	(exists $Zone{lc $tzone}) or $tzone = 'GMT';

	# Now get local time for time zone $tzone
	my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)
	 = localtime( my $time = $gmtsec + $Zone{lc $tzone} );
		my @Days = qw(Sun Mon Tues Wed Thurs Fri Sat);
		my @Months = qw(Jan Feb Mar Apr May Jun July
				Aug Sept Oct Nov Dec);

	return (sprintf("%s. %s. %s, %04d %02d:%02d:%02d%s %s",
	$Days[$wday],$Months[$mon],$mday,$year += 1900,
	($isdst and $hour += $isdst) % 12 || 12,$min,$sec,
	($hour > 11) ? ('PM') : ('AM'), $tzone));
}
1;
__END__

Any comments would be appreciated

--
Many Thanks
Scott Beck


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


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

Date: 11 Oct 1999 22:12:36 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Passing unknown filenames as arguments to another program
Message-Id: <m1r9j1rwl7.fsf@halfdome.holdit.com>

>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:

>> Well, no, echo will have that problem too.

Russ> Depends on your shell.  Since it's a shell builtin, some shells are smart
Russ> enough to be able to handle much larger globs that way.

It's not *universally* a shell built-in.

As in, it wasn't on the One True Unix.  And since Perl ran on said One
True Unix, I must continue to believe the Perl solution can still
produce more optimal results for certain O/S versions.

:-)

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: 11 Oct 1999 22:15:03 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl Interview Question:
Message-Id: <m1oge5rwh4.fsf@halfdome.holdit.com>

>>>>> "Samay" == Samay  <samay1NOsaSPAM@hotmail.com.invalid> writes:

Samay> Simple See if you can test yourself:
Samay> $x=2;

Samay> foreach $x (1..10){
Samay>    print $x;
Samay> }

Samay> print $x;

Samay> Question:What's the last value of $x.

Anyone who reads Chapter 3 of the Llama or stays for the first three
hours of my training class knows the answer.

If that's an interview question, I wouldn't want to work there.

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: 12 Oct 1999 01:28:37 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl lite
Message-Id: <x7d7ulkv0a.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> John Kristian (kristian@netscape.com) wrote on MMCCXXXII September
  A> MCMXCIII in <URL:news:38022B7C.2B2C790F@netscape.com>:
  A> ^^ How can I make Perl occupy less disk space?
  A> ^^ I mean without making it useless, of course.
  A> ^^ 
  A> ^^ The HTML documentation uses a lot of disk space;
  A> ^^ eliminating it would yield a smaller footprint.
  A> ^^ I thought I might replace it with links to the Web.
  A> ^^ Have you tried something similar?


  A> No. du -k /opt/perl yields 25Mb, and that's including the gzipped
  A> tar file and site_perl. Only about 10% of that is taken by 
  A> /opt/perl/man/man1. 

  A> I wouldn't want to delete any of it. Disk space isn't that expensive
  A> nowadays. I'm sure you have other junk you can delete. ;-)

actually i found a place where i needed to do this. my new web/mail host
has a low price deal with only 5MB for $9.95/Month (with virtual
hosting). but they have a crappy old perl (5.004_01 would you believe!)
and no decent modules. so i installed the latest and my needed modules
into my home dir and everything is dandy. but they now take up 6.5MB so
i have to pay an additional $2.95/MB/month. the next level is $24.95 for
50MB so i am saving a whole $9.10/month. i deleted all the docs, extra
stuff, source, etc. all i left was the binary and the modules in
lib. they actually take up the bulk of the space and if i stripped them
of pod it would go down a great deal i think. i know this is crazy just
for the few bucks, but there is a principle here!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
www.sysarch.com  -----  Perl Books: http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 12 Oct 1999 03:28:28 GMT
From: steve1430@my-deja.com
Subject: perl want load mysql DBD
Message-Id: <7tu9sf$vd6$1@nnrp1.deja.com>

I am runing Linux 5 & perl 5.00404
I have installed all the need files and MYSQL
is running fine. However when I try to connect to
a database with perl i get the following error

install_driver(mysql) failed: Can't load
'.././blib/arch/auto/DBD/mysql/mysql.so' for
module DBD::mysql:
 .././blib/arch/auto/DBD/mysql/mysql.so: undefined
symbol: open64 at /usr/lib/perl5/i386-
linux/5.00404/DynaLoader.pm line 168.

I would be gratefull for any help
Thank


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


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

Date: Tue, 12 Oct 1999 03:45:45 GMT
From: ghost24@bctek.com (Ghost)
Subject: Question about tr/srch/repl
Message-Id: <s05bn9m6h1s48@corp.supernews.com>

I have a question about the use of tr/srch/replc. I am new
to perl, and I noticed some people posted about using tr to
count the number of occurences of a letter. Not knowing about
tr I looked in the perlfaq and perlop(1) to see what tr does.

in perlop it shows to count number of occurences you do:
  $cnt = $sky =~ tr/*/*/;
in perlfaq it shows the form:
  $cnt = $sky =~ tr/*//;

Trying them out they both do the same.

Looking at the perlop it says that tr form is:
   tr/SEARCHLIST/REPLACEMENTLIST/cds

and that it translates all occurences of characters in search list
with corresponding character in replacement list, and then returns
the number of characters replaced or deleted.

Well, this makes me think tht the second example should replace all
occurences of * with a "" that would basicly erase every star then
return the number of * in the string. This ofcourse is not what
happens.. They are equivalent, why!? 

Am I missing something.. 

How would you erase all * and return the number?

TIA...

-- 
 ....................................................................
      ++ ghost24@bctek.com ++ http://www.bctek.com/~ghost24 ++      
 ....................................................................
WARNING: Do not read if you are pregnant or nursing or if you are at
risk or are being treated for high blood pressure, heart, liver,
thyroid or psychiatric disease,nervousness, anxiety, depression,
seizure disorder, stroke or difficulty in urination.
Consult you health care professional before reading!!
 ....................................................................



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

Date: Mon, 11 Oct 1999 21:09:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question about tr/srch/repl
Message-Id: <MPG.126c5470a342fccd98a07d@nntp.hpl.hp.com>

In article <s05bn9m6h1s48@corp.supernews.com> on Tue, 12 Oct 1999 
03:45:45 GMT, Ghost <ghost24@bctek.com> says...
+ I have a question about the use of tr/srch/replc. I am new
+ to perl, and I noticed some people posted about using tr to
+ count the number of occurences of a letter. Not knowing about
+ tr I looked in the perlfaq and perlop(1) to see what tr does.
+ 
+ in perlop it shows to count number of occurences you do:
+   $cnt = $sky =~ tr/*/*/;
+ in perlfaq it shows the form:
+   $cnt = $sky =~ tr/*//;
+ 
+ Trying them out they both do the same.

Yes.  See below for why.

+ Looking at the perlop it says that tr form is:
+    tr/SEARCHLIST/REPLACEMENTLIST/cds
+ 
+ and that it translates all occurences of characters in search list
+ with corresponding character in replacement list, and then returns
+ the number of characters replaced or deleted.
+ 
+ Well, this makes me think tht the second example should replace all
+ occurences of * with a "" that would basicly erase every star then
+ return the number of * in the string. This ofcourse is not what
+ happens.. They are equivalent, why!? 
+ 
+ Am I missing something.. 

In perlop:

If the REPLACEMENTLIST is empty, the SEARCHLIST is replicated. This 
latter is useful for counting characters in a class or for squashing 
character sequences in a class. 
 
+ How would you erase all * and return the number?

  $cnt = $sky =~ tr/*//d;

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


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

Date: Tue, 12 Oct 1999 10:16:08 +0800
From: Benny Chee <bennycc@pacific.net.sg>
Subject: Re: Spreadsheets.
Message-Id: <380299E8.CE1EFF1E@pacific.net.sg>

How about trying csv files?
Comma Separated Value File.

It can be read in Excel + Access + several other spreadsheets.

Benny
bennycc@pacific.net.sg

Kangas wrote:

> Other than Excel what spreadsheets can perl connect with??
>
> --
> Michael Kangas
> kangas@anlon.com



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

Date: Mon, 11 Oct 1999 23:50:26 -0500
From: Adrian Mink <akmink@worldnet.att.net>
Subject: Standard Error and NT
Message-Id: <3802BE11.E6A8D32A@worldnet.att.net>

Can someone tell me how to redirect standard error to a file under NT
from a perl script? I'm running
Active state Perl build 517. I running nslookup from the script and have
tried using 2>&1 with nslookup as one of my books suggest, but have had
no luck. Any ideas? Thanks.

Adrian



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

Date: Mon, 11 Oct 1999 22:55:44 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Standard Error and NT
Message-Id: <MPG.126c6d39545d8d639897f8@nntp1.ba.best.com>

Adrian Mink (akmink@worldnet.att.net) seems to say...
> Can someone tell me how to redirect standard error to a file under NT
> from a perl script?

open STDERR, '>errors' or die "bummer on 'errors' $!";


-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Tue, 12 Oct 1999 03:07:38 GMT
From: darkon@one.net (David Wall)
Subject: taint-safe way of getting cwd?
Message-Id: <3802a630_1@news2.one.net>

I would swear that I had been using 

use Cwd;
my $dir=getcwd();

as a way to get the current working directory while running under taint 
mode, but it stopped working tonight, and I have no idea why.  I changed 
getcwd() to fastcwd() in the offending program, and now it works.  
(Incidentally, getcwd() works with -T under win98, but fails under Linux 
2.2.9)

The error message was "Insecure dependency in open while running with -T 
switch", since I did something like 

open FILE, "$dir/filename.txt" or die($!);

The offending program is at http://w3.one.net/~darkon/darkboard/.  Some of 
you have seen it before, but I do hope it has changed for the better since 
then.  

David Wall
darkon@one.net

PS  BTW, my ISP is idiotically paranoid about browsers for some reason -- 
something about "keeping spammers from harvesting email addresses from web 
pages" -- so they have things set to reject "unusual" browsers, like, say, 
emacs.  I've complained about it before, to no avail.  I guess I'll have 
to write a short script, have it pretend it's Netscape, and send it to 
them to prove a point.....


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

Date: Tue, 12 Oct 1999 02:24:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: use strict problem
Message-Id: <oZwM3.215$324.4755@nsw.nnrp.telstra.net>

On Mon, 11 Oct 1999 21:17:31 -0500,
	Frank Hale <frankhale@trespass.net> wrote:
> Say I have the following 2 files.
> 
> -- config.pl
> #!/usr/bin/perl -w 
> # 
> use strict;
> my $name = "frank";
> require "main.pl";
> 
> -- main.pl
> #!/usr/bin/perl -w 
> # 
> use strict;
> print $name;
> 
> howcome when I run config.pl I get the following error
> 
> Global symbol "$name" requires explicit package name at main.pl line 6.
> Compilation failed in require at ./config.pl line 8.

Variable scoped with my are scoped to the enclosing block, file or
eval. That means that if you scope variables with my in one file, you
can't get at them in another.

You should probably read the following documentation.

# perldoc -f my
# perldoc perlsub
/Private Variables via my

Now, there are ways of doing what you want (with the vars pragma, for
example), but I wouldn't really recommend them. And yopu can't do it
with lexically scoped (my) variables. 

What you should really do is provide accessor functions/subs/methods
for locally scoped variables. Access to the variable happens through
accompanying subs. It's generally not a good idea to expose raw access
to variables like this. But YMMV.

Alternatively, you can put this stuff in packages, and always use the
fully qualified name to access them (to make strict happy)

package foo;

$foo::name = '4';

package main;

print $foo::name;

These packages can live in separate files.

> Please forgive me if this is trivial, I am fairly new to Perl.

No problem with that :) We all had to start somewhere.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people make up
Commercial Dynamics Pty. Ltd.   | 3/4 of the population.
NSW, Australia                  | 


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

Date: Mon, 11 Oct 1999 21:36:52 -0400 (EDT)
From: KernelKlink@webtv.net
Subject: Using Perl to add line nums?
Message-Id: <4287-380290B4-1@storefull-214.iap.bryant.webtv.net>

Is it possible to write a Perl script that will add line numbers to an
existing script by using the existing script as an argument? I would
want even the blank lines to be numbered, not just the lines with text
on them. 

Will Perl do this?



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

Date: Tue, 12 Oct 1999 02:29:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Using Perl to add line nums?
Message-Id: <G2xM3.219$324.4755@nsw.nnrp.telstra.net>

On Mon, 11 Oct 1999 21:36:52 -0400 (EDT),
	KernelKlink@webtv.net <KernelKlink@webtv.net> wrote:
> Is it possible to write a Perl script that will add line numbers to an
> existing script by using the existing script as an argument? I would
> want even the blank lines to be numbered, not just the lines with text
> on them. 

# perl -pe '$_ = "$. $_"' filename

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin' crops
Commercial Dynamics Pty. Ltd.   | where there ain't no crops.
NSW, Australia                  | 


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

Date: Mon, 11 Oct 1999 19:46:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Using Perl to add line nums?
Message-Id: <MPG.126c40e8f2891f3998a07c@nntp.hpl.hp.com>

In article <4287-380290B4-1@storefull-214.iap.bryant.webtv.net> on Mon, 
11 Oct 1999 21:36:52 -0400 (EDT), KernelKlink@webtv.net 
<KernelKlink@webtv.net> says...
> Is it possible to write a Perl script that will add line numbers to an
> existing script by using the existing script as an argument? I would
> want even the blank lines to be numbered, not just the lines with text
> on them. 
> 
> Will Perl do this?

Perl will do just about anything.  In one line.  :-)

For Windows/DOS:

     perl -pe "printf '%3d ', $." foo.txt

For Unix:

     perl -pe 'printf "%3d ", $.' foo.txt

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


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

Date: Tue, 12 Oct 1999 03:09:17 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Using Perl to add line nums?
Message-Id: <slrn8058cf.f6l.*@dragons.duesouth.net>

On Mon, 11 Oct 1999 21:36:52 -0400 (EDT), KernelKlink@webtv.net enriched
us with: 
: Is it possible to write a Perl script that will add line numbers to an
: 
: Will Perl do this?

perl -lne 'printf "%-80s # $.\n", $_' script

HTH,

--Matthew


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

Date: Mon, 11 Oct 1999 23:08:43 -0400 (EDT)
From: KernelKlink@webtv.net
Subject: Re: Using Perl to add line nums?
Message-Id: <7046-3802A63B-2@storefull-212.iap.bryant.webtv.net>

Excellent! Thanks Larry.



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

Date: 12 Oct 1999 04:01:30 GMT
From: pete@localhost.localdomain (Peter J. Kernan)
Subject: Re: Using Perl to add line nums?
Message-Id: <slrn805cko.jea.pete@localhost.localdomain>

On Mon, 11 Oct 1999 21:36:52 -0400 (EDT), 
  KernelKlink@webtv.net <KernelKlink@webtv.net> wrote:
 .=Is it possible to write a Perl script that will add line numbers to an
 .=existing script by using the existing script as an argument? I would
 .=want even the blank lines to be numbered, not just the lines with text
 .=on them. 
 .=
  perl -pe 's/^/$./' [FILE]
-- 
  Pete


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

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


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