Re: Yin and Yang of Programming- Everyone talks about Python and says Perl is old news.

2004-09-28 Thread jason corbett
I am a martial artist for 14 years now. I have had
people ask what is the best art to practice? I tell
them look at yourself and see where you fit, how
physically fit are you, etc. Are you going to practice
daily, and live the Martial Way like Shaolin? Do you
have patience and lots of time to practice Tai Chi?
Are you an agressive muscle head who loves the gym and
a good bar fight, and would like Muy Thai or
Brazillian Jiu Jitsu? The answer is all are good if
your committed to the tasks!!  Become excellent at one
or two so you don't be mediocre like many!! People who
practice Martial Arts for example still get their A**
whipped by drunk folks in a bar! Why? Because they
train enough to get an ego, but not enought to become
a true expert! Take your Technical Skill the same as I
did my art and you won't have to worry about no
stinkin' PYTHON nor a guy with arm like a PYTHON!!

Ving Tsun for LIFE!!



--- Gavin Henry [EMAIL PROTECTED] wrote:

 I really like Perl, but lately everywhere I seem to
 go and talk to say I
 shouldn't be learning Perl as it's old and Python is
 better.
 
 Since starting to learn Perl though, every other
 language I started to
 learn/t, C, PHP etc. seem to make more sense now, as
 Perl has cleared
 things up.
 
 When I look at Perl, I can understand it (it kind of
 looks like bash),
 when I look at a Python script, ugh.
 
 I have been also trying to do some gui work with
 perl using wxperl, Python
 seems to be much better suited/supported (for wx)
 and I couldn't find very
 many docs for wxperl. What else is good looking to
 use?
 
 I love CPAN.
 
 Basically, my morale is getting low and I need a
 boost from you guys. Perl
 isn't old is it?
 
 I am on the right path?
 
 Be kind ;-)
 
 Thanks all,
 
 Gavin.
 
 -- 
 Just getting into the best language ever...
 Fancy a [EMAIL PROTECTED] Just ask!!!
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 http://learn.perl.org/
 http://learn.perl.org/first-response
 
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Foo (Bar)

2004-09-08 Thread jason corbett
As a newbie, I have seen the statement foo (bar) mentioned in books and and even on 
this site. I haven't yet seen what this actually mean as I can assume that its just 
for examples. If I am wrong please explain in detail what this is about.
 
Thanks,
JC


Foo (Bar)---I now see the light! (Or that which is made light of)

2004-09-08 Thread jason corbett
 
 
 


jason corbett [EMAIL PROTECTED] wrote:
As a newbie, I have seen the statement foo (bar) mentioned in books and and even on 
this site. I haven't yet seen what this actually mean as I can assume that its just 
for examples. If I am wrong please explain in detail what this is about.

Thanks,
JC


Need help with a Binding Variable excercise

2004-09-08 Thread jason corbett
I am trying to learn about binding variables. i am writing a simple script that with 
select a row of records and print them to screen. I am getting the error
Can't call method bind_param on an undefined value at porqout.pl line 29.
 
Here is the code below.
 
#!/usr/bin/perl -w
use strict; 
use DBI;
 
my $ctn_number='67846270';

 $dbh-prepare(select * from ctn_inv where ctn = ?);
 $sth-bind_param( 1,$ctn_number);
 
 $sth-execute();
 
$dbh-prepare(select * from ctn_inv where ctn = ?);
 $sth-bind_param( 1,$ctn_number);
 
 $sth-execute();
 
 while( my @record= $sth-fetchrow_array())
 
my $record_list = join ',', @record;
 print \n$record_list;  
 
my $sth-finish;
 $dbh-disconnect;
 exit;


Re: Need help with a Binding Variable excercise

2004-09-08 Thread jason corbett
Ooops!! Thanks!!

Jenda Krynicky [EMAIL PROTECTED] wrote:From: jason corbett 
 I am trying to learn about binding variables. i am writing a simple
 script that with select a row of records and print them to screen. I
 am getting the error Can't call method bind_param on an undefined
 value at porqout.pl line 29.
 
 Here is the code below.
 
 #!/usr/bin/perl -w
 use strict; 
 use DBI;
 
 my $ctn_number='67846270';
 
 $dbh-prepare(select * from ctn_inv where ctn = ?);
 $sth-bind_param( 1,$ctn_number);

Don't tell me strict doesn't complain!

Where do you declare $sth and where do you assign to it? It's the 
prepare() method that creates the statement object you should assign 
to $sth:

my $sth = $dbh-prepare(select * from ctn_inv where ctn = ?);
$sth-bind_param( 1,$ctn_number);
...


 $sth-execute();
 
 $dbh-prepare(select * from ctn_inv where ctn = ?);
 $sth-bind_param( 1,$ctn_number);
 
 $sth-execute();
 
 while( my @record= $sth-fetchrow_array())
 
 my $record_list = join ',', @record;
 print \n$record_list; 
 
 my $sth-finish;

What do you expect this to mean? The my definitely does not belong 
here, you do not want to create a brand new empty $sth and call a 
method on it.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






How to read data from and Excel File

2004-08-13 Thread jason corbett
Do I need to have a special module to open/read an Excel spreadsheet, parse it, etc.? 
I am trying to figure out if one is needed and what module is recommended. I went on 
CPAN and I saw SQL Parser, but I am not sure if this is best method.
 
Please advise.
 
JC


Using binding in order to pass values to a sql statement.

2004-08-06 Thread jason corbett
Hello all. I am trying to use bind_param to create a list of values in the form of an 
array. Then I want to query the data base using a basic sql statement where each value 
in my list (array) will be sent to the DBI in order to return a value. I am getting 
and error that says can't call method bind_param on defined value at line *. Here 
in the subroutine that will attempt to do this.
 
 
 
