[16448] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3860 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 31 18:06:30 2000

Date: Mon, 31 Jul 2000 15:05:31 -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: <965081131-v9-i3860@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 31 Jul 2000     Volume: 9 Number: 3860

Today's topics:
        August San Diego Perl Mongers Meeting (Garrett Casey)
    Re: command-line argument <tim@ipac.caltech.edu>
    Re: DBI.pm CGI.pm tutorial needed <lr@hpl.hp.com>
        debug to file <dmfetter.NOSPAM@emeryworld.com>
    Re: debug to file (Colin Keith)
    Re: Difference between a .cgi file and a .pl file? <godzilla@stomp.stomp.tokyo>
    Re: garbage is read from first record in a file <billy@arnis-bsl.com>
    Re: Hash Question - Please help (Colin Keith)
    Re: Help needed with Net::Telnet <vgavan@hotmail.com>
    Re: Help needed with Net::Telnet (Mark W. Schumann)
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <thoren@southern-division.com>
        if last char is comma, delete it <mikek@worldwebserver.com>
    Re: if last char is comma, delete it <aqumsieh@hyperchip.com>
    Re: if last char is comma, delete it <newsposter@cthulhu.demon.nl>
    Re: if last char is comma, delete it <mikek@worldwebserver.com>
    Re: if last char is comma, delete it <makarand_kulkarni@my-deja.com>
    Re: Is "exit()" really necessary? (Tim)
        LWP https 302 Moved Temporarily bkodl@my-deja.com
    Re: Memory leak in perl code <tim@ipac.caltech.edu>
    Re: New Site: www.perlmodules.com (Colin Keith)
        Newbie question: # of characters in a string (Jon S.)
    Re: Newbie question: # of characters in a string (Greg Bacon)
    Re: Newbie question: # of characters in a string <dietmar.staab@t-online.de>
    Re: Newbie question: # of characters in a string (Jon S.)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 31 Jul 2000 21:53:50 GMT
From: adms1@cts.com (Garrett Casey)
Subject: August San Diego Perl Mongers Meeting
Message-Id: <3985f508.1130195@nntp.cts.com>

Well, August is just around the corner.  Per our Web Page 
http://SanDiego.pm.org our next meeting is on August 16, 2000.
It will be hosted by MusicMatch http://www.musicmatch.com

Here is the tentative schedule for the meeting:

Pizza, salad, and beer should be available (yummy)

At around 7:00PM the meeting will begin with normal
starting talk (info on next meeting, any announcements, etc).

7:30-8ish - Bill Caid will talk about MusicMatch, the 
Jukebox, and the system behind them.

After Mr. Caid, Ted Dunning will talk for about 30-45 minutes 
about a new concept called Active Logging and how it can
help aid in debugging systems, creating test scripts for
future systems, and assist in decreasing the number 
of errors in programs.

Our own Bobby Kleemann will follow Mr. Dunning for about 
45-60 minutes.  He will talk about his experiences with Perl
and MusicMatch, and explain how Perl was the best solution
for some problems that MusicMatch has encounterd.

After Bobby talks, we will break.  This will be you opportunity
to talk and network with other Mongers (we have 65+
members).

Also, I just order Programming Perl, 3rd Edition, which I 
will be bringing to the meeting.  Hopefully, several of you 
have picked up the book and will bring it too, so everyone
else will have an opportunity to skim it.  Our September
meeting will focus on reviewing this current version of 
the "Bible."

If you plan to attend the meeting, please RSVP by sending
an email to canetguy@home.com or adms1@cts.com

More information will be posted on http://SanDiego.pm.org when
it becomes available.

****
The San Diego Perl Mongers welcome all new members, at
all programming levels.  We meet every month.  Each member
is given a FREE shell account on our server and access to 
our FRIENDLY mailing list.  Visit http://SanDiego.pm.org 
for more information.


-Garrett Casey
canetguy@home.com
adms1@cts.com



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

