Re: Mail Send problems 1.6 CVS

2001-07-05 Thread David Monarres

I have had the same two problems with 1.16 and cvs (same day). The problem
with sending mail seemed to be solved when I ran my MTA as a deamon, not
through inetd. (do not know if that will help) The address thing I really
haven't found a work around for.
David Monarres <[EMAIL PROTECTED]>
On Thu, 05 Jul 2001 19:13:16 Stephen Binks wrote:
> I've been having problems sendinmail with
> attachments larger than ~10k.
> 
> I built today's CVS (07/04/01) in the hope that it
> would fix the problem but it's still the same.
> 
> Debug output:
> 
> sending with charset: ISO-8859-1
> Message: balsa_sendmsg_destroy(): Start.
> balsa_sendmsg_destroy: Freeing bsm
> Message: balsa_sendmsg_destroy(): Stop.
> Send_Message: 139077320, 1, Connected to MTA
> Send_Message: 139077320, 1, From: 250
> <[EMAIL PROTECTED]>
> >From [EMAIL PROTECTED]: 250
> <[EMAIL PROTECTED]>... Sender ok
> 
> Send_Message: 139077320, 1, To: 250
> <[EMAIL PROTECTED]>
> To [EMAIL PROTECTED]: 250
> <[EMAIL PROTECTED]>... Recipient ok
> 
> Send_Message: 139077320, 1, To: 250
> <[EMAIL PROTECTED]>
> To [EMAIL PROTECTED]: 250
> <[EMAIL PROTECTED]>... Recipient ok
> 
> Send_Message: 139077320, 1, Disconnected
> Send_Message: 139260360, 4, 
> WARNING: Message delivery problem, placing it into
> your outbox.
> System will attempt to redeliver the message until
> you delete it.
> 
> 
> Another problem I've noticed is that the
> Identities Edit dialog will not accept changes
> unless the Identity name has also been changed...
> giving "Error: An Identity with that name already
> exists"
> -- 
> 
> 
> ~~
> Stephen W. Binks
> [EMAIL PROTECTED]
> www.icenet.com.au/~steveb
> ICQ 62863476
> ~~
> 
> ___
> balsa-list mailing list
> [EMAIL PROTECTED]
> http://mail.gnome.org/mailman/listinfo/balsa-list
> 



RE: Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Notabene

Thanks all!

Jeff: Your answer was the one I needed. (duh! I was so tangled in my own
shorts that I forgot to mention the web page connection -- good catch. )

Steve: While I had tried your solution I wasn't seeing it since my test rig
was printing to a web page -- *NOT* doing straight Perl print output to a
screen. I even tried assigning the ASCII code via chr() to a variable --
both w/ and w/o escaping it, but no luck.

Bret: The "Perlish" behavior I was seeing was anything from:

$target's value printing as: This is text<> ; or: This is text;
to:
$target's value printing as: This is textScaler(nxnn) ## don't remember
the exact numbers shown;

not to mention my paw being slapped for the regular coding transgressions in
between cycles of frustration.

Thanks, again for the quicky response, guys!


John--
[EMAIL PROTECTED]

-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 12:41 AM
To: Notabene
Cc: Perl Beginners
Subject: Re: Assigning '<' & '>' as chars to a variable


On Jul 6, Notabene said:

>   $var1   = 'This is text ';
>   $var2   = 'This is more text';
>   $target = $var1.'<'.$var2.'>';

The more common technique is

  $target = "$var1<$var>";

>   This is text 
>
>I've tried "escaping" each of the two symbols but with no luck -- so what's
>the trick and what am I doing wrong, here?

You've probably neglected to tell us that you're printing this to a web
browser, where < and > have special meanings (they delimit tags).  To get
these characters to display as literals, you'll have to use < and
> instead of < and >.

You can automate that via:

  use HTML::Entities;
  print encode_entities("He's  silly!");

--
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: Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Notabene

Thanks all!

Jeff: Your answer was the one I needed. (duh! I was so tangled in my own
shorts that I forgot to mention the web page connection -- good catch. )

Steve: While I had tried your solution I wasn't seeing it since my test rig
was printing to a web page -- *NOT* doing straight Perl print output to a
screen. I even tried assigning the ASCII code via chr() to a variable --
both w/ and w/o escaping it, but no luck.

Bret: The "Perlish" behavior I was seeing was anything from:

$target's value printing as: This is text<> ; or: This is text;
to:
$target's value printing as: This is textScaler(nxnn) ## don't remember
the exact numbers shown;

not to mention my paw being slapped for the regular coding transgressions in
between cycles of frustration.

Thanks, again for the quicky response, guys!


John--
[EMAIL PROTECTED]

-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 12:41 AM
To: Notabene
Cc: Perl Beginners
Subject: Re: Assigning '<' & '>' as chars to a variable


On Jul 6, Notabene said:

>   $var1   = 'This is text ';
>   $var2   = 'This is more text';
>   $target = $var1.'<'.$var2.'>';

The more common technique is

  $target = "$var1<$var>";

>   This is text 
>
>I've tried "escaping" each of the two symbols but with no luck -- so what's
>the trick and what am I doing wrong, here?

You've probably neglected to tell us that you're printing this to a web
browser, where < and > have special meanings (they delimit tags).  To get
these characters to display as literals, you'll have to use < and
> instead of < and >.

You can automate that via:

  use HTML::Entities;
  print encode_entities("He's  silly!");

--
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: Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Brett W. McCoy

On Fri, 6 Jul 2001, Notabene wrote:

> Okay, I surrender...what's the trick to assigning the greater-than (<) and
> the less-than (>) symbols, as characters, to a variable without triggering
> all sorts of unwanted "Perlish" behavior?

What sorts of Perlish behavior are you seeing?  You should be able to use
those characters in a string without even having to escape them.  Are you
getting any error messages?

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

Intel CPUs are not defective, they just act that way.
-- Henry Spencer




RE: Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Steve Howard

Ok, it's getting late. you have to use double quotes.

$target = $var1."\<".$var2."\>";

Sorry,

Steve H.

