Re: DBI question (again)

2001-08-02 Thread Ray Barker



>Extracted from the perl cookbook
>
>use DBI;
>
>$dbh = DBI->connect('DBI:driver:database', 'username', 'auth',
>{ RaiseError => 1, AutoCommit => 1});
>$dbh->do($SQL);
>$sth = $dbh->prepare($SQL);
>$sth->execute();
>while (@row = $sth->fetchrow_array) {
># ...
>}
>$sth->finish();
>$dbh->disconnect();
>
>Concerning this code i have some questions ( i thinks it is very
badly
>documented in the man pages)
>
>-what does '->' stand for ?
>- what does prepare do ?
>- is there a _GOOD_ documentation about this ? I just want some
sample code
>how to make some selects that return multiple data, and than see how
the
>multiple rows are handled with ...
>

good info on using the DBI module (should take you right to prepare):
http://theoryx5.uwinnipeg.ca/CPAN/data/DBI/DBI.html#prepare

There is also a good O'Reilly book titled "Using the Perl DBI" (or
something like that) by Alligator Descartes

-> is the dereference operator--the cookbook won't teach you much
about it

In your case, the $dbh = DBI... returns a database handle(=a
reference to a database object in OO speak).
Then the >$dbh->do($SQL);   runs the do method of the $dbh object

The code you've copied from the cookbook is a bit of nonsense meant
as an example. To make it work you have to fill in the driver, the
database name etc. in the DBI->connect call and you have to put a
legal SQL statement in the $SQL variable.  This is covered in the
above DBI documentation.  In my copy of the cookbook, example 14-7 is
a more nearly working example, but you would still have to point it
to your database.


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




Re: DBI question (again)

2001-08-02 Thread Elie De Brauwer



> good info on using the DBI module (should take you right to prepare):
> http://theoryx5.uwinnipeg.ca/CPAN/data/DBI/DBI.html#prepare
>
> There is also a good O'Reilly book titled "Using the Perl DBI" (or
> something like that) by Alligator Descartes
>

I know of the existence of that book but the problem is, if i order that book 
it would take abount one month to actually have it, and this project has to 
be finished before that ... so i am really searching online material ...

> -> is the dereference operator--the cookbook won't teach you much
> about it
>
> In your case, the $dbh = DBI... returns a database handle(=a
> reference to a database object in OO speak).
> Then the >$dbh->do($SQL);   runs the do method of the $dbh object
>
> The code you've copied from the cookbook is a bit of nonsense meant
> as an example. To make it work you have to fill in the driver, the
> database name etc. in the DBI->connect call and you have to put a
> legal SQL statement in the $SQL variable.  This is covered in the
> above DBI documentation.  In my copy of the cookbook, example 14-7 is
> a more nearly working example, but you would still have to point it
> to your database.

I know it is an example, as in i can make it work i type it in add the driver 
add the query and it works perfectly but i'm not happy with that i want to 
know WHY is works and WHAT it does.

I know but exemple 14-7 isn't a really query it's just an insert  i am 
more interested in query's 

-- 
<==>
 real men do it in perl ;)

 De Brauwer Elie 
   [EMAIL PROTECTED]
<==>

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




Extended patterns

2001-08-02 Thread baby lakshmi

Hi
I really dont understand what is the difference between the patterns and 
extended patters.. i think both are doin the same function. But why they 
called as extended??
Help pointers in this regard will be really helpful.
Thank you
Regards
Babylakshmi M


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


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




inserting lines

2001-08-02 Thread COLLINEAU Franck FTRD/DMI/TAM

Hi!

How can i do to insert several lines in the beginning of a existant file ?

Thanks

Franck

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




Re: DBI question (again)

2001-08-02 Thread Robert Graham

Have a look a the "Short Guide to DBI" available at perl.com  It has an
example with queries.
http://www.perl.com/lpt/a/1999/10/DBI.html

Regards
Robert

- Original Message -
From: "Elie De Brauwer" <[EMAIL PROTECTED]>
To: "Ray Barker" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 10:15 AM
Subject: Re: DBI question (again)


> 
>
> > good info on using the DBI module (should take you right to prepare):
> > http://theoryx5.uwinnipeg.ca/CPAN/data/DBI/DBI.html#prepare
> >
> > There is also a good O'Reilly book titled "Using the Perl DBI" (or
> > something like that) by Alligator Descartes
> >
>
> I know of the existence of that book but the problem is, if i order that
book
> it would take abount one month to actually have it, and this project has
to
> be finished before that ... so i am really searching online material ...
>
> > -> is the dereference operator--the cookbook won't teach you much
> > about it
> >
> > In your case, the $dbh = DBI... returns a database handle(=a
> > reference to a database object in OO speak).
> > Then the >$dbh->do($SQL);   runs the do method of the $dbh object
> >
> > The code you've copied from the cookbook is a bit of nonsense meant
> > as an example. To make it work you have to fill in the driver, the
> > database name etc. in the DBI->connect call and you have to put a
> > legal SQL statement in the $SQL variable.  This is covered in the
> > above DBI documentation.  In my copy of the cookbook, example 14-7 is
> > a more nearly working example, but you would still have to point it
> > to your database.
>
> I know it is an example, as in i can make it work i type it in add the
driver
> add the query and it works perfectly but i'm not happy with that i want to
> know WHY is works and WHAT it does.
>
> I know but exemple 14-7 isn't a really query it's just an insert  i am
> more interested in query's 
>
> --
> <==>
>  real men do it in perl ;)
>
>  De Brauwer Elie
>[EMAIL PROTECTED]
> <==>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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