Date: Mon, 31 Jul 2000 13:52:44 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: command-line argument
Message-Id: <3985E71C.B84A89C@ipac.caltech.edu>

Yidao Cai wrote:
> 
> How can a perl script read command-line arguments, just like a shell
> script does with $1, $2 ?

man perlvar

Look for test regarding the @ARGV. Specifically:


       @ARGV   The array @ARGV contains the command line arguments
intended for 
               the script.  Note that $#ARGV is the generally number of 
               arguments minus one, because $ARGV[0] is the first
argument, NOT 
               the command name.  See "$0" for the command name.


--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Mon, 31 Jul 2000 11:04:58 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: DBI.pm CGI.pm tutorial needed
Message-Id: <MPG.13ef5fa597d63d3298ac10@nntp.hpl.hp.com>

In article <0192fe61.eff94892@usw-ex0102-014.remarq.com> on Mon, 31 Jul 
2000 06:43:24 -0700, RS@ <rschram@reed.edu> <RS@ <rschram@reed.edu>> 
says...

 ...

> #!usr/bin/perl
                 -w
  use strict;
 
> # So happy together...
> use CGI;

  use CGI ':standard';

> use DBI;
> 
> # Grab the parameters from the submitted form.
> # Note the use of CGI.pm's param() function.
> my $user = param('user');
> my $pass = param('pass');

 ...

> my $dbh = DBI::connect('database_driver', $user, $pass)
>             or die "Blah blah blah!";
> 
> # I *think* I could have also put param('user') and so forth in
> # lieu of $user and so forth. Each are expressions which could
> # be interpolated, right?

Why not?  An expression is an expression is ...

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


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

Date: Mon, 31 Jul 2000 12:37:51 -0700
From: "John Doe" <dmfetter.NOSPAM@emeryworld.com>
Subject: debug to file
Message-Id: <8m4kih$a8m$1@news.cnf.com>

Is there a way to have perl send all of it's debugging output to a file
through the initial #!/usr/local/bin/perl line of a script?  I have a script
that does some dynamic web page creation and accesses a postgres db that is
having issues but I have to run the script via web page to produce the
proper environment.  Therefore, I need to be able to have debugging info go
to a file.  I'm still a little wet behind the ears so this may not be a good
question.  Any help is appreciated though.  Thanks.





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

Date: Mon, 31 Jul 2000 20:22:12 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: debug to file
Message-Id: <Udlh5.60$DT4.2126073@nnrp2.clara.net>

In article <8m4kih$a8m$1@news.cnf.com>, "John Doe" <dmfetter.NOSPAM@emeryworld.com> wrote:
>proper environment.  Therefore, I need to be able to have debugging info go
>to a file.  I'm still a little wet behind the ears so this may not be a good

This has been used by me. I wouldn't say its good, but when debugging I'll 
usually result to sticking print "here1";  print "here2 ..."  everywhere :*)

maia% perl -w -Mstrict;
# code on next lines
close(STDERR);
open(STDERR, ">outx" ) || die "Content-Type: text/plain\n\nIck - $!";

warn "kaboomb"; # Send something to STDERR
^D

maia% cat outx 
kaboomb at - line 4.


You could also look at:

open(STDERR, ">&STDOUT);  
See man perlfunc and look in the description for 'open' for this

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Mon, 31 Jul 2000 13:03:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Difference between a .cgi file and a .pl file?
Message-Id: <3985DB84.D7B6DF1@stomp.stomp.tokyo>

"Randal L. Schwartz" wrote:
> Andy wrote:
 
> Andy> the difference is that some servers will only allow a perl
> Andy> script to be executed as a .cgi file extension.
 
> Andy> you will normally find that this happens on older style
> Andy> webservers , most of the newer webservers ( apache ) accept both
> Andy> .pl and .cgi file extensions.
 
(snipped a bit)

> Only in recent versions of Apache have you also been able to add CGI
> recognized "anywhere" using an extension, which to me seems to be a
> Very Bad Idea from a security perspective, intermingling data and code
> much too closely for comfort, not to mention revealing the
> implementation language to outsiders making systematic attack easier.

My perspective and take on these new relaxed standards, Randal,
is they are both a blessing and a curse. I cannot argue your
point of view but can add some positive notes on this change.

For me personally, I like this change. One benefit is I can
replace " index.html " with " index.cgi " for my directory
indexing. This affords me an ability to closely track those
attemping a directory indexing for whatever reason. This does
have rewards when I recognize a selected server with specific
combinations of other information pulled by an index.cgi; it
enhances my ability to predict and thwart security problems.

Another benefit is an ability to load your cgi programs within
a specific directroy tree, well protected not only by index.cgi
but also creative .htaccess documents free of webserver admin
intervention or assistance. Otherwords, I can bury my sensitive
cgi programs deeply beneath multiple layered security checks.
A minor spinoff on this, is an ability to load your programs
within directory trees with very odd names; concealment.

There are quite a few indirect benefits from this cgi everywhere
philosophy we have today. As a result of security problems you
hint at, experts in this area of security have been presented
with new challenges in security and, in turn, have created
solutions for a wide range of security needs. We have better
security now in exchange for relaxing basic security. Our
collective knowledge base of security issues is growning
exponentially now with new problems presented.

It does seem Brenner's early addressing of security issues
and Stein's subsequent cgi.pm are both a result of opening
up servers to abuse with this cgi everywhere thing. Our
cgi wrappers seem to also be an offshoot.

One of the other gals here, not sure which, Abigail or
Elaine, doesn't matter which, both are clear Sages Of
Perl whose words can be taken as gospel truth, one made
mention during a security debate about servers having 
a 'sandbox' for naughty requests. This is another example
of a positive outcome for this issue; servers have no
choice but to be more security aware.

In summary, cgi everywhere, is both a blessing and a curse.
This has brought us new security problems and, has also 
afforded us new security techniques going beyond just
basic issues presented by cgi everywhere. This change has
shifted the burden of security to the shoulders of both
administration and programmers. All are responsible now.

So yes, as you say, there are concerns. Hopefully our
programming community in general, is up to these new
challenges today. I believe we are.

Godzilla!

--
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); 
sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; }
foreach $¿ (@®) { $¢ = $©[$¿-1]; $¢ =~  s/([a-z])/G($1)/gie;
if ($¢ =~ /($©[0])/i) { $¢ = "$¢ "; } print $¢; }
print "!"; exit;


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

Date: Mon, 31 Jul 2000 16:16:54 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: garbage is read from first record in a file
Message-Id: <3985ECC6.9C5131EB@arnis-bsl.com>

rickbowles@my-deja.com wrote:
> 
> When reading the first record in a file I get garbage. I am running on
> AIX 4.3.0 and 4.3.3. I have tried this on perl versions 5.003, 5.004,
> and 5.6.0.
> 
> Has anyone seen this before?
> 
> open( ROUTE_TEMP_FILE, "$WORK_PATH/hostdnld/route/$FILE_NAME.tmp" );
> 
> while ($REC1 = <ROUTE_TEMP_FILE>)
>   {
>   chomp($REC1);
>   print (" $REC1\n");
>   }
> 

 ...skipped...

Why not to check a return code from open() ?

Anyway, the code runs OK on my AIX box.

Please double-check you data file, preferrable with something like od.

Good luck.
Ilja.


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

Date: Mon, 31 Jul 2000 19:11:31 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: Hash Question - Please help
Message-Id: <Dbkh5.54$DT4.2117188@nnrp2.clara.net>

In article <8m43v7$uil$1@nnrp1.deja.com>, t0873 <t0873@my-deja.com> wrote:
> Hi all,
>
>Please help me in this,
>
>I have a hash which has a filename like

No you don't. The code segment you gave isn't a hash. A hash is defined by
%hash

An element in it is referenced by $hash{key}

>$VAR1 = {
>            'file' => 'MYFILE' ,
>            'time' => 5,
>            'sent_dir' => '/.../.../',
>}

