Re: modules

2001-08-14 Thread Rachel Coleman

 How do I know what modules are installed ?
 Does the CGI_Lite module come bundled by default?

This question is a CPAN FAQ, which you can read here:
http://www.cpan.org/misc/cpan-faq.html#How_installed_modules
You may find the other CPAN FAQs useful; the url for the full list is
slightly different: http://www.cpan.org/misc/cpan-faq.html

Best wishes,

Rachel


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




Re: regexp issues TR

2001-07-29 Thread Rachel Coleman

 Let me rephrase what I want to do since I was so unclear the first
 time:  I want to output an error message every time the input
 includes characters that are not the following: A-Za-z0-9_@.- or a
 space(s).

 At this point, I've tried:

 if ($params{$i} !~ /[^\w\@.-\s]/g) {
 print Error Message;
 }
 #output: prints error msg every time

This regex matches anything that is *not* A-Za-z0-9_@.- or space(s) i.e.
your unwanted characters.
You then use the 'does not match' operator !~
You are saying 'if there are no unwanted characters, print error message'.
I suspect that is not what you want :)

 unless ($params{$i} =~ /[^\w\@.-\s]/g) {
 print Error Message;
 }
 #output: prints error msg every time

Here you have the same statement expressed slightly differently:
'Unless there are unwanted characters, print error message'.

This is what japhy meant when he said:

 You're using !=, when you meant to use !~, but you really want to use
=~
 
 {if ($params{$i}!=m/[^\w@.-]/g)
 
   if ($params{$i} =~ /[^\w\@.-]/) {
 # badness
   }

Does that make things clearer?

Rachel


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




Re: sending mail

2001-07-29 Thread Rachel Coleman

 Hi friends, I wanna send mails with the results of some perl scripts. I've
 installed Debian GNU/Linux with Apache, Perl  sendmail. Do I need some
 extra module?

I think you *can* just print stuff directly to sendmail.  However, I found
Net::SMTP to be useful, if a little fiddly.  Mail::Mailer simplifies things,
but turned out to simplify them too much for me when I tried using it for a
project at work (100+ bounced messages in the work mail system did not
impress).  You may have a better experience with it, however.

Best wishes,

Rachel


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




Re: newbie DBI

2001-07-29 Thread Rachel Coleman

 I'm trying to decide on using DBI or an ODBC connection for moving data
 into or out of MS ACCESS 97 (or 2000) and back into the ACCESS table
 [yep, or change inside table].
 
 Given I need to perform all the usual extract and append, etc. tasks, do
 any of you have suggestions or pointers on which to use ? Other life
 lessons also appreciated ...

 If you are going to do any amount of database programming using Perl, I
 would use DBI, rather than finding some special-purpose ODBC module.  The
 beauty if DBI is that no matter what the underlying interface is (ODBC,
 Oracle OCI, sockets) it looks the same from the application programmer's
 side of DBI.
[snip praises]
 Plus there's a really good DBI book out there.  Take a look at it if you
 are jumping into a decent size database project.

I would second Sean's recommendation of DBI.  It's very nice to use, with a
lot of nice neat tricks for doing things. The O'Reilly book is very helpful
(Programming the Perl DBI, by Alligator Descartes  Tim Bunce), although the
first few chapters are a bit basic if you've got a fair grasp of SQL and
databases.  I've found it invaluable in my current job (working with an
Oracle database).

The big advantage is the reusability:
* if your database ever migrates to something a bit more meaty than Access,
you will have very little code to change
* if you want to write something similar for a different database, you will
have very little code to change
* instead of having to learn one set of stuff for ODBC on Windows, and then
learning a whole new set of stuff for anything different, you have one set
of stuff to learn which works with pretty much any database

Best wishes,

Rachel


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




Re: $1

2001-07-29 Thread Rachel Coleman

 Making a mistake once can be exused,
 making it twice is stupidity and
 making the same mistake a third time only proves you have no brain ;-)

 Sorry, I figured out where the problem is...

What was the problem and how did you fix it?  Other people reading the list
(or searching the archive) might have similar problems and want to know how
it was solved?  I'm curious, for one :)

Best wishes,

Rachel



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




Re: Expect

2001-07-29 Thread Rachel Coleman

 Does anyone know where to find good information on the expect module?
 the camel book did not say much about it.