RE: inserting lines

2001-08-02 Thread John Edwards

$orginalFile = "c:\\file.txt";
$newFile = "c:\\newfile.txt";

$textToAdd = "New text\nSecond line ofnew text\n";

open IN, $originalFile or die "Can't open $originalFile: $!";
open OUT, ">$newFile" or die "Can't create $newFile: $!";

print OUT $textToAdd;

while() {print OUT};

close IN;
close OUT;

That should do it. You can then delete the original file and rename the new
one like this.

unlink($originalFile) or die "Can't delete $originalFile: $!";
rename ($newFile, $originalFile) or die "Can't rename $newFile to
$originalFile: $!";

HTH

John
-Original Message-
From: COLLINEAU Franck FTRD/DMI/TAM
[mailto:[EMAIL PROTECTED]]
Sent: 02 August 2001 09:35
To: Perl (E-mail)
Subject: inserting lines


Hi!

How can i do to insert several lines in the beginning of a existant file ?

Thanks

Franck

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


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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




perl debugger

2001-08-02 Thread Ruth Albocher

hi all.
Is there any good stable graphic debugger for perl?
thanks


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




Problems - File Uploading and creation date

2001-08-02 Thread Rajeev Rumale

Dear firends,

I have situation were user can upload a file to our web base application.
The problem is with the date of creation. When ever a new file is uploaded,
I need to first check of the file with same name exists.  If it exist then i
need to check if it is newer than the file being uploaded and prompt the
user accordingly.

For this I need to get the original date of creation of the file being
uploaded.

Any ideas?

I am using Active Perl with IIS 4.0 on Win2k system.

with regards

Rajeev




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




Re: AW: y me

2001-08-02 Thread Brent Michalski


Yeah, I read more after I sent the mail...  I was thinking that the program
didn't produce any output rather than the cgiwrap error.

Oh well, i guess i'll read the whole problem next time before sending
email

brent



   
   
"Alessandro
   
Lenzen" To: "Brent Michalski"  
   
   
   
hausen.de>  cc:
   
Subject: AW: y me  
   
08/02/01 07:09 
   
AM 
   
   
   
   
   




I don't think so. The \n only adds a new line. What does that have to do
with the problem?
al

-Ursprüngliche Nachricht-
Von: Brent Michalski [mailto:[EMAIL PROTECTED]]
Gesendet: Donnerstag, 2. August 2001 14:02
An: peter lee
Cc: [EMAIL PROTECTED]
Betreff: Re: y me



Heehee, I have seen this before and it is enough to drive a person crazy!

Add a \n to the end.  So you have... print ("hello world.\n");


I bet that this "fixes" your program...

Brent




peter lee
 cc:
 Subject: Re: y me
08/02/01
12:37 AM






hi all,

 i went to basics and wrote a simple hello script.

#!/usr/bin/perl
print ("hello world.");

permission=755