This is a reference to an anonymous hash as shown by:

maia% perl -w -Mstrict
my($var) = { wibble=>'x' };
print "\$var = $var, ref = ", ref($var), "\n";

$var = HASH(0x804e054), ref = HASH


A reference is a scalar value that 'points to' the actual data in question. 
As shown, printing the scalar just prints the reference, to get to the data 
you have to de-reference it by replacing 'hash variable' with your 
reference. I.e. if you think of accessing a member of %hash by using 
$hash{key}, you do replace the 'hash' bit with your reference. I.e. 
${$var}{key}

Since this is ugly, Perl has a nice way of doing it using the -> notation:

$var->{key}

maia% perl -w -Mstrict
my($var) = { wibble=>'x', wobble=>'y' };
foreach (keys(%{$var})){  # instead of keys(%hash);
  print "key = $_, val = ", $var->{$_}, "\n";
}

key = wobble, val = y
key = wibble, val = x


(To extrapolate, you can also use references to arrays and use a similar 
notation, thus: $var = [ 3,4,5,5,6 ];   print $var->[0];  prints 3


With the tutorial out of the way, (maybe someone found it useful :) on with 
the question:

>After the specified time, MYFILE is updated in the sent_dir. Now new
>changes say that MYFILE shouldn't get overwritten, but should have new
>format such as month, day, hour and time. my question is is it possible
>to have a some kind of function , inside the hash which can return the
>new value and ASSIGN to 'file'. , so everytime when VAR1 is loaded
>after time , it will have 'file' with MYFILE$mon$mday$hh$mm.

*blinks v. confusedly and cracks out the bullet points* 
- Which specified time? 
- "MYFILE is updated" meaning a file on disk called ../../../MYFILE ? 
- What "new changes" where ? 
Depending on your operating system, a file can be overwritten if you have 
the correct access permissions, but that's nothing to do with what you gave 
here. 
- How can it have a 'new format'. It either is or isn't the same file as 
before. If its not then its been replaced by something or removed, surely?

The 'function inside the hash' I would suggest is best answered by pointing 
you in the direction of an anonymous subroutine. Basically a sub { } which 
you store in the value of a key and then evaluate at a later time ... As to 
what value it returns is upto what you write. I have no idea what 'new 
value' you're refering too and 'ASSIGN to file' means ... ? replace the 
value of the file key in this hash (possible) or write to the file on disk, 
or .. ?

You know, this last sentence makes me think that you're sorely in need of an 
object. It is also something that your code snippet hints at .. man perlobj 
is your friend in that case. If you run up an object to fit your needs you 
would be able to do something like:

package MyObj;

sub new {
  my($class) = shift(@_);
  $class = ref($class) || $class;
  my($this) = { @_ };
  bless( $this, $class );
  $this->timestamp_filename();
}

sub timestamp_filename{
  my($this) = shift(@_);
  @_ = (localtime(time()))[4,3,2,1];
  $this->{filename} = $this->{filename}. sprintf("%02d%02d%02d%02d", @_);
}

1;


$var = MyObj -> new( filename=> x, sent_dir => '../../../' );
print "filename = ", $var->{filename}, "\n";


Soooomething like what you want ?

If not, try giving answers to some of the questions, remember we don't have 
the foggiest what you're talking about unless you give a context or more 
details ... 

*Looks guilty as his random stabs in the dark elicit yelps of pain* :)

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Mon, 31 Jul 2000 18:48:09 GMT
From: "vgavan" <vgavan@hotmail.com>
Subject: Re: Help needed with Net::Telnet
Message-Id: <JRjh5.29153$ga2.843510@newsread2.prod.itd.earthlink.net>

Thanks for your help.
Actually, the prompt $ was the problem, I changed the prompt to
something else and   it works great. Your are right, i did have to
change from scalar to array to get STDOUT.

Now the question why couldn't it find $ prompt, it was escaped correctly?