sub kill_porq{
my @banlist=qw(
222497190
291529832
285471249
280768305
276573798
278628710
297888281
297002394
271831939
127465
245710698
314086723
347803890
253926979
226200204
250702348
246597179
301791980
332270292
344909948
283580543
325838931
349835609
248436566
240499101
245185000
353432496
246334241
279430907
222800122
);
 my $ban='';
 foreach $ban (@banlist){
 
 
 $sth-bind_param (1, $ban);

 
 $sth=$dbh-prepare(select request_no, ban, request_sts, status_act, 
NPAC_Process_ind, external_req_no
  from vstappo.port_request
   where ban = ?
 );
 
 
 $sth-execute();
 
return;
}


setting the environment variables in perl

2004-07-27 Thread jason corbett
How does one go about assuring that the environment variables are properly set in 
perl? I read several books, but none go in depth about how to write a script that 
includes all the required variables, that way nothing gets left out. 
 
Please advise.
 
JC
 
[snipet]
 
 
#!/usr/bin/perl -w

$ENV{ORACLE_HOME}=/orav101/oracle/8.1.7;

use strict; 
use DBI;
use lib '/home/samcsm/jason/myperl/lib/perl5/site_perl/';

 



Having trouble using the Shell within Perl script.

2004-07-26 Thread jason corbett
Hello. I would like to use the shell to run SQL scripts or PL/SQL scripts written by 
co-workers. These scripts are useful and I don't need to do re-work so I am trying to 
use them in my perl script where i can retrieve the data that results from running 
them into a $scalar, @array, or %hash. I cannot seem to GET the values/or variables to 
be stored into a perl variable that I created. Can anyone help me do this? I actually 
have it where I call a sub routine that goes out and runs the script, but I am not 
able to get the data when I return from the shell.
 
Thanks,
JC


Changing the return value of a built in function

2004-07-26 Thread jason corbett
Hello all. I am running into a problem with a proprietary job scheduler that mimicks 
the Cron on a Unix box (with more bells and whistles that a cow farm, but with the 
same amout of BS).
 
I ran a script using DBI-trace(2, 'dbitrace.log'); and noticed that the 
$sth-execute( ); function is returning a value of 6. Question: Can I change this in 
my script to return any value once the SQL script is done? If not, is there a way to 
trick the return value i.e. store it somewhere and if its 6 then return success or 
something?
 
 
thanks
 
 
 
[snitpet of the log file from trace]
 
 fbh 124: 'BAN_UTC_UC_AMT' NULLable, otype   2-  5, dbsize 22/40, p9.s2
  out: ftype 5, bufl 41. indp 0, rlen 0, rcode 0
fbh 125: 'BAN_UTC_TAX_AMT' NULLable, otype   2-  5, dbsize 22/40, p9.s2
  out: ftype 5, bufl 41. indp 0, rlen 0, rcode 0
fbh 126: 'BAN_UTC_ADJ_AMT' NULLable, otype   2-  5, dbsize 22/40, p9.s2
 
 - prepare= DBI::st=HASH(0x4032a6c8) at 4dayreport.pl line 150
- execute for DBD::Oracle::st (DBI::st=HASH(0x4032a6c8)~0x40329164)
dbd_st_execute (for sql f4 after oci f8, out0)...
dbd_st_execute complete (rc0, w00, rpc6, eod0, out0)
- execute= 6 at 4dayreport.pl line 152
- fetchrow_array for DBD::Oracle::st (DBI::st=HASH(0x4032a6c8)~0x40329164)
- fetchrow_array= ( '218990326' '2' '21-MAY-01' '07-JUL-01' undef 'BLCONF' 


How to return to perl from SQL query?

2004-07-23 Thread jason corbett
How can I run a sql script in Oracle and assure that the query won't hang up in the 
Oracle database and yet allow me to fetch data?
 
I am trying several methods, but its still failing. Please advise.
 
JC


Returning variables from sub routines.

2004-07-23 Thread jason corbett
I have a sub routine that I created called dateme.
when i run the sub routine, I am getting errors that Global symbol $process_date 
requires explicit package name at What gives?
 
Thanks,
JC
 
Here is the snipet
 
#---called from
 
dateme( );
 
 
#---
sub dateme{

my $process_date=' '; 
 
  $process_date=localtime( );
 
 return $process_date;

}



Re: Returning variables from sub routines.

2004-07-23 Thread jason corbett
Your correct. Actually I was trying to pass that variable back when it was local to 
the sub routine instead of assigning it to a variable outside the routine i.e 
$process_data2=dateme( );
 
where process_data2 is either global or assigned as my OUTSIDE that particular routine.
 
Thanks,
JC

Flemming Greve Skovengaard [EMAIL PROTECTED] wrote:
jason corbett wrote:
 I have a sub routine that I created called dateme.
 when i run the sub routine, I am getting errors that Global symbol $process_date 
 requires explicit package name at What gives?
 
 Thanks,
 JC
 
 Here is the snipet
 
 #---called from
 
 dateme( );
 
 
 #---
 sub dateme{
 
 my $process_date=' '; 
 
 $process_date=localtime( );
 
 return $process_date;
 
 }
 
 

There is no problem in this sample code.
But somewhere else in your program you must use $process_date without
declaring it first.

-- 
Flemming Greve Skovengaard The killer's breed or the Demon's seed,
a.k.a Greven, TuxPower The glamour, the fortune, the pain,
Go to war again, blood is freedom's stain,
4112.38 BogoMIPS Don't you pray for my soul anymore.



DBI Failure with certain types of queries

2004-07-23 Thread jason corbett
I have a the query below that I am reading from a file and placing in the $sql 
variable.
 
i.e. [snipet]---reads any query in a file to the variable $sql
 
if (open(FOURDAYQ, $fourdayquery)){
 while (FOURDAYQ){
 
 chomp(@myquery=FOURDAYQ);}
 close(FOURDAYQ);
 return @myquery;
  
}
else {
 die open(ERRORLOG, $errorlog)  print ERRORLOG \n$process_date\nQuery is not 
available\n; return 0;}
 
When I get the query into the variable, I try to prepare it using 
$sth=$dbh-prepare($sql); 
 
It is failing and I am not sure why. When I place the query into the variable by 
assignment it works. As long as i first assign the variable, then all is good. 
 
[snipet]-Assignment
i.e. $sql = qq(select p.ban BAN,
   (s.subscriber_no) Ported Number,
  n.last_business_name CONSUMERLNAME,
n.first_name CONSUMERFNAME,
b.account_type,
c.carrier_name Service Provider,
p.sys_creation_date Initiation Date of the Request

 I would like to have a [erl script that will read any SQL query from a file given to 
it and then run the query from within the perl script. Any ideas?
Thanks,
JC



RE: DBI Failure with certain types of queries

2004-07-23 Thread jason corbett
Yes I do. Here THEY are :(
 
PS. Do you think binding will help?
 
 

String found where operator expected at ./select_n.pl line 117, near ban BAN

(Do you need to predeclare ban?)

Bareword found where operator expected at ./select_n.pl line 120, near n.first_name

(Might be a runaway multi-line .. string starting on line 118)

String found where operator expected at ./select_n.pl line 120, near first_name 
CONSUMERFNAME

(Do you need to predeclare first_name?)

String found where operator expected at ./select_n.pl line 122, near carrier_name 
Service Provider

(Do you need to predeclare carrier_name?)

String found where operator expected at ./select_n.pl line 123, near 
sys_creation_date Initiation Date of the Request

(Do you need to predeclare sys_creation_date?)

Bareword found where operator expected at ./select_n.pl line 126, near from

(Missing semicolon on previous line?)

Bareword found where operator expected at ./select_n.pl line 131, near carrier

(Might be a runaway multi-line ,, string starting on line 128)

(Missing semicolon on previous line?)

Bareword found where operator expected at ./select_n.pl line 137, near and 
p.port_path

(Might be a runaway multi-line .. string starting on line 135)

(Do you need to predeclare and?)

Bareword found where operator expected at ./select_n.pl line 141, near where 
S2.request_no

(Might be a runaway multi-line .. string starting on line 139)

(Do you need to predeclare where?)

Bareword found where operator expected at ./select_n.pl line 145, near and 
anl.name_id

(Might be a runaway multi-line .. string starting on line 142)

(Do you need to predeclare and?)

syntax error at ./select_n.pl line 117, near ban BAN

Execution of ./select_n.pl aborted due to compilation errors.



Bob Showalter [EMAIL PROTECTED] wrote:
jason corbett wrote:
 ...
 When I get the query into the variable, I try to prepare it using
 $sth=$dbh-prepare($sql); 
 
 It is failing and I am not sure why.

Do you have RaiseError set to 1? What is the error message after the
prepare?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





How do i return the end of file message in a subroutine?

2004-07-22 Thread jason corbett
I am using an application called Title to kick off jobs instead of using the cron.
I am told that this application doesn't accept SQL embedded inside perl scripts unless 
the SQL  or perl script returns the end of file message. What method in perl returns 
the eof message?
 
is it 
 
sub myroutine {
 
$sql = qq( select * from mytable where rownum  1001);
 
} return eof;
 
 
or calling eof( ) i.e.
 
sub myroutine {
 
$sql = qq( select * from mytable where rownum  1001);
 
eof( ) }
 
return;
 
or are both of these wrong?
 
Thanks,
JC



[This is what I needed]Pattern Matching records from a table query.

2004-07-19 Thread jason corbett
Thanks. I was using the Pipe thing, but the fact is my client wants it in Excel and to 
be able to open it immediately and not click around with the parameters as they are 
not Excel friendly (go figure). I appreaciate your willingness to carry the question 
out to a solution/example and not a quick fix!
 
JC

Charles K. Clarkson [EMAIL PROTECTED] wrote:
jason corbett wrote:

: I want to eliminate the .  (periord) or , (comma) from
: records that I return from a query, but I cannot figure out
: how to approach it. Does Perl have a way that I can match a
: string that from an array, remove a character or characters?
: 
: 
: For example say I have array @records that contain the
: following:
: 
: Myrecord1 Myrecord2 Myrecord3 Myrecord4
: Myrecord5, inc. Myrecord6, LP Myrecord7, LLC
: 
: I want to send this query out to persons in a .csv file but
: the join(,, @record) statement that I am using causes the
: and extra cell to be created at Myrecord5, inc. Myrecord6, LP
: Myrecord7, LLC. 
:
: What I am thinking is to scan records $record[4, 5, 6] by
: using regex matching, and if a comma exists, delete it or
: replace it with ; . I am looking for some commands to do
: this, or at least point me in the right direction.
:
: Any suggestions?

You mention an extra cell. If you are using this for
import to a spreadsheet, you should be able to wrap suspect
fileds with double quotes. Try this.

$_ = qq($_) foreach @record[4, 5, 6];
my $record_list = join ',', @record;


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



Re: Pattern Matching records from a table query.

2004-07-19 Thread jason corbett
Thanks James. I am going to try this method also. Your input is very much appreciated.
 
JC

James Edward Gray II [EMAIL PROTECTED] wrote:
On Jul 16, 2004, at 3:46 PM, jason corbett wrote:

 I want to eliminate the .  (periord) or , (comma) from records 
 that I return from a query, but I cannot figure out how to approach 
 it. Does Perl have a way that I can match a string that from an array, 
 remove a character or characters?


 For example say I have array @records that contain the following:

 Myrecord1 Myrecord2 Myrecord3 Myrecord4 Myrecord5, inc. 
 Myrecord6, LP Myrecord7, LLC

 I want to send this query out to persons in a .csv file but the 
 join(,, @record) statement that I am using causes the and extra cell 
 to be created at Myrecord5, inc. Myrecord6, LP Myrecord7, LLC.

How about?

tr/.,//d foreach @records;

James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Pattern Matching records from a table query.

2004-07-16 Thread jason corbett
I want to eliminate the .  (periord) or , (comma) from records that I return from 
a query, but I cannot figure out how to approach it. Does Perl have a way that I can 
match a string that from an array, remove a character or characters?
 
 
For example say I have array @records that contain the following:
 
Myrecord1   Myrecord2Myrecord3Myrecord4Myrecord5, inc. Myrecord6, LP 
Myrecord7, LLC
 
I want to send this query out to persons in a .csv file but the join(,, @record) 
statement that I am using causes the and extra cell to be created at Myrecord5, inc. 
Myrecord6, LP Myrecord7, LLC. 
 
 
What I am thinking is to scan records $record[4, 5, 6] by using regex matching, and if 
a comma exists, delete it or replace it with ; . I am looking for some commands to 
do this, or at least point me in the right direction. Any suggestions? 
 
 


Still getting warning for Use of uninitialized value in join or string (Please Help)..

2004-07-15 Thread jason corbett
 
I would like to know why this warning is coming back:
 
Use of uninitialized value in join or string at  line 65.

 
 
#!/usr/bin/perl -w
use strict; 
use DBI; 
 
$ENV{ORACLE_HOME}=/orav101/oracle/8.0.6; 
 
[snipet]  


  
  my @record=( );
 
 while( @record= $sth-fetchrow_array( ))
  
{  

 my $recordlist = ' ';
 $recordlist=join(,,@record); #This statement is causing the problem
 


  }exit;
 
$dbh-disconnect;
 
 


RE: Still getting warning for Use of uninitialized value in join or string (Please Help)..

2004-07-15 Thread jason corbett
I see. I guess when I use SQL Plus app. I don't get back any blank cells so I am not 
sure how that is happening. I'll just use the 'no warnings' and move forward. Thanks 
again.


Ed Christian [EMAIL PROTECTED] wrote:
jason corbett wrote:
 I would like to know why this warning is coming back:
 
 Use of uninitialized value in join or string at line 65.

[snip]

 while( @record= $sth-fetchrow_array( ))
 
 {
 
 my $recordlist = ' ';
 $recordlist=join(,,@record); #This statement is causing the problem
 
 
 
 } exit;

Jason,

Sorry if I wasn't clear in my earlier response to you. If there are NULL
values in your array, you will get this warning when you try joining the
elements of the array.

Example:

[EMAIL PROTECTED]:/usr2/local/cablemanager/etc 01:24 PM]$ perl -e 'use warnings;
use strict; my @array; $array[0] = hi; $array[3] = hello; my $string
= join(,,@array); print $string\n;'
Use of uninitialized value in join or string at -e line 1.
Use of uninitialized value in join or string at -e line 1.
hi,,,hello


Your SELECT statement is returning NULL values. If this is expected and
you still want the join to concatenate the other values into a string,
then ignore the warnings. Within your while loop, throw in a no
warnings 'uninitialized'; to quiet that warning. See:

perldoc warnings
perldoc perllexwarn

Otherwise, you'll have to clean up your SELECT statement and ensure that
all of the fields you're looking for are populated. (add WHERE clauses
and such)


Hope that helps,
- Ed


[Solved] Still getting warning for Use of uninitialized value in join or string (Please Help)..

2004-07-15 Thread jason corbett
Actually there are null values coming back periodically from the query. I wasn't aware 
that the table I was using with the SQL PLUS application is static inside an auxillary 
database (with the same name) whereas the table that the Perl script is hitting is 
LIVE and periodically gets updated (by the minute). So the times that I was using the 
SQL PLUS application, I never saw NULL values there. Sorry for the wasted time.
 
JC

perl.org [EMAIL PROTECTED] wrote:
On Thu, 15 Jul 2004 10:22:26 -0700 (PDT), jason corbett wrote
 
 $recordlist=join(,,@record); #This statement is causing the problem
 

I didn't follow the original thread, but if you put:

select nvl( column, '' )

instead of just selecting the column, do you still get the warning?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





RE: Still getting warning for Use of uninitialized value in join or string (Please Help)..

2004-07-15 Thread jason corbett
Thanks Charles. I am just 4months old into Perl. I am actually using th tracing DBI 
utility right now to see what is actually happening.
 
Regards,
JC

Charles K. Clarkson [EMAIL PROTECTED] wrote:
jason corbett wrote:

: I would like to know why this warning is coming back:
:
: Use of uninitialized value in join or string at line 65.

There is an undefined value in @record.

print join ',', 1, 2, undef, 4;



You can test for this with Dumper() from the Data::Dumper
module. Look for a value of undef (without the quotes).

If you find an undefined value, adjust your query to
eliminate it or change undefined values in @record to
something else.


use Data::Dumper 'Dumper';

.
.
.

print Dumper [EMAIL PROTECTED];
next;
my $record_list = join ',', @record;


This is called debugging. You might also read up on
the various debugging tools that come with perl. Get used
to these things. Debugging is as much a part of
programming as problem solving.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328




Extracting headers of a Table in Perl.

2004-07-14 Thread jason corbett
I want to query a database and get data, but the headers don't come back. Is there a 
way that I can extract the headers of a table using Perl? Would it be easier to create 
a format, or should this be done in my SQL script? I don't have 'write' authority to 
the script. I just call it or read it and then run the script from where its at on the 
server.
 
Thanks,
JC


Re: MIME coding flags for sending a .csv or Excel file (Question)

2004-07-13 Thread jason corbett
Thanks John. This was my first PERL program that I wrote and I wasn't sure when to use 
the my vs the our, but your points are well respected. I need more practice to 
understand how the functions/script work so that I can condense the programming 
better. 
 
Question: Is the scalar function always use to return values in a sub? Or is this a 
quick and easy way to do this without using the actual return statement?
Thanks,
JC

John W. Krahn [EMAIL PROTECTED] wrote:
On Monday 12 July 2004 08:21, jason corbett wrote:

 Here is the script that I am using. Remember that the script creates
 the file perfectly and stores the file with data in a folder on the
 server. The emailed copy is being sent out blank.

 #!/usr/bin/perl

use warnings;

 use strict;
 use DBI;
 use lib '/home/samcsm/jason/myperl/lib/perl5/site_perl/';
 use MIME::Lite;


 our ($dbh); #
 our (@files); #
 our ($filename); #
 our ($errorlog); #logs all successes and failures of the report
 our ($dirfolder); #where the treatment report is sent prior to emailing
 our (@record); #holds all records returned from query
 our ($success_var); #flags the script if completion was successful or not
 our ($sql); #
 our ($sth); #
 our ($dayreport); #
 our ($process_date); #used in the log file to tell what date and time a file 
 complete or failed
 our ($month); #
 our ($day); #
 our ($year); #
 our ($truename); #Time stamps the name of each treatment report AFTER the GENERIC 
 name is changed
 our (@times); #Helps Timestamp the treatment reports each day
 our ($reportlog); #Folder for keeping up with all Treatment reports
 our ($fourdayreport); #the path that leads to the location of the generic 4 day 
 report
 our ($recordlist); #allows the for manipulation of data retrieved from query

You should really use 'my' instead or 'our' to declare variables
unless you REALLY REALLY need 'our'. The parentheses are not
required unless you are declaring more then one variable.

our $variable; # no parens required
our ( $var1, $var2 ); # Must use parens

If you had used the warnings pragma you would have been told that
@files, $filename and @record are not being used anywhere which
brings up the next point. You should declare your variables when
you first use them instead of all at the beginning of the program.


 #set up for the file naming covention
 @times = (localtime)[3..5]; # grabs year/month/day values
 ^^
I had to do a double take when I read this. The comment says
year/month/day but the code says day/month/year.


 $month = $times[1] + 1;
 $day = $times[0];
 $year = $times[2] + 1900;

You don't really need the @times array at all:

my ( $day, $month, $year ) = (localtime)[3..5];
$month += 1;
$year += 1900;


 $truename = Tr0.$month.0.$day.$year._4day.csv\n; #Time stamps each file 
 once generic file is renamed

Wow, interpolation AND concatenation. Perhaps either:

my $truename = 'Tr0' . $month . 0 . $day . $year . _4day.csv\n;

Or:

my $truename = Tr0${month}0$day${year}_4day.csv\n;


 [snip code]

 dateme(); #call dateme function and store value in $process_date

Your comment says that you are storing the value in $process_date
so why don't you code it like that:

my $process_date = dateme();


 $success_var = data_collect(); #call data_collection function and store the word 
 success #or failed in $success_var variable

 my $logvariable = logresults($success_var); #call the logresults function and send 
 the success or failed

 mailman(); #call mailman function

 print $logvariable\n; #print the results returned from logresults function

 close(OUTFILE); #close file for errorlog and query
 close(ERRORLOG);

 $dbh-disconnect; #disconnet


 #---SUB ROUTINE FOR COLLECTING 
 DATA---

[ whitespace changed to show error ]

 sub data_collect
 {
 unless (open(OUTFILE,$fourdayreport)) #open 4daytreatment.csv
 {
 die open(ERRORLOG, $errorlog)  #or die and open errorlog.txt
 print ERRORLOG Sorry file $dayreport couldn't be created\n;
 return Failed;
 } #print into errorlog.txt message
 else{
 while( my @record= $sth-fetchrow_array()) #while theres data, collect
 {
 $recordlist=join(,,@record); #separate records with a , and store
 print OUTFILE $recordlist\n; #print to newformatted records to
 #the generic file 4daytreatment.csv
 }
 return success; #send back the word success when done
 }

You are missing the closing subroutine brace!!!

 [snip code]

 #---SUB ROUTINE for Time 
 Stamp-
 sub dateme{
 $process_date=localtime(); #call localtime funcion and store as scalar value

 }return $process_date; #return scalar value of the localtime function

Your return statement is OUTSIDE the subroutine!!!
You are returning a value but you DON'T USE IT!!!

You can use the scalar() function to return a scalar value:

sub dateme {
return scalar localtime;
}



John
-- 
use Perl

What is Use of uninitialized JOIN error?

2004-07-13 Thread jason corbett
Can anyone tell me what is happening here?
 
Thanks,
JC
 
Here is the part of the code that the error is pointing to

 print OUTFILE $recordlist\n; 
$recordlist=join(,,@record);



[The Subroutine] What is Use of uninitialized JOIN error?

2004-07-13 Thread jason corbett
Thanks all for the feedback on the WARNING message that I am getting. I know that I 
can turn warning off at that moment of code, but I want to know for my own knowledge 
what is the warning all about. So, here is the entire sub routine. NOTE** I declared 
@records as a global earlier..
 
JC
 
sub data_collect {unless (open(OUTFILE,$fourdayreport)) 
 
{die open(ERRORLOG, $errorlog) 
 
print ERRORLOG Sorry file $dayreport couldn't be created\n; return Failed;}  
 
else{
 
 while( @record = $sth-fetchrow_array() )  
 { 
# no warnings;  
 
 my $recordlist=join(,,@record);   
   
 print OUTFILE $recordlist\n;   
 
   }return success; 
   
   } 
}
[EMAIL PROTECTED] wrote:




Where do you populate @record? Such messages occur when populating an
array with contents of a file (if the file contains a bunch of newlines).
So make sure you know what the array is getting populated with by testing.


Also, you want to join before printing, correct? So swap the lines (but
that is not the cause of the warning).

 print OUTFILE $recordlist\n;
$recordlist=join(,,@record);

I will try to view the contents of @record with
foreach my $item (@record) {
print  . item: $item\n;
}




__

William Ampeh (x3939)
Federal Reserve Board



My (variable) versus Our (variable)! Please explain the necessity for use....

2004-07-13 Thread jason corbett
Hello folks. I am very thankful for all the help that I am getting here. The only 
thing is when I get some suggestions, I don't normally get the whys along with it. 
One in particular is use of my to assign variables, versus using our. Until I can 
get a Perl scripting class to take, I am teaching myself and sometimes these books 
don't delve into the simple things. So who can answer this?
 
Thanks,
JC



Re: [The Subroutine] What is Use of uninitialized JOIN error?

2004-07-13 Thread jason corbett
I used ---print OUTFILE join(,,@record), \n;--- that you suggested and still got 
the error.
 
 
sub data_collect {unless (open(OUTFILE,$fourdayreport)) 
 
 {die open(ERRORLOG, $errorlog)  
 
   
print ERRORLOG Sorry file $dayreport couldn't be created\n; return Failed;} 
 
 
else{
 while( @record= $sth-fetchrow_array())  

 { 
 print OUTFILE join(,,@record), \n;  
 
 OUTFILE $recordlist\n}
 
return success; }
 
 
}



[EMAIL PROTECTED] wrote:




sub data_collect {unless (open(OUTFILE,$fourdayreport))

{die open(ERRORLOG, $errorlog) 

print ERRORLOG Sorry file $dayreport couldn't be created\n; return
Failed;}

else{

while( @record = $sth-fetchrow_array() )
{
# no warnings;

#INSERTED :::
#Since you are not doing anything with $recordlist, I will do one of the
following:
print OUTFILE join(,,@record), \n;

#OR:
for ( my $i = 0; $i  $#record; $i++) {
( $i  $#record ) ? print $record[$i], : print $record[$i]\n;
}

#::INSTEAD OF :
my $recordlist=join(,,@record);

print OUTFILE $recordlist\n;

}return success;

}
}

__

William Ampeh (x3939)
Federal Reserve Board


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: [The Subroutine...revisited] What is Use of uninitialized JOIN error?

2004-07-13 Thread jason corbett
Here is what I am doing. I shortend the sub, using local variables, and simplifying 
the whole thing to just print to screen. I use your loop once I collect the records 
into the @record variable and join them with ,...
 
Still to no avail, that menacing warning stays.
 
Thanks.
 
 
my $sql=qq( select * from bill where rownum 100
);
 
my $sth=$dbh-prepare($sql);
 
$sth-execute();
 
my $recordlist;
my $dayreport = /cygdrive/c/cygwin/my_Perl/basic_script/testfile.txt;

my @record;

  

 while( @record= $sth-fetchrow_array())
  
{  


 $recordlist=join(,,@record); #This statement is causing the problem

for ( my $i = 0; $i  $#record; $i++) 
{
  print $record[$i],;
}

print $record[$#record]\n;



  }exit;
 
$dbh-disconnect;

[EMAIL PROTECTED] wrote:





What about manually stepping through the array elements?

That is:

for ( my $i = 0; $i  $#record; $i++) {
print $record[$i],;
}
print $record[$#record]\n;


__

William Ampeh (x3939)
Federal Reserve Board



Re: [The Subroutine] What is Use of uninitialized JOIN error?

2004-07-13 Thread jason corbett
Use of uninitialized value in concatenation (.) or string at select_c.pl line 70
and error
Use of uninitialized value in join or string at select_c.pl line 65.
 
are whats showing up
[EMAIL PROTECTED] wrote:




What about manually stepping through the array elements?

That is:

for ( my $i = 0; $i  $#record; $i++) {
print $record[$i],;
}
print $record[$#record]\n;



__

William Ampeh (x3939)
Federal Reserve Board



RE: [The Subroutine...revisited] What is Use of uninitialized JOIN error?

2004-07-13 Thread jason corbett
I have seen null values come up, but when I do this same query in SQL Plus (Oracle 
environment BTW), I am getting no null values.

Ed Christian [EMAIL PROTECTED] wrote:jason corbett wrote:
 Here is what I am doing. I shortend the sub, using local variables,
 and simplifying the whole thing to just print to screen. I use your
 loop once I collect the records into the @record variable and join
 them with ,... 
 
 Still to no avail, that menacing warning stays.
 
 Thanks.
 
 
 my $sql=qq( select * from bill where rownum 100
 );

Explicitly name the columns you want to select on. It could end up
saving you a bunch of headaches in the long run. Also, go into the MySQL
CLI and type your command in, just to make sure you're getting back what
you want... I'm willing to bet that you're getting back NULL values in
one or more of your columns, which may be causing problems in the join
statement.

 
 my $sth=$dbh-prepare($sql);
 
 $sth-execute();
 
 my $recordlist;
 my $dayreport =
 /cygdrive/c/cygwin/my_Perl/basic_script/testfile.txt; 
 
 my @record;
 
 
 
 while( @record= $sth-fetchrow_array())
 
 {
 
 

For debugging, try adding in the following lines:

use Data::Dumper;
print # of columns:  . @record . \n;
print [EMAIL PROTECTED]:\n . Dumper([EMAIL PROTECTED]) . \n;

You may find that your whole array is, in fact, populated with NULL
values...

 $recordlist=join(,,@record); #This statement is causing the problem
 
 for ( my $i = 0; $i  $#record; $i++)
 {
 print $record[$i],;
 }
 
 print $record[$#record]\n;
 
 
 
 } exit;
 
 $dbh-disconnect;



Re: MIME coding flags for sending a .csv or Excel file (Here is the code)

2004-07-12 Thread jason corbett
 attached files are automatically generated daily by 
WNP. If there are any problems with the reports or delivery of reports, please contact 
the CSM on call person at 123-456-7890.');
 
my $message=MIME::Lite-build(
From ='[EMAIL PROTECTED]',
To ='[EMAIL PROTECTED]',
#Cc =
Subject ='Four Day Out Report',
Type ='multipart/mixed',
   
);

 $message-attach ( Type = 'TEXT',
Data ='This email and all attached files are automatically generated daily by 
WNP. If there are any problems with the reports or delivery of reports, please contact 
the CSM on call person at 123-456-7890.');
 
 $message-attach ( 
Path  ='/home/samcsm/treatment/4daytreatment.csv',
type  ='File/.csv',
Filename =$truename,
Disposition ='attachment',
Encoding = 'base64'
);
 
 $message-send;

 return;
 
}#end of mailman subroutine

#---End of 
Script-
 }

Jenda Krynicky [EMAIL PROTECTED] wrote:
From: jason corbett 
 I am sending Excel and .csv files via MIME and it appears that the
 file is created on the server with the needed data, but when the
 script is supposed to email a copy, I am getting blank .csv files. 

Just a wild guess ... are you closing the .csv or Excel files before 
trying to send them? I've heard from someone who was trying to send 
some Excel files created with Spreadsheet::WriteExcel and was 
receiving them empty or incomplete and the problem was that he did 
not close the files first so some of the data was not in the file 
yet.

If this is not the problem show us a piece of code.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: MIME coding flags for sending a .csv or Excel file (Here is the code)

2004-07-12 Thread jason corbett
I will move the close(ERRORLOG) and the close(OUTFILE) as you pointed out and retry. 
As for the parameters, I am passing parameters to only certain functions. I will 
however take note of the mistake with logresults(). Do you think that not passing 
parameters to other functions is incorrect? I am new to this so I am open to 
suggestions.
 
Regards,
JC

Jenda Krynicky [EMAIL PROTECTED] wrote:
From: jason corbett 
 Here is the script that I am using. Remember that the script creates
 the file perfectly and stores the file with data in a folder on the
 server. The emailed copy is being sent out blank.

Seems the problem IS in what I said. Try to move the
close(OUTFILE);
before the
mailman();
call. Or even better. If you open the OUTFILE in data_collect() and 
write to it only in data_collect, you should as well close it in the 
function. Same with ERRORLOG and logresults();

Jenda
P.S.:
mailman(); #call mailman function
??? Such comments do not aide the readability. Just the oposite.
You should only comment the stuff that's not trivial.

P.P.S.: The function logresults() ignores the parameter you pass it. 
The function accesses the global variable $success_var instead! 
Actually none of your functions take any parameters!
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: Is Thank you okay? [was: where to put modules?]

2004-07-09 Thread jason corbett
Good point!

Gunnar Hjalmarsson [EMAIL PROTECTED] wrote:Christopher J. Bottaro wrote:
 thank you everyone for the replies. one quick question though. is
 it customary to thank people for replies? or does it just cause
 more unecessary traffic on the newsgroup?

I'm pretty new here, and don't know for sure if it's considered
customary on this list or not, but I have a view.

I consider myself to be relatively human, and assume that others who
answer questions here do, too. ;-) IMO, saying thanks is good
manners here just like in the rest of the world.

One observation I have made is that this list sometimes looks like a
help desk forum: Somebody asks a question, and get one or a few
replies, and that's it. I don't know if that's how it's supposed to
be, but personally I would like to see more of follow-up comments on
posted suggestions, both from the original posters and from others. I
believe that everyone would benefit from such exchange of thoughts.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






Re: Creating or renaming a file with the creation date included (Impossible?)

2004-07-08 Thread jason corbett
So I guess to automate a script daily, and save it under a name that includes the date 
can only be done with rename() function? Or is there a work around that includes a 
module? If so, please let me know.
 
Regards.
JC

Randal L. Schwartz [EMAIL PROTECTED] wrote:
 Jason == Jason Corbett writes:

Jason How can i rename a file or create a file with the date
Jason included? For example, I want to automate and run reports and
Jason save the reports under the date of when they were created
Jason i.e. JC07082004. Whats the easiest way to do this? Thanks, JC

If you're on Unix, it's impossible. Creation dates/times are not
recorded.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Excel format from a PERL script

2004-07-08 Thread jason corbett
I know this may sound crazy (I have asked crazy question before here so I hope this 
doesn't get me banned!!) but I have this client who receives automated reports from me 
every day from a PERL script. The script comes in a .csv format (changed from .txt 
format) and now they are asking me if I can send it in Excel format.
 
The reason? I had a problem with the server that runs the script, so I used an 
application to query the database and retrieve the data and it just so happens that 
the app. exports the data into Excel, whereas my script doesn't. Now they want it in 
Excel (i guess the few conversion steps cost them too much to hire some one who knows 
Excel other than save , delete, open, exit). 
 
So can Perl save me a mouthful of curse words by doing this SMALL task?
 
Humbly at your mercy,
JC


Re: Excel format from a PERL script

2004-07-08 Thread jason corbett
SPER!! Thanks!!


[EMAIL PROTECTED] wrote:

they want it in Excel (i guess the few conversion steps cost them too much
to hire some one who knows Excel other than save , delete, open,
exit).

So can Perl save me a mouthful of curse words by doing this SMALL task?
___
There is an excellent module by John Macnamara called SpreadsheetWriteExcel
(or something like that). i've used both the Perl version and the port to
PHP...very easy to work with, and has tons of features.

HTH
jeff
_

Humbly at your mercy,
JC








Re: Excel format from a PERL script

2004-07-08 Thread jason corbett
Cool! I appreaciate that!

[EMAIL PROTECTED] wrote:



If I understand your question correctly, then all you is
Spreadsheet::WriteExcel
It comes with an example which is very easy to follow. I have used this
quite a bit and like I said, it is very easy to follow.

__

William Ampeh (x3939)
Federal Reserve Board




MIME coding flags for sending a .csv or Excel file

2004-07-08 Thread jason corbett
I am sending Excel and .csv files via MIME and it appears that the file is created on 
the server with the needed data, but when the script is supposed to email a copy, I am 
getting blank .csv files. 
 
My question:
 
Do I need to identify the file in MIME as a .csv or Excel?
Are there flags that I need to set?
 
Thanks,
JC


Creating or renaming a file with the creation date included......

2004-07-07 Thread jason corbett
How can i rename a file or create a file with the date included? For example, I want 
to automate and run reports and save the reports under the date of when they were 
created i.e. JC07082004. Whats the easiest way to do this? 
 
Thanks,
JC


RE: Creating or renaming a file with the creation date included......

2004-07-07 Thread jason corbett
thanks. I wasn't aware of the rename function. As far as converting to MMDD, can 
that be done on the fly using localtime()? I am reading online docs now, but nothing 
talks about it done on the fly i.e. when I call the function up. If not I will work on 
it some more and follow up with whatever I find out.
 
Regards.


Wiggins d Anconia [EMAIL PROTECTED] wrote:


 jason corbett wrote:
  How can i rename a file or create a file with the date included? For
  example, I want to automate and run reports and save the reports
  under the date of when they were created i.e. JC07082004. Whats the
  easiest way to do this? 
  
  Thanks,
  JC
 
 Using localtime in conjunction with time, you can roll your own
little setup. 
 

Additionally, if you didn't know already, Perl has a 'rename' function
built in, or if you are going to g across file system boundaries you
should look at the File::Copy module.

perldoc -f rename
perldoc -f time
perldoc -f localtime
perldoc File::Copy

Additionally you might consider using the Compress::Zlib for compression
of the logs, and you should definitely consider changing your naming
convention to be MMDD as that will allow the files to sort properly
in their directory.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Attachment(s) not being emailed (shooting blanks!!)

2004-07-06 Thread jason corbett
I am using the script below to mail out attachments after running a job. When I run 
the script, it send out an email with an attachment that is untitled and blank. I want 
to add the attachment which is a text file (myfile.txt) located in 
/home/servername/myfile. Can you see what is wrong in my file?
 
Thanks,
JC
 
 
sub mailman {
 
my $message=MIME::Lite-new(
From ='[EMAIL PROTECTED]',
To ='[EMAIL PROTECTED]',
Subject ='This is a test of the MIME::Lite Mod',
Type ='text/plain',
   
);
 
 $message-attach ( 
From ='[EMAIL PROTECTED]',
To ='[EMAIL PROTECTED]',
Subject ='This is a test of the MIME::Lite Mod',
Type ='text/plain',
Path ='/home/samcsm/jason/treatment',
Id ='fourdayout.txt',
$message-send;
 return;
 
}#end of mailman subroutine



Re: Attachment(s) not being emailed (shooting blanks!!)

2004-07-06 Thread jason corbett
I am not sure what is actually the error. i followed an example to send an HTML doc 
out based on perldoc MIME's example.

JupiterHost.Net [EMAIL PROTECTED] wrote:

jason corbett wrote:
 I am using the script below to mail out attachments after running a job. When I run 
 the script, it send out an email with an attachment that is untitled and blank. I 
 want to add the attachment which is a text file (myfile.txt) located in 
 /home/servername/myfile. Can you see what is wrong in my file?
 
 Thanks,
 JC
 
 
 sub mailman {
 
 my $message=MIME::Lite-new(
 From ='[EMAIL PROTECTED]',
 To ='[EMAIL PROTECTED]',
 Subject ='This is a test of the MIME::Lite Mod',
 Type ='text/plain',
 
 );
 
 $message-attach ( 
 From ='[EMAIL PROTECTED]',
 To ='[EMAIL PROTECTED]',
 Subject ='This is a test of the MIME::Lite Mod',
 Type ='text/plain',
 Path ='/home/samcsm/jason/treatment',
 Id ='fourdayout.txt',

These two entries are not what you said above, is that it by chance?

 $message-send;
 return;
 
 }#end of mailman subroutine


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






I fixed the email problem, but guess what.......

2004-07-06 Thread jason corbett
Ok, I fixed the problem with emailing the file, but its now coming with some type of 
symbols [EMAIL PROTECTED]
 
the file that i am trying to send has been properly created, but MIME::Lite isn't 
emailing it. Its emailing me a textfile with the same name as the file onthe server, 
but without the data in it. Here is the new code:
 
 
 
sub mailman {
 
my $message=MIME::Lite-build(
From ='[EMAIL PROTECTED]',
To ='[EMAIL PROTECTED]',
Subject ='This is a test of the MIME::Lite Mod',
Type ='multipart/mixed',
   
);
 
 $message-attach ( 
From  ='[EMAIL PROTECTED]',
To  ='[EMAIL PROTECTED]',
Subject  ='This is a test of the MIME::Lite Mod',
Type  ='text/plain',
Path  ='/home/samcsm/jason/treatment',

Filename ='fourdayout.txt',
Disposition ='attachment'
   );
 
$message-send;
 return;
 
}#end of mailman subroutine



All Email problems are now resolved (Thanks for your efforts!)

2004-07-06 Thread jason corbett
I was able to narrow down the problem and fix the code. I apologize if I took your 
time away from other trouble shooting tasks. I am still recovering from alchohol and 
Barb-B-Que!!!
 
Good day!


Still having problems installing MIME::Lite locally.

2004-07-02 Thread jason corbett
Here is where I am in the process:
 
I have MIME::Lite located on the server in a folder called 
/home/samcsm/jcorbett/myperl/lib
 
I use this simple script to test out emailing a query below and get the error stating 
that cannot find MIME/Lite.pm' anywhere.
 
Now mind you I have MIME/Lite.pm installed in 
 
/home/samcsm/jcorbett/myperl/lib/perl5/site_perl/MIME/Lite.pm
 
Can you tell me whats wrong?

#!/usr/bin/perl 
use warnings;
use strict;
use DBI;
use MIME::Lite;
 
BEGIN{
unshift (@INC, '/home/samcsm/jason/myperl/lib/perl5/site_perl/MIME/Lite.pm');}
 
$ENV{ORACLE_HOME}=/orav101/oracle/8.0.6; 

#Gather data for connecting to database:
 

our ($sql);
our ($sth);
our ($dbh);
our (@record);
our (@files);
our ($filename);
our ($recordlist);
our $database_temp=dbi:Oracle:#;
our $username=#;
our $passwd=#;

 
$dbh = DBI-connect($database_temp, $username, $passwd) or  
$dbh-{RaiseError} = 1;
 
 
#Set up your sql statement that you want to run in Oracle
 
 $sql=qq( select * from bill where rownum 100);

$sth=$dbh-prepare($sql);
 
#Execute the SQL statememt

$sth-execute();
 
 
while(@record= $sth-fetchrow_array())

 { 
 
 $recordlist=join(|,@record);
 }
 
$sth-finish;

$dbh-disconnect;
 
 my $message=MIME::Lite-new(

From:  ='[EMAIL PROTECTED]',

To:  ='[EMAIL PROTECTED]',

Subject: ='This is a test of the MIME::Lite Mod',
   
 Data  =$recordlist
 
);
 
 
$message-send;
 

 
 
 /home/samcsm/jcorbett/myperl/lib/perl5/site_perl/MIME/Lite.pm


Re: PERL Error when running MIME::Lite

2004-07-01 Thread jason corbett
Thank you. That was a more clearer answer. 
 
Good day!

Wiggins d Anconia [EMAIL PROTECTED] wrote:
 jason corbett wrote:
  How can I install it when I don't have root rights to place it in
the bin?
 
 First, please reply to the list. Second, either get the person who
does have 
 root access to install the module or install it locally in your home
dir and add 
 it to your @INC (someone else can tell you how to do that).
 

Generally this is handled by adding a PREFIX switch to either the perl
Makefile.PL command or by configuring the 'makepl_arg' setting in CPAN.
Additionally you may want to set the LIB switch as well.

See, 5) I am not root, how can I install a module in a personal
directory?

in perldoc CPAN (near the bottom)

Having installed the module, you will then want to add a line similar to,

use lib qw( /path/to/new/lib/dir );

In your script(s). If you don't where the script will live on the system
but can make the new lib directory relative to the script you should
have a look at,

perldoc FindBin

Or consider having the users set the PERL5LIB environment variable with
the new path, for instance in bash,

export PERL5LIB=/path/to/new/lib/dir

HTH, come back if you get stuck or have more questions,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: PERL Error when running MIME::Lite

2004-07-01 Thread jason corbett
I looked at perldoc CPAN for 5 as you stated below, and didn't find anything there. 
It seems like there are some information missing as to how I would install modules and 
use them without being root. Where you stated by configuring the 'makepl_arg' setting 
in CPAN, I would like more information on that also. I was wondering if I needed the 
CPAN module? What would I set the PERL5LIB variable to  if I am using this 
script/module combo on other servers? Finally, i was told by another member on the 
site that mutt... is also an easy way of mailing attachments. Can you expand on this 
if your aware of it?

Hopefully this is not taking too much of your time, but I didn't expect not to be shut 
out of this server that I am supposed to be working on.

Thanks,

JC


Wiggins d Anconia [EMAIL PROTECTED] wrote:
 jason corbett wrote:
  How can I install it when I don't have root rights to place it in
the bin?
 
 First, please reply to the list. Second, either get the person who
does have 
 root access to install the module or install it locally in your home
dir and add 
 it to your @INC (someone else can tell you how to do that).
 

Generally this is handled by adding a PREFIX switch to either the perl
Makefile.PL command or by configuring the 'makepl_arg' setting in CPAN.
Additionally you may want to set the LIB switch as well.

See, 5) I am not root, how can I install a module in a personal
directory?

in perldoc CPAN (near the bottom)

Having installed the module, you will then want to add a line similar to,

use lib qw( /path/to/new/lib/dir );

In your script(s). If you don't where the script will live on the system
but can make the new lib directory relative to the script you should
have a look at,

perldoc FindBin

Or consider having the users set the PERL5LIB environment variable with
the new path, for instance in bash,

export PERL5LIB=/path/to/new/lib/dir

HTH, come back if you get stuck or have more questions,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: Using Perl on a UNIX box where you have no ADMIN rights....

2004-07-01 Thread jason corbett
AWESOME!! Thanks!

zentara [EMAIL PROTECTED] wrote:On Wed, 30 Jun 2004 10:27:22 -0700 (PDT), [EMAIL 
PROTECTED] (Jason
Corbett) wrote:

I want to use perl thats installed on a server here at work. I want to install 
modules that will enhance my scripts, avoiding having to do calls to the shell for 
things that perl already has in place. How can i do this? I know that its more of a 
unix question, but I hope that there is something that can be done.

Do a google search for installing perl modules locally.

Basically what you do is:

1. Make a directory for your local libs in your homedir, say Perl5
2. Put in your .bashrc export PERL5LIB=/home/user/Perl5
3. When you make modules, and do make Makefile.pl, you add the
prefix= configuration option, like:
perl Makefile.pl --prefix=/home/username

You may need to tweak the --prefix location to get it where you want.
Just try a module and see where it installs, then adjust accordingly.

If you are allowed access to the c compiler, you should be able to
have any module you wanteven your own version of Perl.



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






Using Perl on a UNIX box where you have no ADMIN rights....

2004-06-30 Thread jason corbett
I want to use perl thats installed on a server here at work. I want to install modules 
that will enhance my scripts, avoiding having to do calls to the shell for things that 
perl already has in place. How can i do this? I know that its more of  a unix 
question, but I hope that there is something that can be done.
 
Thanks.
JC


PERL Error when running MIME::Lite

2004-06-30 Thread jason corbett
Cannot locate MIME/Lite.pm in @INC. @INC contains: 
/usr/local/perl156/lib/5.6.1/PA-RISC2...
 
Any one know about this?
 
Thanks,
JC



Installing a module when you have limited permissions

2004-06-29 Thread jason corbett
Hello. I wanted to know if someone has installed a PERL module on a server where they 
had limitied permissions? I am not extremely UNIX savy but I do know the basic and 
know the something about the file structures, etc. Can someone tell me how I can 
install MIME::Lite on a server where I may use it, and give others permission to use 
my install?
 
Thanks,
JC


Time stamping a process in a log file

2004-06-28 Thread jason corbett
i want to use the sub routine to time stamp processes and such whenever 
i need to. So, I wrote this below to call the routine into a variable 
$process_date. Is there a better way to read the date into a variable 
and use it?

Thanks,

JC
sub dateme{
  $process_date=system('return date');

}return;




How to email my results to a group of people....

2004-06-28 Thread jason corbett
I have a script that is automated every morning. 
I want to send this out to the team without logging onto the network and emailing the 
file from a shell script that i also wrote like this:
 

`mailx -s Email Header [EMAIL PROTECTED]  filename.txt`;

 

so, I hear PEAL has emailing (in attachment format) capabilities? I down-loaded the 
module MIME::Lite, but I am not sure how to get this going. Can anyone help? Or is 
there a better (or other) way?

Regards,

JC



Using MIME::Lite to send mail/or attachments

2004-06-23 Thread jason corbett
Can anyone tell me where I can find MIME::Lite or any other perl method to send 
attachments/documents in mail format? If you have tips or scripts on using it to send 
mail (documents attached), please let me know.
 
Thanks,
JC



The Proper way to define a global variable.

2004-06-22 Thread jason corbett
Hello. I am using variables that are local in my scripts by doing the my 
$variable_name technique.
 
Can someone tell me if there is an official way to define a global variable?



Creating a format for a table of data

2004-06-16 Thread jason corbett
I need to create headers that I can use when querying data from the database. It seems 
that I am not making the right code because it hasn't shown up in my file, but I also 
don't get any errors. Can some look at the code and tell me where I am going wrong?
 
thanks
JC
 

#Connecting to the database:database=database_name1','$username','$passwd'

my $dbh = DBI-connect($database, $username, $passwd) 
or die Can't connect to Oracle database: $!\n $DBI::errstr\n; 

$dbh-{RaiseError} = 1;
 
#Set up your sql statement that you want to run in Oracle

my $sql=qq( select * from bill where rownum100
);
 
#Prepare the SQL statement for running and it'll be stored in Oracle buffer

my $sth=$dbh-prepare($sql);
 
#Execute the SQL statememt

$sth-execute();
 
#my $i=0;

#my $count=0;

my $recordlist;

my $dayreport = /cygdrive/c/cygwin/my_Perl/basic_script/testfile.txt;
 
my @record;

format MYFORMAT = 
BAN
@
$recordlist,
.

unless (open(OUTFILE,$dayreport)){ print Sorry file $dayreport couldn't be 
created\n}
else{
 
while( @record= $sth-fetchrow_array())
  
{

 $recordlist=join(|,@record);

write (MYFORMAT);
print OUTFILE $recordlist\n;
  

  }   
}
 
close(OUTFILE);

#$count++;  #tells number of records
#print $count;  #and prints number at the end of the program

$dbh-disconnect;


SQL PLUS

2004-06-11 Thread jason corbett
What would I need to call SQL Plus into action for PERL?


-
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

Best Technique to display a query.

2004-06-11 Thread jason corbett
What technique can I use to take a quick SQL query and get the data back in columns 
and rows? I am trying to make a format template, but I would like a way to make a 
quick display template that will work with all my simple SQL queries.
 
 
Thanks,
JC


-
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

What the 'FETCH' is up with Perl?

2004-06-10 Thread jason corbett
Hello all. Can someone tell me what is the difference in the various ways to FETCH 
data from a database? I bought like 3 books and they don't really go in depth with the 
reasons why there are several of them, and what happens if you interchange them with 
different scenarios.
 
Thanks.
 
Here are the ones that I am asking about:
 
Fetch
Fetchrow
Fetchrow_array
fetchall_arrayref
fetchrow_hashref
 
Any others please add explanation.
Thanks.
JC
 
 


-
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

Have you seen this error before?

2004-06-10 Thread jason corbett
I am getting the error: 
 
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
ARRAY(0x1024df4)
 
when I run the script below:
 
 
#!/usr/bin/perl -w
use strict; 
use DBI; 

my $dbh = DBI-connect($database, $username, $passwd) 
  or die Can't connect to Oracle database: \n $DBI::errstr\n; 

$dbh-{RaiseError} = 1;
#Set up your sql statement that you want to run in Oracle
my $sql=qq( select ctn from ctn_inv where rownum 11
);
 
#Prepare the SQL statement for running and it'll be stored in Oracle buffer
my $sth=$dbh-prepare($sql);
#Execute the SQL statememt
$sth-execute;

while( my $record= $sth-fetch())
{
 
 print $record\n;
}


-
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

I need to use data collected from a query

2004-06-09 Thread jason corbett
I am writing a script that'll query the database, and I want to do 2 things:
 
1. Print it to screen with my desired format.
 
If I like what I see:
 
2. Print it to a file.
 
Any suggestions?
 
Here is my query for writing to a file:
 
__
 
 
#!/usr/bin/perl -w
 
use strict; 

use DBI; 
 
#  $ENV{ORACLE_HOME}=/orav101/oracle/8.0.6; 

#Gather data for connecting to database:

print Enter the database name that you want to connect to: ;
chomp (my $database_name1=STDIN);

print Enter the username: ;
chomp (my $username=STDIN);

print Enter the password: ;
chomp (my $passwd=STDIN);

#Must define the database here:
my $database=dbi:Oracle:$database_name1;

#Connecting to the database:database=database_name1','$username','$passwd'

my $dbh = DBI-connect($database, $username, $passwd) 
  or die Can't connect to Oracle database: \n $DBI::errstr\n; 

$dbh-{RaiseError} = 1;
 
#Set up your sql statement that you want to run in Oracle

my $sql=qq( select * from ctn_inv where rownum 10
);
 
#Prepare the SQL statement for running and it'll be stored in Oracle buffer
my $sth=$dbh-prepare($sql);
 
#Execute the SQL statememt
$sth-execute;

 
my $outputme=  /cygdrive/c/cygwin/my_Perl/basic_script/testfile1.txt;
my @record_list;
my $record;
 
 
  while { @record_list = $sth-fetchrow_array;
 } 
 
open(TESTFILE1, $outputme);

  foreach $record (@record_list)
 {
  print  TESTFILE1;
  }
close($outputme);

$dbh-disconnect;
 
 


-
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

Query Oracle, show results (need help!!)

2004-06-08 Thread jason corbett
Hello all. I am trying to log into an Oracle database, send this query {
select * from ban where row num  100} and I am getting erros like:
 
can't call method 'execute' on an undefined value at (filename) line_number. Got any 
suggestions?
 
 
using the following perl script:
 
#!/usr/bin/perl -w
use strict; 
use DBI; 
#  $ENV{ORACLE_HOME}=/orav101/oracle/8.0.6; 

#Gather data for connecting to database:
 
 
print Enter the database name that you want to connect to: ;
chomp (my $database_name1=STDIN);
print Enter the username: ;
chomp (my $username=STDIN);
print Enter the password: ;
chomp (my $passwd=STDIN);

#Must define the database here:
my $database=dbi:Oracle:$database_name1;

#Connecting to the database:database=database_name1','$username','$passwd'

#Note the variables for username and password must be username and passwd ONLY!!
my $dbh = DBI-connect($database, $username, $passwd) 
  or die Can't connect to Oracle database: \n $DBI::errstr\n; 

#Set up your sql statement that you want to run in Oracle
my $sql=qq(select * from ban where row num  100);
 
Prepare the SQL statement for running and it'll be stored in Oracle buffer
my $sth=$dbh-prepare($sql);
 
#Execute the SQL statememt
$sth-execute || die Couldn't execute statement;

while (my @record= $sth-fetchrow_array)
{
 for  (@record){
  print (@record);
}
print \n\n;
}

$dbh-disconnect;
 
 
 


-
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

Connecting to Oracle over network

2004-05-24 Thread jason corbett
Hello. I am using Windows 2000 to connect to an Oracle database over the company 
network. I have the DBI/DBD drivers installed on my computer. I want to connect using 
the script below. When i run the script, it doesn't come back with anything. It just 
goes to the command prompt. Can someone tell me how to do this, and what env variables 
need to be set and where? I am not using any proxies btw.
 
Regards,
JC
 
#!perl -w
use strict; 
use DBI; 
#  $ENV{ORACLE_HOME}=what goes here??; 
my $dbh = DBI-connect('DBI:Oracle:','[EMAIL PROTECTED]','passwd' 
 ) or die Can't connect to Oracle database: \n $DBI::errstr\n; 
my $msg = 
  $dbh-selectrow_array( 
 SELECT SYSDATE || ' Hello Cygwin DBI! :-)' message FROM DUAL 
   ); 
# Let's have some formatting fun! :-) 
my $msg_len = length( $msg ); 
my $underline = '=' x ($msg_len + 6); 
print \n, $underline, \n, 
|| , ' ' x $msg_len,  ||, \n, 
|| , $msg,  ||, \n, 
|| , ' ' x $msg_len,  ||, \n, 
$underline, \n\n; 
$dbh-disconnect;



-
Do you Yahoo!?
Yahoo! Domains - Claim yours for only $14.70/year