still no luck.  :(  whats weird is that the first line

is the same as other working perl scripts.

pete



--- matthschulz <[EMAIL PROTECTED]> wrote:
> 2 possibilities I got in mind:
>
> 1.   Your script is not executable
> 2.   try ./scriptname
>
>
> Am Mittwoch,  1. August 2001 19:34 schrieben Sie:
> > hi all,
> >
> >  i have a new script that i put in the same
> directory as
> > other working scripts, however when i try to
> execute
> > i keep getting a "cgiwrap error: execution not
> permitted
> > ...script file not found"
> >
> > any ideas?
> >
> > thanks,
> > pete
>
>
>


=
"Computer games don't affect kids; I mean if Pac-Man affected us as kids,
we'd all be running around in darkened rooms, munching magic pills and
listening to repetitive electronic music."
(Kristian Wilson, Nintendo, Inc, 1989)

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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






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







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




RE: Valid DB Handle Assertion Test

2001-08-02 Thread Bob Showalter

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 9:44 AM
> To: [EMAIL PROTECTED]
> Subject: Valid DB Handle Assertion Test
> 
> 
> 
> Can I test for the existence of a method without actually calling it?

I don't know. Maybe, but some methods are implemented via AUTOLOAD, so may
not "exist" in the sense you mean.

> 
> Basically what I'm trying to do is to verify that $dbh is 
> still a valid
> handle.
> I want to use this as an assertion test at the start of a function.
> 
> # verify that the $dbh is valid
> if ( !defined($dbh->disconnect() ) )
>  {
>  print "dbh is invalid\n" ;
>  exit 1
>  }

Well, this won't work, becuase it's testing the result returned from calling
$dbh->disconnect.

You have 3 possiblities with $dbh:

1. $dbh is a reference to a connected database handle.

2. $dbh is a reference to an unconnected database handle.

3. $dbh is not a reference to a database handle at all.

You can use perl's ref() function to distinguish the first two cases from
the last. see

   perldoc -f ref

Once you know you have a database handle, you can use $dbh->{Active} to
tell whether it is connected (per DBI docs, although this may vary from
driver to driver). Actually, calling disconnect on an unconnected handle
seems to be harmless and treated as a no-op.

Another approach is to wrap the disconnect in eval, which lets you capture
the error rather than having it stop your program:

   eval { $dbh->disconnect(); };

If $dbh is not a database handle, the relevant error message will be in $@.

   perldoc -f eval

> 
> # $dbh is valid so we can safely disconnect
> $dbh->disconnect()

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




Re: Where is DB_File::Lock module?

2001-08-02 Thread Abdulaziz Ghuloum

Hello,

It's on cpan:

http://search.cpan.org/search?dist=DB_File-Lock

Hope this helps,,,

Aziz,,,

In article <[EMAIL PROTECTED]>, "Carlos C .
Gonzalez" <[EMAIL PROTECTED]> wrote:

> Hi everyone,
> 
> I am going absolutely nuts trying to find where to get the DB_File::Lock
> module.  I have looked all over CPAN, have done searches on Google.com
> and while there is some info on it I can't find out where to download
> it.
> 
> Does anyone have any suggestions?
>

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




number of line

2001-08-02 Thread COLLINEAU Franck FTRD/DMI/TAM

Hi!

I would like to store the number of a line whitch corresponds to a string.

How can i do ?

Thanks

FRanck 

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




Confusion with hash reference and Mail::IMAPClient

2001-08-02 Thread Chris Rogers

I am using the Mail::IMAPClient module and the extension BodyStructure to
connect to Exchange Server 5.5. Everything seems to be working great ( I
love this module ) except for one thing. When I use the BodyStructure
extension, either nothing is being returned in the object or I don't know
how to access it. I can log on to server, query the mailbox and all it's
folders without any trouble but I can't seem to get a message bodystructure.
The docs show one example but I can't seem to get it to work for me. Here's
a snippet of code:
#
use CGI;
use Mail::IMAPClient;
use Mail::IMAPClient::BodyStructure;

$imapp = Mail::IMAPClient->new (
Server =>
$servername,
User =>
$username,
Password =>
$password,
Uid => 1,
Debug => 1
);
$imapp->select($foldername);
my $struct =
Mail::IMAPClient::BodyStructure->new($imapp->fetch($msguid,"bodystructure"))
;
$btype = $struct->bodytype;
$bsubtype = $struct->bodysubtype;

#

When the code is run, I don't get any errors but I don't get the
bodystructure either. I have tried this many different ways but none seem
to work. Having turned on the debug option, I can see that the request is
sent to the server and the server does respond:

3 UID FETCH 12 bodystructure

Sent 30 bytes
Read: * 2 FETCH (BODYSTRUCTURE ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL
NIL "7BIT" 489 9 NIL NIL NIL) UID 12)
3 OK FETCH completed

If I print $struct, I get the following though the =HASH(...) part varies:
Mail::IMAPClinet::BodyStructure=HASH(0x87d6b64)

If anyone has any ideas, please let me know. Any help would be greatly
appreciated.

Thanks,
Chris



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




Re: inserting lines

2001-08-02 Thread Paul


--- COLLINEAU Franck FTRD/DMI/TAM
<[EMAIL PROTECTED]> wrote:
> Hi!
> 
> How can i do to insert several lines in the beginning of a existant
> file ?
> 
> Thanks
> 
> Franck
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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




Re: Valid DB Handle Assertion Test

2001-08-02 Thread JCervoni


It appears that the only kind of assertion test I could do would be to test
$dbh like this

if ( !defined($dbh) || $dbh eq '' )
 {
 print "dbh is invalid\n" ;
 exit 1
 }

Jeff

> Can I test for the existence of a method without actually calling it?
>
> Basically what I'm trying to do is to verify that $dbh is still a valid
handle.
> I want to use this as an assertion test at the start of a function.
>
> # verify that the $dbh is valid
> if ( !defined($dbh->disconnect() ) )
>{
>print "dbh is invalid\n" ;
>exit 1
>}
>
> # $dbh is valid so we can safely disconnect
> $dbh->disconnect()
>
>Jeff



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




RE: shared hash - how ?

2001-08-02 Thread Brian