"Mark W. Schumann" <catfood@apk.net> wrote in message
news:8ltq54$mn3@junior.apk.net...
> In article <s4rg5.17698$5N1.621916@newsread1.prod.itd.earthlink.net>,
> vgavan <vgavan@hotmail.com> wrote:
> >Thank you for your help in advance.
> >It returns no data.
>
> Good!  I mean, at least you are telling us specifically what happens
> instead of saying "it doesn't work."  But now let me ask some more
> questions before answering yours.
>
> >#!/usr/local/bin/perl
>
> append -w here.
>
> >use Net::Telnet ();
>
> Good idea to use the existing module.  This will save a lot of work.
>
> use strict;
>
> >$username = q(oracle);
> >$passwd = q(oracle);
> >
> >$t = new Net::Telnet (Timeout => 10 , Prompt => "/\$/");
>
> || die "can't create telnet object: $!".
>
> >$t->open('0');
>
> || die "can't open telnet connection: $!".
>
> >$t->login($username, $passwd);
>
> || die "can't login as \"$user\" with password \"$passwd\": $!";
>
> >$lines = $t->cmd('ps -ef | grep pmon_$ORACLE_SID');
>
> || die "problem running command: $!" unless ($lines);
>
> >print $lines;
>
> From the manpage for Net::Telnet:
>
>            In a scalar context the characters read are discarded
>            and a boolean is returned indicating the success or
>            failure of sending the command string and reading the
>            prompt.
>
> By causing Net::Telnet::cmd to return a scalar, you're asking it to
> return just a success or failure code.  Maybe you should have gotten a
> 1 or 0 or something on STDOUT instead of nothing at all.  But you
> probably meant to write something like this, which causes
> Net::Telnet::cmd to return an array:
>
> @lines = $t->cmd('ps -ef | grep pmon_$ORACLE_SID');
>
> print join ("\n", @lines) . "\n";
>
> But remember, "or die" is your friend.
>
>




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

Date: 31 Jul 2000 17:20:06 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Help needed with Net::Telnet
Message-Id: <8m4qi6$iml@junior.apk.net>

In article <JRjh5.29153$ga2.843510@newsread2.prod.itd.earthlink.net>,
vgavan <vgavan@hotmail.com> wrote:
>Actually, the prompt $ was the problem, I changed the prompt to
>something else and   it works great. Your are right, i did have to
>change from scalar to array to get STDOUT.
>
>Now the question why couldn't it find $ prompt, it was escaped correctly?

That looked right to me anyway.

But what did you change it TO?



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

Date: Mon, 31 Jul 2000 12:04:58 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <3985CDDA.D294F004@stomp.stomp.tokyo>

Marcel Grunauer wrote:
 
>  Ben Kennedy wrote:
> > Godzilla! wrote:

 
> May I ask you both to take this to private email?

 
You may once you have made the same request of Flavell,
D. Foy, O'Neil, Stowe, Rosler, McCellen and literally
dozens of others who routinely and frequently post 
articles of zero worth and, who blather and bray
for days on end about a lot of nothing.

Their rate of worthless article postings exceeds
my rate by no less than one-hundred to one. I am
not a regular poster here, this you well know.

If you do not make this request of others, I will
brand you a bigot practicing hard core discrimination.


Godzilla!

-- 
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); 
sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; }
foreach $¿ (@®) { $¢ = $©[$¿-1]; $¢ =~  s/([a-z])/G($1)/gie;
if ($¢ =~ /($©[0])/i) { $¢ = "$¢ "; } print $¢; }
print "!"; exit;


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

Date: Mon, 31 Jul 2000 21:38:22 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: I Am An Idiot
Message-Id: <8m4koj$3kr$11$2@news.t-online.com>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:3985B7BE.16C0CD31@stomp.stomp.tokyo...

> I carry a Beretta 9mm handgun within my fashionable personal
> valise of choice, at all times. However, a Smith & Wesson 38
> special will kill you just the same. Reality dictates there
> is no difference between the two.

uhhh... a troll with a gun!