-Original Message-
From: Notabene [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 11:36 PM
To: Perl Beginners
Subject: Assigning '<' & '>' as chars to a variable


Okay, I surrender...what's the trick to assigning the greater-than (<) and
the less-than (>) symbols, as characters, to a variable without triggering
all sorts of unwanted "Perlish" behavior?

I want to do something on the order of:

$var1   = 'This is text ';
$var2   = 'This is more text';
$target = $var1.'<'.$var2.'>';

so that I can finally do:

print $target; ## or otherwise manipulate the $target variable

and be able to see this result:

This is text 

I've tried "escaping" each of the two symbols but with no luck -- so what's
the trick and what am I doing wrong, here?

Thanks, all.


John--
[EMAIL PROTECTED]




Re: Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Jeff 'japhy' Pinyan

On Jul 6, Notabene said:

>   $var1   = 'This is text ';
>   $var2   = 'This is more text';
>   $target = $var1.'<'.$var2.'>';

The more common technique is

  $target = "$var1<$var>";

>   This is text 
>
>I've tried "escaping" each of the two symbols but with no luck -- so what's
>the trick and what am I doing wrong, here?

You've probably neglected to tell us that you're printing this to a web
browser, where < and > have special meanings (they delimit tags).  To get
these characters to display as literals, you'll have to use < and
> instead of < and >.

You can automate that via:

  use HTML::Entities;
  print encode_entities("He's  silly!");

-- 
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: Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Steve Howard

Escape the characters.
$target = $var1.'\<'.$var2.'\>';

See if those back slashes get you what you want to see.

Steve H.

-Original Message-
From: Notabene [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 11:36 PM
To: Perl Beginners
Subject: Assigning '<' & '>' as chars to a variable


Okay, I surrender...what's the trick to assigning the greater-than (<) and
the less-than (>) symbols, as characters, to a variable without triggering
all sorts of unwanted "Perlish" behavior?

I want to do something on the order of:

$var1   = 'This is text ';
$var2   = 'This is more text';
$target = $var1.'<'.$var2.'>';

so that I can finally do:

print $target; ## or otherwise manipulate the $target variable

and be able to see this result:

This is text 

I've tried "escaping" each of the two symbols but with no luck -- so what's
the trick and what am I doing wrong, here?

Thanks, all.


John--
[EMAIL PROTECTED]




Assigning '<' & '>' as chars to a variable

2001-07-05 Thread Notabene

Okay, I surrender...what's the trick to assigning the greater-than (<) and
the less-than (>) symbols, as characters, to a variable without triggering
all sorts of unwanted "Perlish" behavior?

I want to do something on the order of:

$var1   = 'This is text ';
$var2   = 'This is more text';
$target = $var1.'<'.$var2.'>';

so that I can finally do:

print $target; ## or otherwise manipulate the $target variable

and be able to see this result:

This is text 

I've tried "escaping" each of the two symbols but with no luck -- so what's
the trick and what am I doing wrong, here?

Thanks, all.


John--
[EMAIL PROTECTED]





SQL - Multiple Updates ?

2001-07-05 Thread Rajeev Rumale

Greetings !.

I have some problem with executing a SQL  update statement while updating
multiple records at a time.

I have tried different ways but it is udating one a single (first) record.
The same sql statement works perfectly when run directly on the MY SQL
prompt.

The code i have used are

1.
@del_list = split(",", $in{del_industry});
foreach $id (@del_list) {
 $id= "(industry_id='$id')";
}
$where = join(" or ", @del_list);
$sql ="update industry_list set deleted='y' where ($where)";
$dbh = DBI->connect($site{dsn});
&displayError("Unable to delete the option. $sql")
unless($dbh->do($sql));

# The contents of $sql are "update industry_list set deleted='y' where
((industry_id='001') or (industry_id='002') or (industry_id='003') or
(industry_id='004') or (industry_id='005'))"


2.
$dbh = DBI->connect($site{dsn});
$sql .="update industry_list set deleted='y' where industry_id = ?";
my $sth = $dbh->prepare($sql);
@del_list = split(",", $in{del_industry});
foreach $del_id (@del_list){
$content .= "trying to deleted $del_id";
$sth->execute($del_id);
}


with regards


Rajeev Rumale
___

Yesterday is history.  Tomorrow a mystery. 
Today is a gift. That's why it's called Present.
___







SQL - Multiple Updates ?

2001-07-05 Thread Rajeev Rumale

Greetings !.

I have some problem with executing a SQL  update statement while updating
multiple records at a time.

I have tried different ways but it is udating one a single (first) record.
The same sql statement works perfectly when run directly on the MY SQL
prompt.

The code i have used are

1.
@del_list = split(",", $in{del_industry});
foreach $id (@del_list) {
 $id= "(industry_id='$id')";
}
$where = join(" or ", @del_list);
$sql ="update industry_list set deleted='y' where ($where)";
$dbh = DBI->connect($site{dsn});
&displayError("Unable to delete the option. $sql")
unless($dbh->do($sql));

# The contents of $sql are "update industry_list set deleted='y' where
((industry_id='001') or (industry_id='002') or (industry_id='003') or
(industry_id='004') or (industry_id='005'))"


2.
$dbh = DBI->connect($site{dsn});
$sql .="update industry_list set deleted='y' where industry_id = ?";
my $sth = $dbh->prepare($sql);
@del_list = split(",", $in{del_industry});
foreach $del_id (@del_list){
$content .= "trying to deleted $del_id";
$sth->execute($del_id);
}




- Original Message -
From: "Wagner-David" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Friday, July 06, 2001 10:21 AM
Subject: RE: -d & other file tests


> You are passing the source diretory and file, yet when doing the
> test you are only doing the source file and not combining the directory
and
> file. Without seeing what you are passing, this would be my first guess. I
> say this becuase you always pring the two together when you print.
>
> Wags ;)
>
> -Original Message-
> From: Adam Theo [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 05, 2001 17:59
> To: Perl Beginners
> Subject: -d & other file tests
>
>
>
> Hello, Adam Theo here;
>
> i was wondering if there is something i must declare to use file tests
> such as -d and -e? i have code which i am working on, and i need to
> check to see if a file is a directory. if it is, i run a subroutine.
>
> i recall having used file tests before, and successfully. i don't recall
> having to declare anything special to use them, such as 'use File::Test'
> or something like that. i just used it in the code, like any other core
> perl function/operator.
>
> here is the bit of code relevant to the file tests. through 'print' and
> data::dumper, i have isolated the root of my problem. it is that the
> file tests are not being done. the perl interpreter doesn't seem to know
> to check if the file is a directory, and just skips over it, going on to
> the final 'else' loop, even though it knows of the file, and can do
> other stuff with it, just not file tests.
>
> sub check_source {
>  my($source_dir, $source_file) = @_;
>  print("Checking $source_dir/$source_file.\n");
>  if ($source_file =~ /^\./) {
>print("Can't open file '$source_dir/$source_file':
>  System file.\n");
>  }
>  elsif (-d $source_file) {
>print("$source_dir/$source_file is a directory.\n");
>$source_dir = "$source_dir/$source_file";
>&get_sources($source_dir);
>  }
>  elsif ($source_file =~ /(\.xml)$/) {
>print("$source_dir/$source_file is a source file.\n");
>&parse_source($source_dir, $source_file);
>  }
>  else {
>print("No match!\n");
>  }
> }
>
> thanks in advance!
> --
>/\   Theoretic Solutions (www.Theoretic.com):
>   //\\'Activism, Software, and Internet Services'
> //--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
>][ 'Personal history, analysis, and favorites'
>][   Birthright Online (www.Birthright.net):
>   'Keeping the best role-playing game alive'
> Email & Jabber:   Other:
> -Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
> -General: [EMAIL PROTECTED]   -ICQ: 3617307
> -Personal: [EMAIL PROTECTED]  -Phone: (850)8936047
>




RE: -d & other file tests

2001-07-05 Thread Wagner-David

You are passing the source diretory and file, yet when doing the
test you are only doing the source file and not combining the directory and
file. Without seeing what you are passing, this would be my first guess. I
say this becuase you always pring the two together when you print.

Wags ;)

-Original Message-
From: Adam Theo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 17:59
To: Perl Beginners
Subject: -d & other file tests



Hello, Adam Theo here;

i was wondering if there is something i must declare to use file tests 
such as -d and -e? i have code which i am working on, and i need to 
check to see if a file is a directory. if it is, i run a subroutine.

i recall having used file tests before, and successfully. i don't recall 
having to declare anything special to use them, such as 'use File::Test' 
or something like that. i just used it in the code, like any other core 
perl function/operator.

here is the bit of code relevant to the file tests. through 'print' and 
data::dumper, i have isolated the root of my problem. it is that the 
file tests are not being done. the perl interpreter doesn't seem to know 
to check if the file is a directory, and just skips over it, going on to 
the final 'else' loop, even though it knows of the file, and can do 
other stuff with it, just not file tests.

sub check_source {
 my($source_dir, $source_file) = @_;
 print("Checking $source_dir/$source_file.\n");
 if ($source_file =~ /^\./) {
   print("Can't open file '$source_dir/$source_file':
 System file.\n");
 }
 elsif (-d $source_file) {
   print("$source_dir/$source_file is a directory.\n");
   $source_dir = "$source_dir/$source_file";
   &get_sources($source_dir);
 }
 elsif ($source_file =~ /(\.xml)$/) {
   print("$source_dir/$source_file is a source file.\n");
   &parse_source($source_dir, $source_file);
 }
 else {
   print("No match!\n");
 }
}

thanks in advance!
--
   /\   Theoretic Solutions (www.Theoretic.com):
  //\\'Activism, Software, and Internet Services'
//--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
   ][ 'Personal history, analysis, and favorites'
   ][   Birthright Online (www.Birthright.net):
  'Keeping the best role-playing game alive'
Email & Jabber:   Other:
-Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
-General: [EMAIL PROTECTED]   -ICQ: 3617307
-Personal: [EMAIL PROTECTED]  -Phone: (850)8936047



Re: -d & other file tests

2001-07-05 Thread Jeff 'japhy' Pinyan

On Jul 5, Adam Theo said:

>sub check_source {
> my($source_dir, $source_file) = @_;
> print("Checking $source_dir/$source_file.\n");
> if ($source_file =~ /^\./) {
>   print("Can't open file '$source_dir/$source_file':
> System file.\n");
> }
> elsif (-d $source_file) {

You mean to be checking "$source_dir/$source_file", not just $source_file.

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




-d & other file tests

2001-07-05 Thread Adam Theo


Hello, Adam Theo here;

i was wondering if there is something i must declare to use file tests 
such as -d and -e? i have code which i am working on, and i need to 
check to see if a file is a directory. if it is, i run a subroutine.

i recall having used file tests before, and successfully. i don't recall 
having to declare anything special to use them, such as 'use File::Test' 
or something like that. i just used it in the code, like any other core 
perl function/operator.

here is the bit of code relevant to the file tests. through 'print' and 
data::dumper, i have isolated the root of my problem. it is that the 
file tests are not being done. the perl interpreter doesn't seem to know 
to check if the file is a directory, and just skips over it, going on to 
the final 'else' loop, even though it knows of the file, and can do 
other stuff with it, just not file tests.

sub check_source {
 my($source_dir, $source_file) = @_;
 print("Checking $source_dir/$source_file.\n");
 if ($source_file =~ /^\./) {
   print("Can't open file '$source_dir/$source_file':
 System file.\n");
 }
 elsif (-d $source_file) {
   print("$source_dir/$source_file is a directory.\n");
   $source_dir = "$source_dir/$source_file";
   &get_sources($source_dir);
 }
 elsif ($source_file =~ /(\.xml)$/) {
   print("$source_dir/$source_file is a source file.\n");
   &parse_source($source_dir, $source_file);
 }
 else {
   print("No match!\n");
 }
}

thanks in advance!
--
   /\   Theoretic Solutions (www.Theoretic.com):
  //\\'Activism, Software, and Internet Services'
//--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
   ][ 'Personal history, analysis, and favorites'
   ][   Birthright Online (www.Birthright.net):
  'Keeping the best role-playing game alive'
Email & Jabber:   Other:
-Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
-General: [EMAIL PROTECTED]   -ICQ: 3617307
-Personal: [EMAIL PROTECTED]  -Phone: (850)8936047




RE: creating columns on the fly

2001-07-05 Thread Steve Howard

It's irrelevant where the damon (service) is running. Either method will
work remotely, or on the local machine. It only depends on what you connect
to. Yes, you can do this, and in fact I do it quite frequently. Usually, I
make my scripts to read an ini file or some similar configuration mechanism
and have a switch there to either execute the script on the machine as it is
running, or to just write the script out to a file for me to have, and
possibly execute else where. One that I have actually writes the .SQL script
to create a subscription to a remote publication, and sends it across to
another machine along with a .bat file (also generated by the perl script,
and the zipped database backup file that the perl script has produced. Once
it is there, I use sockets to execute the batch on the remote machine to
execute the batch which uses ISQL to execute the SQL script which unzips the
backup file, restores to the database, and creates the subscription on that
machine. What I'm saying is that it is only limited by your creativity.

However, I can sit at my desk, and run some variant of the second example on
any of the servers in our data center, or across the wan on one of our
remote failover sites. All you need is some way of connecting to the remote
service (ODBC is my favorite, but is by no means the only way. You can use
DBI, and DBD::ODBC to execute this on the remote machine.

I am sitting at home, so this will be hand typed into the e-mail body, so
there may be some syntax error, but this should give you an idea of how to
do what I am talking about (BTW, I tend to go a bit overboard in my
explanations. I don't mean to offend, I just want to be sure I give a full
example):


 use strict;
 use DBI;
  my $dsn   = "northwind";

  # define the location of the sql server.
  my $database  = "DBI:ODBC:$dsn";
  my $db_user   = "sa"; #bad idea. create a different user.
  my $db_password   = "";

  # connect to the sql server.
  my $dbh = DBI->connect($database,$db_user,$db_password, {AutoCommit=>1,
LongReadLen => 4000});
   $dbh->do("USE Northwind");

my $tablename  = "Customers";   #example because you are normally using a
variable.


open (outfile, ">c:/develop/test.sql"); #change to the file you want to use.

print outfile qq{CREATE TABLE $tablename ( \n};

my $select = qq{select name, type_name(xtype) + case
when type_name(xtype) in ('varchar', 'char','nvarchar', 'nchar') then 
'('
+ cast(length as varchar) + ')'
else ''
end,
case isnullable
when 1 then 'null'
else 'not null'
end
from syscolumns where id = object_id('customers')
order by colorder};

$selecth = $dbh->prepare($select) || die qq{can't
prepare\n$select\n$dbh::errstr\n};

$selecth->execute() || die qq{can't execute\n$select\n$dbh::errstr\n};

my ($row, $colname, $coltype, $nullable);

$selecth->bind_columns(undef, \($colname, $coltype, $nullable));
my $def = '';
while ($row = $selecth->fetchrow_arrayref) {

$def = $def. qq{,\n\t\t$colname\t\t$coltype\t\t$nullable};
}
$def =~ s/,//;
$def = $def.')';
print outfile $def;


Now open your test.sql and look at your generated SQL script. That's just a
simple definition. I can't teach you all there is to know about SQL 7's
system catalogues, but you have everything you need in sysobjects, and
syscolumns, and sysindexes (although I usually use sp_helpindex to bring in
information to create indexes on the fly). From there, it's really up to you
how creative you get, and how well you do it.

Have fun.

Steve H.

-Original Message-
From: eric wang [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 5:47 PM
To: Steve Howard
Subject: RE: creating columns on the fly


This is a good idea, but the problem is I want to generate a *.sql file so I
can take that to anywhere and be able to upload/update multiple databases
using only one sql file.
Is that possible?
Also, your second method will only work if I am executing this script on my
local computer.  But in my situation, I need to process the data on a Unix
machine, then this unix machine will generate the *.sql file.  Then I will
take this file to another machine(s) where the database is stored (NT
machine).  Is this possible?

Eric

-Original Message-
From: Steve Howard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 3:08 PM
To: eric wang; dave hoover; [EMAIL PROTECTED]
Subject: RE: creating columns on the fly


Two ways you can do it that I can give an example of. One is to query the
system catalogue directly embedding this:


SELECT name FROM syscolumns WHERE id = object_id('')

(of course, substituting the table name in the appropriate place).

or, if you are using DBI, you can pull a full list of columns in a statement
handle doing something like this (snipped out of a replication program I
have been workin

Absolute Path

2001-07-05 Thread SAWMaster

Hi group!

Little bit of background.  I made a perl cgi that scans a directory for files and auto 
generates a html page with hyperlinks to download whatever files are in the directory. 
 I don't
know if there's an easier way to do this than what I did (built it from scratch) but 
I'm doing this to learn Perl, not to make things easy.  I had this working locally 
through 
localhost, using the full path to the files, but it won't work if someone tries to 
access it remotely.  Anyway, on to the problem.

I'm having trouble writting my absolute path for a link to a .zip file in a cgi script.

Here's my code.

while($i < ($#filelist))
{
if ((@filelist[$i] ne '.') && (@filelist[$i] ne '..'))
{
print "@filelist[$i]";
print "\n";
}
$i++;
}

The problem being, that because this file is in my CGI bin, I need to back track to 
the parent directory a few times and then follow another branch of the directory 
structure back out to the ftp directory..

I can't add a C:\ to the front of it because then it can only be accessed locally.

I'm thinking I could use something like 
\\..\\..\\ftp\\public\\downloads\\assortedfiles\\

To backtrack like in Unix, but it doesn't work like I thought it would.  I'm using 
Windows 98 and Apache web server to do this in.  So my cgi-bin is in the standard
c:\program files\apache group\apache\cgi-bin\

My full path to ftp is:

c:\ftp\public\downloads\assortedfiles\

I don't know, I may be on the right track with the Unix style .. and perhaps just 
messed up with my quoting in the script.  Or, I'm completely lost.

Can someone help me?

-Dave




cannot run program compiled with perlcc

2001-07-05 Thread Jay Anantharaman


I cannot run the following program compiled
with perlcc (seems to be a problem with IO.so
not getting properly loaded?)

Wonder why?  How can it be fixed?

Thanks!
-Jay


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

use IO::File;

$fh = new IO::File;

if ( $#ARGV < 0 ) {
  $fh->fdopen(fileno(STDIN),"r");
}
else {
  $File = $ARGV[0];
  $fh->open("< $File") || die "Can't read $File";
}

print <$fh>;

$fh->close;

autoflush STDOUT 1;

## --- END PROGRAM -

Platform: Intel Solaris
Perl version: 5.00503

Here is what I get 
> ./test
Can't locate object method "new" via package "IO::File".


And here is what I get when its compiled:
> perlcc test.pl


Compiling test.pl:

Making C(test.pl.c) for test.pl!
/usr/local/bin/perl -I/home/khayam8/TechDev/scripts
-I/usr/local/lib/perl5/5.00503/i86pc-solaris -I/usr/local/lib/perl5/5.00503
-I/usr/local/lib/perl5/site_perl/5.005/i86pc-solaris
-I/usr/local/lib/perl5/site_perl/5.005 -I. -MO=CC,-otest.pl.c test.pl
test.pl syntax OK
Use of uninitialized value at
/usr/local/lib/perl5/5.00503/i86pc-solaris/B/CC.pm line 284.
Use of uninitialized value at
/usr/local/lib/perl5/5.00503/i86pc-solaris/B/CC.pm line 288.
Use of uninitialized value at
/usr/local/lib/perl5/5.00503/i86pc-solaris/B/CC.pm line 284.
Use of uninitialized value at
/usr/local/lib/perl5/5.00503/i86pc-solaris/B/CC.pm line 288.
Use of uninitialized value at
/usr/local/lib/perl5/5.00503/i86pc-solaris/B/CC.pm line 284.
Use of uninitialized value at
/usr/local/lib/perl5/5.00503/i86pc-solaris/B/CC.pm line 288.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
No definition for sub Fcntl::O_NDELAY
No definition for sub Fcntl::O_NDELAY (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
No definition for sub Fcntl::O_TEXT
No definition for sub Fcntl::O_TEXT (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
No definition for sub Fcntl::O_EXLOCK
No definition for sub Fcntl::O_EXLOCK (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
No definition for sub Fcntl::O_TRUNC
No definition for sub Fcntl::O_TRUNC (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
No definition for sub Fcntl::O_DEFER
No definition for sub Fcntl::O_DEFER (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
No definition for sub Fcntl::O_NONBLOCK
No definition for sub Fcntl::O_NONBLOCK (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
No definition for sub Fcntl::O_RDONLY
No definition for sub Fcntl::O_RDONLY (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
No definition for sub Fcntl::O_NOCTTY
No definition for sub Fcntl::O_NOCTTY (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
No definition for sub Fcntl::O_SHLOCK
No definition for sub Fcntl::O_SHLOCK (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
No definition for sub Fcntl::O_BINARY
No definition for sub Fcntl::O_BINARY (unable to autoload)
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B/C.pm
line 602.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
Use of uninitialized value at /usr/local/lib/perl5/5.00503/i86pc-solaris/B.pm
line 194.
No definition for sub Fcntl::O_C

RE: creating columns on the fly

2001-07-05 Thread Steve Howard

Two ways you can do it that I can give an example of. One is to query the
system catalogue directly embedding this:


SELECT name FROM syscolumns WHERE id = object_id('')

(of course, substituting the table name in the appropriate place).

or, if you are using DBI, you can pull a full list of columns in a statement
handle doing something like this (snipped out of a replication program I
have been working on).:



my $dbh = DBI->connect($database,$db_user,$db_password, {AutoCommit=>0,
LongReadLen => 4000});
my $dbh1 = DBI->connect($database,$db_user,$db_password, {AutoCommit=>0,
LongReadLen => 4000});
$dbh->do("USE Northwind");
$dbh1->do("USE Northwind_copy");

my $select = $dbh->prepare("SELECT * FROM Customers") || die qq{Can't
execute\n$select\n  $dbh::errstr\n};
local($\, $,) = ("\n", "\t");
$columnlist = '['.join('], [', @{$select->{NAME}}).']'; #get the column
list from the dbi   function.
print @{$select->{NAME}}[0..$#{$select->{NAME}}]; #for demo only. Shows the
array of column names


As you can see from the print statement, the column names are now
referencable in the @{$select->{NAME}}

array. (Notice that $select is the statement handle. If you used $sth your
array would be @{$sth->{NAME}} There are other properties that can be pulled
in similar manners from the statement handles. Once you get the hang of
using this, you can easily get the other properties listed in perldoc DBI.

Hope this helps,

Steve H.


-Original Message-
From: eric wang [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 2:58 PM
To: dave hoover; Eric Wang; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: creating columns on the fly


Thanks for the tip,
But what if I am using Microsoft SQL server 7?
is there a way to do this?
eric

-Original Message-
From: dave hoover [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 12:43 PM
To: Eric Wang; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: creating columns on the fly


Eric Wang wrote:
[snip]
> First, I decided that I will need to generate the
> SQL statements inside
> the perl script. (i.e. print SQL "insert...
> blah..").

If you use DBI, this is no problem, in fact, it's
expected.  You will probably call
$sth->execute(SQL_HERE).  You can plug in a previously
generated scalar variable at SQL_HERE.

> But, I need to know
> if this column I insert into has already existed or
> not? if not, create
> it, otherwise just insert it. So, the simple
> question is can I do this?
[snip]

Yes. You can query the database first to see if it's
there, then based on the results, construct your SQL
statement with UPDATE/INSERT accordingly.



=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/




Re: I did it!!!

2001-07-05 Thread K.L. Hayes

Hello Newbie,

And let us not forget to scold you on your non-use of "strict". The
use of it in this list will help avoid future flames & find errors in
longer, more complex scripts.

I'll demonstrate the use of it, & include the tips posted thus far...

#!c:/perl/bin/perl -w

use strict;

my $number;
my $mult;
my $result;

print "Enter a number:  ";
chomp($number = );
print "Enter a multiplier:  ";
chomp($mult = );
$result = $number * $mult;
print "The result you ignorant fool is: $result\n";

## OR ##

#!c:/perl/bin/perl -w

use strict;

print "Enter a number:  ";
chomp(my $number = );
print "Enter a multiplier:  ";
chomp(my $mult = );
my $result = $number * $mult;
print "The result, you ignorant fool, is: $result\n";

## OR ##

#!c:/perl/bin/perl -w

use strict;

my ($number,$mult,$result);

print "Enter a number:  ";
chomp($number = );
print "Enter a multiplier:  ";
chomp($mult = );
$result = $number * $mult;
print "The result, you ignorant fool, is: $result\n";



Thursday, July 05, 2001, 5:01:20 PM, you wrote:

CS> I’m sure I could get flamed for this, but I just successfully wrote my first
CS> program! Yaaahhh!

CS> ## perl 

CS> #!c:/perl/bin/perl -w

CS> print STDOUT "Enter a number:  ";
CS> chop($number = );
CS> print STDOUT "Enter a multiplier:  ";
CS> chop($mult = );
CS> $result = $number * $mult;
CS> print STDOUT "The result you ignorant fool is: $result\n";


CS> Cool, huh?  Not gonna win any awards, but at least I know how to use STDIN
CS> and STDOUT.

-- 
Best regards,
K.L. Hayes
mailto:[EMAIL PROTECTED]

+===+
+   "Inherently, each one of us has the substance   +
+   within to achieve whatever our goals and dreams +
+   define. What is missing from each of us is the  +
+   training, education, knowledge and insight to   +
+   utilize what we already have." -- Mark Twain+
+===+





Re: Text file parsing - one chunk v char by char

2001-07-05 Thread Mike Breeze

Very nice! I love Perl:)

Cheers Ken,

Breezy

Ken wrote:

> $/ = "¬";
>
> Then while() will only bring in each record.
>
> - Original Message -
> From: "Mike Breeze" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, July 05, 2001 1:23 PM
> Subject: Text file parsing - one chunk v char by char
>
> > Hi there,
> >
> > I'm writing some code that has to parse a text file containing a series
> > of records. The records are a direct export from a third party DB and
> > are delimited by the "¬" char (I hope that comes out on all your email
> > clients but I guess it doesn't really matter.
> >
> > What bothers me is that the text file contains only one line which in
> > turn contains many records. The test files I have are only 300 or 400K,
> > but I'm a bit worried at the risk of receiving a huge file to parse
> > which may leave me wanting for memory.
> >
> > I'm used to parsing files where each record is written to it's own line.
> > I.e.
> >
> > while (  ) {
> > my $job = Job->new();
> > chomp;
> > $job->FromStr( $_ );
> > push ( @{ $self->{people} }, $job );
> > }
> >
> > I could do:
> >
> > while (  ) {
> > my @jobs = split /\¬/;
> > foreach my $jobstr ( @jobs ) {
> >  my $job = Job->new();
> >  job->FromStr( $jobstr );
> >  push ( @{ $self->{people} }, $job );
> > }
> > }
> >
> > But this seems to me to be a little clunky given that I may receive a
> > HUGE one lined file one day. Is this a valid risk, or am I being too
> > careful?
> >
> > Cheers
> >
> > Breezy
> >
> >





Re: I did it!!!

2001-07-05 Thread Chas Owens

On 05 Jul 2001 16:02:40 -0500, Humberto Varela wrote:
> you have an error in your syntax:
> 
> 
> >print STDOUT "The result you ignorant fool is: $result\n";
> 
> should be:
> 
> print STDOUT "The result, you ignorant fool, is: $result\n";
> 
> commas help emphasize that "pause" in the print statement.
> 
> : )
> 
>

I think "The result -- you ignorant fool -- is: $result\n" or "The
result (you ignorant fool) is: $result\n".  The first puts emphasis on
"you ignorant fool," and the seconds treats it like an aside.  Also (on
a Perl note) the STDOUT is unnesessary and chomp is preferable to chop.
STDOUT is the default selected filehandle so you don't have to specify
it unless you have mucked about with select.  Chop removes the last
character (whatever it is) and chomp removes the record seperator (which
by default is \n).
 
--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
Hail Eris, Hack Linux!





Re: I did it!!!

2001-07-05 Thread Humberto Varela

you have an error in your syntax:


>print STDOUT "The result you ignorant fool is: $result\n";

should be:

print STDOUT "The result, you ignorant fool, is: $result\n";

commas help emphasize that "pause" in the print statement.

: )




I did it!!!

2001-07-05 Thread Customer Service

I’m sure I could get flamed for this, but I just successfully wrote my first
program! Yaaahhh!

## perl 

#!c:/perl/bin/perl -w

print STDOUT "Enter a number:  ";
chop($number = );
print STDOUT "Enter a multiplier:  ";
chop($mult = );
$result = $number * $mult;
print STDOUT "The result you ignorant fool is: $result\n";


Cool, huh?  Not gonna win any awards, but at least I know how to use STDIN
and STDOUT.



RE: creating columns on the fly

2001-07-05 Thread Chas Owens

DBD::Sybase is reported to work.  You might also try DBD::ODBC.

On 05 Jul 2001 12:58:23 -0700, eric wang wrote:
> Thanks for the tip,
> But what if I am using Microsoft SQL server 7?
> is there a way to do this?
> eric
> 
> -Original Message-
> From: dave hoover [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 05, 2001 12:43 PM
> To: Eric Wang; [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: creating columns on the fly 
> 
> 
> Eric Wang wrote:
> [snip]
> > First, I decided that I will need to generate the
> > SQL statements inside
> > the perl script. (i.e. print SQL "insert...
> > blah..").  
> 
> If you use DBI, this is no problem, in fact, it's
> expected.  You will probably call
> $sth->execute(SQL_HERE).  You can plug in a previously
> generated scalar variable at SQL_HERE.
> 
> > But, I need to know
> > if this column I insert into has already existed or
> > not? if not, create
> > it, otherwise just insert it. So, the simple
> > question is can I do this?
> [snip]
> 
> Yes. You can query the database first to see if it's
> there, then based on the results, construct your SQL
> statement with UPDATE/INSERT accordingly.
> 
> 
> 
> =
> Dave Hoover
> "Twice blessed is help unlooked for." --Tolkien
> http://www.redsquirreldesign.com/dave
> 
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> 
--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
P'tang!





Perl & Outlook/Exchange

2001-07-05 Thread Gross, Stephan

I'd like to write a Perl application that will tell me how many messages are
sitting in an Exchange mailbox.  Implementations of both POP3 and IMAP can
query a mailbox given the username and password.  The problem is that I have
several mailboxes all using the same user account.  Outlook can do this
because it understands "profiles" - i.e., name, password *and* mailbox.  Can
someone point me to a Perl solution or Microsoft API?

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

 



RE: PLaying with CGI's

2001-07-05 Thread Ryan Ware

>Can you run a web browser under Linux?  
Yes
>I don't have any experience w/ Linux.  Am I over my head?  
It is not all point and click and forget about it, but it is much more
powerful and stable.  I would recommend Mandrake if you've never used linux
before.  You can download it free from http://www.mandrake.com. But if
you've never used it before, I would reccomend buying a distribution of
linux from a computer store, that way you will get a manual.
>Do I necessarily need Red Hat?
No, any linux will do.  Red Hat, Slackware, Debian, Mandrake, Suse, your
favorite linux here, are all generally the same underneath.  

Most any distribution will come with all the development and database tools
you need for a good website.  MySql and Postgres are a couple of good
databases that you usually get.






> -Original Message-
> From: Customer Service [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, July 05, 2001 3:15 PM
> To:   Perl Beginners
> Subject:  PLaying with CGI's
> 
> Roger G. Romeril replied to an email about test sites for cgi scripts.  He
> mentioned that instead, it would be better to get a stripped down pc and
> load Linux, perl, and apache and play with that.  Well, I decided to do
> just
> that.  While the suggestion wasn't specifically aimed at me, I thought
> that
> the suggestion was a good one.  I located an old P166 open-architecture pc
> with a 4gig hd and 32 mg ram.  Just need to get a cdrom. No problem.  But
> I
> have some questions:
> Can you run a web browser under Linux?
> Does perl behave better/differently than on a M$ machine?
> I don't have any experience w/ Linux.  Am I over my head?
> Where do I get Linux?
> Do I necessarily need Red Hat?
> 
> Thanks in advance.  My goal is to learn perl and CGI scripting well enough
> to administer my own site.  I want to learn how to access a database with
> my
> scripts to provide live content on the fly and provide an e-commerce
> solution for my Company, a small mom & pop business that recently has made
> a
> very successful break onto the web in September, 2000 (by yours truly).
> What databases work the best for this type of project?
> Are there any other tools/software/utilities I'll need?
> 
> Thank you,
> Nathan
> Internet Graphics and Design
> www.tandrtrailer.com 
> 



DBI and Oracle 8I

2001-07-05 Thread Conrad, Bill (ThomasTech)

Hi All

I don't know if this is the right place to ask this but here goes.
Please direct me to other lists if appropriate.

I would like to use Perl to access are Oracle 8I version 817
database on Solaris 2.6. 

1) Do the current DBI packages support this?
2) If so, what packages do I need?


Thanks

Bill Conrad




RE: PLaying with CGI's

2001-07-05 Thread Canavan, John

Nathan,
I run Netscape on my Linux box at home. (Or at least I did until I
overclocked my system by too much and fried it).  I haven't run Perl on
Wintel systems yet, but am in the process of trying it.  I learned most of
what I needed to know from "Linux for Dummies".  You'll probably get a lot
of suggestions for O'Reilly books, too.  They're quite good.  As far as
getting Linux, you can buy it from Red Hat, Debian, or others, or if you
have a pretty quick modem, you can download it.  Just use your favorite
search engine (www.google.com is a good one), and search for "Linux
distribution".

A better choice would be to look for a linux users' group.  There should be
at least one in your area.  They usually have events where you bring your
computer, and they'll install and configure Linux for you.  They'll also
help you with several newbie questions, and probably point you to more
resources than I've ever heard of.

-Original Message-
From: Customer Service [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 14:15
To: Perl Beginners
Subject: PLaying with CGI's


Roger G. Romeril replied to an email about test sites for cgi scripts.  He
mentioned that instead, it would be better to get a stripped down pc and
load Linux, perl, and apache and play with that.  Well, I decided to do just
that.  While the suggestion wasn't specifically aimed at me, I thought that
the suggestion was a good one.  I located an old P166 open-architecture pc
with a 4gig hd and 32 mg ram.  Just need to get a cdrom. No problem.  But I
have some questions:
Can you run a web browser under Linux?
Does perl behave better/differently than on a M$ machine?
I don't have any experience w/ Linux.  Am I over my head?
Where do I get Linux?
Do I necessarily need Red Hat?

Thanks in advance.  My goal is to learn perl and CGI scripting well enough
to administer my own site.  I want to learn how to access a database with my
scripts to provide live content on the fly and provide an e-commerce
solution for my Company, a small mom & pop business that recently has made a
very successful break onto the web in September, 2000 (by yours truly).
What databases work the best for this type of project?
Are there any other tools/software/utilities I'll need?

Thank you,
Nathan
Internet Graphics and Design
www.tandrtrailer.com 





Re: Redefining a Subroutine

2001-07-05 Thread Jeff 'japhy' Pinyan

On Jul 5, [EMAIL PROTECTED] said:

>I need to redefine a subroutine from one package to a subroutine from
>another.
>
>This code works and does what I want it to, however I need to write it so
>it isn't hard coded. The posible necessary escapes, evals, single quotes
>and double quotes make me woozy.
>
># WORKS  #
>   undef &Default_DB::special_code ;
>   *DatabaseLib::special_code= \&Sybase_DB::special_code ;

You want to do symbolic reference work.  This is one of the only times you
should use them.

  {
no strict 'refs';  # in case that's on, which it should be
my $old_func = 'Old::Function';
my $new_func = 'New::Func';

*$old_func = \&$new_func;
  }

-- 
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[2]: Parent and Current Directories

2001-07-05 Thread Maxim Berlin

Hello SAWMaster,
Thursday, July 05, 2001, Maxim Berlin <[EMAIL PROTECTED]> wrote:

S>> I'm  trying to list all files in a directory EXCEPT the current and
S>> the parent directories.

S>> ie.

S>> .
S>> ..
S>> file1
S>> file2
S>> file3

S>> Is not what I want.  I only want:

S>> file1
S>> file2
S>> file3

S>> I thought I had the right code, but I don't.

S>> while($i < ($#filelist))
S>> {
S>> if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))

MB> try $filelist[$i]
1. and, what the strange if condition? it is always true.


S>> {
S>> print @filelist[$i];
S>> print "\n";
S>> $i++;
S>> }
2. you have endless loop here. $i never increment, if 'if
condition' wrong.

S>> }


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





PLaying with CGI's

2001-07-05 Thread Customer Service

Roger G. Romeril replied to an email about test sites for cgi scripts.  He
mentioned that instead, it would be better to get a stripped down pc and
load Linux, perl, and apache and play with that.  Well, I decided to do just
that.  While the suggestion wasn’t specifically aimed at me, I thought that
the suggestion was a good one.  I located an old P166 open-architecture pc
with a 4gig hd and 32 mg ram.  Just need to get a cdrom. No problem.  But I
have some questions:
Can you run a web browser under Linux?
Does perl behave better/differently than on a M$ machine?
I don’t have any experience w/ Linux.  Am I over my head?
Where do I get Linux?
Do I necessarily need Red Hat?

Thanks in advance.  My goal is to learn perl and CGI scripting well enough
to administer my own site.  I want to learn how to access a database with my
scripts to provide live content on the fly and provide an e-commerce
solution for my Company, a small mom & pop business that recently has made a
very successful break onto the web in September, 2000 (by yours truly).
What databases work the best for this type of project?
Are there any other tools/software/utilities I’ll need?

Thank you,
Nathan
Internet Graphics and Design
www.tandrtrailer.com 




Re: Parent and Current Directories

2001-07-05 Thread Paul Johnson

On Thu, Jul 05, 2001 at 02:43:01PM -0500, SAWMaster wrote:
> Hello group!
> 
> I'm trying to list all files in a directory EXCEPT the current and the parent 
>directories.
> 
> I thought I had the right code, but I don't.
> 
> while($i < ($#filelist))
> {
> if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))
> {
> print @filelist[$i];
> print "\n";
> $i++;
> }
> }

You need to check your boolean logic.  Try && instead of ||
And use $filelist[$i]

or (untested)

for (@filelist)
{
if ($_ ne '.' && $_ ne '..')
{
print $_;
print "\n";
}
}

or

print map { "$_\n" } grep { ! /^\.\.?$/ } @filelist;

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



Re: Parent and Current Directories

2001-07-05 Thread Jeff 'japhy' Pinyan

On Jul 5, SAWMaster said:

>while($i < ($#filelist))
>{
>if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))
>{
>print @filelist[$i];
>print "\n";
>$i++;
>}
>}

The chief problem is your logic.

  if ($f ne '.' || $f ne '..') {
print $f;
  }

When '.' gets to this, it fails the ($f ne '.') test.  So it tries the ($f
ne '..') test, and succeeds, so it is printed.  Similarly, when '..' gets
to the ($f ne '.') test, it succeeds, so it is printed.

Change the logic to:

  if ($f ne '.' && $f ne '..') {
# ...
  }

and it will work.

You might just want to use a for-loop, by the way:

  for (@files) {
print "$_\n" if $_ ne '.' and $_ ne '..';
  }

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




Redefining a Subroutine

2001-07-05 Thread JCervoni

I need to redefine a subroutine from one package to a subroutine from
another.

This code works and does what I want it to, however I need to write it so
it isn't hard coded. The posible necessary escapes, evals, single quotes
and double quotes make me woozy.

# WORKS  #
   undef &Default_DB::special_code ;
   *DatabaseLib::special_code= \&Sybase_DB::special_code ;


At this point  I really have no idea how the syntax should look to do the
above, can someone help?

I think it should start like this:

$old_module  = "\&DefaultLib\:\:special_code" ;
$new_module = "\&SybaseLib\:\:special_code" ;




Jeff









Re: Parent and Current Directories

2001-07-05 Thread Maxim Berlin

Hello SAWMaster,

Thursday, July 05, 2001, SAWMaster <[EMAIL PROTECTED]> wrote:

S> Hello group!

S> I'm  trying to list all files in a directory EXCEPT the current and
S> the parent directories.

S> ie.

S> .
S> ..
S> file1
S> file2
S> file3

S> Is not what I want.  I only want:

S> file1
S> file2
S> file3

S> I thought I had the right code, but I don't.

S> while($i < ($#filelist))
S> {
S> if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))

try $filelist[$i]

S> {
S> print @filelist[$i];
S> print "\n";
S> $i++;
S> }
S> }

S> I was thinking, maybe it's not equal to . and .. because of a newline at the end of 
. and .. ?

S> But I tried a chop, or chomp and it just took off the last letter of all files, 
problem unsolved.

S> Can someone steer a newbie in the right direction again?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





RE: creating columns on the fly

2001-07-05 Thread eric wang

Thanks for the tip,
But what if I am using Microsoft SQL server 7?
is there a way to do this?
eric

-Original Message-
From: dave hoover [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 12:43 PM
To: Eric Wang; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: creating columns on the fly 


Eric Wang wrote:
[snip]
> First, I decided that I will need to generate the
> SQL statements inside
> the perl script. (i.e. print SQL "insert...
> blah..").  

If you use DBI, this is no problem, in fact, it's
expected.  You will probably call
$sth->execute(SQL_HERE).  You can plug in a previously
generated scalar variable at SQL_HERE.

> But, I need to know
> if this column I insert into has already existed or
> not? if not, create
> it, otherwise just insert it. So, the simple
> question is can I do this?
[snip]

Yes. You can query the database first to see if it's
there, then based on the results, construct your SQL
statement with UPDATE/INSERT accordingly.



=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/




Parent and Current Directories

2001-07-05 Thread SAWMaster

Hello group!

I'm trying to list all files in a directory EXCEPT the current and the parent 
directories.

ie.

.
..
file1
file2
file3

Is not what I want.  I only want:

file1
file2
file3

I thought I had the right code, but I don't.

while($i < ($#filelist))
{
if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))
{
print @filelist[$i];
print "\n";
$i++;
}
}

I was thinking, maybe it's not equal to . and .. because of a newline at the end of . 
and .. ?

But I tried a chop, or chomp and it just took off the last letter of all files, 
problem unsolved.

Can someone steer a newbie in the right direction again?

-Dave




Re[2]: How to check it a $Var is empty

2001-07-05 Thread Tim Musson

Hey Jeff & Others,

Thursday, July 05, 2001, 2:04:17 PM, my MUA believes you used
(X-Mailer not set) to write:

Thanks for the tip (don't my SOMETHING if CONDITION;).

I got the same response from 2 people.  Is there a reason I should
pick one solution over the other?  Or is this another case of
TMTOWTDI? 

JjP> It is inadvisable to do:
JjP>   my SOMETHING if CONDITION;
JjP> because you cause Perl to do some weird things which I'd rather not get
JjP> into.

JjP>   while (<>) {
JjP> chomp;
JjP> my @line = split /,/;
JjP> my @group = (@line == 3) ? split(/_/, $line[2]) : ();
JjP> print "$line[0] $line[1] $group[-1]\n";
JjP>   }


DML> BEWARE of this construct, it has a hidden gotcha.  Do this instead:

DML> my @Group;
DML> @Group = split(/_/, $Line[2]) if (defined($Line[2]));

DML> Otherwise, the 'my' is also inside of the 'if', which causes bizarre
DML> problems.

-- 
[EMAIL PROTECTED]
Using The Bat! (http://www.ritlabs.com/the_bat/) eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
Why get even, when you can get odd?




Re: creating columns on the fly

2001-07-05 Thread dave hoover

Eric Wang wrote:
[snip]
> First, I decided that I will need to generate the
> SQL statements inside
> the perl script. (i.e. print SQL "insert...
> blah..").  

If you use DBI, this is no problem, in fact, it's
expected.  You will probably call
$sth->execute(SQL_HERE).  You can plug in a previously
generated scalar variable at SQL_HERE.

> But, I need to know
> if this column I insert into has already existed or
> not? if not, create
> it, otherwise just insert it. So, the simple
> question is can I do this?
[snip]

Yes. You can query the database first to see if it's
there, then based on the results, construct your SQL
statement with UPDATE/INSERT accordingly.



=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Text file parsing - one chunk v char by char

2001-07-05 Thread Ken


$/ = "¬";

Then while() will only bring in each record.


- Original Message -
From: "Mike Breeze" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 1:23 PM
Subject: Text file parsing - one chunk v char by char


> Hi there,
>
> I'm writing some code that has to parse a text file containing a series
> of records. The records are a direct export from a third party DB and
> are delimited by the "¬" char (I hope that comes out on all your email
> clients but I guess it doesn't really matter.
>
> What bothers me is that the text file contains only one line which in
> turn contains many records. The test files I have are only 300 or 400K,
> but I'm a bit worried at the risk of receiving a huge file to parse
> which may leave me wanting for memory.
>
> I'm used to parsing files where each record is written to it's own line.
> I.e.
>
> while (  ) {
> my $job = Job->new();
> chomp;
> $job->FromStr( $_ );
> push ( @{ $self->{people} }, $job );
> }
>
> I could do:
>
> while (  ) {
> my @jobs = split /\¬/;
> foreach my $jobstr ( @jobs ) {
>  my $job = Job->new();
>  job->FromStr( $jobstr );
>  push ( @{ $self->{people} }, $job );
> }
> }
>
> But this seems to me to be a little clunky given that I may receive a
> HUGE one lined file one day. Is this a valid risk, or am I being too
> careful?
>
> Cheers
>
> Breezy
>
>




Re: Text file parsing - one chunk v char by char

2001-07-05 Thread Chas Owens

If "¬" is the record seperator then use the record seperator variable
($/) to get the individual records:

{#create a new scope to prevent changes from effecting everthing else
local ($/) = "¬";
while () {
chomp; #get rid of "¬" on the end;
do_something_with_a _record($_);
}
} # $/ goes out of scope and everyone is happy 

On 05 Jul 2001 20:23:37 +0100, Mike Breeze wrote:
> Hi there,
> 
> I'm writing some code that has to parse a text file containing a series
> of records. The records are a direct export from a third party DB and
> are delimited by the "¬" char (I hope that comes out on all your email
> clients but I guess it doesn't really matter.
> 
> What bothers me is that the text file contains only one line which in
> turn contains many records. The test files I have are only 300 or 400K,
> but I'm a bit worried at the risk of receiving a huge file to parse
> which may leave me wanting for memory.
> 
> I'm used to parsing files where each record is written to it's own line.
> I.e.
> 
> while (  ) {
> my $job = Job->new();
> chomp;
> $job->FromStr( $_ );
> push ( @{ $self->{people} }, $job );
> }
> 
> I could do:
> 
> while (  ) {
> my @jobs = split /\¬/;
> foreach my $jobstr ( @jobs ) {
>  my $job = Job->new();
>  job->FromStr( $jobstr );
>  push ( @{ $self->{people} }, $job );
> }
> }
> 
> But this seems to me to be a little clunky given that I may receive a
> HUGE one lined file one day. Is this a valid risk, or am I being too
> careful?
> 
> Cheers
> 
> Breezy
> 
> 
--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
Or not.





Text file parsing - one chunk v char by char

2001-07-05 Thread Mike Breeze

Hi there,

I'm writing some code that has to parse a text file containing a series
of records. The records are a direct export from a third party DB and
are delimited by the "¬" char (I hope that comes out on all your email
clients but I guess it doesn't really matter.

What bothers me is that the text file contains only one line which in
turn contains many records. The test files I have are only 300 or 400K,
but I'm a bit worried at the risk of receiving a huge file to parse
which may leave me wanting for memory.

I'm used to parsing files where each record is written to it's own line.
I.e.

while (  ) {
my $job = Job->new();
chomp;
$job->FromStr( $_ );
push ( @{ $self->{people} }, $job );
}

I could do:

while (  ) {
my @jobs = split /\¬/;
foreach my $jobstr ( @jobs ) {
 my $job = Job->new();
 job->FromStr( $jobstr );
 push ( @{ $self->{people} }, $job );
}
}

But this seems to me to be a little clunky given that I may receive a
HUGE one lined file one day. Is this a valid risk, or am I being too
careful?

Cheers

Breezy




Re: referncing hashes of array references

2001-07-05 Thread Jeff 'japhy' Pinyan

On Jul 5, Bob Mangold said:

>print ${${$hashREF}{'foo'}}[1];

I posted earlier this week that

  $$ref[$idx] (and ${$ref}[$idx] too)

and

  $ref->[$idx]

are the same.  So...

  $$hashref{foo}

is

  $hashref->{foo}

and then

  ${ $hashref->{foo} }[1]

is

  $hashref->{foo}->[1]

which can be shrunk to

  $hashref->{foo}[1]

-- 
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: referncing hashes of array references

2001-07-05 Thread Brett W. McCoy

On Thu, 5 Jul 2001, Bob Mangold wrote:

> if I have a hash that contains array refs as its values and I create a
> reference for it, what are the different ways that i can access the information
> in the array?
>
> for example.
>
> my %hash;
> my @array = ('red','white','blue');
> $hash{'foo'} = \@array;
> my $hashREF = \%hash;
> print ${${$hashREF}{'foo'}}[1];
>
> now I know that will print "white". but is there another syntax that will get
> me the same result and is a little easier to read?

Yes, you can use the infix arrow syntax:

print $hashREF->{foo}->[1];

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

If you had any brains, you'd be dangerous.




referncing hashes of array references

2001-07-05 Thread Bob Mangold

if I have a hash that contains array refs as its values and I create a
reference for it, what are the different ways that i can access the information
in the array?

for example.

my %hash;
my @array = ('red','white','blue');
$hash{'foo'} = \@array;
my $hashREF = \%hash;
print ${${$hashREF}{'foo'}}[1];

now I know that will print "white". but is there another syntax that will get
me the same result and is a little easier to read?

-bob

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: FW: Optional Variables

2001-07-05 Thread Chas Owens

Oops, sorry I got tied up here and forgot I was going to send you more
info.  Basicly what you need to do is this:

my $query = "
select this, that
from table
where constant_where_clause_stuff = other constant_stuff
";

$option = @ARGV ? " and filename = $ARGV[0] " : " ";

$query .= $option . " group by whatever sort by whatever";

$sth = $dbh->prepare($query);

$sth->execute;

.
.
.
etc.

On 05 Jul 2001 13:47:14 -0400, Kim Green wrote:
> I don't know how or where to put & how to use this $option.  
> What if my Default value is a sql statement? Can I just include the name 
> of the file handle between the brackets?
> 
> 
> 
> -Original Message-
> From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 29, 2001 6:40 PM
> To: M.W. Koskamp
> Cc: Evgeny Goldin (aka Genie); [EMAIL PROTECTED]
> Subject: Re: Optional Variables
> 
> 
> On Fri, 29 Jun 2001, M.W. Koskamp wrote:
> 
> 
> > > my $option = @ARGV ? shift : ;
> >
> > Above option only works for 1 parameter tho (and commandline arguments).
> > For function calls i like to use 'named parameters' by accepting a hash of
> > options.
> 
> Well, yeah, but the topic *was* command-line arguments, not function
> arguments.  You can easily loop through @ARGV, unshifting as you go, until
> @ARGV is depleted and default values assigned.
> 
> -- Brett
>  http://www.chapelperilous.net/btfwk/
> 
> A free society is one where it is safe to be unpopular.
>   -- Adlai Stevenson
> 
--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
Pzat!





Re: modules & path to perl

2001-07-05 Thread Peter Scott

At 02:03 PM 7/5/01 -0400, David Gilden wrote:
> > perldoc CPAN and look for the autobundle command.  You'll have to define
> > your own personal CPAN directory first, but this is the "official"
> > way.  Dirtier way:
> >
> > find `perl -e 'print "@INC"'` -name "*.pm" -print
> >
>
>Got a long list of stuff, and wanted to write to a file,
>What did I miss here? (almost there...)

Redirect:

find `perl -e 'print "@INC"'` -name "*.pm" -print > modules


>#!/usr/bin/perl
>
>@array = ("test","dave");
>
>push @array ,`find "@INC" -name "*.pm"`;
>
>open (ML, ">modulelist") or die "could not write file $!";
>
>
>while (@array){
>print  "$_\n";
>}

Er, just stick the module list in a file from the command line, no need to 
write a Perl script to do it.  Then clean it up with an editor.

If you're looking for more details, autobundle is the way to go; it will 
tell you version numbers.  CPAN.pm can even tell you which modules have 
more recent versions available.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re: How to check it a $Var is empty

2001-07-05 Thread Jeff 'japhy' Pinyan

On Jul 5, Tim Musson said:

>I want to split to @Group only if the 3rd element of @Line has data.
>It works, but I get an error (Use of uninitialized value in split)
>using -w, strict, and diagnostics. Should I be doing this differently?
>
>while (<>) { chomp;
>my @Line = split(/,/);
>
>my @Group = split(/_/, $Line[2]) if ($Line[2]); # err msg here for uid3
>
>print "\n", $Line[0], $Line[1], " $Group[-1]"; # testing
>}

It is inadvisable to do:

  my SOMETHING if CONDITION;

because you cause Perl to do some weird things which I'd rather not get
into.

  while (<>) {
chomp;
my @line = split /,/;
my @group = (@line == 3) ? split(/_/, $line[2]) : ();
print "$line[0] $line[1] $group[-1]\n";
  }

-- 
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: Re[2]: How to check it a $Var is empty

2001-07-05 Thread David M. Lloyd

On Thu, 5 Jul 2001, Tim Musson wrote:

> CO> WAG: try 
> CO> my @Group = split(/_/, $Line[2]) if (defined($Line[2]));
> 
> Thanks, that did it. I should just listen to myself talk sometimes. I
> was just saying to a coworker, "I only want to split if $Line[2] is
> defined"!

BEWARE of this construct, it has a hidden gotcha.  Do this instead:

my @Group;
@Group = split(/_/, $Line[2]) if (defined($Line[2]));

Otherwise, the 'my' is also inside of the 'if', which causes bizarre
problems.

- D

<[EMAIL PROTECTED]>




Re[2]: How to check it a $Var is empty

2001-07-05 Thread Tim Musson

Hey Chas,

Thursday, July 05, 2001, 1:16:05 PM, my MUA believes you used
Evolution/0.10.99 (Preview Release) to write:

>> I want to split to @Group only if the 3rd element of @Line has data.

>> I would like to put nothing in $Group[-1] if $Line[2] is empty.
>> 
>> while (<>) { chomp;
>> my @Line = split(/,/);
>> 
>> my @Group = split(/_/, $Line[2]) if ($Line[2]); # err msg here for uid3
>> 
>> print "\n", $Line[0], $Line[1], " $Group[-1]"; # testing
>> }
>>

CO> WAG: try 
CO> my @Group = split(/_/, $Line[2]) if (defined($Line[2]));

Thanks, that did it. I should just listen to myself talk sometimes. I
was just saying to a coworker, "I only want to split if $Line[2] is
defined"!

-- 
[EMAIL PROTECTED]
Using The Bat! (http://www.ritlabs.com/the_bat/) eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
Your mouse has moved. Windows must now reboot. Click OK to continue.




perl and Dial-up Networking.

2001-07-05 Thread Johnathan Thibodeau

Does anybody know how, if possible, I could get access to Dial-up
Networking settings in WIndows? I need to make a set-up CD for the ISP I
work for, and I want to use perl for compatability reasons (plus I don't
like VB).

I suppose this question could extend to any Mac people out there aswell,
with whatever MacOS uses to make a PPP connection.

Johnathan Thibodeau

Bureaucrat, n.:
A person who cuts red tape sideways.
-- J. McCabe




Re: FW: Optional Variables

2001-07-05 Thread Brett W. McCoy

On Thu, 5 Jul 2001, Kim Green wrote:

> I don't know how or where to put & how to use this $option.
> What if my Default value is a sql statement? Can I just include the name
> of the file handle between the brackets?

You can do something like

my $option = @ARGV ? shift : 'SELECT * FROM my_table';

or

my $option = @ARGV ? shift : '/usr/local/db/queries.sql';

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

The future isn't what it used to be.  (It never was.)




FW: Optional Variables

2001-07-05 Thread Kim Green

I don't know how or where to put & how to use this $option.  
What if my Default value is a sql statement? Can I just include the name 
of the file handle between the brackets?



-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 29, 2001 6:40 PM
To: M.W. Koskamp
Cc: Evgeny Goldin (aka Genie); [EMAIL PROTECTED]
Subject: Re: Optional Variables


On Fri, 29 Jun 2001, M.W. Koskamp wrote:


> > my $option = @ARGV ? shift : ;
>
> Above option only works for 1 parameter tho (and commandline arguments).
> For function calls i like to use 'named parameters' by accepting a hash of
> options.

Well, yeah, but the topic *was* command-line arguments, not function
arguments.  You can easily loop through @ARGV, unshifting as you go, until
@ARGV is depleted and default values assigned.

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

A free society is one where it is safe to be unpopular.
-- Adlai Stevenson



Weekly list FAQ posting

2001-07-05 Thread casey

NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?

June 25, 2001

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

`perldoc perldoc'

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?

YES! You have been warned! If you don't want to get ~100 emails per day
from thi

Re: modules & path to perl

2001-07-05 Thread Peter J. Scott

At 01:29 PM 7/5/01 -0400, David Gilden wrote:
>How do I list what my ISP has on there server in terms of Modules?

perldoc CPAN and look for the autobundle command.  You'll have to define 
your own personal CPAN directory first, but this is the "official" 
way.  Dirtier way:

find `perl -e 'print "@INC"'` -name "*.pm" -print

>And what is the command (at the command line) to tell me what version

perl -v

>The server has on it / and or the path to perl.

which perl





Re: modules & path to perl

2001-07-05 Thread Tyler Longren

do a 'which perl' at the command line to get the location of perl.  Not sure
about the modules.  To get the version of perl, do 'perl --version' at the
command line.

Tyler
- Original Message -
From: "David Gilden" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 12:29 PM
Subject: modules & path to perl


> How do I list what my ISP has on there server in terms of Modules?
> And what is the command (at the command line) to tell me what version
> The server has on it / and or the path to perl.
> Thanks
>
> Dave G.
>
> 
> Looking for Web Talent, You found it!
> portfolio: www.coraconnection.com/web/
> email: [EMAIL PROTECTED]
> tel/fax: (860) 231-9988
> 




creating columns on the fly

2001-07-05 Thread Eric Wang

Hi guys,

I am writing a perl script that will take some command prompt parameters
and linking it with a SQL server database.  I sort of have an idea on how
to do it.  But need you guys to give me some directions as to which way
is the best.

First, I decided that I will need to generate the SQL statements inside
the perl script. (i.e. print SQL "insert... blah..").  But, I need to know
if this column I insert into has already existed or not? if not, create
it, otherwise just insert it. So, the simple question is can I do this?
The more complex question is can I embed SQL code blocks(procedures
and functions instead of a simple insert statement)  inside perl script?


Thanks,
Eric



*
*Eric T. Wang   *
*Bioinformatic Support and DNA Sequencing Core SRA  *
*University of California, Irvine College of Medicine   *
*Department of Biological Chemistry *
*RK Moyzis Lab  *
*[EMAIL PROTECTED]   *
*949-824-1870   *
*




modules & path to perl

2001-07-05 Thread David Gilden

How do I list what my ISP has on there server in terms of Modules?
And what is the command (at the command line) to tell me what version 
The server has on it / and or the path to perl.
Thanks

Dave G.


Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988




Re: How to check it a $Var is empty

2001-07-05 Thread Chas Owens

On 05 Jul 2001 13:01:33 -0400, Tim Musson wrote:
> perlers,
> 
> I want to split to @Group only if the 3rd element of @Line has data.
> It works, but I get an error (Use of uninitialized value in split)
> using -w, strict, and diagnostics. Should I be doing this differently?
> 
> I run this with a filename parm, and the file contains:
> uid1,cn 1,ua_bit_essd
> uid2,cn 2,ua_bit_essd_si
> uid3,cn 3,
> 
> I would like to put nothing in $Group[-1] if $Line[2] is empty.
> 
> while (<>) { chomp;
> my @Line = split(/,/);
> 
> my @Group = split(/_/, $Line[2]) if ($Line[2]); # err msg here for uid3
> 
> print "\n", $Line[0], $Line[1], " $Group[-1]"; # testing
> }
> 
> Thanks!
> 
> -- 
> [EMAIL PROTECTED]
> Using The Bat! eMail v1.53d
> Windows NT 5.0.2195 (Service Pack 1)
> Luxuriantly hand-crafted from only the finest ASCII. 
> 
>

WAG: try 
my @Group = split(/_/, $Line[2]) if (defined($Line[2]));
--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
Umlaut Zebra über alles!





Re: Confused

2001-07-05 Thread Peter J. Scott

At 08:41 PM 7/4/01 -0500, RL Autry wrote:

>A friend of mine sent me a file to write
>  to help get me started on programming Perl.
>So I did (in notepad):
>
>#!/usr/bin/perl -w
>use strict;
>while (<>) {
>if ( /book/i or /bk/i) {
>print;
>}
>
>When I run it in my dos window --
>  I get an error message that says:
>
>Missing right curly or square bracket at findit.pl line 6, at end of line
>syntax error at findit.pl line 6, at EOF
>Execution of findit.pl aborted due to compilation errors.
>
>
>
>Do I need to compile this file before I use it?

No.

>I thought perl was a "self-compiling language".

More or less.

>What is it looking for?

Believe it or not, the missing right curly or square bracket at line 6.  If 
you indent your code, you'll find it easier to see where one's missing:

#!/usr/bin/perl -w
use strict;
while (<>) {
   if ( /book/i or /bk/i ) {
 print
   }



Anything look unbalanced about that?




Re: string position

2001-07-05 Thread Ken

Oh oh oh!  I want to try!

use strict;

my( $var, $long_var );
$var = '123456';
$long_var = ' ' x 19 . $var;
print "$long_var\n";

*in the distance you hear the sounds of someone beating something with a
stick*

- Original Message -
From: "F.H" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 9:31 AM
Subject: string position


> Hi,
> I'd like to be able to print a string at a specific location . Is there
any function that does that.
> $test = "abcd';
> I want to print $test at position 20-25.
> I appreciate if someone can help
>
> Thanks
> I.S
> __
> Get your own FREE, personal Netscape Webmail account today at
http://webmail.netscape.com/
>




How to check it a $Var is empty

2001-07-05 Thread Tim Musson

perlers,

I want to split to @Group only if the 3rd element of @Line has data.
It works, but I get an error (Use of uninitialized value in split)
using -w, strict, and diagnostics. Should I be doing this differently?

I run this with a filename parm, and the file contains:
uid1,cn 1,ua_bit_essd
uid2,cn 2,ua_bit_essd_si
uid3,cn 3,

I would like to put nothing in $Group[-1] if $Line[2] is empty.

while (<>) { chomp;
my @Line = split(/,/);

my @Group = split(/_/, $Line[2]) if ($Line[2]); # err msg here for uid3

print "\n", $Line[0], $Line[1], " $Group[-1]"; # testing
}

Thanks!

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
Luxuriantly hand-crafted from only the finest ASCII. 




Re: string position

2001-07-05 Thread Brett W. McCoy

On Thu, 5 Jul 2001, Brett W. McCoy wrote:

> On Thu, 5 Jul 2001, F.H wrote:
>
> > I'd like to be able to print a string at a specific location . Is there any 
>function that does that.
> > $test = "abcd';
> > I want to print $test at position 20-25.
> > I appreciate if someone can help
>
> You will need something like the Curses module that will let you define
> areas of the screen as windows and let you specifically set screen
> locations.  Curses is available from CPAN.

Never mind... I read the question as "printing at location 20,25",
thinking you meant a screen location.

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

The bigger the theory the better.




Re: string position

2001-07-05 Thread Brett W. McCoy

On Thu, 5 Jul 2001, F.H wrote:

> I meant, counting characters from left to right, $test will occupy charcater 
>position 20 through 25, the print out will look like this.
>
>,abcd  ,
>
> there are other string variables before and after that $test of course. Greg

Oh, you should use the substr function for that: perldoc -f substr.

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

Your own qualities will help prevent your advancement in the world.




Re: string position

2001-07-05 Thread Brett W. McCoy

On Thu, 5 Jul 2001, F.H wrote:

> I'd like to be able to print a string at a specific location . Is there any function 
>that does that.
> $test = "abcd';
> I want to print $test at position 20-25.
> I appreciate if someone can help

You will need something like the Curses module that will let you define
areas of the screen as windows and let you specifically set screen
locations.  Curses is available from CPAN.

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

MATH AND ALCOHOL DON'T MIX!
Please, don't drink and derive.

Mathematicians
Against
Drunk
Deriving




Re: string position

2001-07-05 Thread Chas Owens

On 05 Jul 2001 11:31:32 -0400, F.H wrote:
> Hi,
> I'd like to be able to print a string at a specific location . Is there any function 
>that does that.
> $test = "abcd';
> I want to print $test at position 20-25.
> I appreciate if someone can help
>  
> Thanks
> I.S
> __
> Get your own FREE, personal Netscape Webmail account today at 
>http://webmail.netscape.com/
> 

Okay, let me take another shot at it: you want a format:

while (<>) {
my ($number_var, $test, $centered_var) = split;
write;
} 

#1 2 3 4 5 6 7
#234567890123456789012345678901234567890123456789012345678901234567890
format STDOUT =
@##@<@
$number_var$test $centered_var
.


Take a look at "perldoc -f write" and "perldoc -f perlform".

--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
Or is it?





New to Perl

2001-07-05 Thread Akens, Anthony

Hello,
I'm completely new to perl, but have a good deal of experience with c / c++.
I'm wondering if there are any good websites that will give me a basic
introduction to programming in perl (data structures, etc).  I've found
references to a few books, but would like to gather some basic info from the
net before spending the cash.  Thanks in advance for any info.

Tony Akens



RE: Match Keys in two Hashes - THANKS!

2001-07-05 Thread Perl Beginner

Just a note to say:

THANK YOU ALL VERY MUCH FOR YOUR HELP!!!

:o)

-Original Message-

At 01:08 PM 7/2/01 -0500, Perl Beginner wrote:
>Hello,
>
>I'm your typical beginner who is kind of stuck. Here is the problem:
>
>I have two hashes, each has ~40,000 key/value pairs. I need to find which
>keys in one hash are the same as the keys in the other hash. The ones that
>have the same key then need their values diffed. This is how I was trying
to
>accomplish this:
>
>  while (($key1,$value1) = each (%yesterdayhash)) {
>   while (($key2,$value2) = each (%todayhash))  {
>
>if (($key1 eq $key2) {
>   $delta = ($value2 - $value1) ;
>}
>   }
>  }
>
>I let this run for over 48 hours and it never completed! One of our Perl
>experts said I did a big no-no. Everything in those while statements will
be
>iterating ~40,000 * 40,000 times.
>
>My question is how else can I find the same keys in two hashes and then
diff
>their values without taking forever?




Re: string position

2001-07-05 Thread F.H

I meant, counting characters from left to right, $test will occupy charcater position 
20 through 25, the print out will look like this.

   ,abcd  ,  

there are other string variables before and after that $test of course. Greg 

Meckes <[EMAIL PROTECTED]> wrote:
>
> You can try:
> 
> $test = "abcd";
> 
> $test = sprintf "%24s" , $test;
> 
> 
> Greg
> 
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
__
Get your own FREE, personal Netscape Webmail account today at 
http://webmail.netscape.com/



Re: string position

2001-07-05 Thread Greg Meckes

You can try:

$test = "abcd";

$test = sprintf "%24s" , $test;


Greg

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: string position

2001-07-05 Thread Chas Owens

On 05 Jul 2001 11:31:32 -0400, F.H wrote:
> Hi,
> I'd like to be able to print a string at a specific location . Is there any function 
>that does that.
> $test = "abcd';
> I want to print $test at position 20-25.
> I appreciate if someone can help
>  
> Thanks
> I.S
> __
> Get your own FREE, personal Netscape Webmail account today at 
>http://webmail.netscape.com/
> 

Try perldoc -f substr


$test = "This that and the other: foo bar baz foobar foobaz";
print substr($test, 19, 5), "\n";



ther:


--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
Keep the Lasagna flying!





Re: progress Bar

2001-07-05 Thread Jorge Goncalvez


- Begin Forwarded Message -

Delivered-To: [EMAIL PROTECTED]
From: Jorge Goncalvez <[EMAIL PROTECTED]>
Subject: Re: progress Bar



I have seen the widget demo for using TK::progressBar but it doesn't help me 
very munch because I don't know how to make my progress bar go up with my 
process tftp.

I tried my process tftp, it takes 1.6s to get a file of 62090 Ko,and 1.6 s for a 
file of 1K but unfortunely this times are not proportionnal and with the same 
file I 've got differents times (perhaps due of the network).So I don't know how 
i can implement this progress bar.
I know only one thing when the process is finished it writes some informations 
into a file like syslogd.

Thanks.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

- End Forwarded Message -





string position

2001-07-05 Thread F.H

Hi,
I'd like to be able to print a string at a specific location . Is there any function 
that does that.
$test = "abcd';
I want to print $test at position 20-25.
I appreciate if someone can help
 
Thanks
I.S
__
Get your own FREE, personal Netscape Webmail account today at 
http://webmail.netscape.com/



http, ftp, and perl

2001-07-05 Thread S.J.

I am trying to write a program that will allow a Perl program running from a windows 
nt system to access ftp and http files. Which modules/formats would I need to use to 
do this?



RE: $ARGV

2001-07-05 Thread Chas Owens

$ARGV[0] and $ARGV[1] are not file handles.  They are elements of
commandline argument array @ARGV.  ARGV is a special file handle that
holds the current file being read by an empty <> operator.  $ARGV is
another special variable that holds the name of the file currently being
read by an empty <> operator.

On 05 Jul 2001 16:04:03 +0100, Govinderjit Dhinsa wrote:
>   I have tried to find out in full detail about the file handle $ARGV
> and only got the basics.  
> 
>   Could any one please explain the $ARGV in more detail, e.g. how to
> put a input file into the $ARGV, if the input file was constantly changing!
> 
> 
> 
>   The File in may program:
>   
>   open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!;
>   open sortcode,">$ARGV[1]";
>   while($line=){
>   
> 
>   Thanks,
>   GD 
> 
--
Today is Sweetmorn, the 40th day of Confusion in the YOLD 3167
You are what you see.





RE: $ARGV

2001-07-05 Thread Govinderjit Dhinsa

I have tried to find out in full detail about the file handle $ARGV
and only got the basics.  

Could any one please explain the $ARGV in more detail, e.g. how to
put a input file into the $ARGV, if the input file was constantly changing!



The File in may program:

open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!;
open sortcode,">$ARGV[1]";
while($line=){


Thanks,
GD 



Re: simple regexp

2001-07-05 Thread Mario Todorow

Try this one line command
perl -ne ' print "$1\n" if /\s(\S+\.\S+\.\S+\.\S+)\s/' file

Cordially

Mario




EXPORT and EXPORT_OK

2001-07-05 Thread JCervoni


Is it possible to change @EXPORT during runtime?


I'm trying to import subroutines in the following manner:

- I have a file called DBLib.pm which imports a file "DefaultLib.pm" via a
"use".


DBLib.pm
###
package DBLib.pm

use strict ;
require Exporter ;
use DefaultLib  ;
use vars qw(@ISA @EXPORT @EXPORT_OK);
@ISA = qw(Exporter) ;


- DefaultLib.pm  explicitly sets @EXPORT = to a list of functions I want to
export into DBLib.pm

DefaultLib.pm
###
package DefaultLib ;

use strict ;
require Exporter ;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter) ;
@EXPORT = qw(&default_code) ;


- SybaseLib.pm, OracleLib.pm are set up the same way that DefaultLib.pm is
set up.


The overall question is that I want to be able to write a separate perl
script that makes a call to "use DBLib ;".
The DBLib.pm  file will have a section of code to test for an environment
variable of DBTYPE and determine which additional library to "use"
(SybaseLib.pm, OracleLib.pm, etc)...

When the database specific library gets imported (SybaseLib.pm) any
subroutine with the same name as a subroutine in DefaultLib.pm should get
redefined and use the one in SybaseLib.pm.  Additionally, to reference any
subroutine regardles of which pm file it actually exists in should be able
to be called from an outside script  by

use DBLib ;

# default code here would be (same for all db's)
&DBLib::default_code ;

# db specific code here (main script doesn't know  which db its connected
through)
&DBLib::add_user ;


This I hope can be accomplished by using the AUTOLOAD subroutine to check
for the existence of the subroutine being called and decide where to branch
to using the following sequence.

-look first in DBLib::
-next look in SybaseLib::   # (or whatever DBTYPE was set to)
-last look in DefaultLib::
-error and exit if the subroutine hasn't been found


The part that doesn't seem to work is that the functions from SybaseLib.pm
don't overlay any subroutines with the same name in DefaultLib.

So to simplify my question,  is what I'm trying to do possible?

I have tried many different approaches to accomplish this so, I have much
of the code written allready.  This is all very stripped down in hopes that
it would make more sense without too much detail at first.  Hope someone
out there can help.

Thanks,

Jeff




Re:Progress bar

2001-07-05 Thread Jorge Goncalvez


- Begin Forwarded Message -

Date: Thu, 5 Jul 2001 16:15:05 +0200 (MEST)
From: Jorge Goncalvez 
Subject: Re:Progress bar
To: [EMAIL PROTECTED]
Mime-Version: 1.0
Content-MD5: EFvZDRoA/ttGIJBKvpTZIQ==


- Begin Forwarded Message -

Delivered-To: [EMAIL PROTECTED]
From: Jorge Goncalvez <[EMAIL PROTECTED]>
Subject: Re:Progress bar
To: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-MD5: Lcr6TetMGiqwQM6b4LCs4Q==
X-Filtered-By: PerlMx makes it fast and easy.  See 
http://www.ActiveState.com/Products/PerlMx/Header
X-BeenThere: [EMAIL PROTECTED]
X-Mailman-Version: 2.0.5
List-Help: 

List-Post: 
List-Subscribe: 
, 

List-Id: Discussions relating to ActivePerl on Win32 platforms 

List-Unsubscribe: 
, 

List-Archive: 
Date: Thu, 5 Jul 2001 15:56:34 +0200 (MEST)

Hi, i must implement a progress bar in my Perl Tk script to show the progression 
of a tftp processus, how can I do this?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

- End Forwarded Message -


- End Forwarded Message -





Re:number of records

2001-07-05 Thread Brett W. McCoy

On Thu, 5 Jul 2001, Jorge Goncalvez wrote:

> I have the following :
>
> @drives = Win32::DriveInfo::DrivesInUse();
>
> How can I get the number of element in the array @drives?

my $num_drives = @drives;

An array in scalar context gives the number of elements.

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

Things fall apart; the centre cannot hold.




Re: Using getopt::std return hash with value of 1 rather than argument

2001-07-05 Thread Craig Moynes/Markham/IBM

>The perldoc for getopt::std states:
>Hash keys will be x (where x is the switch name) with key
>values the value of the argument or 1 if no argument is
>specified

This is true for getopt, but not getopts.
Getopts puts the parameter in the hash table (I am working on 5.005_03
built for aix )

perldoc -m Getopt::Std
# Usage:
#   getopts('a:bc');# -a takes arg. -b & -c not. Sets opt_* as a
#   #  side effect.

So in your case:
getopts("n:hfc",\%option);

So n will expect an argument while h, f, and c will not (thus the 1 in the
hash).

Hope this helps

-
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]





Using getopt::std return hash with value of 1 rather than argument

2001-07-05 Thread charles

> Clean this up as:
> if ($option{n}) {
>  $domain = $option{n}
>  add();
> }
>
> Don't use ARGV once you have used getopt (or getopts).  The hash you
> specify to the option getter
> creates the keys as the flags and the values as the associated parameter.
>
> #if -f, then set $path
> if ($option{f}) {
>  $path = "/etc/nameserver/".$option{f};
>  update();
> }
>

i better start out by saying that i am using

This is perl, version 5.005_03 built for i386-linux

when i change my code to reflect what you have above,
the value for the key appears to be "1" rather than
the actual argument specified on the command line.

The perldoc for getopt::std states:

   Hash keys will be x (where x is the switch name) with key
   values the value of the argument or 1 if no argument is
   specified

so it seems as though my arguments are not getting passed for
some reason.

here is my code, in its entirety. i've removed some flag options
for more concise reading and testing

thanks! -charles


#!/usr/bin/perl -w

use strict;
use Getopt::Std;

my $filename = "/root/named.clients";
my $domain;
my %option;

getopts("nhfc",\%option);

#if no arguments are specified, echo the help menu
if ( $#ARGV < 0 ) {
  help();
  exit;
}

#if -h, then echo help menu
if ($option{h}) {
  help();
  exit;
}

#if -n, then set $domain equal to the argument
if ($option{n}) {
  $domain = $option{n};
  add();
}

sub add {
open FH, ">>$filename" or die "Cant open config file $!\n";
  print FH "zone \"$domain\" in \{\n\ttype
master\;\n\tfile\"clients\/db.$domain\"\;\n\tallow-query \{ any\; \}\;
\}\;\n\n";
close FH;
open FH, $filename;
  $/ = "\;\n\n";
  my @array = ;
  @array = sort @array;
close FH;
open FH, ">$filename";
  print FH @array;
close FH;
print "\nThe domain $domain has been added to your \/etc\/named.conf
file.\n\n";}
}

sub help {

print<
  -h print this help page

EOF
}






RE: \r

2001-07-05 Thread Aaron Craig

At 14:13 05.07.2001 +0100, Govinderjit Dhinsa wrote:
> What is the code please to get, after field 6;
> \r (carriage return)
>
> I tried this, but no luck;
> $fields[6] =~ s\r//;

try $fields[6] =~ s/\r//;
^
|
|
note added front slash

>Any help would be much appreciated!!!
>Thanks,
>GD
>
> #
> PROGRAM:
>
> #!/path/to/perl -w
> use strict;
>
> open CSV," open NEW,">vt04-07-01.csv-changed";
> while (){
> chomp;
>
> my @fields = split ',';
>
> splice @fields, 2, 1;
>
> splice @fields, 5, 1;
>
> $fields[6] =~ s\r//;
>
> for (@fields) { print NEW "$_" }
> }
> close CSV;
> close NEW;
> exit;
>
> [End of file]
> 

Aaron Craig
Programming
iSoftitler.com




RE: \r

2001-07-05 Thread Govinderjit Dhinsa

What is the code please to get, after field 6;
\r (carriage return)

I tried this, but no luck;
$fields[6] =~ s\r//;

Any help would be much appreciated!!!
Thanks,
GD

#
PROGRAM:

#!/path/to/perl -w
use strict;

open CSV,"vt04-07-01.csv-changed";
while (){
chomp;

my @fields = split ',';

splice @fields, 2, 1;

splice @fields, 5, 1;

$fields[6] =~ s\r//;

for (@fields) { print NEW "$_" }
}
close CSV;
close NEW;
exit;

[End of file]




Re: mod_perl

2001-07-05 Thread Francisco Ho

At 01:20 PM 07/05/2001 +0530, you wrote:
>Hi All
>
>Today I installed Indigo Perl on my system and when I tried the sample 
>code which came along with the installation to test mod_perl it gave an 
>error as "Page not found"
>
>I checked the following before posting
>a) I found that the file exists
>b) path in the html page is also correct.
>c) Apache which came along with the installation is running and displays
> "Apache/1.3.19 (Win32) mod_perl/1.24_01 running..."
>d) When I tried checking the $ENV if 'MOD_PERL' exist but failed 

Hi, Joel!

Since you are mentioning Win32, I could assume you are running Apache in a 
Windows box. I have a similar problem but in a Linux box, and was solved 
adding/editing httpd.conf with the following lines (not sure if it works 
the same way in Windows, but it may give you a hint):

ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/

#this tells where the script files will be. Important for the next step

AddHandler cgi-script .cgi
AddHandler cgi-script .pl

#tells which extensions will be "read" as scripts instead of just text files.
#of course, I am asuming that the scripts will be placed in cgi-bin


>Can you all help me in the following

As for the rest, sorry, I don't have that knowledge, yet...




RE: number of records

2001-07-05 Thread Robin Lavallee (LMC)


Use it in scalar context:

my $num_elements = @drives;

-Robin

> -Original Message-
> From: Jorge Goncalvez [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, July 05, 2001 8:14 AM
> To:   [EMAIL PROTECTED]
> Subject:  Re:number of records
> 
> I have the following :
> 
> @drives = Win32::DriveInfo::DrivesInUse();
> 
> How can I get the number of element in the array @drives?
> 
> $cc2-> checkbutton (-label=>$drives[0], -variable => \$A);
> $cc2-> checkbutton (-label=>$drives[1], -variable => \$B);
> $cc2-> checkbutton (-label=>$drives[2], -variable => \$C);
> $cc2-> checkbutton (-label=>$drives[3], -variable => \$D);
> $cc2-> checkbutton (-label=>$drives[4], -variable => \$E);
> $cc2-> checkbutton (-label=>$drives[5], -variable => \$F);
> $cc2-> checkbutton (-label=>$drives[6], -variable => \$G);
> $cc2-> checkbutton (-label=>$drives[7], -variable => \$H);
> $cc2-> checkbutton (-label=>$drives[8], -variable => \$I);
> 
> 
> 
> to simplify this code .



Executing Script from Sendmail

2001-07-05 Thread David Rankin

Hello,

I am trying to write a script that is run by piping email to
it from an alias.  The script is running on Red Hat Linux
7.0, and the MTA's sendmail.  I'm also using smrsh.  I'm not
sure if the problem is with the script or something else,
but here's the code I'm using (just for testing right now, I
know there's a lot I'd have to do to tighten up security on
something like this) . . .

#!/usr/bin/perl -w
use strict;

open TEST, ">test.txt";
print TEST "Test Worked";
close TEST;

I'd expect that if it worked, I'd get a file called
"text.txt" with the text "Test Worked" in the same directory
as the script.  Right now I get nothing.  The mail doesn't
get bounced back.  I don't get any error messages from
anywhere.  I read through some sendmail FAQ's about using
smrsh and searched around on Google, but I can't figure out
what could be wrong.

As suggested by the smrsh documentation, I didn't put the
actual script in /etc/smrsh, just a link to its real
location, and the alias is set to pipe to the script at the
/etc/smrsh path.

If anyone's got any suggestions, I'd really appreciate it.

Thanks!

-Dave

_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




Re:number of records

2001-07-05 Thread Jorge Goncalvez

I have the following :

@drives = Win32::DriveInfo::DrivesInUse();

How can I get the number of element in the array @drives?

$cc2-> checkbutton (-label=>$drives[0], -variable => \$A);
$cc2-> checkbutton (-label=>$drives[1], -variable => \$B);
$cc2-> checkbutton (-label=>$drives[2], -variable => \$C);
$cc2-> checkbutton (-label=>$drives[3], -variable => \$D);
$cc2-> checkbutton (-label=>$drives[4], -variable => \$E);
$cc2-> checkbutton (-label=>$drives[5], -variable => \$F);
$cc2-> checkbutton (-label=>$drives[6], -variable => \$G);
$cc2-> checkbutton (-label=>$drives[7], -variable => \$H);
$cc2-> checkbutton (-label=>$drives[8], -variable => \$I);



to simplify this code .




RE: Windows2000

2001-07-05 Thread Conrad, Bill (ThomasTech)


I click on "reply to all" and delete the individuals address, leaving only
the address to the list. That way the individual doesn't get two e-mails.

Bill Conrad

-Original Message-
From: RL Autry [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 03, 2001 3:45 PM
To: Aaron Craig; [EMAIL PROTECTED]
Subject: Re: Windows2000


At 05:15 AM 7/3/2001, Aaron Craig wrote:
>  ie, you've got nothing to worry about :)

Thanks Aaron that helps more than you know.

I keep replying to these posts but it is not going to the list.
It is going to the individual who sent it. People have suggested
that I reply to the list so I can get more help on this. But when
I click reply it addresses it to the individual. So this time I clicked
on reply to all. That seems to be the only way I can get a message
in the form of a reply to the list.

Am I doing something wrong or is that just the way this list works?

Thanks,
RL



RE: Regex

2001-07-05 Thread Govinderjit Dhinsa

Thank you for your time and your valuable help is much appreciated.
I made the changes to the program like you suggested, however I get
this error, when I run the program!

##
 A3 GD > perl CSV.PL;
Global symbol "$line" requires explicit package name at csv.pl; line
6.
Execution of csv.pl; aborted due to compilation errors.
%SYSTEM-F-ABORT, abort
##

The modified program:
###
#!/path/to/perl -w
use strict;

open CSV,"vt04-07-01.csv-changed";
while($line=){
chomp;

my @fields = split ',';

splice @fields, 2, 1;

for (@fields) { print NEW "blah $_\n" }
}
close CSV;
close NEW;
exit;

[End of file] 


##

> ### USE STRICT AND -w I can not stress that enough!!! ###
> 
> #!/path/to/perl -w
> use strict;
> 
> ### use CAPS for filehandles to avoid conflicts with reserved words... use
> $ARGV in both places, or neither ###
> open CSV, "$ARGV[0] or die "Cannot open $ARGV[0]",$!;
> open NEW,">vt04-07-01.csv-changed";
> 
> ### we'll put all the input into $_ it makes things easier i think... ###
> while () {
> 
> ### kill trailing \n ###
> chomp;
> 
> ### split the fields on comma's from $_ and put them in @fields ###
> my @fields = split ',';
> 
> ### 3rd element of @fields holds unwanted info, we'll splice it out...
> perldoc -f splice for more details ###
> splice @fields, 2, 1;
> 
> ### an arbitrary print statement to show you all went well
> for (@fields) { print NEW "blah $_\n" }
> 
> ### feel free to add more code in... ###
> }
> 
> hope this helps,
> 
> Jos Boumans


> Thanks,
Kind Regards,
>  GD



RE: newwin function

2001-07-05 Thread Sally

I can't help any more I'm afraid, hope you sort it,

Regards,

Sally

-Original Message-
From: George S Pereira [mailto:[EMAIL PROTECTED]]
Sent: 05 July 2001 12:17
To: Sally
Cc: [EMAIL PROTECTED]
Subject: RE: newwin function



Yes, but is there a workaround. maybe by changing the height of each line
to 1.5% of what it is now.

I'm not very sure that what I'm saying is even possible.. But the
Idea remains.




George Savio Pereira

Email : [EMAIL PROTECTED]


On Thu, 5 Jul 2001, Sally wrote:

> Surely if in the man pages the parameters are integers then only integers
> can be used?
> 
> 
> -Original Message-
> From: George S Pereira [mailto:[EMAIL PROTECTED]]
> Sent: 05 July 2001 10:16
> To: [EMAIL PROTECTED]
> Subject: newwin function
> 
> 
> 
> Hi All,
> 
>   I'm using a Curses kit called CDK (Curses Development Kit).
> 
>   There is a C function in one of the files which calls the system
> function newwin(). The parameters given are the height, width, Xpos and
> Ypos.
> 
>   newwin() creates a window of the given height and width.
> 
>   But the problem, is that, if I give 1.5 as the height. It creates
> a window having the height just 1 line.
> 
>   Is there any way that I can make the height to something like 1.5,
> instead of 1, because, 1 is too small, and 2 is too big?
> 
>   All of newwin parameter's according to the man pages are int.
> 
> 
> 
> George Savio Pereira
> 
> Email : [EMAIL PROTECTED]
> 
> 
> 




RE: newwin function

2001-07-05 Thread George S Pereira


Yes, but is there a workaround. maybe by changing the height of each line
to 1.5% of what it is now.

I'm not very sure that what I'm saying is even possible.. But the
Idea remains.




George Savio Pereira

Email : [EMAIL PROTECTED]


On Thu, 5 Jul 2001, Sally wrote:

> Surely if in the man pages the parameters are integers then only integers
> can be used?
> 
> 
> -Original Message-
> From: George S Pereira [mailto:[EMAIL PROTECTED]]
> Sent: 05 July 2001 10:16
> To: [EMAIL PROTECTED]
> Subject: newwin function
> 
> 
> 
> Hi All,
> 
>   I'm using a Curses kit called CDK (Curses Development Kit).
> 
>   There is a C function in one of the files which calls the system
> function newwin(). The parameters given are the height, width, Xpos and
> Ypos.
> 
>   newwin() creates a window of the given height and width.
> 
>   But the problem, is that, if I give 1.5 as the height. It creates
> a window having the height just 1 line.
> 
>   Is there any way that I can make the height to something like 1.5,
> instead of 1, because, 1 is too small, and 2 is too big?
> 
>   All of newwin parameter's according to the man pages are int.
> 
> 
> 
> George Savio Pereira
> 
> Email : [EMAIL PROTECTED]
> 
> 
> 




Re: Regex

2001-07-05 Thread Jos I. Boumans

Hi,

the problem you have is not a bit one, so the solution is fairly simple..
however, there are some issues you need to concider in your script, so let
me show you a few pointers:

### USE STRICT AND -w I can not stress that enough!!! ###

#!/path/to/perl -w
use strict;

### use CAPS for filehandles to avoid conflicts with reserved words... use
$ARGV in both places, or neither ###
open CSV, "$ARGV[0] or die "Cannot open $ARGV[0]",$!;
open NEW,">vt04-07-01.csv-changed";

### we'll put all the input into $_ it makes things easier i think... ###
while () {

### kill trailing \n ###
chomp;

### split the fields on comma's from $_ and put them in @fields ###
my @fields = split ',';

### 3rd element of @fields holds unwanted info, we'll splice it out...
perldoc -f splice for more details ###
splice @fields, 2, 1;

### an arbitrary print statement to show you all went well
for (@fields) { print NEW "blah $_\n" }

### feel free to add more code in... ###
}

hope this helps,

Jos Boumans




> What I need to delete from the file is: Field [3]
> Can any body please suggest what else needs to be added to the
> script that I wrote below to do this task please.
> THE PROGRAM so far:

> open csv," open new,">vt04-07-01.csv-changed";
> while($line=){
> chomp $line;
>
> $fields[3] =~
>
> }
> close csv;
> close new;
> exit;
>
> [End of file]
>
>
> Any help would be much appreciated as I only have two days to this
> in!!!
> Thanks,
> GD
>




RE: Regex

2001-07-05 Thread Govinderjit Dhinsa

Hi, I have been asked to write a perl script, to Delete 1 field in a
input file and then print to a output file!

What I need to delete from the file is: Field [3]
Can any body please suggest what else needs to be added to the
script that I wrote below to do this task please.

  The big problem being that the data in the File is not sorted in any
form,
  e.g. no Headings etc.  The only thing separating the fields is  a
  comment=  ,

Here is two data items examples from the input file (each data is streachted
along ONE LINE) :
(The field [3] that I need to get rid of is "006" and the number is not
always the same)

"Value Telecom",98599.00,"006","Welcome to Value Telecom. If you have any
queries please contact Customer Services on 0845 6555000
or visit any Carphone Warehouse
store.","44776811","SS",,"2001-07-04-08.03.32.221465"

"Value Telecom",98599.00,"006","Welcome to Value Telecom. If you have any
queries please contact Customer Services on 0845 6555000
or visit any Carphone Warehouse
store.","447947022824","SS",,"2001-07-04-08.03.32.221465"


THE PROGRAM so far:

open csv,"vt04-07-01.csv-changed";
while($line=){
chomp $line;

$fields[3] =~

}
close csv;
close new;
exit;

[End of file]


Any help would be much appreciated as I only have two days to this
in!!!
Thanks,
GD



RE: newwin function

2001-07-05 Thread Sally

Surely if in the man pages the parameters are integers then only integers
can be used?


-Original Message-
From: George S Pereira [mailto:[EMAIL PROTECTED]]
Sent: 05 July 2001 10:16
To: [EMAIL PROTECTED]
Subject: newwin function



Hi All,

I'm using a Curses kit called CDK (Curses Development Kit).

There is a C function in one of the files which calls the system
function newwin(). The parameters given are the height, width, Xpos and
Ypos.

newwin() creates a window of the given height and width.

But the problem, is that, if I give 1.5 as the height. It creates
a window having the height just 1 line.

Is there any way that I can make the height to something like 1.5,
instead of 1, because, 1 is too small, and 2 is too big?

All of newwin parameter's according to the man pages are int.



George Savio Pereira

Email : [EMAIL PROTECTED]





Re:Win32::Driveinfo

2001-07-05 Thread Jorge Goncalvez

Hi, I try to use Win32::DriveInfo and I installed Win32-Api via ppm and when I 
want to use it I 've got the following error can't locate Win32/DriveInfo.pm in 
@INC.

Thanks.




newwin function

2001-07-05 Thread George S Pereira


Hi All,

I'm using a Curses kit called CDK (Curses Development Kit).

There is a C function in one of the files which calls the system
function newwin(). The parameters given are the height, width, Xpos and
Ypos.

newwin() creates a window of the given height and width.

But the problem, is that, if I give 1.5 as the height. It creates
a window having the height just 1 line. 

Is there any way that I can make the height to something like 1.5,
instead of 1, because, 1 is too small, and 2 is too big?

All of newwin parameter's according to the man pages are int.



George Savio Pereira

Email : [EMAIL PROTECTED]





Re:dynamic menu

2001-07-05 Thread Jorge Goncalvez

Hi, I would like to do a dynamic menu in Perl Tk ie I would like to display all 
available drive in my computer dynamically because now it has been hard written.
(A,B,C,D,E,F,G,H,I)
How I can do this.


My code:

sub makemenu{
my $menubar = $mw->Menu(-type => 'menubar',
-relief=>'flat');

$mw->configure(-menu => $menubar);

my $mnu0 = $menubar->cascade(-label => 'Control',
 -tearoff => 0,
 -font => "Arial 8 normal"
 );

$mnu0->command( -label => 'Quitter',
 -accelerator => 'Q',
 -font => "Arial 8 normal",
-command =>sub{$mw->destroy()});

$mnu0->separator();

my $mnu1 = $menubar->cascade(-label => '~Options',
 -tearoff => 0,
 -font => "Arial 8 normal"
 

 );

my $cc = $mnu1->cascade(-label=>'~Language');

$cc-> checkbutton (-label=>'Generic Alcatel', -variable => \$GENERIC);
$cc-> checkbutton (-label=>'French', -variable => \$FRENCH);


my $cc2 = $mnu1->cascade(-label=>'~Drive');

$cc2-> checkbutton (-label=>'A', -variable => \$A);
$cc2-> checkbutton (-label=>'B', -variable => \$B);
$cc2-> checkbutton (-label=>'C', -variable => \$C);
$cc2-> checkbutton (-label=>'D', -variable => \$D);
$cc2-> checkbutton (-label=>'E', -variable => \$E);
$cc2-> checkbutton (-label=>'F', -variable => \$F);
$cc2-> checkbutton (-label=>'G', -variable => \$G);
$cc2-> checkbutton (-label=>'H', -variable => \$H);
$cc2-> checkbutton (-label=>'I', -variable => \$I);

$mnu1->separator();

my $mnu2 = $menubar->cascade(-label => 'Alcatel',
 -tearoff => 0,
 -font => "Arial 8 normal"
 );

$mnu2->command( -label => 'About',
-accelerator => 'A',
-font => "Arial 8 normal",
-command =>sub{about()}
   );


} #end sub makemenu

 




Re: RE:regular expression

2001-07-05 Thread Me

> Hi, I have the following string into a file:
>
> LOG_INFO : cpcdos23.col.bsf.alcatel.fr: read request for
/bootp/popo.txt:
> success.
>
> And I have this code:
>
> my ($f)=@_;
> $thistime=(stat($f))[9];
> return if ($thistime == $mtime);
>
> $mtime=$thistime;
> my $dummy;
> open (FILE, $f) || warn "Couldn't open file $f: $!";
> @lines=;
> close (FILE);
> ($dummy, $IP_address, $read, $status)=split(":",$lines[$#lines-2]);
> $IP_address=~s/^\s*(.*)\s*$/$1/;
> ($client_name)=split(/\./,$IP_address);
> $read=~/.*bootp(.*)\s*/;
> $boot_file=$1;
> $install_file_path=~/\/(.+):/;
>
>
> It works fine but only ythe last line doesn't work in fact i want to
display
> /bootp/popo.txt.


> $install_file_path=~/\/(.+):/;

First, I'm pretty sure you expect this statement to set
$install_file_path to something, but the reverse is true;
the thing on the left of the =~ operator is assumed to be
the string being searched. If the thing to the left is not
defined, the statement does nothing. I'd assume you
want $read in place of $install_file_path.

Second, there's a ":" in your regex, but there can't be any
":"s in the string that's been split up, because ":" is the
character on which the original string was split, and the
character on which the string is split is thrown away
(unless you tell split to do otherwise).

Try:

$read=~/.*(\/bootp.*)\s*/;
$install_file_path=$1;





RE:regular expression

2001-07-05 Thread Jorge Goncalvez

Hi, I have the following string into a file:

LOG_INFO : cpcdos23.col.bsf.alcatel.fr: read request for /bootp/popo.txt: 
success.

And I have this code:

my ($f)=@_;
$thistime=(stat($f))[9];
return if ($thistime == $mtime);

$mtime=$thistime;
my $dummy;
open (FILE, $f) || warn "Couldn't open file $f: $!";
@lines=;
close (FILE);
($dummy, $IP_address, $read, $status)=split(":",$lines[$#lines-2]);
$IP_address=~s/^\s*(.*)\s*$/$1/;
($client_name)=split(/\./,$IP_address);
$read=~/.*bootp(.*)\s*/;
$boot_file=$1;
$install_file_path=~/\/(.+):/;


It works fine but only ythe last line doesn't work in fact i want to display
/bootp/popo.txt. 




mod_perl

2001-07-05 Thread Joel Divekar

Hi All

Today I installed Indigo Perl on my system and when I tried the sample code 
which came along with the installation to test mod_perl it gave an error as 
"Page not found"

I checked the following before posting
a) I found that the file exists
b) path in the html page is also correct.
c) Apache which came along with the installation is running and displays
 "Apache/1.3.19 (Win32) mod_perl/1.24_01 running..."
d) When I tried checking the $ENV if 'MOD_PERL' exist but failed 

Can you all help me in the following

a) I stared Perl programming with Activestate and today also I am using
 Activestate Perl on Win2k system but mod_perl from active state
 comes with a price tag Any suggestions ?

c) Is IndigoPerl right option for mod_perl programming

d) One important thing with Activestate, I never had any problem adding 
additional
 modules (Well not tried from CPAN). And I am loyal to Activestate only 
because of
 the simplicity and easy managebility.

e) I am looking for a Perl distribution which is simple to install and 
manage. I should be
 able to add modules without compiling (I don't have any C++ compiler). 
I want to
 do web programming using mod_perl on Win32 environment.

Please help me  this problem has been troubling me for months ... and 
for few day I have some time to shift to another distribution if required.

Regards

Joel


--
QuantumLink Communications, Bombay, India





  1   2   >