Somebody on the mod_perl mailing list might be able to help you better
than somebody on the begginers perl list.  This is a bit OT (okay, it's
way out in left field.  If you go to http://perl.apache.com you can sign
up for the list.

#!/usr/bin/Brian Johnson
$job= "Laziness";
$pay= 0;
$motivation = "None";
$business   = "Source1Results.com, LLC";
$website= "www.source1results.com";
if($contact_brian) {
  $sendmail = "brianj\@source1results.com";
}

> 
> Hi All!
> 
>  I'm developing a multilanguage site on apache with mod_perl.
> A dictionary is stored in database.
> All page must to access the database to find the words in the selected
> language. It can be slow.
> I tought, I should make a hash to store the text when it come first
> form the database. The cgi will look for the text in the hash first
> then the database if it not found in the hash.
> 
> Q: How can I share the hash between the processes ?
> 
> Thanks, Gabor.
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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




Certification

2001-08-02 Thread Shepard, Gregory R


I was looking online for information on Perl Certification but only found
people discussing it, and not where to get it. Is certification available?
And who provides the most valid certification?
Thanks!




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




Re: File Handling question - easy

2001-08-02 Thread Michael Fowler

On Thu, Aug 02, 2001 at 11:03:23AM -0700, Jon wrote:
> My problem is, I want to do this for a bunch of different patterns (ex. 
> ".txt", ".this", ".that").

You could say <*.txt *.this *.that>, or you can use opendir, readdir, and a
regex (perhaps grep).


> How can I make what is inside the angle brackets a variable?

You don't, it can confuse Perl and users having to look at your code.  Use
glob() instead of angle brackets, in this case.

$pats = "*.txt *.this *.that";
print join("\n", glob($pats);


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

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




Re: Putting results of find into an array

2001-08-02 Thread Michael Fowler

On Wed, Aug 01, 2001 at 10:08:13AM -0700, Greg Tomczyk wrote:
> 
> Thank you for the response. I must confess that I have been reading the
> Perldocs, but I am having some logic troubles, difficult to understand how
> to use File::Find.  I tried using the push routine, but that listed all
> files instead of only listing all files that have "domain.com".

find() is pretty simple; you give it a subroutine and a list of directories,
and it recursively finds files in those directories and calls the subroutine
for each file (remember, directories are files too).

my @files;
find(\&wanted, "...");

sub wanted {
if (match criteria goes here) {
push(@files, $File::Find::name);
}
}



> If I change code back to print("$name\n"); It will list only files found
> that meet grep criteria.

The code you have, with the correction I showed you, will push onto @files
only those files that match.


> I would much rather do the whole thing in straight perl, but I need
> the find to recursively search directories and not cross filesystems or
> links, as well as tell me the names and locations of files.

File::Find::find is straight Perl, and does exactly what you need.


> To cleanup the routine exec, I am not sure how to do it, and have it do
> what I want.

As I said, simply replace it with a call to system() and check the return
value.  That is largely what the find2perl doexec() is already doing, but it
has extra code in there for handling {} and -ok.


I'm trying, possibly vainly, to explain everything from a broad perspective. 
Your questions don't really include anything specific that can be explained.
If you could look through the code being used, and try to point out things
you're confused about, this list could help you better.


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

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




Re: regular expression

2001-08-02 Thread Jeff 'japhy/Marillion' Pinyan

On Aug 2, Messervy, Joe M said:

>I want to get rid of machine1, machine2, and machine4 as there were no
>matching logs for these events.
>I tried as a test perl -p -i -e 's//nmachine//g' myfile   and get the
>following error:
>Illegal division by zero at -e line 1, <> line 1. (and all data is lost in
>myfile).

Um, you have an extra / in your s///.  Also, there is no "nmachine" in
your file.

You MEANT to do

  s/nmachine//g;

but you probably REALLY meant to do

  perl -n -i -e 'print unless /machine/' myfile

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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




Re: memory for implied array/list read

2001-08-02 Thread Michael Fowler

On Thu, Aug 02, 2001 at 03:46:22PM -0400, Jeff 'japhy/Marillion' Pinyan wrote:
> On Aug 2, Michael Fowler said:
> 
> >You can only print a string.  When print is given multiple arguments it
> >joins them with $" before printing.  This is documented in perldoc -f print.
> 
> *Cough* $, not $".
>
> $" is used when you put an array (or array slice) in double quotes.

Oh, right, of course.  I usually get those confused, and probably should've
checked.  Sorry folks.

 
> And, upon checking the source, you're incorrect.

Well, good.  p5p++  :)

I knew I should have sprinkled more "equivalent to", "similar to", etc.
throughout the description.  Some of the efficiency hacks thrown into perl
can really screw with one's descriptions of Perl behaviour.


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

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




Re: Certification

2001-08-02 Thread Jeff 'japhy/Marillion' Pinyan

On Aug 2, Paul said:

>That would be Merlyn (Randall Schwartz) &co. at Stonehenge,
>if you want to call it that.
>But it isn't a certification, I don't think.
>
>Randall?

chop(), if'n you don't mind. ;)

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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




Re: Valid DB Handle Assertion Test

2001-08-02 Thread JCervoni


I wrote a module  called DBIv that does a 'use DBI ; '.

These are the functions that I defined.  This module was written with the
intention of providing 2 things:
   - a very simple interface
   - database independence

--
 Connection Functions:
$dbh = &DBIv::OpenDBConnection($server, $database, $uid, $password)
;
  &DBIv::CloseDBConnection($dbh) ;

Query Functions:
$rh_results=  &DBIv::SelectQuery($dbh, $query) ;
$rows_inserted =  &DBIv::InsertQuery($dbh, $query) ;
$rows_affected =  &DBIv::UpdateQuery($dbh, $query) ;
$rows_affected =  &DBIv::DeleteQuery($dbh, $query) ;

Stored Procedures:
$return_value = &DBIv::ExecuteStoredProcedure($dbh, $command) ;
$return_value = &DBIv::ExecuteSQLBatch($dbh, \@commands) ;

Display Result Functions:
&DBIv::DisplayAllResults($rh_results, $format) ;

Extract Portions of a Result Set:
$row_count  = &DBIv::ReadResultRowCount($rh_results) ;
$col_count  = &DBIv::ReadResultColCount($rh_results) ;
@values = &DBIv::ReadResultColumn($rh_results, $column) ;
@values = &DBIv::ReadResultColumn($rh_results, $column) ;
$value  = &DBIv::ReadResultRowColumn($rh_results, $row,
$column) ;