hey troll, you don't need a gun - you are pretty good in shooting your own
feet with perl

too bad that you miss your keyboard all the times

gruß
thoren
8#X

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com





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

Date: Mon, 31 Jul 2000 19:02:22 GMT
From: "Mike King @work" <mikek@worldwebserver.com>
Subject: if last char is comma, delete it
Message-Id: <3985CD48.77DB1F26@worldwebserver.com>

I'm trying to build an sql query that will be run through the DBI. The
user will select the fields they want from a form, and the script will
construct the SQL statement accordingly. My problem is, on most queries,
I end up building statements such as:

SELECT one, two, three, FROM table

So I've decided to construct an intermediate string such as

$string = 'one, two, three,';

then make the SQL statement:

$sql="SELECT $string FROM table";

My question: how can I strip the last character from $string  if it
happens to be ","???

-Mike K.


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

Date: Mon, 31 Jul 2000 19:12:18 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: if last char is comma, delete it
Message-Id: <7aog3ef71n.fsf@merlin.hyperchip.com>


"Mike King @work" <mikek@worldwebserver.com> writes:

> My question: how can I strip the last character from $string  if it
> happens to be ","???

	s/,$//;

--Ala


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

Date: 31 Jul 2000 19:13:32 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: if last char is comma, delete it
Message-Id: <8m4j4s$aaq$4@internal-news.uu.net>

Mike King @work <mikek@worldwebserver.com> wrote:
> I'm trying to build an sql query that will be run through the DBI. The
> user will select the fields they want from a form, and the script will
> construct the SQL statement accordingly. My problem is, on most queries,
> I end up building statements such as:

> SELECT one, two, three, FROM table

> So I've decided to construct an intermediate string such as

> $string = 'one, two, three,';

> then make the SQL statement:

> $sql="SELECT $string FROM table";

You could store the column names in a list and then use
join to make the comma-separated string

> My question: how can I strip the last character from $string  if it
> happens to be ","???

Check out the 'perlre' manual page to get information on regular expressions.

Erik



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

Date: Mon, 31 Jul 2000 19:43:57 GMT
From: "Mike King @work" <mikek@worldwebserver.com>
Subject: Re: if last char is comma, delete it
Message-Id: <3985D707.4DB46643@worldwebserver.com>


Thank you. Didn't realize, there was some whitespace at the end of the
string, so I changed it:

$attr =~ s/,\s$//;

Works great!

-Mike K.

Ala Qumsieh wrote:
> 
> "Mike King @work" <mikek@worldwebserver.com> writes:
> 
> > My question: how can I strip the last character from $string  if it
> > happens to be ","???
> 
>         s/,$//;
> 
> --Ala


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

Date: Mon, 31 Jul 2000 14:01:59 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: "Mike King @work" <mikek@worldwebserver.com>
Subject: Re: if last char is comma, delete it
Message-Id: <3985E947.F1D7DA89@my-deja.com>

> 
> My question: how can I strip the last character from $string  if it
> happens to be ","???

store column names in a array

@arr = ( 'col1', 'col2', 'col3');
then use join () with comma as glue

@string = join "," , @arr ;

you will never have the comma at the end.

--


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

Date: Mon, 31 Jul 2000 19:41:57 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: Is "exit()" really necessary?
Message-Id: <8F828C935indigodimcom@166.93.207.145>

bart.lateur@skynet.be (Bart Lateur) wrote in
<qq69os8jvqfkh3tlbf3e7ltu5p1f7k98k1@4ax.com>: 

>Abigail wrote:
>
>>.. I try to avoid exit() as much as possible. If I ever need it inside
>>a .. sub, I tend to consider this a defeat. So I'll try to get rid of
>>it. 
>>
>>To me, that falls in the same category as not using return, goto,
>>regexes, addition, or semicolons.
>
>"goto", maybe. the others: bogus.
>
>The problem with exit() is that it is untrappable. You can no longer
>reuse your code.

Plus there was a CERT advisory this spring concerning a security hole
if you fail to check the return value of exit.

