Calling touch ...

2001-06-11 Thread innovative-peripherals


I'm trying to write a script that opens a file, then matches some 
characters, and then writes the output to an HTML file on the fly.

Everything works except I also want to timestamp a file with touch
in the same perl script and that doesn't work. Touch is active as I 
can 'touch' the file on the console. But my code inside the perl 
script doesn't work.

Here is the latest statements that I tried.

system 'touch', 'test0612a.shtml';

exec 'touch', 'test0612a.shtml';

Thanks for any help,
~





Question about the Curses module

2001-06-11 Thread George S Pereira


Hi All,

The people I work with here have decided to shift from APT, and
are using Curses for visual display of forms. However there is a problem, 

While creating a new textfield using Curses, the boundary of the
field is usually set on. But even if it is set to False, the space of the
boundary is still set to the same, this cannot be reduced. 

I want to know, if anybody has used Curses, then how do we reduce
the boundary space around the fields?

I don't think it is possible to do it in the module, as it calls
the relevant C function. But if there is any way to do this, please tell
me.

Thanks in Advance



===
Pure Tyranny is the pinnacle of an uncontrolled lust for power.
Pure Intelligence is the pinnacle of an uncontrolled lust for knowledge
-- T.R.R
===

Mountains cannot be surmounted except by winding paths
-- Johann Wolfgang Von Goethe
===

George Savio Pereira

Email : [EMAIL PROTECTED]





Re: Regex question

2001-06-11 Thread Chas Owens


> print "$#list\n";
> print scalar(@list);
> 
> would return
> 
> 3
> 4