Error Message:
$DBIv::errstr - Contains err message text if one has occurred
-

By simplified interface, I mean that the number of statements required to
submit a query and get results are reduced.  In most cases this reduces the
series of steps such as prepare, execute, ... etc. single step.

More importantly it provides a level of database independence by
dynamically loading in another module via AUTOLOAD depending on the
database type that is being connected to.  In other words based on an
Environment variable I would load another module into DBIv such as
Sybase_DB.pm or Oracle_DB.pm, and Default.pm.  Each of these modules would
have the same functions, but written in different ways.  This is very
similar to the way that DBIx works.  However due to my inexperience with
programming classes I couldn't get DBIx to work the way I thought that it
should so I developed this library without it.


> What do you mean by "valid"?
>
> Are you trying to verify $dbh is an object that has a disconnect() method
in
> its class?
>
>if (ref($dbh) && UNIVERSAL::can($dbh, "disconnect")) {
># $dbh is an object with a disconnect() method
>}

I was just trying to make sure that if I executed the code:

$dbh->disconnect()

I would always catch any possible error.  I was worried not only about
disconnection errors caused by the database, but also programmer errors
where $dbh might have been inadvertantly defined as a string 'xyz' or '' or
undef.  All these cases are captured quite nicely by using an earlier
suggestion in the list:

--

sub CloseDBConnection {
my ($dbh) = @_ ;

my ($status) ;

# avoid the eval for the simple error cases if possible
if (!defined($dbh) || $dbh eq '')
{
$DBIv::errstr = "Error: Unable to close connection.\nInvalid database
handle." ;
return 0 ;
}

# in order to trap programmer error
# use an eval to catch invalid $dbh values
eval { $dbh->disconnect(); } ;

if ($@ ne '')
{
$DBIv::errstr = "Error: Unable to close connection.\n($@)" ;
return 0 ;
}

return  1 ;
}



Thanks for the reminder of the use of $dbh->ping ... I had forgotten about
that. I may use that elsewhere.

Thanks to everyone who helped on this.

Jeff



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




RE: Certification

2001-08-02 Thread Brett W. McCoy

On Thu, 2 Aug 2001, Shepard, Gregory R wrote:

> Thanks for suggesting the Stonehenge training. That appears to be the best
> route.
> And I understand Larry's feeling regarding certification. As long as you can
> do it, who needs certification? But, of course, its nice to have a little
> framed sheet of paper that certifies you skill.

It has been said that those who have the skill are already doing it, and
those who have a certification wish they were doing it.  (This was actualy
in refernce to system administrator certification, but I think it still
applies).  In more cases than not, a certification indicates more that you
passed a test, not that you necessarily can apply that knowledge into real
world situations.  That only comes with experience.

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

NEWARK has been REZONED!!  DES MOINES has been REZONED!!


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




RE: File Handling question - easy

2001-08-02 Thread Bob Showalter

> -Original Message-
> From: Jon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 2:03 PM
> To: [EMAIL PROTECTED]
> Subject: File Handling question - easy
> 
> 
> I don't know if I sent my first email correctly.  Sorry for 
> the repeat if I 
> did, I'm new :)
> 
> Hello,
> The code below takes all files in my current directory that 
> have filenames 
> ending with ".txt". Using this stuff I can loop through those 
> files and do 
> what I need to do.
> 
> My problem is, I want to do this for a bunch of different 
> patterns (ex. 
> ".txt", ".this", ".that"). How can I make what is inside the 
> angle brackets 
> a variable? I've tried to use eval to build my while 
> statement and I can't 
> make it work. Help Please?
> 
> while(<*.txt>)
> {
> ### do stuff, given a filename
> }

Use glob():

   my $patterns = '*.txt *.this *.that';
   for (glob($patterns)) { ... }

P.S. I'm surprised this works with while(). I didn't realize fileglobs
were magical inside while(), but it appears they are... Is this documented?

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




RE: Help with Net::Telnet module

2001-08-02 Thread Bob Showalter

> -Original Message-
> From: S. Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 5:05 PM
> To: [EMAIL PROTECTED]
> Subject: Help with Net::Telnet module
> 
> 
> I am looking for some help debugging a problem with the 
> Net::Telnet module
> written by Jay Rogers.
> 
> Here's the subroutine I am having problems with:
> 
> sub login
>   {
>$errmode = 'return';
>$hostaddress = 'xxx.xxx.xxx.xxx'; 
>$prompt = '/Sheldon_NS16>/';
>$username = '';
>$password = '';
>$obj = new Net::Telnet ( Host => $hostaddress,
> Errmode => $errmode,
> Prompt =>  $prompt,
> Timeout => 15,
> Port => 23 );
>   $obj->login($username, $password);  # line 212
>   $errmsg = $obj->errmsg;
>   print STDOUT "Error - $errmsg\n" unless ($errmsg eq "");
>   }
> 
> This subroutine is part of a larger script (sheldon.pl) that 
> calls this
> subroutine once per minute
>  to login to a modem pool to get user information and log it 
> for tracking
> users usage.  
> The program will run for 1-2 days before dying.  The error I get is as
> follows:
> 
> Can't call method "login" on undefined value at ./sheldon line 212.
> 
> As I said above, the script will run for a day or two collecting data
> without any problems, then
> die with the error above.  Any Perls of wisdom out there?