-T


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

Date: Mon, 31 Jul 2000 18:46:53 GMT
From: bkodl@my-deja.com
Subject: LWP https 302 Moved Temporarily
Message-Id: <8m4hiq$9ve$1@nnrp1.deja.com>

Hi, I am having trouble downloading HTTPS files via LWP. I've read the
LWP FAQ and installed Crypt-SSLeay. However, the following script still
results in error "302 Moved Temporarily". I'm using perl 5.005_03 with
libwww 5.48 on WinNT 4 Workstation, Service Pack 3. Here is the script:

use LWP::UserAgent;
use LWP::Debug qw(+conns);
use HTTP::Cookies;

# my $URL = 'http://mail.yahoo.com/';    # works
my $URL = 'https://www.nodeworks.com/';  # does not work

my $ua = new LWP::UserAgent;
$ua->proxy(['http','https','ftp'] => 'http://internet.ps.net');
$ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt", autosave =>
1, ignore_discard => 1));
my $res = $ua->request(new HTTP::Request GET => $URL);

print ($res->is_success) ? $res->as_string : $res->status_line;
exit 0;

Here is the output:

LWP::Protocol::http::request: GET https://www.nodeworks.com/ HTTP/1.0
Authorization: Basic bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=
Host: www.nodeworks.com
User-Agent: libwww-perl/5.48

LWP::Protocol::http::request: HTTP/1.0 302 Moved Temporarily

Content-Length: 299

Location: https://www.nodeworks.com/

<HTML><HEAD><TITLE>Novell BorderManager</TITLE></HEAD>
<BODY><b><p>HTTPS request from Netscape browser is being redirected.<p>
Keep pressing this <A HREF="https://www.nodeworks.com/">link</A> till
all the persistent connections with your browser are closed,to view the
secure page.</b>
</BODY></HTML>


Any ideas?

Thanks for your help,
Brian.


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


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

Date: Mon, 31 Jul 2000 14:55:54 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Memory leak in perl code
Message-Id: <3985F5EA.4CDC9EC1@ipac.caltech.edu>

Greg Roberts wrote:
> ... What I've
> noticed, with using top, is that the script's memory usage grows at a
> rapid rate until it dies from taking up too much system memory. The loop
> looks something like this:
> 
> while(1)
> {
>   chdir (dir)
>   @contents = `ls -l`
> 
>   foreach $entry (@contents)
>   {
>     process $entry...
>   }
> }
> 
> ... Now I'm no programming guru by any means, so I
> don't really know how to tackle this one.

Find out which statement(s) is(are) causing the leak. Is it the chdir?
Comment it out and run on the current dir all the time and see. Is it
the 'ls -l'? Comment it out and replace it with a static list. Etc. 

Or instead you could replace it with code that draws on the File::Find
module, or use code that bypasses chdir and `ls -l`, like this (very
untested):

# Assuming the directory names are given on the command line ...
for my $dir (@ARGV) {
  opendir(DIR,"$dir") or die "can't open '$dir'; $!";
  my @files = map { "$dir/$_" } readdir(DIR); # '/' is OS dependant
  closedir(DIR) or die "can't read(close) '$dir'; $!";
  for my $file (@files) {
    # Do stuff on files. E.g. ...
    next if -d $file || -l _; # Files only, not sub-dir.s or symlinks
    my @fileinfo = stat(_); # See 'perldoc -f stat'
    my $size     = -s _;
    # ... etc.
  }
}
--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Mon, 31 Jul 2000 19:17:13 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: New Site: www.perlmodules.com
Message-Id: <Zgkh5.55$DT4.2117922@nnrp2.clara.net>

In article <398538d5_2@nnrp1.news.uk.psi.net>, "Steve Jones" <steve.jones@takethisoutproact.net> wrote:
>By the way, how do I find out how to compile/install/use the MIMETools
>module and install it on NT? What resources do I need? Why does MAKE break?