Unless somebody was messing with the $[ (array index starts at)
variable.  Example:


#!/usr/bin/perl -w

use strict;

my @list = qw(one two three four);

print "The last element of \@list is $#list\n";
print "There are ", scalar(@list), " elements in \@list\n";

$[ = 5;

print "The last element of \@list is $#list\n";
print "There are ", scalar(@list), " elements in \@list\n";



The last element of @list is 3
There are 4 elements in @list
The last element of @list is 8
There are 4 elements in @list


Messing with $[ is unhealthy and a sign of a very sick mind.

--
Today is Pungenday, the 17th day of Confusion in the YOLD 3167
P'tang!





Re: checking for the @ symbol

2001-06-11 Thread Peter Scott

At 11:08 PM 6/11/01 -0500, [EMAIL PROTECTED] wrote:

>i am writing a script that tests to see if an \@ symbol is entered by an
>end user. i am trying to look at other alternatives that a malicious end
>user might do to get around my checking. right now, i am doing a simple
>
> if ( $add_alias =~ /\@/ ) {
>
>could an end user enter an escaped ascii character code that would be
>interpretted as \@

Interpreted in what context?  I'm not aware of how a lowly @ character in 
your input could pose a danger, so if you enlightened us as to exactly what 
you're concerned about perhaps we can help.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re: Perl FAQ A Day

2001-06-11 Thread Hasanuddin Tamir

On Mon, 11 Jun 2001, Jeff Yoak <[EMAIL PROTECTED]> wrote,

> Date: Mon, 11 Jun 2001 16:41:59 -0700
> From: Jeff Yoak <[EMAIL PROTECTED]>
> To: Hasanuddin Tamir <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Subject: Re: Perl FAQ A Day
>
> At 01:58 AM 6/12/01 +0700, Hasanuddin Tamir wrote:
> > > http://perl.faq-by-day.org/ .
> >
> >I've subscribed for a few weeks, and I like it.  It's really great
> >to have such a resource.  Thanks a lot for the effort.  You do a
> >wonderful job.
>
> Actually, I do a pretty terrible job.  :-)  That's the 1997 version of the
> FAQ and I've been too lazy to update it with the FAQ from 5.6.x .  And I
> don't use real mailing list software so people are often confused about how
> to get on or off of the list.  And at least three months ago, Tom Phoenix
> suggested an improvement to the site whereby people could ask their own
> questions and he was convinced he could enlist the help of a few experts to
> provide good answers.  This forum partially realizes that, I suppose.  But
> other than a flash of a good idea 6 years ago, and once updating the FAQ, I
> haven't really done much.  But that doesn't stop me from promoting it or a
> lot of people from seeming to find it useful.  ;-)
>
> But thank you for the compliment.  I'm glad to hear it is useful to you.

Well, you know, I think I already read (almost) all text from the perlfaqs.
I can't remember all of them precisely, only that I know where to look for
something.  So I infrequently reread them randomly without any interest for
particular topic (for that I just use the perldoc -q).

Tom Christiansen (if I recall well) used to post random Perl FAQ daily in
the clp.misc, but I haven't been in the ng for quite long time.  When I got
URL about this daily faq, it reminds me to what Tom did in the ng and I
didn't need a second thought to subscribe.

Frankly, I don't realize about the FAQ being a bit old.  I'm mostly with
5.005_03.  I just installed 5.6 few days ago and I haven't read all the
manual and faq from the new installation.  I'd like to help to enhance
this service.  But I haven't had any idea, I think I only have a little
spare time for that.


regards
s::a::n
-- 
http://www.trabas.com




checking for the @ symbol

2001-06-11 Thread charles

i am writing a script that tests to see if an \@ symbol is entered by an
end user. i am trying to look at other alternatives that a malicious end
user might do to get around my checking. right now, i am doing a simple

if ( $add_alias =~ /\@/ ) {

could an end user enter an escaped ascii character code that would be
interpretted as \@

thanks -cjm




RE: Issuing rollback() for database handle being DESTROY'd without explicit disconnect().

2001-06-11 Thread Steve Howard

Actually, you disconnect your database handle...in this case:

$dbh->disconnect;

but that's not what I see in your script.

What I see happening in your script is that you are connecting twice using
the same database handle without ever disconnecting the database handle the
first time. There should be no reason to connect to the same database a
second time in this script unless you are using the results from the
statement handle in the first database handle in the query in the second
database handle. In this case, you aren't, so take out the second connection
string, and you should get rid of this error. The disconnect error should
not occur even if you do not explicitly disconnect from the database before
the end of the script - unless you have uncommitted transactions (unlikely
if you are using MySQL).

If you ever need to use the results of the first query in a second query
before finishing with the first statement handle, simply use a different
database handle, and statement handle for the second one: ex: $dbh1, and
$sth2. or $Mysql_Database and $insert...or whatever makes sense to you to
use$dbh, and $sth are only examples of database and statement handles.
You can use whatever makes sense in your program.

Hope this helps.

Steve Howard



-Original Message-
From: Brent Michalski [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 11, 2001 9:02 AM
To: FLAHERTY, JIM-CONT
Cc: Beginners (E-mail)
Subject: Re: Issuing rollback() for database handle being DESTROY'd
without explicit disconnect().



I saw no $dbi->disconnect; statement in your code.  If you do not
disconnect, and the program ends, you will get the above message

brent




"FLAHERTY,
JIM-CONT" To: "Beginners (E-mail)"
<[EMAIL PROTECTED]>
Subject: Issuing
rollback() for database
  handle being DESTROY'd without
ex plicit
06/11/01 09:00 AM disconnect().






Why am I getting this  ??

Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().



the code


#!/usr/bin/perl

#  Script to maintain  KBHD Stats  #
#   Version  1.0   #
#   date : 6 Jun 01#

# require "subparseform.lib";
# &Parse_Form;
###
#  Start Writing the Page #
###
open(LOG,">/var/www/html/kbhd/stats.php");

print LOG "\n";
print LOG " Stats for Techs \n";
print LOG "\n";

print LOG "\n";

print LOG "\n";

print LOG "  Stats Page\n";
print LOG " \n";
print LOG "\n";

# 

##
# get stats
##

use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "user";
my $password = "password";

$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select count(*)from jobs where status =
'closed'");
$sth1 -> execute or die " unable to execute query ";

my $array_ref = $sth1 -> fetchall_arrayref();
  foreach $row(@$array_ref){

my($closedJ) = @$row;

}


print LOG "  ";
print LOG " Overall Stats";
print LOG "\n";
print LOG "  \n";
print LOG "  \n";
print LOG "\n";

print LOG "";
print LOG "Number Of ";

print LOG "Closed Jobs :  ";
print LOG "\n";
print LOG "$closedJ \n";

print LOG "Total Time\n";
print LOG "Average time per Call\n";
print LOG " \n";
print LOG "\n";

print LOG "\n";
print LOG "Grades for techs \n";

###
#Query techs names#
###
use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "";
my $password = "";

$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select username from tech1");
$sth1 -> execute or die " unable to execute query ";
my $array_ref = $sth1 -> fetchall_arrayref();
  foreach $row(@$array_ref){

   my($tech) =@$row  ;

  print LOG " $tech \n";

print LOG " \n";

 print LOG "\n";

print LOG "    Total Jobs
Completed\n";
print LOG "  \n ";
print LOG "   
53<

/b>\n";
print LOG "\n";
print LOG " \n";
print LOG "   Total Hours Spent  
<

/td>\n";
print LOG " \n";
print LOG "    56\n";
print LOG "\n";
print LOG "\n";
print LOG " \n";
print LOG "  \n";
print LOG "   \n";
print LOG "\n";
print LOG "\n";
print LOG "   Average
time to";


print LOG "Complete \n";
print LOG "   \n";
print LOG "    67\n";
print LOG "\n";

print LOG "  \n";

print LOG "\n";









}

close(LOG);







Re: how to create a file

2001-06-11 Thread -

On Monday 11 June 2001 21:23, Steve Howard wrote:
> Quick comment: Make sure the quote types match when opening the file:
>
>
> open (FILE, ">text.txt");

  Yep, I knew I was going too fast.I've been mixing my quotes all 
evening.  



RE: how to create a file

2001-06-11 Thread Steve Howard

Quick comment: Make sure the quote types match when opening the file:


open (FILE, ">text.txt");


-Original Message-
From: - [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 11, 2001 10:15 PM
To: [EMAIL PROTECTED]
Subject: Re: how to create a file


On Monday 11 June 2001 19:52, bdale16 wrote:
> I want a perl program when executed to send the data to a file such as
> text.txt but i dont need to open the file first. apparently i don't
> understand what the command is to  do this
>
>  If it is  open close or write ?
>  any suggestions on the right command to use and the yntex so i can
> experiment with saving data created in pearl programs to files

You could...

open (FILE, '>text.txt");
Print FILE "Text to put in file.\n";
close(FILE);

BTW, the > is used before the filename to open it for writing.  Anything
already in the file will be lost of you use this.  If you just want to add
to
the file use >> before the filename when opening it.  Also, if you don't use
> or >> the file will be opened for reading only.




Re: how to create a file

2001-06-11 Thread -

On Monday 11 June 2001 19:52, bdale16 wrote:
> I want a perl program when executed to send the data to a file such as 
> text.txt but i dont need to open the file first. apparently i don't
> understand what the command is to  do this
>
>  If it is  open close or write ?
>  any suggestions on the right command to use and the yntex so i can 
> experiment with saving data created in pearl programs to files

You could...

open (FILE, '>text.txt");
Print FILE "Text to put in file.\n";
close(FILE);

BTW, the > is used before the filename to open it for writing.  Anything 
already in the file will be lost of you use this.  If you just want to add to 
the file use >> before the filename when opening it.  Also, if you don't use 
> or >> the file will be opened for reading only.



Re: Getting Perl to interact with passwd

2001-06-11 Thread Karthik Krishnamurthy

On Tue, 12 Jun 2001, Paul wrote:
> --- Daniel Ames <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > 
> > This was brought up before, but the archives didn't really answer my
> > question.
> > 
> > I'm trying to get my script to reset a password for me via the passwd
> > command. Keep in mind, I'm very new, so if this is dumb, try not to
> > laugh:
> > 
> > #!/usr/bin/perl
> > 
> > open(handle, "| passwd joeuser");
> > 
> > print handle "password\n";
> > print handle "password\n";
> > close(handle);
> > 
> > Here's what it spits out:
> > 
> > Changing password for user joeuser
> > New UNIX password: Retype new UNIX password:
> > New UNIX password:
> > New UNIX password:
> > passwd: Conversation error
> > 
> > Then it dies. I know I'm doing this wrong. Any ideas?
> > 
> > Thanks!
> 
> WARNING: *STRICTLY* SPECULATION! =o)
> 
> 
> 
>  maybe passwd is actually reading directly from the terminal, rather
> than just from stdin? You might end up having to fork a process and
> write to `tty`. Hope not, but it's possible.
> 
> 
> 
> List?

i distinctly remember reading something to that effect. the passwd program must
be reading from the controlling terminal /dev/tty. if so the correct way to
implement this entirely in perl would be to set up a pair of pseudo terminals,
fork a process, have the child make the slave pseudo terminal a controlling
terminal and spawn passwd. 

/kk

p.s. i believe that is what expect does, but in a general sort of way



Re: SunEd Perl Class - Day 1

2001-06-11 Thread Rogério Brito

On Jun 11 2001, Peter Scott wrote:
> It just is that way.  Larry probably felt that the usefulness of hashes 
> interpolating was not worth giving up another character that would have to 
> be escaped if desired literally.

I don't also know, but I can make the conjecture that another
reason why we can't interpolate a hash in a string may be
related to it's limited usefulness, since the order of listing
it may not be deterministic.


[]s, Roger...

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  Rogério Brito - [EMAIL PROTECTED] - http://www.ime.usp.br/~rbrito/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



how to create a file

2001-06-11 Thread bdale16

I want a perl program when executed to send the data to a file such as  text.txt but i 
dont need to open the file first.
 apparently i don't understand what the command is to  do this 

 If it is  open close or write ?
 any suggestions on the right command to use and the yntex so i can  experiment with 
saving data created in pearl programs to files




Re: extracting substr

2001-06-11 Thread Karen Cravens

On 10 Jun 2001, at 10:05, Dave Cross wrote:

> On Sat, Jun 09, 2001 at 06:33:21PM -0500, Karen Cravens ([EMAIL PROTECTED]) wrote:
> > Someone can probably fine-tune which places don't 
> > actually need three digits and whatnot, too.

> It can be a bit more complex that that tho'. The first diit in a set of
> three can only be 1 or 2, if the first digit is 2 then the second one can
> only be 1 to 5, if the second digit is 5 then the third can only be 1 to
> 5.

Yeah, that's what I meant by "fine tuning."
 
> Of course, trying to cope withthat makes the regex far more complex and
> you might think it's too much extra effort for too little gain :)

Unless you're likely to get things-which-look-like-IP-addresses-but-
aren't, yeah.

-- 
Karen J. Cravens ([EMAIL PROTECTED])



Re: Installing new Modules problem

2001-06-11 Thread Tony Cook

On Mon, 11 Jun 2001, Jos I. Boumans wrote:

> my 2 bits say the latter is the easiest way, *if* it works of course...
> sadly, ppm is not always up to date (they still ship POE 0.09, whilst we're
> at 014 now, and dont even run imager or libwin32, but enough ranting).

I have a simple repository that you can use with PPM that includes Imager.

In ppm, type:

  set repository DEVELOPHELP http://ppd.develop-help.com/ppd/

the Imager binaries include jpeg, tiff and png support compiled in.  No
font support yet unfortunately.

Tony




Re: extracting substr

2001-06-11 Thread Dave Cross

On Sat, Jun 09, 2001 at 06:33:21PM -0500, Karen Cravens ([EMAIL PROTECTED]) wrote:
> On 9 Jun 2001, at 16:21, William wrote:
> 
> >if (($L) = ($_) =~ m/\b([0-9.0-9.0-9.0-9]+)\b/ ) {
> 
> A valid IP address is going to look like four groups of one to three 
> digits separated by dots.
> 
> So if "one to three digits" is \d{1,3} (\d is the same as [0-9]), the 
> regex is going to want to look something more like
> 
> /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
> 
> Notice the quoted-metacharacter dots, otherwise you'll get wacky 
> matches.
> 
> Now, the \b's are probably rendered moot by greediness, so unless 
> you are trying to avoid picking up "x12.34.56.78" you can take 
> those out.  Someone can probably fine-tune which places don't 
> actually need three digits and whatnot, too.

It can be a bit more complex that that tho'. The first diit in a set of
three can only be 1 or 2, if the first digit is 2 then the second one can
only be 1 to 5, if the second digit is 5 then the third can only be 1 to
5.

Of course, trying to cope withthat makes the regex far more complex and
you might think it's too much extra effort for too little gain :)

Dave...




Re: Regex question

2001-06-11 Thread fliptop

Bruno Veldeman wrote:
> 
> And another thing:
> > print $dirs[$#dirs];

@list = ('one', 'two', 'three', 'four');
print $#list;

the output would be

3

$#somelist returns the last element number of an array.  note this is
the element number, which starts at 0.  to get the number of variables
in the array, use scalar():

print "$#list\n";
print scalar(@list);

would return

3
4



Re: SunEd Perl Class - Day 1

2001-06-11 Thread Peter Scott

At 07:24 PM 6/11/01 -0500, Tom Yarrish wrote:
>Well, if anyone is interested, my first day at Sun's Perl Class went 
>pretty well.  However, I do have a couple of questions that came up during 
>the course of the day.  I'm hoping someone can clarify.
>
>1) Okay, with array slices...they give you an example of doing this:
>
> ($f[0], $f[1], $f[2]) = @array
>(are the parentheses correct with this?  I'm doing the example from memory)

That's correct, if a bit odd for illustrating array slices.  Better would 
have been something like

 ($f[0], $f[1], $f[2]) = qw(my brain hurts);

and pointing out that the array slice syntax (see below) is exactly 
equivalent to this.

>Why can't you do this:
>
> ($f[0..2]) = @array

Think dollar sign = scalar = one and only one thing.  At sign = array = 
several things.  Therefore,

 @f[0..2] = qw(my brain hurts);

>I tried it and it didn't work (obviously), but I was curious as to the 
>reason why.
>
>2) With a hash, does the "key" part of the hash have to be a string, or 
>can it be a number?

Doesn't matter, Perl will stringify it anyway.  You won't be able to tell 
the difference.

>3) Why can you do this:
>
> print "$foo";
>or this
> print "@bar";
>but not this
> print "%foobar";

It just is that way.  Larry probably felt that the usefulness of hashes 
interpolating was not worth giving up another character that would have to 
be escaped if desired literally.

>I am actually enjoying the class so far, it's definitely what I needed to 
>get kick started in Perl (I just don't have the time to read all my 
>O'Reilly books on my own).  Of course, I'm sure the Stonehenge Training 
>would be better, but they have to set up shop in Chicago ;p

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




SunEd Perl Class - Day 1

2001-06-11 Thread Tom Yarrish

Well, if anyone is interested, my first day at Sun's Perl Class went pretty well.  
However, I do have a couple of questions that came up during the course of the day.  
I'm hoping someone can clarify.

1) Okay, with array slices...they give you an example of doing this:

($f[0], $f[1], $f[2]) = @array
(are the parentheses correct with this?  I'm doing the example from memory)

Why can't you do this:

($f[0..2]) = @array

I tried it and it didn't work (obviously), but I was curious as to the reason why.

2) With a hash, does the "key" part of the hash have to be a string, or can it be a 
number?

3) Why can you do this:

print "$foo";
or this
print "@bar";
but not this
print "%foobar";

I am actually enjoying the class so far, it's definitely what I needed to get kick 
started in Perl (I just don't have the time to read all my O'Reilly books on my own).  
Of course, I'm sure the Stonehenge Training would be better, but they have to set up 
shop in Chicago ;p

Thanks,
Tom
#!/usr/bin/perl -w
# 526-byte qrpff, Keith Winstein and Marc Horowitz <[EMAIL PROTECTED]>
# MPEG 2 PS VOB file on stdin -> descrambled output on stdout
# arguments: title key bytes in least to most-significant order
$_='while(read+STDIN,$_,2048){$a=29;$c=142;if((@a=unx"C*",$_)[20]&48){$h=5;
$_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$d=
unxV,xb25,$_;$b=73;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=($t=255)&($d
>>12^$d>>4^$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9
,$_=(map{$_%16or$t^=$c^=($m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t
^=(72,@z=(64,72,$a^=12*($_%16-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271))
[$_]^(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval




Re: Perl FAQ A Day

2001-06-11 Thread Jeff Yoak

At 07:58 PM 6/11/01 -0400, Kevin Meltzer wrote:

>Odd that you get errors, I don't.

http://www.perlfaq.com/frequent.html
is broken.  There was another page with a similar message.  Last time it 
was one of the first pages I visited, but I can't seem to locate it 
again.  Somehow I missed the "Enter the Database" link at the top and had 
only visiting links near the bottom.

>However, due to an iffy copyright, you couldn't really include the entries
>anyways. Last I knew, and read on  the 'contributing' page all authors held
>copyright to their individual entries. So, you may want to contact the
>individuals before using them.

Ugh.  That would be way too much work.  The license on the Perl FAQ is nice 
in that I didn't need to get any permission for what I was doing.  Of 
course, I wrote to both gnat and Tom out of courtesy, and gnat replied and 
thought it was a good idea and said he approved.  (I couldn't reach Tom 
because at the time I had access to four servers that were capable of 
sending mail and all four were on his list of mail servers that harbor 
spammers and as such mail from any of them bounced back to me 
unread.  Ironically, four years later he wrote to me asking why I hadn't 
considered hosting the list at perl.com, which would have required 
contacting him.)

>Some of these may appear in the Perl Tips list in the coming months.

Cool.  What's that?

Cheers,
Jeff





Re: Matching '@' symbol in regexp

2001-06-11 Thread Jeff Yoak

At 06:24 PM 6/11/01 -0400, Jeff 'japhy' Pinyan wrote:
> >Can anybody suggest me how to match '@' symbol in a regexp to match e-mail
> >ids etc.
>
>I suggest you don't try to write your own email-matching regex.  But just
>because you asked, use \@.

This list is a really great experiment in handling questions of this sort 
without getting upset and pointing to FAQs and documentation and things 
like that, but in some cases, particularly if you are going to suggest 
something like the above, a pointer to why is probably in order.  (But 
still don't get upset.  :-)

Writing a regular expression that matches all RFC 822 addresses and nothing 
else is really, really hard to do correctly.  There are a couple floating 
around that at least come close to doing the job, and as you'd expect 
people have encapsulated the process and it is available.

CPAN has Email::Valid for checking the validity of email addresses.  A 
description can be found here:

http://search.cpan.org/doc/MAURICE/Email-Valid-0.13/Valid.pm

That one will also do hostname lookups optionally.

Depending on exactly what you need, if you want a single regular expression 
that comes close to doing the job, I remember that Tom Christiansen wrote a 
monster of one that either completely determines rfc 822 compatibility or 
close a few years back.  Searching around the net will likely turn it up.

Cheers,
Jeff






Re: Perl FAQ A Day

2001-06-11 Thread Kevin Meltzer

On Mon, Jun 11, 2001 at 04:48:56PM -0700, Jeff Yoak ([EMAIL PROTECTED]) spew-ed forth:
> At 10:23 PM 6/11/01 +0200, Evgeny Goldin (aka Genie) wrote:
> 
> I've never seen perlfaq.com before.  I've clicked a couple of links and am 
> getting error messages about errors processing various directives.  I can't 
> actually seem to find any actual questions and answers.  Who writes 
> that?  One implication of the page is that the questions and answers are 

Odd that you get errors, I don't.

> user entered.  If that is true, I'd want to pretty carefully examine the 
> content for quality.  I think one of the biggest values in the Perl FAQ is 
> that it is so extraordinarily well-written and precise.  Many of the web 
> collections I've seen in the past contain a lot of mistakes and 
> misinformation and I would feel bad about including something like that 
> unknowingly.

The Q&A on perlfaq.com (which, BTW, has had no new entries in far far too long)
are posted by people which you wouldn't have to worry about quality. Entries
were never allowed from the general public, but by people (me included) who Joe
Hall deemed fit to post.

However, due to an iffy copyright, you couldn't really include the entries
anyways. Last I knew, and read on  the 'contributing' page all authors held
copyright to their individual entries. So, you may want to contact the
individuals before using them. 

Some of these may appear in the Perl Tips list in the coming months.

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Politics is the entertainment branch of industry.
-- Frank Zappa



Re: Simple problem goes astray

2001-06-11 Thread Jeff 'japhy' Pinyan

On Jun 11, Gary Luther said:

>  5   $new_name =~ tr/ \/&-/_sad/;

Why not use tr!!! instead of tr///?  It'll read more easily.  Or even:

  tr{ /&-}
{_sad};

>  5   $new_name =~ tr/ \/&-<>/_sadlg/;

You didn't read the docs on tr///.  The - character serves as a character
range generator.  tr/0-9// is like tr/0123456789//, and tr/a-e// is like
tr/abcde//.  The - is safe when at the beginning or end of a tr///, or
when backslashed or when after a character seen as the end of a range:

  tr/-aeiou//;
  tr/aeiou-//;
  tr/a-z-//;

So, the solution is to \ the -, or put it somewhere else.

  tr{ /&<>-}
{_salgd};

or

  tr! /&\-<>!_sadlg!;

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: Perl FAQ A Day

2001-06-11 Thread Jeff Yoak

At 10:23 PM 6/11/01 +0200, Evgeny Goldin (aka Genie) wrote:

>Cool, although I didn't have to read FAQ ( prefer to find the answers
>by myself ;) it's still a good idea to read it occasionally.
>
>Are you planning to get the contents of http://www.perlfaq.com too ?

Unlikely.  As I mentioned in the last message, I've been pretty lazy about 
it.  Ripping apart the new FAQ into a format that seemed like a good idea 
to me 6 years ago is a higher priority, or perhaps instead I should change 
the code so that it randomly pulls out a pair from the installed version of 
perl so that I could save myself the trouble every few years.  (Having a 
current perl installed isn't extra effort because I always have that anyway.)

I've never seen perlfaq.com before.  I've clicked a couple of links and am 
getting error messages about errors processing various directives.  I can't 
actually seem to find any actual questions and answers.  Who writes 
that?  One implication of the page is that the questions and answers are 
user entered.  If that is true, I'd want to pretty carefully examine the 
content for quality.  I think one of the biggest values in the Perl FAQ is 
that it is so extraordinarily well-written and precise.  Many of the web 
collections I've seen in the past contain a lot of mistakes and 
misinformation and I would feel bad about including something like that 
unknowingly.

Cheers,
Jeff





Re: Perl FAQ A Day

2001-06-11 Thread Jeff Yoak

At 01:58 AM 6/12/01 +0700, Hasanuddin Tamir wrote:
> > http://perl.faq-by-day.org/ .
>
>I've subscribed for a few weeks, and I like it.  It's really great
>to have such a resource.  Thanks a lot for the effort.  You do a
>wonderful job.

Actually, I do a pretty terrible job.  :-)  That's the 1997 version of the 
FAQ and I've been too lazy to update it with the FAQ from 5.6.x .  And I 
don't use real mailing list software so people are often confused about how 
to get on or off of the list.  And at least three months ago, Tom Phoenix 
suggested an improvement to the site whereby people could ask their own 
questions and he was convinced he could enlist the help of a few experts to 
provide good answers.  This forum partially realizes that, I suppose.  But 
other than a flash of a good idea 6 years ago, and once updating the FAQ, I 
haven't really done much.  But that doesn't stop me from promoting it or a 
lot of people from seeming to find it useful.  ;-)

But thank you for the compliment.  I'm glad to hear it is useful to you.

Cheers,
Jeff





Simple problem goes astray

2001-06-11 Thread Gary Luther



Okay guys & gals..sorry to ask simple minded 
questions..they must fit my personality :-(
 
I want to do a simple transliteration. 
 
THE STRING:
 
 $new_name='NEW & RE-PORT V/3 TO TEST.11Jun01149232.test';
 
THIS WORKS:
 
  1 #!/usr/local/bin/perl 
-w  2  3 
$new_name='NEW & RE-PORT V/3 TO > WEEK < MONTH 
TEST(MIN).11Jun01149232.test';  4   
print "new_name - $new_name\n";  5   
$new_name =~ tr/ \/&-/_sad/;  6   
print "new_name after tr - $new_name\n";  
7   exit
ANSWER:
 
/common/bin>./testitnew_name - NEW & RE-PORT V/3 TO > WEEK 
< MONTH TEST(MIN).11Jun01149232.testnew_name after tr - 
NEW_a_REdPORT_Vs3_TO_>_WEEK_<_MONTH_TEST(MIN).11Jun01149232.test
Now I want to get rid of "<", ">", "(", and ")" in the 
new_name.
 
THIS DOES NOT WORK(step 1):
 
  1 #!/usr/local/bin/perl 
-w  2  3 
$new_name='NEW & RE-PORT V/3 TO > WEEK < MONTH 
TEST(MIN).11Jun01149232.test';  4   
print "new_name - $new_name\n";  5   
$new_name =~ tr/ \/&-<>/_sadlg/;  
6   print "new_name after tr - 
$new_name\n";  7   exit
NOR THIS:
 
  1 #!/usr/local/bin/perl 
-w  2  3 
$new_name='NEW & RE-PORT V/3 TO > WEEK < MONTH 
TEST(MIN).11Jun01149232.test';  4   
print "new_name - $new_name\n";  5   
$new_name =~ tr/ \/&-\<\>/_sadlg/;  
6   print "new_name after tr - 
$new_name\n";  7   exit
I GET  THIS ANSWER:
 
/common/bin>./testitnew_name - NEW & RE-PORT V/3 TO > WEEK 
< MONTH TEST(MIN).11Jun01149232.testnew_name after tr - 
NEW_a_REgPORT_Vsg_TO_g_WEEK_g_MONTH_TESTlMINJungtest
I didn't proceed to step two which would transliterate () to rq 
respectively.
 
Any thoughts appreciated.I'm hiding my face 'cause it is 
probably very sophomoric, but I don't see it.
 
TIA
 
---"They 
that can give up essential liberty    to obtain a little temporary 
safety    deserve neither liberty  nor 
safety."  

 
-- Benjamin Franklin 
-R    
Gary LutherRR  
RR   
SAFRR  RR UTABEGAS  2500 BroadwayRR 
RR    
Helena, MT 
59602 
[EMAIL PROTECTED]RR RR  ULE 
!!    RR  
RR   
Visit our website atRR   
RR  
http://www.safmt.org

BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Gary Luther
TEL;WORK:0631
ORG:;Computer Center
TEL;PREF;FAX:(406) 444-0684
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Luther;Gary
TITLE:Systems Administrator
END:VCARD




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Ask Bjoern Hansen

On Sat, 9 Jun 2001, Karen Cravens wrote:

> On 9 Jun 2001, at 0:22, Karen Cravens wrote:
>
> > Not only that, but there's certainly a potential for abuse of the
> > Reply-To misfeature, unless the software is bright enough to look
> > for the sort of thing that... well, let's find out, shall we?
>
> Well, that answers *that* question.

Actually, it points out one of the reasons why munging the Reply-To:
header is a really bad idea. It makes use of the Reply-To header for
people who need it impossibly. It also makes it impossibly to send a
post to the list asking to reply to sender only (and using the reply
to header to "enforce" it).

Please read http://www.unicom.com/pw/reply-to-harmful.html

One of the most important points is that it's much MUCH worse to
accidentially send a private mail to the whole list (thousands of
people will see it) than the other way around.

On lists with "low-tech" people reply-to munging might make sense;
but people clued enough to be using Perl are generally powerusers
enough to appreciate the better flexibility from not munging the
mails.

I realize that the beginners lists might be relatively more
"low-tech" than the almost 100 other public lists at perl.org; but
on all of those the consensus is to not mess with the headers and I
am not going to introduce confusion by operating them in technically
different ways.

> Hope anybody who replies to that knows how to use their email
> client effectively, or that the unsub is also verified...

It is.

> Further exercises in how evil *that* sort of thing could get are left to
> the reader... I am going *no* further down this road.

If people abuse the list we'll deal with the abuse.


 - ask ([EMAIL PROTECTED])

-- 
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();




Re: Matching '@' symbol in regexp

2001-06-11 Thread Jeff 'japhy' Pinyan

On Jun 11, sugatan achutan said:

>Can anybody suggest me how to match '@' symbol in a regexp to match e-mail 
>ids etc.

I suggest you don't try to write your own email-matching regex.  But just
because you asked, use \@.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Matching '@' symbol in regexp

2001-06-11 Thread sugatan achutan

Can anybody suggest me how to match '@' symbol in a regexp to match e-mail 
ids etc.
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




RE: Getting Perl to interact with passwd

2001-06-11 Thread Daniel Ames

At 01:14 PM 6/11/01 -0700, Paul wrote:
> > #!/usr/bin/perl
> >
> > open(handle, "| passwd joeuser");
> >
> > print handle "password\n";
> > print handle "password\n";
> > close(handle);
> >
> > Here's what it spits out:
> >
> > Changing password for user joeuser
> > New UNIX password: Retype new UNIX password:
> > New UNIX password:
> > New UNIX password:
> > passwd: Conversation error
> >
> > Then it dies. I know I'm doing this wrong. Any ideas?
> >
> > Thanks!
>
>WARNING: *STRICTLY* SPECULATION! =o)
>
>
>
>  maybe passwd is actually reading directly from the terminal, rather
>than just from stdin? You might end up having to fork a process and
>write to `tty`. Hope not, but it's possible.

Check the man page for your passwd, it might have an entry like this:

--stdin
   This option is used to indicate that passwd  should
   read  the  new  password from standard input, which
   can be a pipe.

There again, when I try it, I get a message that

$ passwd --stdin
Only root can do that

But maybe you *are* root...

Otherwise, you're going to need something like Expect.pm.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
-

Awesome! That worked! Thanks Peter! ^_^

Daniel



RE: readline fails on Sun machines?

2001-06-11 Thread McIntyre, Terry

Thanks to those who helped point me in the right direction.

I looked at the man page, 
http://www.perldoc.com/perl5.6/pod/func/readline.html,
and found two forms: 

readline(*STDIN) and readline;
the form which I used (readline STDIN) 
was not mentioned.

The second form uses an inline form or readline,
according to the docs; on the Solaris version,
it appears to be broken. I switched to readling(*STDIN),
and it works as expected.

Thanks!

 <> 



THe following code works on my AIX machines, 
but not on Solaris machines. All are running Perl 5.005_03.

What's the story?

Thanks!

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

print "account = " ;
$account = readline STDIN ;
chomp($account);
print "account: $account\n";





Re: Text::Abbrev module?

2001-06-11 Thread Jeff 'japhy' Pinyan

On Jun 11, RICHARD A. NAKROSHIS (Contractor) said:

>After poking around in the online documentation with AS 626, I came
>across reference to the Text::Abbrev module.  There's not a whole lot of
>documentation for it, and I frankly can't figure out what it supposed to
>do, or to come up with a good example program of what it does.
>
>Anyone find a use for this module?

Yes.  To abbreviate commands.

Here's a list of commands: START STOP QUEUE QUIT

Here's the abbreviation list:

qw(
  STASTART
  STAR   START
  START  START
  STOSTOP
  STOP   STOP
  QUEQUEUE
  QUEU   QUEUE
  QUEUE  QUEUE
  QUIQUIT
  QUIT   QUIT  
);

See the usefulness?  I can say "que", and the hash find that "que" maps to
"queue".

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: Text::Abbrev module?

2001-06-11 Thread Peter Scott

At 05:04 PM 6/11/01 -0400, RICHARD A. NAKROSHIS (Contractor) wrote:
>After poking around in the online documentation with AS 626, I came
>across reference to the Text::Abbrev module.  There's not a whole lot of
>documentation for it, and I frankly can't figure out what it supposed to
>do, or to come up with a good example program of what it does.
>
>Anyone find a use for this module?

It looks from the documentation as though its purpose is to create a hash 
whose keys are all the unambiguous truncations of a set of commands, and 
whose values are those commands.

You'd use this in a command parser that wanted to save the user as much 
typing as possible.

Example:

$ perl -MText::Abbrev -le '$hr = abbrev qw(quit quirk edit exit save); 
for(keys %$hr){print "$_: $hr->{$_}"}'
exi: exit
edit: edit
quirk: quirk
ed: edit
quir: quirk
s: save
quit: quit
ex: exit
edi: edit
sav: save
save: save
sa: save
exit: exit


Documentation follows:

SYNOPSIS

 use Text::Abbrev;
 abbrev $hashref, LIS


DESCRIPTION

Stores all unambiguous truncations of each element of LIST as keys in the
associative array referenced by $hashref. The values are the original list 
elements.


EXAMPLE

 $hashref = abbrev qw(list edit send abort gripe);

 %hash = abbrev qw(list edit send abort gripe);

 abbrev $hashref, qw(list edit send abort gripe);

 abbrev(*hash, qw(list edit send abort gripe));

  abbrev - create an abbreviation table from a list
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




RE: Win32::MsgBox syntax

2001-06-11 Thread Gross, Stephan

from http://www.le-berre.com/perlxtd.htm

MsgBox function

Display a message box.

Syntax

MsgBox($Message,$Type,$Caption); 

 $Message
   Text to be displayed in the dialog box.
 $Type
   Defines the type (Icon & Buttons) of the message box. To define
the value sum the desired
   Buttons option and Icon option.
 $Caption 
   Text to be displayed in window header.

  Buttons Option
  Icon Option
Returned
Value
   0
   Ok
16
Hand
 1
 Ok
   1
   Ok, Cancel
32
Question
 2
 Cancel
   2
   Abort, Retry, Ignore 
48
Exclamation
 3
 Abort
   3
   Yes, No, Cancel
64
Asterisk
 4
 Retry
   4
   Yes, No
 5
 Ignore
   5
   Retry, Cancel
 6
 Yes
 7
 No


Example

use Win32;

Win32::MsgBox("A first step for Perl in the Windows GUI world !");

Win32::MsgBox('Bug detected',48,'Alert ! Alert');

$result = Win32::MsgBox('Meet me at the coffee machine ?', 16+4, 'Tired ?');

(($result == 6) ? print "I am on my way !\n" : print "bye !\n");


___
Stephan Gross   Loral Skynet 908-470-2388 [EMAIL PROTECTED]
 



-Original Message-
From: RICHARD A. NAKROSHIS (Contractor)
[mailto:[EMAIL PROTECTED]]
Sent: Monday, June 11, 2001 5:04 PM
To: Perl Beginners
Subject: Win32::MsgBox syntax


While perusing the online documentation for AS 626, I tried out the
Win32::MsgBox module, but ran into a snag.  It says:

Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]])
 [EXT] Create a dialogbox containing MESSAGE. FLAGS specifies the
 required icon and buttons according to the following table: 

 0 = OK
 1 = OK and Cancel
 2 = Abort, Retry, and Ignore
 3 = Yes, No and Cancel
 4 = Yes and No
 5 = Retry and Cancel

 MB_ICONSTOP  "X" in a red circle
 MB_ICONQUESTION  question mark in a bubble
 MB_ICONEXCLAMATION   exclamation mark in a yellow triangle
 MB_ICONINFORMATION   "i" in a bubble

How do you specify FLAGS?  If I use "2", then I'll get the three
buttons.  Or if I use MB_ICONQUESTION, I'll get my question mark in a
bubble.  But what if you wanted BOTH?  How do you do that?



Text::Abbrev module?

2001-06-11 Thread RICHARD A. NAKROSHIS (Contractor)

After poking around in the online documentation with AS 626, I came
across reference to the Text::Abbrev module.  There's not a whole lot of
documentation for it, and I frankly can't figure out what it supposed to
do, or to come up with a good example program of what it does.

Anyone find a use for this module?
 S/MIME Cryptographic Signature


Win32::MsgBox syntax

2001-06-11 Thread RICHARD A. NAKROSHIS (Contractor)

While perusing the online documentation for AS 626, I tried out the
Win32::MsgBox module, but ran into a snag.  It says:

Win32::MsgBox(MESSAGE [, FLAGS [, TITLE]])
 [EXT] Create a dialogbox containing MESSAGE. FLAGS specifies the
 required icon and buttons according to the following table: 

 0 = OK
 1 = OK and Cancel
 2 = Abort, Retry, and Ignore
 3 = Yes, No and Cancel
 4 = Yes and No
 5 = Retry and Cancel

 MB_ICONSTOP  "X" in a red circle
 MB_ICONQUESTION  question mark in a bubble
 MB_ICONEXCLAMATION   exclamation mark in a yellow triangle
 MB_ICONINFORMATION   "i" in a bubble

How do you specify FLAGS?  If I use "2", then I'll get the three
buttons.  Or if I use MB_ICONQUESTION, I'll get my question mark in a
bubble.  But what if you wanted BOTH?  How do you do that?
 S/MIME Cryptographic Signature


Re: Getting Perl to interact with passwd

2001-06-11 Thread Peter Scott

At 01:14 PM 6/11/01 -0700, Paul wrote:
> > #!/usr/bin/perl
> >
> > open(handle, "| passwd joeuser");
> >
> > print handle "password\n";
> > print handle "password\n";
> > close(handle);
> >
> > Here's what it spits out:
> >
> > Changing password for user joeuser
> > New UNIX password: Retype new UNIX password:
> > New UNIX password:
> > New UNIX password:
> > passwd: Conversation error
> >
> > Then it dies. I know I'm doing this wrong. Any ideas?
> >
> > Thanks!
>
>WARNING: *STRICTLY* SPECULATION! =o)
>
>
>
>  maybe passwd is actually reading directly from the terminal, rather
>than just from stdin? You might end up having to fork a process and
>write to `tty`. Hope not, but it's possible.

Check the man page for your passwd, it might have an entry like this:

--stdin
   This option is used to indicate that passwd  should
   read  the  new  password from standard input, which
   can be a pipe.

There again, when I try it, I get a message that

$ passwd --stdin
Only root can do that

But maybe you *are* root...

Otherwise, you're going to need something like Expect.pm.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re[2]: Installing new Modules problem

2001-06-11 Thread Tim Musson

Hey Evgeny,

Monday, June 11, 2001, 4:11:54 PM, you wrote:

>> I download a
>> module from activestate but when I try to install it I get the following
>> error.
>> 
G:\Perl\bin>>>ppm install win32-gui.ppd

EGaG> Why not to visit the CPAN, take the tar.gz distribution, open it and run
EGaG> perl makefile.pl
EGaG> make
EGaG> make test
EGaG> make install ?

EGaG> That's so easy - I never understood things trying to automate those
EGaG> basic actions .. like some ppm tool

I have never had that work.  I don't the std M$ OS has a "make"
binary.  Isn't that used for compiling?  I did drop to a command
prompt and type make, and got an error that it was not a command.

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.51
Windows NT 5.0.2195 (Service Pack 1)
MS Windows -- From the people who brought you EDLIN! 





Re: Getting Perl to interact with passwd

2001-06-11 Thread Paul


--- Daniel Ames <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> This was brought up before, but the archives didn't really answer my
> question.
> 
> I'm trying to get my script to reset a password for me via the passwd
> command. Keep in mind, I'm very new, so if this is dumb, try not to
> laugh:
> 
> #!/usr/bin/perl
> 
> open(handle, "| passwd joeuser");
> 
> print handle "password\n";
> print handle "password\n";
> close(handle);
> 
> Here's what it spits out:
> 
> Changing password for user joeuser
> New UNIX password: Retype new UNIX password:
> New UNIX password:
> New UNIX password:
> passwd: Conversation error
> 
> Then it dies. I know I'm doing this wrong. Any ideas?
> 
> Thanks!

WARNING: *STRICTLY* SPECULATION! =o)



 maybe passwd is actually reading directly from the terminal, rather
than just from stdin? You might end up having to fork a process and
write to `tty`. Hope not, but it's possible.



List?


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Getting Perl to interact with passwd

2001-06-11 Thread Daniel Ames

Hi all,

This was brought up before, but the archives didn't really answer my
question.

I'm trying to get my script to reset a password for me via the passwd
command. Keep in mind, I'm very new, so if this is dumb, try not to laugh:

#!/usr/bin/perl

open(handle, "| passwd joeuser");

print handle "password\n";
print handle "password\n";
close(handle);

Here's what it spits out:

Changing password for user joeuser
New UNIX password: Retype new UNIX password:
New UNIX password:
New UNIX password:
passwd: Conversation error

Then it dies. I know I'm doing this wrong. Any ideas?

Thanks!




Re: readline fails on Sun machines?

2001-06-11 Thread Greg Martin

Quite possibly have the wrong location of perl.

I would type:

cd /
whereis perl

you can manually check /usr/bin and /usr/sbin

Once you find perl you can simply update your shibang line.

Let me know if that helps.

Greg Martin
Verio TSG
[EMAIL PROTECTED]

- Original Message - 
From: "McIntyre, Terry" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 11, 2001 12:42 PM
Subject: readline fails on Sun machines?


> THe following code works on my AIX machines, 
> but not on Solaris machines. All are running Perl 5.005_03.
> 
> What's the story?
> 
> Thanks!
> 
> #!/usr/local/bin/perl -w
> 
> print "account = " ;
> $account = readline STDIN ;
> chomp($account);
> print "account: $account\n";




RE: Installing new Modules problem

2001-06-11 Thread Peter Cornelius

> 
> > I download a
> > module from activestate but when I try to install it I get 
> the following
> > error.
> > 
> G:\Perl\bin>>ppm install win32-gui.ppd
> 
> Why not to visit the CPAN, take the tar.gz distribution, open 
> it and run
> perl makefile.pl
> make
> make test
> make install ?
> 
> That's so easy - I never understood things trying to automate those
> basic actions .. like some ppm tool

Unless maybe you're on a sindows box that doesn't have make and you haven't
(or the sys admin won't) install cygwin and anyway you need to compile
binaries and  it can't find a DLL so you just want to use activestates
pre-tested, pre-compiled, thingies since you paid for the friggin cd and...

Not that I'd ever use ppm or -MCPAN myself though.



Re[2]: Installing new Modules problem

2001-06-11 Thread Evgeny Goldin (aka Genie)


JIB> your options:
JIB> - get M$ visual c++ development kit (4 cd's and a hell of a lot of cash) to
JIB> get the c compiler
JIB> - use PPM which has pre-compiled binaries in their ppm format

Sure, you're right.

I just always have the Visual Studio installed ( it's only a part of
one CD MS Visual Studio ) so never had any problem with both "nmake" and
"cl" ( the MS compiler that sometimes used during the installation )





Re: Perl FAQ A Day

2001-06-11 Thread Evgeny Goldin (aka Genie)


Cool, although I didn't have to read FAQ ( prefer to find the answers
by myself ;) it's still a good idea to read it occasionally.

Are you planning to get the contents of http://www.perlfaq.com too ?





text formatting??

2001-06-11 Thread Brennan, Corey

I am new to perl/tk and I am wondering how to format a report in a text
widget. Can I use the formats that I had in my scripts before Tk, or do I
have to do something new?  I've looked for answers in "Learning Perl/Tk"
(O'Reilly) and on the net, but I can't seem to find anything.  

Thanks

---
Corey 





Re: Installing new Modules problem

2001-06-11 Thread Jos I. Boumans

first of all, on a windows machine, you dont have 'make'... best
substitution i found is 'nmake' (it gets referred to somewhere in the AS
manual).
second of all, quite a few modules require a c compiler to be installed...
now, again, windows does not ship with a c compiler by default, so here are
your options:
- get M$ visual c++ development kit (4 cd's and a hell of a lot of cash) to
get the c compiler
- use PPM which has pre-compiled binaries in their ppm format

my 2 bits say the latter is the easiest way, *if* it works of course...
sadly, ppm is not always up to date (they still ship POE 0.09, whilst we're
at 014 now, and dont even run imager or libwin32, but enough ranting).

as for your original problem:

try run -> cmnd -> ppm (running ppm directly has caused an error or 2 now
and then on my box)
search win32
install that-module-you-like (no need to add .ppd at the end)

hth,

Jos Boumans

> > I download a
> > module from activestate but when I try to install it I get the following
> > error.
> >
> G:\Perl\bin>>ppm install win32-gui.ppd
>
> Why not to visit the CPAN, take the tar.gz distribution, open it and run
> perl makefile.pl
> make
> make test
> make install ?
>
> That's so easy - I never understood things trying to automate those
> basic actions .. like some ppm tool
>
>
>




Re: stringify question

2001-06-11 Thread Evgeny Goldin (aka Genie)


Overloading in Perl isn't such an advanced topic, I think.
The classic "Object Oriented Perl" by Damian Conway explains this
thoroughly ( as well as zillions of other things ).

Let me know if you'll really need a detailed material - I can copy
the chapter for you.





Re: Installing new Modules problem

2001-06-11 Thread Evgeny Goldin (aka Genie)


> I download a
> module from activestate but when I try to install it I get the following
> error.
> 
G:\Perl\bin>>ppm install win32-gui.ppd

Why not to visit the CPAN, take the tar.gz distribution, open it and run
perl makefile.pl
make
make test
make install ?

That's so easy - I never understood things trying to automate those
basic actions .. like some ppm tool





Re: readline fails on Sun machines?

2001-06-11 Thread rob chanter

On Mon, Jun 11, 2001 at 01:42:47PM -0400, McIntyre, Terry wrote:
> THe following code works on my AIX machines, 
> but not on Solaris machines. All are running Perl 5.005_03.
> 
> What's the story?
> 
> Thanks!
> 
> #!/usr/local/bin/perl -w
> 
> print "account = " ;
> $account = readline STDIN ;
> chomp($account);
> print "account: $account\n";

Seems to me you want a typeglob rather than a bare filehandle for
readline (perldoc -f readline). So, 

$account = readline (*STDIN);

But just reading the filehandle using

$account = ;

or 

while (defined($account = ))

ought to be just fine.

I don't know of any situations where you'd prefer readline to <>, and
the latter is certainly more idiomatic.

cheers
rob c



Re: Perl FAQ A Day

2001-06-11 Thread Hasanuddin Tamir

On Mon, 11 Jun 2001, Jeff Yoak <[EMAIL PROTECTED]> wrote,

> Hi All,
>
>   It occurred to me that some of you might be interested in a little mailing
> list I maintain.  It is broadcast only and mails a randomly selected
> question / answer pair from the Perl FAQ each day to everyone on the
> list.  Nice way to pick up selected bits of new Perl knowledge.
>
> http://perl.faq-by-day.org/ .

I've subscribed for a few weeks, and I like it.  It's really great
to have such a resource.  Thanks a lot for the effort.  You do a
wonderful job.


regards
s::a::n
-- 
http://www.trabas.com




Re: readline fails on Sun machines?

2001-06-11 Thread Peter Scott

At 01:42 PM 6/11/01 -0400, McIntyre, Terry wrote:
>THe following code works on my AIX machines,
>but not on Solaris machines. All are running Perl 5.005_03.
>
>What's the story?
>
>Thanks!
>
>#!/usr/local/bin/perl -w
>
>print "account = " ;
>$account = readline STDIN ;
>chomp($account);
>print "account: $account\n";

Confirmed with 5.005_03 on Solaris 2.5.1.  I'd say you've got a bug there, 
because it does not happen with perl 5.6.1 on the same platform, nor does 
it happen with the <> operator (which is supposed to be the same).

Therefore, either upgrade, or use  instead of readline STDIN.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




readline fails on Sun machines?

2001-06-11 Thread McIntyre, Terry

THe following code works on my AIX machines, 
but not on Solaris machines. All are running Perl 5.005_03.

What's the story?

Thanks!

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

print "account = " ;
$account = readline STDIN ;
chomp($account);
print "account: $account\n";




Perl FAQ A Day

2001-06-11 Thread Jeff Yoak

Hi All,

It occurred to me that some of you might be interested in a little mailing 
list I maintain.  It is broadcast only and mails a randomly selected 
question / answer pair from the Perl FAQ each day to everyone on the 
list.  Nice way to pick up selected bits of new Perl knowledge.

http://perl.faq-by-day.org/ .

Cheers,
Jeff





Re: Passing FileHandle as Arguments Always Better?

2001-06-11 Thread Michael Fowler

On Mon, Jun 11, 2001 at 10:44:15AM -0400, Charles Lu wrote:
> &function_one (\*FILE);
[snip]
> &function_one("temp.txt");
[snip]
> Why is the first method almost always the preferred one?
Neither is overwhelmingly preferred over the other, that I've seen.  The
only benefit to passing a reference, as opposed to passing the name (which
is just a string), is you can easily differentiate between a string and a
filehandle.  This would be useful if, say, your function could accept a
handle, or a filename to open.


> More importantly, is it better to pass filehandle into a subroutin than
> pass in the name of the output file as arugument and construct(define) the
> filehandle WITHIN the subroutine?

You give no clarification on what you mean by "better".  It's easier on the
subroutine writer to get a handle; it's easier on the caller of the
subroutine to pass a filename.  You really can't make a mass generalization
that "passing a file(handle|name) is better"; it depends on the situation.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Re: Getting to the contents of a class..

2001-06-11 Thread Michael Fowler

On Mon, Jun 11, 2001 at 12:24:00PM +0200, Ela Jarecka wrote:
> Unfortunately, it doesn't seem to work... :-(
> 
> My constructor:
> 
> sub new {
>my $that = shift;
>my $class = ref($that) || $that;
>my $self = {
>   %myflds,
>};
>bless $self, $class;
>return $self;
> }

This method works just fine, provided %myflds is at least declared
beforehand (you are using strict, yes?):

test.pl
===
{
package Class;
my %myflds = qw(foo bar blah doo);

sub new {
my $that = shift;
my $class = ref($that) || $that;
my $self = { %myflds };
bless $self, $class;
return $self;
}
}

print Class->new(), "\n";


> ./test.pl
Class=HASH(0x4000d220)

Exactly as expected.


> > Ela Jarecka wrote:
> > 
> > >
> > > foreach my $item ( keys $reqrec->myflds ) {  #line 26
> > >  ...
> > > }

If, out of the constructor you showed us above, you're expecting the myflds
method to automatically be created, and return your hash, it's not going to
happen.  You have to define a myflds method, probably something along the
lines of:

sub myflds {
my $self = shift;
return $self;
}

>From this point on, you can now refer to %{ $reqrec->myflds }.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Re[2]: Perl and the MicroSoft NT/Win2000 GUI

2001-06-11 Thread Tim Musson

Thanks Jindra,

Monday, June 11, 2001, 10:06:13 AM, you wrote:

JV> Workaround is to use pl2bat script which encapsulates the perl
JV> source within a .bat file and handles everything as necessary.

JV> It is the way already suggested here, I just wanted to point out
JV> the PL2BAT script, which is part of ActivePerl (at least..).

I knew it came from somewhere, just forgot where.  I had been adding
the encapsulation manually... :-(

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.51
Windows NT 5.0.2195 (Service Pack 1)
#include ;





Re: stringify question

2001-06-11 Thread Peter Scott

At 06:18 PM 6/11/01 +0200, Ruth Albocher wrote:
>hi
>I have started learning perl recently as I need to maintain someone's
>old code.
>under 'use overload'  along with other 'normal' overloaded operators he
>has: qw("", stringify)
>i understand each word separately.. but.. where's it invoked and how?

It's really pretty simple.  "use" causes a compile-time loading of 
overload.pm, which reads in its arguments and associates subroutines with 
certain operations like addition, etc.  Then whenever a variable that has 
been told it belongs to the overloaded class is used in one of those 
operations, instead of the normal (say) addition being done, the designated 
subroutine is called instead.

In your case, the routine 'stringify' (which you'll find lower down in that 
same code) will be called whenever a variable is used in a string context, 
for instance, interpolated in double quotes: "Hello, $friend".

>is there a recommended site i can look things like this up (other than
>the man and the camel)?
>thanks,
>ruthie

While the syntax and semantics of overloading are fairly easy to 
understand, its use is usually considered advanced because it requires 
understanding O-O programming in Perl.  If you've only just started 
learning Perl you're trying to run before you can walk.  Bummer, but there 
it is.  My advice is to get a copy of the Llama (Randal needs a new SUV :-) 
and make sure you can understand it.  Otherwise you'll be on a shaky 
foundation.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re: Get character from a string

2001-06-11 Thread Paul


--- DeXteR <[EMAIL PROTECTED]> wrote:
> Like we have string $blah = "abcdef" and i wand for example character
> 5,  the "e", to mess around with further. How should i do that?

I'd probably say

  substr($blah,4,1)

( though you could do something wierd like
  
  (split '', $blah)[4]

if you wanted to, lol)

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



stringify question

2001-06-11 Thread Ruth Albocher

hi
I have started learning perl recently as I need to maintain someone's
old code.
under 'use overload'  along with other 'normal' overloaded operators he
has: qw("", stringify)
i understand each word separately.. but.. where's it invoked and how?
is there a recommended site i can look things like this up (other than
the man and the camel)?
thanks,
ruthie






Re: search.cpan.org is down is there a mirror?

2001-06-11 Thread Elaine -HFB- Ashton

Brett W. McCoy [[EMAIL PROTECTED]] quoth:
*>On Mon, 11 Jun 2001, Hill, Ronald wrote:
*>
*>> It seems that some stupid fool has messed with the search function of CPAN.
*>> Does anyone know if there is another site like this?
*>
*>You can access it via the command-line:
*>
*>perl -MCPAN -e 'shell'

Not entirely. That only searches the contents of the long module list not
the entire contents of CPAN itself.

e.



Re: Why do I have to type 'perl programname.pl' ???

2001-06-11 Thread Brett W. McCoy

On Mon, 11 Jun 2001, Bryan Gmyrek wrote:

> How do I set up my Linux system so that I don't need to type:
> $perl programname.pl
> but just
> $programname.pl
> to get the program to run??

You don't need to do anything to Linux, you need to find out where the
perl executable lives (type 'which perl' to get its full path), and then
you need to put this at the top of your Perl program:

#!/path/to/perl

and then make sure your Perl program is executable (chmod +x)

and if that fails, try typing ./programname.pl -- most Unix-based systems
don't have the current directory in the path, so you need to tell the
system you want to execute a program in the current directory by
prepending it with ./

-- Brett
   http://www.chapelperilous.net/btfwk/

Why was I born with such contemporaries?
-- Oscar Wilde




Re: Why do I have to type 'perl programname.pl' ???

2001-06-11 Thread Brent Michalski


as long as you have your:

#!/usr/bin/perl

line at the top... The only other thing you should need to do is to make
the program executable

chmod 755 programname.pl

the 755 is just an example, not necessarily right in all cases... you may
want to read up a bit on unix permissions to get a complete grasp of what's
going on...


good luck...

brent



   

"Bryan Gmyrek" 

  

eptor.com>   cc:   

 Subject: Why do I have to type 'perl  

06/11/01 10:39 AMprogramname.pl' ???   

   

   





How do I set up my Linux system so that I don't need to type:
$perl programname.pl
but just
$programname.pl
to get the program to run??
Thanks!







RE: Installing new Modules problem.

2001-06-11 Thread Michael Risser

You would actually be better off using ActiveState's Perl Package Manager
(PPM). If you are not familiar with it or CPAN, it is a command line tool
that simplifies the task of installing modules. 

To invoke ppm on the command line, simply issue the command 'ppm'.

At the ppm prompt, if you know the name of the module simply type 'install
moduleName' or type 'help' or '?' for a listing of the commands.

Hope this helps.


Michael D. Risser
Java Developer
Machine Vision Products, Inc.
760-438-1138 ext 107

-- Due to the current economic situation, the light at the end of the tunnel
will be turned off until further notice.


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 11, 2001 6:22 AM
> To: [EMAIL PROTECTED]
> Subject: Installing new Modules problem.
> 
> 
> 
> 
> Hi,
> 
> Can somebody please help me with installing new modules.  I download a
> module from activestate but when I try to install it I get 
> the following
> error.
> 
> G:\Perl\bin>ppm install win32-gui.ppd
> Failed to load PPM_DAT file
> Error installing package 'win32-gui.ppd': Could not locate a 
> PPM binary of
> 'win
> 2-gui.ppd' for this platform
> 
> Is there a problem with my installation?
> 
> 
> Thanks
> 
> 
> Jason
> 
> 
> 
> 
> 
> 



Why do I have to type 'perl programname.pl' ???

2001-06-11 Thread Bryan Gmyrek

How do I set up my Linux system so that I don't need to type:
$perl programname.pl
but just
$programname.pl
to get the program to run??
Thanks!



Re: how can system() execute all .exe file?

2001-06-11 Thread Mark Folse

Are you specifying the full file path? Are you using UNIX-style forward
slashes for directory delimiters?

Perl on NT will follow Windows conventions about finding and executing
files, and I never rely on the search path. Its always better to give a
full path to the executable.

Ex.

   #!/usr/bin/perl -w
   # Running an exe in DOSneyland with full path & 'Nixian slashes
   use Strict;
   use Diagnostics;
   system ("e:/ntreskit/ls.exe -l e:/eric");
--- zhongji tao <[EMAIL PROTECTED]> wrote:
> I am working on NT, IIS server. I tried system() to execute .exe
> file. But only those files that in c:\windows directory can be 
> executed. It does not work even I copy and paste some other .exe file
> in that directory. Anyone know how to solve the problem?
> 
> thanks.
> 


=

-
Notice: This e-mail is protected by the U.S. Constitution and the U.N. Declaration of 
Human Rights. Unauthorized interception by any public or private agency is an ugly 
sort of work to be in. Does your mother know you spend your days reading other 
people's mail? Would she be proud of you?

-
Please visit: http://clubs.yahoo.com/clubs/district41democrats

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: Get character from a string

2001-06-11 Thread Jeff 'japhy' Pinyan

On Jun 11, DeXteR said:

>I'm writing a program (what else should i do with perl) and now i got to 
>get a character from a string, things like that happen those days.
>Like we have string $blah = "abcdef" and i wand for example character 5, 
>the "e", to mess around with further. How should i do that?

You want to use substr(), probably:

  substr($string, 0, 1);  # get the first character
  substr($string, 1, 1);  # get the second character

  # etc.

  substr("japhy", 1, 1);  # 'a'
  substr("japhy", 2, 3);  # 'phy'

Read 'perldoc -f substr'.  You might also want index(), to find the
occurrence of a substring in another string.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Get character from a string

2001-06-11 Thread DeXteR

Hi all,
I'm writing a program (what else should i do with perl) and now i got to 
get a character from a string, things like that happen those days.
Like we have string $blah = "abcdef" and i wand for example character 5, 
the "e", to mess around with further. How should i do that?

gReeTz Arjen Heidinga


-- 
Windows leads to fear,
fear leads to hate,
hate leads to Linux
  




Re: search.cpan.org is down is there a mirror?

2001-06-11 Thread Brett W. McCoy

On Mon, 11 Jun 2001, Hill, Ronald wrote:

> It seems that some stupid fool has messed with the search function of CPAN.
> Does anyone know if there is another site like this?

You can access it via the command-line:

perl -MCPAN -e 'shell'

-- Brett
   http://www.chapelperilous.net/btfwk/

Did I SELL OUT yet??




Re: search.cpan.org is down is there a mirror?

2001-06-11 Thread Elaine -HFB- Ashton

Hill, Ronald [[EMAIL PROTECTED]] quoth:
*>Hi All,
*>
*>It seems that some stupid fool has messed with the search function of CPAN.
*>Does anyone know if there is another site like this?

Read the front page at http://search.cpan.org/.

And, the CPAN FAQ also lists several search engines besides search.cpan
including, http://kobesearch.cpan.org/. Of course, if they decide to go at
that engine too, there's always $400 for ASDN.

e.



Re: Passing FileHandle as Arguments Always Better?

2001-06-11 Thread Paul


--- Charles Lu <[EMAIL PROTECTED]> wrote:
> If you want to write a subroutine that write the output to a text
> file you can do this:
> 
> open FILE ">temp.txt" or die;
> &function_one (\*FILE);
> 
> sub function_one{
> my $fh = shift;
> print $fh "blah blah blah\n";
> }
> 
> OR you can do this:
> 
> &function_one("temp.txt");
> 
> sub function_one{
> my $file = shift;
> open FILE ">$file" or die;
> print FILE "blah blah blah\n";
> }
> 
> Why is the first method almost always the preferred one? 

It isn't *always*. It depends on the circumstances.
If the function is always working on the same file, it's probably a bad
idea to keep opening and closing it, especially since you aren't doing
an appending open, so you truncate every time, blasting the previous
contents. On the other hand, if the sub could encapsulate the whole
write, there are times when it would be better to have it handle all
the open/write/close process.

> More importantly, is it better to pass filehandle into a subroutin
> than pass in the name of  the output file as arugument and
> construct(define) the filehandle WITHIN the subroutine?

Same (see above).
Still, I'd use FileHandle when I could.
It makes cleaner code.

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



search.cpan.org is down is there a mirror?

2001-06-11 Thread Hill, Ronald

Hi All,

It seems that some stupid fool has messed with the search function of CPAN.
Does anyone know if there is another site like this?

Thanks

Ron



Re: Arrays of Hashes - Still stumped :(

2001-06-11 Thread Paul


--- Bryan Gmyrek <[EMAIL PROTECTED]> wrote:
> I've written a program where I need to use an array of hashes.  The
> basic code I am having problems with is:
> 
> sub read_from_file{
> #input: file name that holds lines of info in the form  key: value
> #action: add these to an array of hashes
> #return: array of hashes
>   my $file = $_[0];
>   my @inputs;
>   my $i=0;
>   open(IN,"$file");
>   while(){
>   chomp;
>   if(/seperator/){
>   $i++;
>   }
>   elsif(/category\:\s/){
>   $inputs[$i]{category}=$';
>   }
>   elsif(/artist\:\s/){

Did you mean to say "artist" here, or "product"?

>   $inputs[$i]{product}=$';
>   }
>   }
>   close(IN);
>   return @inputs;
> }
> 
> The input file is of the form:
> 
> seperator
> 
> category: example category
> 
> product: example artist
> 
> seperator
> 
> category: example category 2
> 
> product: example artist 2
> 
> and so on
> 
> So, in the end I think you should end up with an array of hashes in
> the form:
> 
> @inputs = (
> {
>category => "example category",
>product   => "example product",
> },
> {
>category=> "example category 2",
>product=> "example product 2",
> },
> );

Looks right

> My question is:
> 
> Why does it only 'sort of' work?  I call the routine later with:
> 
> my @other_array = &read_from_file("my_file");
> 
> and then I try to iterate over the new array of hashes and perform
> some functions, but only $other_array[1] holds any information
> ($other_array[0] should not, but $other_array[2] should)  

Might be the "artist"/"product" thing above

> I'm totally stumped here, any suggestions?  Is it how I am returning
> the array?  Should I return a reference to the array or something
like
> that?

Might be clearer, but what you have is probably visually cleaner.
The array you're passing back is just a list of scalar references to
the hash elements of the my() array you made in the function anyway, so
it would seem more consistent. Just remember to receive it accordingly;
the way you're doing it, the array you have (which doesn't require any
special dereferencing) catches the elements of the sub's version, and
everything below that level is actually the same literal memory space.
Passing the array back as a non-ref just passes back a list of element
refs which you catch as element refs so they need no special handling.

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Passing FileHandle as Arguments Always Better?

2001-06-11 Thread Charles Lu

If you want to write a subroutine that write the output to a text file you 
can do this:

open FILE ">temp.txt" or die;
&function_one (\*FILE);


sub function_one{
my $fh = shift;
print $fh "blah blah blah\n";
}

OR you can do this:

&function_one("temp.txt");

sub function_one{
my $file = shift;
open FILE ">$file" or die;
print FILE "blah blah blah\n";
}

Why is the first method almost always the preferred one?  More importantly, 
is it better to pass filehandle into a subroutin than pass in the name of 
the output file as arugument and construct(define) the filehandle WITHIN the 
subroutine?

thanks

_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Arrays of Hashes - Still stumped :(

2001-06-11 Thread Bryan Gmyrek



-Original Message-
From: Bryan Gmyrek 
Sent: Friday, June 08, 2001 5:15 PM
To: '[EMAIL PROTECTED]'
Subject: Arrays of Hashes


I've written a program where I need to use an array of hashes.  The
basic code I am having problems with is:

sub read_from_file{
#input: file name that holds lines of info in the form  key: value
#action: add these to an array of hashes
#return: array of hashes
my $file = $_[0];
my @inputs;
my $i=0;
open(IN,"$file");
while(){
chomp;
if(/seperator/){
$i++;
}
elsif(/category\:\s/){
$inputs[$i]{category}=$';
}
elsif(/artist\:\s/){
$inputs[$i]{product}=$';
}
}
close(IN);
return @inputs;
}

The input file is of the form:

seperator

category: example category

product: example artist

seperator

category: example category 2

product: example artist 2

and so on

So, in the end I think you should end up with an array of hashes in the
form:

@inputs = (
{
   category => "example category",
   product   => "example product",
},
{
   category=> "example category 2",
   product=> "example product 2",
},
);


My question is:

Why does it only 'sort of' work?  I call the routine later with:

my @other_array = &read_from_file("my_file");

and then I try to iterate over the new array of hashes and perform some
functions, but only $other_array[1] holds any information
($other_array[0] should not, but $other_array[2] should)  

I'm totally stumped here, any suggestions?  Is it how I am returning the
array?  Should I return a reference to the array or something like that?


Thanks!!!

Bryan



how can system() execute all .exe file?

2001-06-11 Thread zhongji tao

I am working on NT, IIS server. I tried system() to execute .exe file. But only those 
files that in c:\windows directory can be 
executed. It does not work even I copy and paste some other .exe file in that 
directory. Anyone know how to solve the problem?

thanks.



Re: Perl and the MicroSoft NT/Win2000 GUI

2001-06-11 Thread Jindra Vavruska

IIRC Win don't pass arguments to programs started by
"extension association" (even when Win Registry is set
up completely). I don't know why this is.

Workaround is to use pl2bat script which encapsulates
the perl source within a .bat file and handles
everything as necessary.

It is the way already suggested here, I just wanted to
point out the PL2BAT script, which is part of
ActivePerl (at least..).

CD \DIRECTORY\WITH\MY\SCRIPT
PL2BAT my-program.pl

Then you have my-program.pl and my-program.bat

Start it as any other .bat file

When you make changes to your perl program, be sure to
run PL2BAT again when you're finished. Otherwise you
might be quite surprised why your chnages didn't wotk
(unless you run it as 'perl my-program.pl').

Jindra Vavruska

CD to the directory 
--- Tim Musson <[EMAIL PROTECTED]> wrote:
> Hey ggage,
> 
> Friday, June 08, 2001, 12:17:50 PM, you wrote:
> 
> gmc> I would like to run a perl script and pass in
> an argument (ARGV[0]) by
> gmc> dragging a textfile icon on to the perl script
> icon.  This would be on an
> gmc> NT/Win2000 system using the icons in file
> manager, desktop, etc.  The
> gmc> argument passed in would be the path to the
> textfile.  This works with a
> gmc> DOS batfile, but I'm having trouble with a
> ".pl" file.
> 
> Did you try wrapping your perl code in M$ batch code
> and making it a
> .bat file instead of a .pl file?  for example:
> 
> == start of wrapping.bat ==
> 
> @rem & @echo off
> @perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
> @goto EndOfPerl
> @rem ';
> #!/perl -w
> 
> #Sec=$T[0],M=1,H=2, mDay=3,Mon=4,Yr=5,
> wDay=6,yDay=7, isdst=8
> @T=localtime(time); $T[4]++; $T[5]=1900+$T[5];
> $DTS="$T[5]/$T[4]/$T[3]-$T[2]:$T[1]"; 
> 
> print "\nIt's $DTS, you just ran $0, check it
> out.\n\n";
> 
> __END__
> :EndOfPerl
> @pause
> 
> == end of wrapping.bat ==
> 
> -- 
> [EMAIL PROTECTED]
> Using The Bat! eMail v1.51
> Windows NT 5.0.2195 (Service Pack 1)
> Always remember to pillage BEFORE you burn.
> 
> 
> 
> NetZero Platinum
> No Banner Ads and Unlimited Access
> Sign Up Today - Only $9.95 per month!
> http://www.netzero.net


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: Issuing rollback() for database handle being DESTROY'd without explicit disconnect().

2001-06-11 Thread Brent Michalski


I saw no $dbi->disconnect; statement in your code.  If you do not
disconnect, and the program ends, you will get the above message

brent



   
 
"FLAHERTY, 
 
JIM-CONT" To: "Beginners (E-mail)" 
<[EMAIL PROTECTED]> 
Subject: Issuing rollback() for 
database  
  handle being DESTROY'd without ex 
plicit  
06/11/01 09:00 AM disconnect().
 
   
 
   
 




Why am I getting this  ??

Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().



the code


#!/usr/bin/perl

#  Script to maintain  KBHD Stats  #
#   Version  1.0   #
#   date : 6 Jun 01#

# require "subparseform.lib";
# &Parse_Form;
###
#  Start Writing the Page #
###
open(LOG,">/var/www/html/kbhd/stats.php");

print LOG "\n";
print LOG " Stats for Techs \n";
print LOG "\n";

print LOG "\n";

print LOG "\n";

print LOG "  Stats Page\n";
print LOG " \n";
print LOG "\n";

# 

##
# get stats
##

use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "user";
my $password = "password";

$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select count(*)from jobs where status =
'closed'");
$sth1 -> execute or die " unable to execute query ";

my $array_ref = $sth1 -> fetchall_arrayref();
  foreach $row(@$array_ref){

my($closedJ) = @$row;

}


print LOG "  ";
print LOG " Overall Stats";
print LOG "\n";
print LOG "  \n";
print LOG "  \n";
print LOG "\n";

print LOG "";
print LOG "Number Of ";

print LOG "Closed Jobs :  ";
print LOG "\n";
print LOG "$closedJ \n";

print LOG "Total Time\n";
print LOG "Average time per Call\n";
print LOG " \n";
print LOG "\n";

print LOG "\n";
print LOG "Grades for techs \n";

###
#Query techs names#
###
use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "";
my $password = "";

$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select username from tech1");
$sth1 -> execute or die " unable to execute query ";
my $array_ref = $sth1 -> fetchall_arrayref();
  foreach $row(@$array_ref){

   my($tech) =@$row  ;

  print LOG " $tech \n";

print LOG " \n";

 print LOG "\n";

print LOG "    Total Jobs
Completed\n";
print LOG "  \n ";
print LOG "   
53<

/b>\n";
print LOG "\n";
print LOG " \n";
print LOG "   Total Hours Spent  
<

/td>\n";
print LOG " \n";
print LOG "    56\n";
print LOG "\n";
print LOG "\n";
print LOG " \n";
print LOG "  \n";
print LOG "   \n";
print LOG "\n";
print LOG "\n";
print LOG "   Average
time to";


print LOG "Complete \n";
print LOG "   \n";
print LOG "    67\n";
print LOG "\n";

print LOG "  \n";

print LOG "\n";









}

close(LOG);








Re: File Handles as arguments...

2001-06-11 Thread Paul


--- Mike Breeze <[EMAIL PROTECTED]> wrote:
> -- Original Message --
> From: "Evgeny Goldin (aka Genie)" <[EMAIL PROTECTED]>
> >
> >> CODE 3:
> >> printit(*Some_Handle);
> >
> >> CODE 4:
> >> printit(\*Some_Handle);
> >
> >
> >If you're choosing between those two - CODE 4 looks better as it
> passes
> >the reference to typeglob instead of the typeglob itself and passing
> >references is always the better way to do things.
> >CODE 4 is a usual way for passing "filehandles" and I personally use
> it ..
> >
> >Going further we may discover a proper modules for handling such
> >things - Joseph Hall in his "Effective Perl Programming" offers to
> use
> >IO::File.

Personally, I recommend using FileHandle objects, which are anonymous
references you can save in any scalar and then pass about and use just
like any other filehandle. They even work neatly in recursive
functions, because you can assign them to my()'d vars. All you need is:

  use FileHandle;
  my $fh = new FileHandle $file; # or ">$file", or whatever

  some_func($fh);

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: [META] Rants (was:Re: space)

2001-06-11 Thread rob chanter

On Mon, Jun 11, 2001 at 11:57:36AM +0200, Aaron Craig wrote:
> At 01:22 11.06.2001 -0800, you wrote:
> 
> >If the reply issue is really difficult for new users to deal with, why is it
> >everyone who is complaining about it has already found a workaround?
> 
> My whole issue with the thing is that we've been forced to find a 
> workaround.  If one of the goals of good programming is to do away with 
> unnecessary bullox, then shouldn't this list, as an example to beginning 
> programmers, be configured *better* then the other lists out there?  If 
> none of us that know how to program decently would ever write code that 
> required users to find workarounds, why does the list get sent in such a 
> way that in order to reply to the list we have to come up with a workaround?
> 

Oh dear. What *have* I stirred up here? It's not *that* important.
Personally, I prefer to do list replies manually, because ultimately it
gives me more control and my mail client of choice can do it. If the
list managers decide to munge Reply-To headers, I won't care a lot. The
purist in me says that everything inside the envelope should be mine to
control, but mailing lists are kind of a different beast. FWIW, it's 
about a 50-50 split on the lists I subscribe to. 

But OTOH, I don't think it's really "elitist" to make the judgement 
that driving a mail UA is lower on the computer-using evolutionary scale 
than programming, or even than finding, subscribing to and understanding 
the mechanics of mailing lists. The general tone here is pretty friendly
when it comes to the actual Perl questions, and we've had a few ... er
... friendly tips being exchanged about how people can use their mail
software better.

Ah well, back to Perl.

rgds
rob c



Issuing rollback() for database handle being DESTROY'd without explicit disconnect().

2001-06-11 Thread FLAHERTY, JIM-CONT

Why am I getting this  ??

Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().

 
 
the code 
 

#!/usr/bin/perl

#  Script to maintain  KBHD Stats  #
#   Version  1.0   #
#   date : 6 Jun 01#

# require "subparseform.lib";
# &Parse_Form;
###
#  Start Writing the Page #
###
open(LOG,">/var/www/html/kbhd/stats.php");
 
print LOG "\n";
print LOG " Stats for Techs \n";
print LOG "\n";
 
print LOG "\n";
 
print LOG "\n";
 
print LOG "  Stats Page\n";
print LOG " \n";
print LOG "\n";
 
# 
 
##
# get stats 
##
 
use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "user";
my $password = "password";
 
$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select count(*)from jobs where status =
'closed'");
$sth1 -> execute or die " unable to execute query ";
 
my $array_ref = $sth1 -> fetchall_arrayref();
  foreach $row(@$array_ref){
 
my($closedJ) = @$row;
 
}
 

print LOG "  ";
print LOG " Overall Stats";
print LOG "\n";
print LOG "  \n";
print LOG "  \n";
print LOG "\n";
 
print LOG "";
print LOG "Number Of ";
 
print LOG "Closed Jobs :  "; 
print LOG "\n";
print LOG "$closedJ \n";
 
print LOG "Total Time\n";
print LOG "Average time per Call\n";
print LOG " \n";
print LOG "\n";
 
print LOG "\n";
print LOG "Grades for techs \n";
 
###
#Query techs names#
###
use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "";
my $password = "";
 
$dbh =DBI ->connect($data_source, $username, $password); 
my $sth1 = $dbh -> prepare("select username from tech1");
$sth1 -> execute or die " unable to execute query ";
my $array_ref = $sth1 -> fetchall_arrayref();
  foreach $row(@$array_ref){
 
   my($tech) =@$row  ;

  print LOG " $tech \n";
 
print LOG " \n";
 
 print LOG "\n";
 
print LOG "    Total Jobs
Completed\n";
print LOG "  \n ";
print LOG "   
53<
 
/b>\n";
print LOG "\n";
print LOG " \n";
print LOG "   Total Hours Spent  
<
 
/td>\n";
print LOG " \n";
print LOG "    56\n";
print LOG "\n";
print LOG "\n";
print LOG " \n";
print LOG "  \n";
print LOG "   \n";
print LOG "\n";
print LOG "\n";
print LOG "   Average
time to";
 

print LOG "Complete \n";
print LOG "   \n";
print LOG "    67\n";
print LOG "\n";
 
print LOG "  \n";
 
print LOG "\n";
 
 
 
 
 
 
 
 

}
 
close(LOG);




Re: rant on space

2001-06-11 Thread Kevin Meltzer

And on this 'formal request' please consider this discussion closed (unless
reopenned for more opinions). We know, and have gotten a few emails, about
peoples opinions on filters, headers, etc...

Youre feelings are all known, and any changes that seem appropriate with the
headers of the list email will be made, and announced.

Cheers,
Kevin

On Mon, Jun 11, 2001 at 06:40:36AM -0700, Mark Folse ([EMAIL PROTECTED]) 
spew-ed forth:
> Consider this a formal request that the list messages should default to
> reply to the list, and either copy the originator (or no one). This
> would best accomodate the way people communicate on lists, in my view.
> 
> I didn't originate this thread, but I feel compelled to comment in that
> I typically use a list client that is not configurable to accomodate
> this. I also find that this behhavoir is different that that of most of
> the lists I have followed via this account.
> 
> TIA

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"I'm hopeful. I know there is a lot of ambition in Washington, obviously. But I
hope the ambitious realize they are more likely to succeed with success as
opposed to failure."
-- G.W. Bush, Interview with the AP 01/18/2001



Re: rant on space

2001-06-11 Thread Mark Folse

Consider this a formal request that the list messages should default to
reply to the list, and either copy the originator (or no one). This
would best accomodate the way people communicate on lists, in my view.

I didn't originate this thread, but I feel compelled to comment in that
I typically use a list client that is not configurable to accomodate
this. I also find that this behhavoir is different that that of most of
the lists I have followed via this account.

TIA

=

-
Notice: This e-mail is protected by the U.S. Constitution and the U.N. Declaration of 
Human Rights. Unauthorized interception by any public or private agency is an ugly 
sort of work to be in. Does your mother know you spend your days reading other 
people's mail? Would she be proud of you?

-
Please visit: http://clubs.yahoo.com/clubs/district41democrats

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Installing new Modules problem.

2001-06-11 Thread Jason . Smith



Hi,

Can somebody please help me with installing new modules.  I download a
module from activestate but when I try to install it I get the following
error.

G:\Perl\bin>ppm install win32-gui.ppd
Failed to load PPM_DAT file
Error installing package 'win32-gui.ppd': Could not locate a PPM binary of
'win
2-gui.ppd' for this platform

Is there a problem with my installation?


Thanks


Jason









Re: File Handles as arguments...

2001-06-11 Thread Mike Breeze

-- Original Message --
From: "Evgeny Goldin (aka Genie)" <[EMAIL PROTECTED]>
>
>> CODE 3:
>> printit(*Some_Handle);
>
>> CODE 4:
>> printit(\*Some_Handle);
>
>
>If you're choosing between those two - CODE 4 looks better as it passes
>the reference to typeglob instead of the typeglob itself and passing
>references is always the better way to do things.
>CODE 4 is a usual way for passing "filehandles" and I personally use it ..
>
>Going further we may discover a proper modules for handling such
>things - Joseph Hall in his "Effective Perl Programming" offers to use
>IO::File.

Thanks Genie.

Mike



Re: File Handles as arguments...

2001-06-11 Thread Evgeny Goldin (aka Genie)


> CODE 3:
> printit(*Some_Handle);

> CODE 4:
> printit(\*Some_Handle);


If you're choosing between those two - CODE 4 looks better as it passes
the reference to typeglob instead of the typeglob itself and passing
references is always the better way to do things.
CODE 4 is a usual way for passing "filehandles" and I personally use it ..

Going further we may discover a proper modules for handling such
things - Joseph Hall in his "Effective Perl Programming" offers to use
IO::File.





Re: AW: Getting to the contents of a class..

2001-06-11 Thread Jos Boumans

first, i'll explain a little bit about references:

they *refer* to a (anonymous) data structure, and the need thing about
them is that they behave like scalars when passed around and such.

another thing you have to understand that if you want a hash of hashes,
that is not possible:
perl keeps it's data as flat data structures and hence wouldnt be able
to tell where one list (array/hash) would end and the other would start
this is the same problem you have when passing 2 arrays to a subroutine;
they will become one array.

what you would want is the following:

either just use $self as the container for whatever is in %myflds;
my $self = \%myflds

or set the contents of $self explicitely:

my $self = {
foo => 'bar',
bar => 'quux',
};

i refer you to 2 tutorials i wrote on that subject, which can be found
here:
http://www.sharemation.com/~perl/tut

you will want to read the first tutorial (data structures) and the third
one (references)
i think they will clear up most of the confusion.

hope this helps,

Jos Boumans

Ela Jarecka wrote:

> Unfortunately, it doesn't seem to work... :-(
>
> My constructor:
>
> sub new {
>my $that = shift;
>my $class = ref($that) || $that;
>my $self = {
>   %myflds,
>};
>bless $self, $class;
>return $self;
> }
>
> Please help,
> Ela
>
> > -Ursprüngliche Nachricht-
> > Von: Jos Boumans [mailto:[EMAIL PROTECTED]]
> > Gesendet: Montag, 11. Juni 2001 12:04
> > An: Ela Jarecka
> > Cc: Beginners list (E-Mail)
> > Betreff: Re: Getting to the contents of a class..
> >
> >
> > What myflds probably is (if used a 'normal' contructor
> > returning a hashref), is
> > a hashref
> >
> > if you want to acces it, you'll need something like:
> >
> > foreach my $item ( keys %{$reqrec->myflds} ) { ..}
> >
> > now, if that is not working, you might want to concider
> > posting the constructor
> > of your module to the list, it would make it easier for us to
> > indicate the
> > problem
> >
> > hth,
> >
> > Jos Boumans
> >
> > Ela Jarecka wrote:
> >
> > >
> > > foreach my $item ( keys $reqrec->myflds ) {  #line 26
> > >  ...
> > > }
> > >
> > > I get an error:
> > > 'Can't locate object method "myflds" via package "DataReq"
> > at makeReq line
> > > 26'
> > >
> > > How should I indicate that 'myflds' is a hash? I've tried
> > putting an '%' in
> > > front of 'myflds' but it returned
> > > an error as well.
> >




AW: Getting to the contents of a class..

2001-06-11 Thread Ela Jarecka

Unfortunately, it doesn't seem to work... :-(

My constructor:

sub new {
   my $that = shift;
   my $class = ref($that) || $that;
   my $self = {
  %myflds,
   };
   bless $self, $class;
   return $self;
}

Please help,
Ela

> -Ursprüngliche Nachricht-
> Von: Jos Boumans [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 11. Juni 2001 12:04
> An: Ela Jarecka
> Cc: Beginners list (E-Mail)
> Betreff: Re: Getting to the contents of a class..
> 
> 
> What myflds probably is (if used a 'normal' contructor 
> returning a hashref), is
> a hashref
> 
> if you want to acces it, you'll need something like:
> 
> foreach my $item ( keys %{$reqrec->myflds} ) { ..}
> 
> now, if that is not working, you might want to concider 
> posting the constructor
> of your module to the list, it would make it easier for us to 
> indicate the
> problem
> 
> hth,
> 
> Jos Boumans
> 
> Ela Jarecka wrote:
> 
> >
> > foreach my $item ( keys $reqrec->myflds ) {  #line 26
> >  ...
> > }
> >
> > I get an error:
> > 'Can't locate object method "myflds" via package "DataReq" 
> at makeReq line
> > 26'
> >
> > How should I indicate that 'myflds' is a hash? I've tried 
> putting an '%' in
> > front of 'myflds' but it returned
> > an error as well.
> 



Re: [META] Rants (was:Re: space)

2001-06-11 Thread Paul Johnson

On Mon, Jun 11, 2001 at 10:33:03AM +0200, Aaron Craig wrote:

> -- I just got done 
> downloading 200 some odd messages,

I'll agree that some of the messages on this list are very odd indeed :-)

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



Re: Getting to the contents of a class..

2001-06-11 Thread Jos Boumans

What myflds probably is (if used a 'normal' contructor returning a hashref), is
a hashref

if you want to acces it, you'll need something like:

foreach my $item ( keys %{$reqrec->myflds} ) { ..}

now, if that is not working, you might want to concider posting the constructor
of your module to the list, it would make it easier for us to indicate the
problem

hth,

Jos Boumans

Ela Jarecka wrote:

>
> foreach my $item ( keys $reqrec->myflds ) {  #line 26
>  ...
> }
>
> I get an error:
> 'Can't locate object method "myflds" via package "DataReq" at makeReq line
> 26'
>
> How should I indicate that 'myflds' is a hash? I've tried putting an '%' in
> front of 'myflds' but it returned
> an error as well.




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Aaron Craig

At 01:22 11.06.2001 -0800, you wrote:

>If the reply issue is really difficult for new users to deal with, why is it
>everyone who is complaining about it has already found a workaround?

My whole issue with the thing is that we've been forced to find a 
workaround.  If one of the goals of good programming is to do away with 
unnecessary bullox, then shouldn't this list, as an example to beginning 
programmers, be configured *better* then the other lists out there?  If 
none of us that know how to program decently would ever write code that 
required users to find workarounds, why does the list get sent in such a 
way that in order to reply to the list we have to come up with a workaround?

I agree that this thread probably isn't the most pressing issue facing the 
Perl community today, but it does bring up one of my pet peeves about the 
programming world, which is where the elitist issue came up.  I agree with 
you that there should be levels of distinction between programmers -- 
someone who doesn't have the knowledge to understand what's going on in a 
conversation should keep their mouth shut and listen, and not clutter up 
the conversation with basic questions that would be better asked 
elsewhere.  This isn't elitism, this is organization.

Perhaps elitism isn't even the correct word.  It just seems to me that we, 
being techy people, often get into a techy frame of mind, which lead us to 
setting things up in a way that causes us to push more buttons, just so 
that we do it differently from the rest of the world.  I'm sure that's not 
the situation with this list, but the reply-to conversation brought the 
tech issue to mind, and perhaps that's why I joined in the fray in the 
first place.

I didn't mean to write a book :)

Aaron Craig
Programming
iSoftitler.com




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Michael Fowler

On Mon, Jun 11, 2001 at 10:36:31AM +0200, Aaron Craig wrote:
> >At 23:24 08.06.2001 -0500, you wrote:
> >
> >If you don't know how to manage your mail or aren't willing to learn then
> >you probably don't have any business joining a mailing list and then
> >whining about it on the list.
> 
> 
> 
> Doesn't this run dangerously close to an elitist attitude that we of the 
> Perl community are trying to rid ourselves of?

Just to be clear, we of the Perl community are not trying to rid ourselves
of elitist attitudes.  The reason the perl-beginners list was started (as
far as I understand it) is to provide an area where the elitist attitudes
are put aside in order to assist people that are new.  perl-beginners is
just one list, containing just a few users in the massive Perl community; it
does not speak for the entire community.

Furthermore, there is a purpose to elitist attitudes; they enforce a minimum
level for a user to attain in order to communicate in a given forum.  This
is desirable in certain cases; p5p shouldn't be full of people asking for
basic Perl help.  Where elitist attitudes become offensive is when they turn
into flames, but that doesn't mean elitist attitudes should be done away
with entirely.

If the reply issue is really difficult for new users to deal with, why is it
everyone who is complaining about it has already found a workaround?  I
understand that I wouldn't have seen such replies, but someone by now should
have, or at the very least the list maintainers should've received a
complaint.  Is there anyone on the list who -can't- handle replying to the
list correctly, or is this just a straw man put up by people who would just
rather not deal with it?

I'm not trying to be insulting or anything, but is this truly an issue, or
just an annoyance?


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Getting to the contents of a class..

2001-06-11 Thread Ela Jarecka

Hi,
I've just defined a small class, DataReq. It contains a hash called 'myflds'
and a couple of functions for writing/retrieving data.

Now, in my main program, I've included the following code:

my $reqrec = new DataReq;

if ( ($reqrec->fillrec(@mylist)) == undef ) {
   die "fillrec failed!\n";
}

foreach my $item ( keys $reqrec->myflds ) {  #line 26
 ...
}

I get an error:
'Can't locate object method "myflds" via package "DataReq" at makeReq line
26'

How should I indicate that 'myflds' is a hash? I've tried putting an '%' in
front of 'myflds' but it returned 
an error as well.

Could anyone help?
Thanx in advance,
Ela



How to remove "@INC entries at compile time "

2001-06-11 Thread SeenuNattu

Hi All,
 It seems that by default perl looks for the locations of the perl modules 
given by the @INC directory. Now I want to build a version of perl ( with all 
extensions statically linked ) and which does not have any INC directory  
dependencires in it during compile time. 

 It I succeed in this process, I will have a single executable which does not 
need any specific location to find its modules ( like strict.pm or POSIX.pm ) 
and all its modulex will be statically linked to its executable.

 Can some one suggest me the way to do it ?

This is what I did on my Linux machine.

a) Downloaded the 5.6.1 source and unpacked the contens on a 
/home/seenu/perl-5.6.1 location.
b) ran the following script, ./configure ( here i chose all the default 
options, except to disable dynamic loading  ) 
c)  and followed by " make miniperl ". The build process completed 
successfully.

Now when I tried to execute a simple perl program which looks something like

#!/home/seenu/perl-5.6.1/miniperl
use strict ;

I got the following error from the command line :-
Can't locate strict.pm in @INC (@INC contains: 
/home/seenu/perl/lib/5.6.1/i686-linux /home/seenu/perl/lib/5.6.1 
/home/seenu/perl/lib/site_perl/5.6.1/i686-linux 
/home/seenu/perl/lib/site_perl/5.6.1 /home/seenu/perl/lib/site_perl .) at 
./test-.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.

Thanks in advance,
Seenu.
 




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Aaron Craig


>At 23:24 08.06.2001 -0500, you wrote:
>
>If you don't know how to manage your mail or aren't willing to learn then
>you probably don't have any business joining a mailing list and then
>whining about it on the list.



Doesn't this run dangerously close to an elitist attitude that we of the 
Perl community are trying to rid ourselves of?  I don't think the fact that 
many email clients have advanced filtering features means that a list 
should force you to discover what all of them are.  As has been said here 
by others, of all the lists I'm subscribed to, this is the only one 
configured in this way.
Aaron Craig
Programming
iSoftitler.com




Re: NEW LINE

2001-06-11 Thread Me

> A bit safer way to do this would be the following:

Jos is right in principle, but wrong in one detail.
Setting $/ to undef isn't the same as setting it to ''.
Setting it to undef makes the <> input operator
slurp the whole file.




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Aaron Craig

At 19:48 08.06.2001 -0700, Peter Scott wrote:

>>Saves on bandwidth, and doesn't
>>fill up a users mailbox with duplicate messages.  I personaly hate
>>checking my email to find it filled with messages that should have
>>been sent into the folders for that mailing list.
>
>Mine all get sent to the same folder, because I have a filter that says 
>they go there if To: contains [EMAIL PROTECTED] OR Cc: contains 
>[EMAIL PROTECTED]


But I still have to download two messages for every one -- I just got done 
downloading 200 some odd messages, of which a portion are unnecessary 
duplicates.

Aaron Craig
Programming
iSoftitler.com




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Aaron Craig

At 19:18 08.06.2001 -0700, Peter Scott wrote:

>I use Eudora also, and it works just fine.  To reply to the person who 
>sent the message, I hit Reply.  To reply to that person and the list, I 
>hit Reply To All.  To reply to just the list and not the sender would be 
>rude, but if I wanted to do it, I'd do Reply To All and delete their name 
>from the To: line.


Except I always get two copies of every message in this way -- one from the 
sender and one from the list :)

Aaron Craig
Programming
iSoftitler.com




Re: [META] Rants (was:Re: space)

2001-06-11 Thread Aaron Craig

At 19:18 08.06.2001 -0700, Peter Scott wrote:

>I use Eudora also, and it works just fine.  To reply to the person who 
>sent the message, I hit Reply.  To reply to that person and the list, I 
>hit Reply To All.  To reply to just the list and not the sender would be 
>rude, but if I wanted to do it, I'd do Reply To All and delete their name 
>from the To: line.

Good move -- I hadn't tried reply to all.
Aaron Craig
Programming
iSoftitler.com




Re: NEW LINE

2001-06-11 Thread Jos Boumans

That code is a bit tricky, since you're now changing the behaviour of $/
throughout the entire file

A bit safer way to do this would be the following:

open I, "yourfile.txt";#open a textfile for reading
{ local $/;#undef $/, which is essentially the
same as $/ = ''; we use the 'local' to make sure it's value get's
restored upon exiting the block
   my $in = ;   #put all of the file in $in;
   do_stuff_with($in)#do some stuff with the text in $in
}# exit loop, restore $/; NOTE: this
also resets the value of $in... if you dont want that, set the 'my $in'
above the block, rather then in it

hth,

Jos Boumans

Me wrote:

> > Can anyone send me any solution
> > to read the paragraph from a text file?
>
> To read paragraphs (delimited by one or more blank
> lines (really blank, no spaces or tabs)), change the
> record separator from its default (newline) to the
> null string ('').
>
> $/ = '';
>
> while (<>) {
> print;
> }




NEW LINE

2001-06-11 Thread arvind Bir

CAn any one suggest a pattern for checking the newline character at the end
of line?

Problem:Actually the requirement is that I want to read no. of lines by
comparing the newline character which will tell that this is the end of
paragraph? Can anyone send me the code for this or any alternative solution
to read the paragraph from a text file?


Thanks in advance.

Arvind Bir


- Original Message -
From: "bdale16" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 10, 2001 1:13 PM
Subject: numb array getting value for letter array


? How do i affect this type of result to my existing code
if a grade of a 90-100 = an A
and a grade of  80-90   = a   B
and a grade of  70-80 = a C
and a grade of 60-70 = a D
and a grade of 0-60 = a F

I understand i am creating 2 more arrays but i need to get a range and
assign it to a Letter

 any help would be appreciated thanks
sincerely robert bush
[EMAIL PROTECTED]


print "Enter Name Of Student:";
$name = ;
chomp ($name);

$grade1=gradeinput("First");
$grade2=gradeinput("Second");
$grade3=gradeinput("Third");

$avg= ($grade1 + $grade2 + $grade3) /3;

# new code @letter = ("A..D" ,"F");
# new code @chart = (90, 80, 70, 60, 0);

# new code for ($I=0, $I<5, $I++)
#new code {
#new code if ($avg >= $chart[I])
# new code {
 #get $grade
#new code }
#new code }

print "$name received $avg \n ";

sub gradeinput
{ #beg
 my ($prompt, $grade);
 $prompt = $_[0];
{ #first loop
print "Enter $prompt grade from 0 to 100  ";
$grade = ;
chomp ($grade);
if ($grade <0 || $grade >100)

  { #sec loop beg
  print "You Must Enter a Number is Beteween Zero and Less Than 100\n";
  redo
  } #end of first loop
}  #end of second loop
return ($grade);

}#end









  1   2   >