I don't know anything about Net::Telnet, but I'd say the call to
Net::Telnet::new is failing for some reason. You're not checking the return
value from new(). Perhaps there is a way to do that?


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




Valid DB Handle Assertion Test

2001-08-02 Thread JCervoni


Can I test for the existence of a method without actually calling it?

Basically what I'm trying to do is to verify that $dbh is still a valid
handle.
I want to use this as an assertion test at the start of a function.

# verify that the $dbh is valid
if ( !defined($dbh->disconnect() ) )
 {
 print "dbh is invalid\n" ;
 exit 1
 }

# $dbh is valid so we can safely disconnect
$dbh->disconnect()



Jeff


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




Weekly list FAQ posting

2001-08-02 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?

July 11, 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: memory for implied array/list read

2001-08-02 Thread Michael Fowler

On Thu, Aug 02, 2001 at 09:20:43AM -0700, Paul wrote:
>   print ;
> 
> If IN is accessing a large file, does the second syntax try to slurp
> the whole thing into memory before printing it? Or is there some
> internal optimization that doles it through in bufferloads?

AFAIK, print  is not special-cased to read chunk by chunk.  In fact,
it's more ineffecient than simply slurping the entire file in and then
printing it.  The syntax is equivalent to:

print join($", );


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

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




RE: input output append

2001-08-02 Thread Shepard, Gregory R

Try

$Directory=
$file="$directory.$file.txt";  # don't forget to add "\" between dir and
file

open FH, ">$file" or die "Cannot open $file:$!"; 

print FH "blah  \n";
print FH ""blah  \n";
print FH ""blah  \n";

close FH;


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 4:10 PM
To: [EMAIL PROTECTED]
Subject: input output append


HI,
anyone knows the right syntax for  reading and writing (appending) to a
file.
I tried this and it didn't seem to work
open (FH,"+< file.txt" )

Thanks

I.S


__
Your favorite stores, helpful shopping tools and great gift ideas.
Experience the convenience of buying online with Shop@Netscape!
http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at
http://webmail.netscape.com/


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

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




RE: input output append

2001-08-02 Thread Bob Showalter

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 5:10 PM
> To: [EMAIL PROTECTED]
> Subject: input output append
> 
> 
> HI,
> anyone knows the right syntax for  reading and writing 
> (appending) to a file.

I assume you mean "open a file for both reading and writing", since
the code you posted doesn't do any reading or writing.

> I tried this and it didn't seem to work
> open (FH,"+< file.txt" )

Define "didn't seem to work". The file must exist for this open to succeed.

open(FH, '+>>file.txt') will open file for append, creating if necessary,
and allowing read access. But all writes go to end of file.

perldoc perlopentut gives all the gory details of how to open things.

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




Networking problem: can't connect via sockets

2001-08-02 Thread Brett R. Gordon

Hi! This is the ezmlm program. I'm managing the
[EMAIL PROTECTED] mailing list.

I'm working for my owner, who can be reached
I'm trying to created a multi-threaded server to accomplish some distributed
processing.

While compiling Perl with thread support, I noticed during 'make test' that
io:multihomed and io:sock failed their tests, both reporting 'connection
failed: timed out'.

I know that I have network access.  But when I wrote a client and server,
and tried testing them on the localhost, they never seemed to connect.  I
used code straight out of "Perl Recipes".  The two programs just hang,
waiting for the other to connect.  However, I receive no error messages. The
socket *seems* to bind correctly.

Are there any workarounds? Any wierd bugs?  I'm using perl 5.6.1 (downloaded
and compiled last night) on a RH linux 7.

Much thanks.


Cheers,
Brett





Brett R. Gordon
B.S. Information Systems and Economics '02
M.S. Information Systems Management '03
Heinz School of Public Policy and Management
Carnegie Mellon University

Hamlet: "What a piece of work is a man! how noble in reason!
how infinite in faculties!"  -Hamlet, II.2.319

Puck: "Lord, what fools these mortals be!"  -Midsummer Night's Dream,
III.3.116



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




Re: Using a pipe in a split command

2001-08-02 Thread Brett W. McCoy

On Fri, 3 Aug 2001, Darren Edgerton wrote:

> What i really want to do is use a variable to contain the pipe
> ie
> my $separator = "|";
> my @arr = split(/$separator/,$somevar);
>
> Now:
> $arr[0] = "h"
> $arr[1] = "e"
>
> How do i get the split command to use $separator correctly ??

The problem is that | is a pattern metacharacter (to separate
alternatives), and still needs to be escaped, since the regexp in the
argument list can accept an expression for dynamically generated runtime
patterns.  If you want to match on |, you need to escape it.

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

Prediction is very difficult, especially of the future.
- Niels Bohr


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




Where is DB_File::Lock module?

2001-08-02 Thread Carlos C . Gonzalez

Hi everyone,

I am going absolutely nuts trying to find where to get the DB_File::Lock 
module.  I have looked all over CPAN, have done searches on Google.com 
and while there is some info on it I can't find out where to download it. 

Does anyone have any suggestions?

-- 
Carlos 
www.internetsuccess.ca

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




RE: Where is DB_File::Lock module?

2001-08-02 Thread Bob Showalter