Does it say something about "missing separator on line  ..." ?
Then check that you have a tab character on that line. If it is that, I'm 
starting to think that the Makefile.PL proggy generator (ExUtils::MakeMaker 
?) is broken because its popped up alot just recently.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Mon, 31 Jul 2000 21:19:48 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Newbie question: # of characters in a string
Message-Id: <3985e6e0.25438893@news.earthlink.net>

Hi,

I'm having problems with a data validation issue which should, quite
frankly, be simple.  But, I can't get it to work.  (It's possible it's
a script error, but I've tried it a couple of ways.)

I can't seem to count the number of characters in a string.  I've
tried writing a tr/// command multiple different ways (as just tr///,
with a . to match any character like tr/.//, with a .* to match
multiple characters like tr/*.//, and on and on.) and I can't seem to
do it.

I first used the command within an if statement like this

if ( (($foostring =~ tr///) <= 40) || (($foostring =~ tr///) >= 1) ) {
$foovalid = "ok" }

I've also tried the "count a word" style example used in Learning Perl
and the Perl FAQ.

    $count = ($foostring =~ tr/X//);
    print "There are $count X charcters in the string";

Only, like I said above, in place of X, I've either had nothing, or
put in various other things to try and match.
(http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#How_can_I_count_the_number_of_oc)

I know this is a dumb newbie question, but both learning perl (the
book) and the perl docs just give me how to count the number of things
which match something.  Not how to count everything.  That said, and
link to a better regular expression tutorial would be appreciated.

Thanks,

Jon


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

Date: Mon, 31 Jul 2000 21:28:23 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Newbie question: # of characters in a string
Message-Id: <sobrrntudbm99@corp.supernews.com>

In article <3985e6e0.25438893@news.earthlink.net>,
    Jon S. <jonceramic@nospammiesno.earthlink.net> wrote:

: I can't seem to count the number of characters in a string.  I've
: tried writing a tr/// command multiple different ways (as just tr///,
: with a . to match any character like tr/.//, with a .* to match
: multiple characters like tr/*.//, and on and on.) and I can't seem to
: do it.

tr/// doesn't accept regular expressions.  tr/.// will simply count
the dots in $_.

If you want the length of a string, use Perl's length() operator.
Find its documentation in the perlfunc manpage.

Greg
-- 
Carrying the idea further (reductio ad absurdum? :-) C<local $$;>
would be identical to fork()...
    -- Jarkko Hietaniemi


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

Date: Mon, 31 Jul 2000 23:36:01 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: Newbie question: # of characters in a string
Message-Id: <8m4reo$7d5$16$1@news.t-online.com>

In article <3985e6e0.25438893@news.earthlink.net>,
jonceramic@nospammiesno.earthlink.net (Jon S.) wrote:


> I can't seem to count the number of characters in a string.  I've tried
Try function "length".

BTW, don't try length to find the size of an array or hash

Use "scalar @array" resp. scalar keys %hash for these data structures.

Look at the documentation, Luke. ;-)

Greetings, Dietmar


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

Date: Mon, 31 Jul 2000 21:49:39 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Newbie question: # of characters in a string
Message-Id: <3985f1b0.28206999@news.earthlink.net>

On Mon, 31 Jul 2000 21:28:23 GMT, gbacon@HiWAAY.net (Greg Bacon)
wrote:

>In article <3985e6e0.25438893@news.earthlink.net>,
>    Jon S. <jonceramic@nospammiesno.earthlink.net> wrote:
>
>: I can't seem to count the number of characters in a string.  I've
>: tried writing a tr/// command multiple different ways (as just tr///,
>: with a . to match any character like tr/.//, with a .* to match
>: multiple characters like tr/*.//, and on and on.) and I can't seem to
>: do it.
>
>tr/// doesn't accept regular expressions.  tr/.// will simply count
>the dots in $_.
>
>If you want the length of a string, use Perl's length() operator.
>Find its documentation in the perlfunc manpage.
>
>Greg

Thanks Greg.

For those who care, the link on perl.com is:
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/length.html

Jon


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

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


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