Try http://theoryx5.uwinnipeg.ca/CPAN/data/Expect.pm/Expect.html

Found by my usual route for finding out more about a module, which is:

1. Go to www.cpan.org
2. Follow the link 'Perl core and CPAN modules documentation (Randy Kobes)'
3. Search for module name, usually by 'module name or description'
4. If I get a result that looks like what I'm after, following the [
documentation ] link

Hope that helps you now, and in the future :)

Best wishes,

Rachel


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




Re: Compiling into C source code.

2001-07-29 Thread Rachel Coleman

 sorry, i figured this one out myself,
 
 thanks anyway! :)

What was the answer?

Best wishes,
Rachel


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




Re: Array::compare question

2001-07-29 Thread Rachel Coleman

  Does someone know if the array::compare module can handle array of
 arrays?

I haven't seen anyone answer this yet.  Based on the documentation
(http://theoryx5.uwinnipeg.ca/CPAN/data/Array-Compare/Compare.html),
Array::Compare takes 2 arrays and tells you if they are the same, or
different, with the additional option of reporting the elements which are
different.

An 'array of arrays' is actually an array of _references_ to arrays.  Are
you wanting to compare each array to every other array?  You could do that
by dereferencing pairs of arrays and using Array::Compare on each of them
(but this could be timeconsuming with a lot of arrays).

E.g.


foreach ( @array_of_arrayrefs ) {
my @array_copy = @array_of_arrayrefs; # make a copy to test against
my @test_arr1 = @{$_};# dereference array
foreach ( @array_copy ) {
my @test_arr2 = @{$_};
#Do Array::Compare stuff here with @test_arr1 and @test_arr2
}
}

This needs some tidying up, a more efficient algorithm, and getting the
results of the comparisons, but I hope it is a start.

Best wishes,

Rachel



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




Re: output file for download

2001-07-25 Thread Rachel Coleman

 you just need to provide a link to your file.
 simply,a href=$myfileclick here to download my file/a
 and the browser,itself will automatically bring that dialog box,
 whenever user clicks on  Click here to download my file.

 I would like to create the file dynamically with a cgi program and send it
 to the browser rather than placing an href to a static file. This may not
 even be possible, but it would simplify things on my end.

So, generate a filename, create that file on your disk and provide a link to
that file.  I do something like this with an application I'm developing at
work.  Because there's a script to clear files each night, I append the
hour, minute and second to an id we already use like so:

my $filename = join( _, ( $id, (localtime)[2,1,0]));
(I'll explain this in the PS below)

Then you just need to do something like:

open( OUTPUT, $filename ) or die Could not open $filename: $!;
# Always always always check the effect of any file open attempt
print OUTPUT stuff you want to print to file
# print data to the file

and in the webpage use something like:
a href=$filename click here to download your information/a

Hope that helps,

Rachel

P.S. How that filename is generated:
The join function joins together the items of a list with the character you
specify
e.g. join( x, (a,b,c,d,e) ) will produce axbxcxdxe

localtime is a perl function (see perldoc -f localtime for a full
explanation)
In array context (indictated by the brackets around it above) it returns a
list of 9 elements, each holding a different piece of information about the
current time.  I've taken an array slice including the elements 2,1 and 0
which hold respectively the hour, minute and second values on the server at
the moment I call the function.

Finally, I use Perl's ability to concatenate lists e.g.
@newlist = ( $a, @oldlist) or
@newlist = ( $a, ( $b, $c, $d ) )

In my example above, the (localtime)[2,1,0] can be thought of as ($b, $c,
$d), and the $id as $a
So, join is presented with the character _ and 4 elements of a list, and
generates scalars like rc0153f_12_31_20.



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




RE: passing form values to another Perl script

2001-07-19 Thread Rachel Coleman

On Wed, 18 Jul 2001 [EMAIL PROTECTED] wrote:

 So how exactly do I add the error checking in there?
 Hints anyone since I am very new to this whole process.

http://gunther.web66.com/FAQS/taintmode.html

has some good clear explanations.

 I don't know that's what he asked about... he said he wanted to use values
 from a form as command-line arguments to another script.  Regardless, you
 still need to practice safe form validation practices, no matter what you
 ned up doing with the data.

 -- Brett

Best wishes,

Rachel Coleman



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




Re: Running perl scripts on other machines and getting feedback

2001-07-19 Thread Rachel Coleman

On Wed, 18 Jul 2001, Westlake, Andy wrote:
 I have written a short perl script to report disk usage on our various
 systems at our site.  What I would like to do is run the script from a page
 on our intranet and get the feedback back.  Now I can do this using rsh but
 I am sure there is a way of doing it in perl.  So any ideas please?

I am going to assume you mean a script that runs on a particular machine
which you are also using as a webserver.  If that is the case, you just
need to adapt your existing script to be a cgi script:

* Have a web page with a link or form submission ( depending on whether
you want to offer your users options for the script ) to the script
* At the start of the script extract any user input
* Next run the existing code and capture its results in variables
* Build an output page including those variables

You will probably find CGI.pm useful, both for extracting any input and
building the output.
Don't forget: use warnings, taint and strict :)

Best wishes,

Rachel Coleman



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




Re: Comparison of a string and filename

2001-07-18 Thread Rachel Coleman

On Wed, 18 Jul 2001, Arvind Baldeo wrote:
 As can be seen above, both $filename and $myfile are same, but it fails when
 I test using the ($myfile eq $filename) operator in the script.

 Any suggestions?

First: you are chomping $filename, but putting a newline in $myfile.
Second: use -w and strict
Below is your script with my changes - this runs for me, and given a file
of the right name, prints the 'correct filename' line.

Rachel

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

my ( $filename, $mon, $hour, $day, $min, $year, $curseq, $myfile );

 chomp( ($filename) = `ls -rt | tail -1` );

 #date
 chomp($mon=`date +%m`);
 chomp($hour=`date +%H`);
 chomp($day=`date +%d`);
 chomp($min=`date +%M`);
 chomp($year=`date +%Y`);
 $curseq=$hour*4;

$myfile= $year.$mon.$day.$curseq.data;
print $myfile\n;

# old way, with \n
#$myfile= $year.$mon.$day.$curseq.data\n;
#print $myfile;

 if ($myfile eq $filename){
print The last file has correct filename : $myfile\n;
   }
 


Best wishes,

Rachel Coleman



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




Re: foreach examples/usage

2001-07-17 Thread Rachel Coleman

On Tue, 17 Jul 2001, Evan Panagiotopoulos wrote:

 I have an array of X elements and I want to go from the first element
 (is it zero?) to the last. I have a variable containing the number of
 elements in the array. If the array has 22 elements does it go from 0
 to 21 or 1 to 22?

foreach doesn't need to know the number of elements - it just goes from
the first element to the last

e.g.

#!/usr/bin/perl -w
my @array = (1,2,3,4,5,6,7,8,9);

# explicit scalar variable
foreach my $item ( @array ) {
print $item;
}
# newline for tidiness
print \n;

# do it again using the implicit $_ variable
foreach ( @array ) {
print;
}
# newline for tidiness
print \n;

This script prints out:
123456789
123456789


Best wishes,

Rachel Coleman



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




Re: Problems with ^M

2001-07-17 Thread Rachel Coleman

On Mon, 16 Jul 2001, System Administrator wrote:

 This is for newbies, right? Can anyone tell me why a s/^M//g won't get
 rid of the annoying ^M on the end of each line of an imported Paradox
 database?

I know you've had one solution to this problem already but as TMTOWTDI ...

^M is the carriage return character, used in windows but not Unix.  It can
be represented in Perl by \r.

So: s/\r//g should also work.

Best wishes,

Rachel Coleman



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




Re: Probably a no-brainer - the last two messages.

2001-06-05 Thread Rachel Coleman

On Tue, 5 Jun 2001, Gary Luther wrote:

 MESSAGES:

 Useless use of string in void context at /common/bin/whaduname.AA line 56.
 Useless use of string in void context at /common/bin/whaduname.AA line 60.

 The lines and supporting evidence:

 33 $cdate='/common/lib/cdatetest';

 35 $cnum='/common/lib/cnumtest';


  56open(CD, $cdate) || Can't open $cdate: $!;
  60open(CN, $cnum) || Can't open $cnum: $!;

You need to do something with the Can't open blah  strings, e.g.
insert 'print' or 'die' before them.  You aren't putting the strings to
any use, therefore they are 'useless'.  Does that make sense?

Best wishes,

Rachel Coleman