> -Original Message-
> From: Carlos C.Gonzalez [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 01, 2001 7:35 PM
> To: [EMAIL PROTECTED]
> Subject: Where is DB_File::Lock module?
> 
> 
> Hi everyone,
> 
> I am going absolutely nuts trying to find where to get the 
> DB_File::Lock 
> module.  I have looked all over CPAN, have done searches on 
> Google.com 
> and while there is some info on it I can't find out where to 
> download it. 
> 
> Does anyone have any suggestions?

Use the CPAN module to get and install modules.

   perldoc CPAN

   perl -MCPAN -e shell
   cpan> install DB_File::Lock


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




Re: boolean logic - what am I doing wrong?

2001-08-02 Thread Paul


--- Ron Woodall <[EMAIL PROTECTED]> wrote:
> Hi All:

Hi, Ron.

> A bit of a conundrum here.

Reformatting (forgive if offensive):

> while (attlist[$x] =~ m|

Re: File Handling question - easy

2001-08-02 Thread Jon

Bob-Mike-Jerry,
Thanks guys

Jon

At 01:36 PM 8/2/01 -0500, Jerry Preston wrote:
>Jon,
>
>Read all the files in the directory then go through them based on the
>file ext
>and do what you want.
>
>   opendir( PROGRAM, "./" );
>   foreach $program ( readdir( PROGRAM )) {
> if( $program =~ ".txt" ) {
>### do stuff, given a filename
> }elsif( $program =~ ".this" ) {
>### do stuff, given a filename
> }
>   }
>
>Jerry
>
>
>Jon wrote:
> >
> > I don't know if I sent my first email correctly.  Sorry for the repeat if I
> > did, I'm new :)
> >
> > Hello,
> > The code below takes all files in my current directory that have filenames
> > ending with ".txt". Using this stuff I can loop through those files and do
> > what I need to do.
> >
> > My problem is, I want to do this for a bunch of different patterns (ex.
> > ".txt", ".this", ".that"). How can I make what is inside the angle brackets
> > a variable? I've tried to use eval to build my while statement and I can't
> > make it work. Help Please?
> >
> > while(<*.txt>)
> > {
> > ### do stuff, given a filename
> > }
> >
> > Jon
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


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




Re: boolean logic - what am I doing wrong?

2001-08-02 Thread Michael Fowler

On Thu, Aug 02, 2001 at 12:51:55PM -0400, Ron Woodall wrote:
> Hi All:
> 
>   A bit of a conundrum here.
> 
>   while (attlist[$x] =~ m|

Re: File Handling question - easy

2001-08-02 Thread Jerry Preston

Jon,

Read all the files in the directory then go through them based on the
file ext 
and do what you want.

  opendir( PROGRAM, "./" );
  foreach $program ( readdir( PROGRAM )) {
if( $program =~ ".txt" ) {
### do stuff, given a filename
}elsif( $program =~ ".this" ) {
### do stuff, given a filename
}
  }

Jerry


Jon wrote:
> 
> I don't know if I sent my first email correctly.  Sorry for the repeat if I
> did, I'm new :)
> 
> Hello,
> The code below takes all files in my current directory that have filenames
> ending with ".txt". Using this stuff I can loop through those files and do
> what I need to do.
> 
> My problem is, I want to do this for a bunch of different patterns (ex.
> ".txt", ".this", ".that"). How can I make what is inside the angle brackets
> a variable? I've tried to use eval to build my while statement and I can't
> make it work. Help Please?
> 
> while(<*.txt>)
> {
> ### do stuff, given a filename
> }
> 
> Jon
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

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




Re: memory for implied array/list read

2001-08-02 Thread Jeff 'japhy/Marillion' Pinyan

On Aug 2, Michael Fowler said:

>You can only print a string.  When print is given multiple arguments it
>joins them with $" before printing.  This is documented in perldoc -f print.

*Cough* $, not $".

$" is used when you put an array (or array slice) in double quotes.



And, upon checking the source, you're incorrect.

/* from pp_hot.c:pp_print() */

while (MARK <= SP) {
if (!do_print(*MARK, fp))
break;
MARK++;
if (MARK <= SP) {
if (!do_print(PL_ofs_sv, fp)) { /* $, */
MARK--;
break;
}
}
}

That loop, in Perl, would look like:

  $_ = 0;
  while ($_ < @output) {
last unless NATIVE_PRINT($output[$_]);
$_++;
if ($_ < @output) {
  $_--, last unless NATIVE_PRINT($,);
}
  }

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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




RE: zipping files with Active State Perl

2001-08-02 Thread Tim Noll

For most purposes, I've found it much easier to just make a system call to
an external program rather than using a Perl module. I've messed with
Compress::Zlib a bit, which is a standard module, but it seemed to be
overkill for what I needed.

For example, if you have WinZip on your box, you can access it via a system
call. I don't know the full command line syntax since I don't use it myself,
but you can get details from http://www.winzip.com/xcmdline.htm.

Personally, I use Zip (http://www.info-zip.org/pub/infozip/) since it's free
and I can put it on as many servers as necessary. In fact, I believe that
its compression engine is what powers Compress::Zlib. Again, you can just
use a system call for this.


-Original Message-
From: Rich Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 31, 2001 2:51 PM
To: [EMAIL PROTECTED]
Subject: zipping files with Active State Perl


Does anyone know how to zip files with Perl on a windows platform?
I have a couple of directories that I want to zip up and archive
periodically.

Thanks!

richf



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




Re:[apology]inserting lines

2001-08-02 Thread Paul


--- Paul <[EMAIL PROTECTED]> wrote:

Sorry for the null-mail, ladies and gents.
I apparently hit the wrong button and sent a quoted response to the
list without adding anything to it. I apologize for wasting your time,
mailbox space, and bandwidth. =o)

Now, since I did so:

> --- COLLINEAU Franck FTRD/DMI/TAM
> <[EMAIL PROTECTED]> wrote:
> > Hi!

Hi. :o)

> > How can i do to insert several lines in the
> > beginning of a existant file ?
> > Thanks
> > Franck

assuming files orig.txt and top.add, try

  open NEW, ">tmpout$$" or die "$! tmpout$$";
  open IN,  "top.add"   or die "$! top.add";
  print NEW while ;
  open IN,  "orig.txt"  or die "$! orig.txt";
  print NEW while ;
  rename "tmpout$$", "orig.txt" or die "$! rename";

To add datat to the *top* of a file, you have to rewrite the whole
file. That's just the nature of filesystems. You always add data at the
bottom, or overwrite what's there.

Does that help?


__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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




Re: File Handling question - easy

2001-08-02 Thread Michael Fowler

On Thu, Aug 02, 2001 at 02:31:28PM -0400, Bob Showalter wrote:
> P.S. I'm surprised this works with while(). I didn't realize fileglobs
> were magical inside while(), but it appears they are... Is this documented?

Yes, perldoc perlop, in the I/O Operators section (5.6.1 version):

  A (file)glob evaluates its (embedded) argument only when it is
  starting a new list.  All values must be read before it will start
  over.  In list context, this isn't important because you automatically
  get them all anyway.  However, in scalar context the operator returns
  the next value each time it's called, or "undef" when the list has run
  out.  As with filehandle reads, an automatic "defined" is generated
  when the glob occurs in the test part of a "while", because legal glob
  returns (e.g. a file called 0) would otherwise terminate the loop.
  Again, "undef" is returned only once.


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

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




RE: File Handling question - easy

2001-08-02 Thread Jon

Bob,
I got it from "Perl Black Book" by S. Holzner, section on globs.  Very very 
good book to learn Perl from, extremely easy to read, excellent for 
beginners and I'm not going to know this for a long while but I think it is 
an excellent book for intermediate Perl dudes too.  End of section reads 
like this:

Let me give you a useful hint: Using the glob function internally, Perl 
allows you to write expressions like this, which will print the names of 
the files with the extension .txt:

while (<*.txt>) {
 print;
}




> > while(<*.txt>)
> > {
> > ### do stuff, given a filename
> > }
>
>Use glob():
>
>my $patterns = '*.txt *.this *.that';
>for (glob($patterns)) { ... }
>
>P.S. I'm surprised this works with while(). I didn't realize fileglobs
>were magical inside while(), but it appears they are... Is this documented?
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


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




Pipe to a command

2001-08-02 Thread Hal Wigoda



How do you run a command on a unix box
from a perl script
and capture the results??

Like a grep command??



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




Re: boolean logic - what am I doing wrong?

2001-08-02 Thread Adam Turoff

On Thu, Aug 02, 2001 at 12:51:55PM -0400, Ron Woodall wrote:
> Hi All:
> 
>   A bit of a conundrum here.
> 
>   while (attlist[$x] =~ m|

RE: Valid DB Handle Assertion Test

2001-08-02 Thread JCervoni

> Another approach is to wrap the disconnect in eval, which lets you
capture
> the error rather than having it stop your program:
>
>   eval { $dbh->disconnect(); };
>
> If $dbh is not a database handle, the relevant error message will be in
$@.
>
>   perldoc -f eval
>
>

I think the eval method is the way for me to go.  It never occurred to me
to try it that way even though I've used eval quite a bit.

Thanks you've been a big help.

Jeff


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




Re: Fun With Perl list ???? where is it ? :)

2001-08-02 Thread Silvio Luis Leite Santana

OK, officially too :)

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


Silvio Luis Leite Santana wrote:
> 
> Hi all
> Is there actually a Fun With Perl list?
> (ok, this list is funny already, but not officially :) )
> I think I learn better when I'm having fun
> (that's why I think so easy to learn Perl reading
> the camel book, and learning everything else by
> the o'reilly books)
> If there isn't a list, perhaps a site?
> A site full of one-liners, japhs, cake recipes,
> better-way-to-do-somethings, most compact code
> to do that other thing, gotchas, tips, ...,
> but always funny, intricate and smart,
> that would be fantastic.
> Thanks all
> Silvio
> 
> ---
> 
>From: Peter Scott <[EMAIL PROTECTED]>   Mon 16:21
>Subject: Re:[OT?]Deleting Duplicate Lines one-liner
>To: [EMAIL PROTECTED], [EMAIL PROTECTED]
>CC: Perl Beginners <[EMAIL PROTECTED]>
> 
>It is beautiful, but I fear it could scare a beginner away.  I'd
> rather
>such brilliance were directed to the Fun With Perl list than exposed
> to
>people many of whom are no doubt still wondering whether Perl is a
>write-only language.

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