[23667] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5874 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 30 09:05:45 2003

Date: Sun, 30 Nov 2003 06:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 30 Nov 2003     Volume: 10 Number: 5874

Today's topics:
    Re: DBI error handling <tore@aursand.no>
        Dynamic check boxes from two arrays <Blnukem@hotmail.com>
    Re: Dynamic check boxes from two arrays <bigus_34@yahoo.co.uk>
    Re: Dynamic check boxes from two arrays <noreply@gunnar.cc>
    Re: Dynamic check boxes from two arrays <Blnukem@hotmail.com>
    Re: hash key evaluation creates an entry ! (Malcolm Dew-Jones)
    Re: Memory Allocation Error when to fetching BLOB field (William Herrera)
    Re: Newsgroup Searching Program <gerardlanois@netscape.net>
    Re: Reading Dates from Excel-file (William Herrera)
    Re: Reading Dates from Excel-file <gpatnude@adelphia.net>
    Re: Reading Dates from Excel-file <invalid-email@rochester.rr.com>
    Re: Reading Dates from Excel-file (bruno)
    Re: Reading Dates from Excel-file (bruno)
    Re: redirect using location header does not work from a <noreply@gunnar.cc>
    Re: redirect using location header does not work from a <flavell@ph.gla.ac.uk>
    Re: subnets eating each other? <dominix"at"despammed.com>
    Re: subnets eating each other? <dominix"at"despammed.com>
    Re: subnets eating each other? <Juha.Laiho@iki.fi>
    Re: subnets eating each other? <perl@my-header.org>
    Re: subnets eating each other? <perl@my-header.org>
        Syntax checking of user input (mike)
    Re: Syntax checking of user input <nospam@bigpond.com>
        trouble with DBI/CGI (David Morel)
    Re: trouble with DBI/CGI <noreply@gunnar.cc>
    Re: trouble with DBI/CGI (Sam Holden)
    Re: trouble with DBI/CGI <Juha.Laiho@iki.fi>
    Re: trouble with DBI/CGI <r_reidy@comcast.net>
    Re: trouble with DBI/CGI <REMOVEsdnCAPS@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 30 Nov 2003 13:16:36 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: DBI error handling
Message-Id: <pan.2003.11.30.00.03.44.846442@aursand.no>

On Sat, 29 Nov 2003 18:27:10 +0000, Randal L. Schwartz wrote:
>> IMO, it's a bad habit to try to find out if your application, or a module
>> it's using, dies if there are ways to handle the errors in a better way.
>> With the DBI module - and most other modules - that's not a problem (as
>> explained in a previous post from me).

> You're not "thinking Perl" then.  I find the RaiseError mechanism
> to create much cleaner code.  When enabled, I can do things like:
> 
> eval {
>  ...;
>  ...;
>  ...;
>  ...;
> };
> if ($@) {
>   # something went wrong with something in this section
> }
> 
> whereas without RaiseError, I'm stuck setting status variables
> and nesting if statements to get the same effect.

Really?  Consider this code;

  my $sth = $dbh->prepare( 'SELECT * FORM user' ); # typo 'FORM'
  if ( $sth->execute() ) {
      # Works!
  }
  else {
      # Doesn't work!
  }
  $sth->finish();

I think this is cleaner, and I also suspect it to be faster than using
'eval'.  Doesn't 'eval' spawn of a "mini-Perl" process, and doesn't it
take some time to run?  Doesn't that hurt in a DB'ish application?


-- 
Tore Aursand <tore@aursand.no>
"To cease smoking is the easiset thing I ever did. I ought to know,
 I've done it a thousand times." -- Mark Twain


------------------------------

Date: Sun, 30 Nov 2003 11:05:41 GMT
From: "Blnukem" <Blnukem@hotmail.com>
Subject: Dynamic check boxes from two arrays
Message-Id: <9akyb.26771$iU5.7107291@news4.srv.hcvlny.cv.net>

Hi All
Could someone please look at this and tell me why I cant get it to work
please.

#!/usr/bin/perl

print "Content-type: text/html\n\n";

my @DaysPlayedCheckBox;

my @GamingDays = qw(Sun Mon Tue Wed Thur Fri Sat);
my @DaysPlayerPlays = qw(Mon Tue Wed Sat);

my $Count = 0;
foreach my $DaysPlayed (@GamingDays) {

if ($DaysPlayed eq $DaysPlayerPlays[$Count]){
$xdata = "<input type=\"checkbox\" name=\"$DaysPlayed\"
value=\"$DaysPlayed\" checked>$DaysPlayed";
}else{
$xdata = "<input type=\"checkbox\" name=\"$DaysPlayed\"
value=\"$DaysPlayed\">$DaysPlayed";
}
push (@DaysPlayedCheckBox, $xdata);
$Count ++;
}

print @DaysPlayedCheckBox;



Thanks in adavnce
Blnukem






------------------------------

Date: Sun, 30 Nov 2003 12:01:41 -0000
From: "Bigus" <bigus_34@yahoo.co.uk>
Subject: Re: Dynamic check boxes from two arrays
Message-Id: <G_kyb.2110$PR.17265@newsfep4-glfd.server.ntli.net>


"Blnukem" <Blnukem@hotmail.com> wrote in message
news:9akyb.26771$iU5.7107291@news4.srv.hcvlny.cv.net...
> Hi All
> Could someone please look at this and tell me why I cant get it to work
> please.
>
> #!/usr/bin/perl
>
> print "Content-type: text/html\n\n";
>
> my @DaysPlayedCheckBox;
>
> my @GamingDays = qw(Sun Mon Tue Wed Thur Fri Sat);
> my @DaysPlayerPlays = qw(Mon Tue Wed Sat);
>
> my $Count = 0;
> foreach my $DaysPlayed (@GamingDays) {
>
> if ($DaysPlayed eq $DaysPlayerPlays[$Count]){
> $xdata = "<input type=\"checkbox\" name=\"$DaysPlayed\"
> value=\"$DaysPlayed\" checked>$DaysPlayed";
> }else{
> $xdata = "<input type=\"checkbox\" name=\"$DaysPlayed\"
> value=\"$DaysPlayed\">$DaysPlayed";
> }
> push (@DaysPlayedCheckBox, $xdata);
> $Count ++;
> }
>
> print @DaysPlayedCheckBox;

Follow the foreach through. You are saying:

if ($DaysPlayed eq $DaysPlayerPlays[0]), which translates to - if (Sun =
Mon)
if ($DaysPlayed eq $DaysPlayerPlays[1]), which translates to - if (Mon =
Tue)
if ($DaysPlayed eq $DaysPlayerPlays[2]), which translates to - if (Tue =
Wed)
if ($DaysPlayed eq $DaysPlayerPlays[3]), which translates to - if (Wed =
Sat)
if ($DaysPlayed eq $DaysPlayerPlays[4]), which translates to - if (Thu = )
if ($DaysPlayed eq $DaysPlayerPlays[5]), which translates to - if (Fri = )
if ($DaysPlayed eq $DaysPlayerPlays[6]), which translates to - if (Sat = )

Sth like this would do what you want it to do:

foreach $DaysPlayed ( @GamingDays ) {
    if ("@DaysPlayerPlays" =~ /$DaysPlayed/) {
        # checked
    }
    else {
        # not checked
    }
}


Bigus





------------------------------

Date: Sun, 30 Nov 2003 12:59:53 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Dynamic check boxes from two arrays
Message-Id: <bqcmfd$20q17b$1@ID-184292.news.uni-berlin.de>

Blnukem wrote:
> Could someone please look at this and tell me why I cant get it to
> work please.

Please ask questions that make sense!!
- What did you expect the code to do?
- What does it do?

Please use indenting for better readability.

Assuming that you wonder why no checkboxes get checked, this is a
suggestion (the changes make the $Count variable redundant):

> my @DaysPlayerPlays = qw(Mon Tue Wed Sat);

Instead of that you may want a hash:

     my %DaysPlayerPlays;
     @DaysPlayerPlays{qw(Mon Tue Wed Sat)} = ();

> if ($DaysPlayed eq $DaysPlayerPlays[$Count]){

Instead of that you may want:

     my $xdata;
     if (exists $DaysPlayerPlays{$DaysPlayed}){

The problem is dealt with in the FAQ:

     perldoc -q certain

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



------------------------------

Date: Sun, 30 Nov 2003 12:23:42 GMT
From: "Blnukem" <Blnukem@hotmail.com>
Subject: Re: Dynamic check boxes from two arrays
Message-Id: <ijlyb.28390$iU5.7318850@news4.srv.hcvlny.cv.net>

Bigus thanks that's exactly what I needed!


"Bigus" <bigus_34@yahoo.co.uk> wrote in message
news:G_kyb.2110$PR.17265@newsfep4-glfd.server.ntli.net...
>
> "Blnukem" <Blnukem@hotmail.com> wrote in message
> news:9akyb.26771$iU5.7107291@news4.srv.hcvlny.cv.net...
> > Hi All
> > Could someone please look at this and tell me why I cant get it to work
> > please.
> >
> > #!/usr/bin/perl
> >
> > print "Content-type: text/html\n\n";
> >
> > my @DaysPlayedCheckBox;
> >
> > my @GamingDays = qw(Sun Mon Tue Wed Thur Fri Sat);
> > my @DaysPlayerPlays = qw(Mon Tue Wed Sat);
> >
> > my $Count = 0;
> > foreach my $DaysPlayed (@GamingDays) {
> >
> > if ($DaysPlayed eq $DaysPlayerPlays[$Count]){
> > $xdata = "<input type=\"checkbox\" name=\"$DaysPlayed\"
> > value=\"$DaysPlayed\" checked>$DaysPlayed";
> > }else{
> > $xdata = "<input type=\"checkbox\" name=\"$DaysPlayed\"
> > value=\"$DaysPlayed\">$DaysPlayed";
> > }
> > push (@DaysPlayedCheckBox, $xdata);
> > $Count ++;
> > }
> >
> > print @DaysPlayedCheckBox;
>
> Follow the foreach through. You are saying:
>
> if ($DaysPlayed eq $DaysPlayerPlays[0]), which translates to - if (Sun =
> Mon)
> if ($DaysPlayed eq $DaysPlayerPlays[1]), which translates to - if (Mon =
> Tue)
> if ($DaysPlayed eq $DaysPlayerPlays[2]), which translates to - if (Tue =
> Wed)
> if ($DaysPlayed eq $DaysPlayerPlays[3]), which translates to - if (Wed =
> Sat)
> if ($DaysPlayed eq $DaysPlayerPlays[4]), which translates to - if (Thu = )
> if ($DaysPlayed eq $DaysPlayerPlays[5]), which translates to - if (Fri = )
> if ($DaysPlayed eq $DaysPlayerPlays[6]), which translates to - if (Sat = )
>
> Sth like this would do what you want it to do:
>
> foreach $DaysPlayed ( @GamingDays ) {
>     if ("@DaysPlayerPlays" =~ /$DaysPlayed/) {
>         # checked
>     }
>     else {
>         # not checked
>     }
> }
>
>
> Bigus
>
>
>




------------------------------

Date: 29 Nov 2003 19:58:58 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: hash key evaluation creates an entry !
Message-Id: <3fc96b02@news.victoria.tc.ca>

Edo (eddGallary2@hotmail.com) wrote:
: > 
: > When you dereference $foo{bar}, and the key 'bar' does not exist in %foo,  
: > an empty reference is created automagically for you.  This is so you can 
: > do things like:
: > 
: >     for (something)
: >     {
: >         push @{ $foo{bar} }, $somevalue;
: >     }
: > 
: > without having to do backflips to see if you've initialized $foo{bar} to 
: > an array reference yet.  This is not a feature of hash values; it's a 
: > feature of scalars in general:
: > 
: >     for (something)
: >     {
: >         push @$foo, $somevalue;
: >     }
: > 
: > will work just fine if $foo has not been initialized.
: > 
: > So to answer your question, the code
: > 
: >     if (@{$foo{bar}} == $enf)
: > 
: > will in fact create an empty array reference at $foo{bar} if it had not 
: > been previously initialized to anything.  If that's not acceptable, then 
: > you should check with exists:
: > 
: >     if (exists $foo{bar})
: > 
: > or if you're not quite sure what might be stored there:
: > 
: >     if (exists $foo{bar}  &&  ref $foo{bar} eq 'ARRAY')
: > 
: I know that there is an array there, but I want to find out how many 
: aref are there under the key 1 of the hash. and if more than $enf then 
: splice it to be equal to $enf. I am having hard time doing that.

To find the size of the array, using $# or @

	use strict;

	my %set;
	$set{1} = [1,2,3,4,5,6,7];

	print "\n syntax for array \n";

	print @{$set{1}};

	print "\n same syntax, but get index instead of values \n";

	print $#{$set{1}} ;

	print "\n or get number of elements \n";

	print scalar @{$set{1}} ;





------------------------------

Date: Sun, 30 Nov 2003 02:26:47 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Memory Allocation Error when to fetching BLOB field from MS-SQL server Table
Message-Id: <3fc954b6.21550677@news2.news.adelphia.net>

On Sat, 29 Nov 2003 20:33:04 -0500, "Bazil" <Admin@goMonitor.com> wrote:

>If anyone has experience in fetching a Blob field on MS-SQL(7) please have a
>look at this.
>
>I am trying to fetch a Blob column (Image) from a MS-SQL(7) table.
>The select terminates with and error:
>"Could not allocate enough memory (-1 bytes) for column 1."
> it dies on line 14.
>
>Thanks for any suggestion.
>
>9    $SqlString = " Select viewcontent  from NewProfile where  ID='Prof2' ";
>10   if(($dbh->Sql( $SqlString )))
>11  {
>12    $ErrMsg = 'SQL-Err:'.$dbh->Error();
>13    print "SQL ERR on: $SqlString $ErrMs
>14   die
>15  };
>16   $dbh->FetchRow();
>17   {
>18   undef %Data;
>19   %Data       = $dbh->DataHash();
>10   $FldContent=$Data{$_[1]};

Suggestion: can you fetch a small, non-blob data entry form the same database?
If you can, then see how big of a blob you can fetch without error--start with
a blob one byte in size.

Can you add a line to the database with the test data oulined above?

---
Use the domain skylightview (dot) com for the reply address instead.


------------------------------

Date: Sun, 30 Nov 2003 04:09:56 GMT
From: Gerard Lanois <gerardlanois@netscape.net>
Subject: Re: Newsgroup Searching Program
Message-Id: <ubrquebu3.fsf@netscape.net>

Mike Flannigan <mikeflan@earthlink.net> writes:

> the group function doesn't return anything.  When I
> run the script below, it just prints:
> 
> last =
> first =
> newsgroup name =
> :    0 articles  (0       to
> 0      )
> 
> 
> I'm guessing the problem has something to do with my
> host server "news.west.earthlink.net".
> 
> 
> Mike
> 
> 
> 
> use strict;
> use Net::NNTP;
> 
> #set lexical variables
> my($SERVER, $nntp, $articles, $first, $last, $ng_name);
> 
> #define NNTP server
> $SERVER = 'news.west.earthlink.net';
> #declare new Net::NNTP object - or die with a connection failure
> #message
> $nntp = Net::NNTP->new($SERVER, Debug=>0)
> or die "Can't connect to server $SERVER: $!\n";

So far, so good.

Does your news server require an account and password?  If so, you'll
want to add lines that look like this:

my $account = 'myaccount';
my $password = 'secret';

$nntp->authinfo($account, $password) 
or die "ERROR: Net::NNTP->authinfo() failed.\n";

> #define what newsgroup to use -
> #get the newsgroup name, amount of article, the first article number
> #and last article number
> ($articles,$first,$last,$ng_name) =
> $nntp->group('comp.lang.perl.misc');

There is a return code you can ask for which might help you diagnose
the problem.  Maybe add some lines right after your call to group() which
look like this:

my $code = $nntp->code;
print 'group() returned code '.$code."\n";

Then you can look up the value in section 2.4 of the NNTP RFC:

    http://www.faqs.org/rfcs/rfc977.html


You can also check the $nntp->code value immediately after your call
to authinfo() above.  That will help you diagnose any potential user
name and password issues.

If you really think there is a problem with the server, you can telnet
into port 119 on the server machine and speak raw commands to it.
I've done this numerous times in order to demonstrate problems to
various NSPs I've subscribed to.  The RFC lists all the possible
commands.  If you forget, you can just type HELP - and the server will
give you the list of commands it supports (GROUP, QUIT, etc).  You
will notice a strong correlation between the commands and the methods
of class Net::NNTP.


-Gerard
http://home.san.rr.com/lanois/perl/


------------------------------

Date: Sun, 30 Nov 2003 02:29:05 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Reading Dates from Excel-file
Message-Id: <3fc955da.21842813@news2.news.adelphia.net>

On 29 Nov 2003 14:44:22 -0800, in comp.lang.perl.misc you wrote:

>
>use Win32::OLE::Const 'Microsoft Excel';
>use strict;
>
>my $excelfile = "test.xls";
>
>sub readexcelfile {
>	my $source = $_[0];
>	
>	my @all;
>	my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
>	    || Win32::OLE->new('Excel.Application', 'Quit');  
>	my $Book = $Excel->Workbooks->Open("$source"); 	     
>	my $Sheet = $Book->Worksheets(1);                      
>	
>	my $rows = $Sheet->UsedRange->Rows->Count;
>	my $blatt = $Sheet->Range("A1:K$rows")->{'Value'};   
>	$Book->Close(0);
>
>	foreach my $ref_zeile (@$blatt) {                    
>		my $line = "";
>		for my $item (@$ref_zeile) {
>			$line.=$item."\t"; 
>		}

#########

I think that here is the problem, I think. You are assuming that $item is a
simple scalar. But sometimes it is a reference to a date object, an array, etc:

see docs for  Win32::OLE::Variant -- you may need to use that module BTW:

        my $v = Variant(VT_DATE, "April 1 99");
        print $v->Date(DATE_LONGDATE), "\n";
        print $v->Date("ddd',' MMM dd yy"), "\n";will print:

        Thursday, April 01, 1999
        Thu, Apr 01 99

###########

>		push(@all,$line);
>	} 
>	#@all = reverse sort buildvgl @all;
>	return @all;
>}
>



---
Use the domain skylightview (dot) com for the reply address instead.


------------------------------

Date: Sun, 30 Nov 2003 03:08:02 GMT
From: "Greg Patnude" <gpatnude@adelphia.net>
Subject: Re: Reading Dates from Excel-file
Message-Id: <madyb.4764$zL1.500734@news1.news.adelphia.net>

Win32::OLE is not very "portable" -- you're basically stuck on windows with
the ActiveState port and having to have MS Office applications installed on
the box...

If you are interested in manipulating Excel spreadsheets programatically
WITHOUT MS Office -- I suggest you look into the Spreadsheet-ParseExcel
modules at CPAN:

http://search.cpan.org/~kwitknr/Spreadsheet-ParseExcel-0.2602/ParseExcel.pm


Greg Patnude / The Digital Demention
2916 East Upper Hayden Lake Road
Hayden Lake, ID 83835
(208) 762-0762



"bruno" <bskorepa@yahoo.com> wrote in message
news:f542e1ac.0311290330.5be1e632@posting.google.com...
> I have a script that reads an excel file.
> Since I upgraded to activeperl 5.8 the date-fields are read as:
>
> Win32::OLE::Variant=SCALAR(0x20d341c)
>
> before I got real date-values (although I do not remember what
> perl-version I had before).
> Platform: win2000
>
> thanks for any hints,
> Bruno




------------------------------

Date: Sun, 30 Nov 2003 03:08:21 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Reading Dates from Excel-file
Message-Id: <3FC95D46.3050308@rochester.rr.com>

bruno wrote:

> As I was told to provide a code sample, here it is:
> This function returns an array of lines, where every line 
> contains the cells of the excel spreadsheet seperated by tabs.
> 
> Cells that contain simple text or numbers are exported as expected,
> cells that contain date values are exported as:
> Win32::OLE::Variant=SCALAR(0x20d341c)
> 
> eg:
> 
> number	text	date
> 491	Stammdaten	Win32::OLE::Variant=SCALAR(0x20d341c)
> 487	Abrechnung	Win32::OLE::Variant=SCALAR(0x20d25e0)
> 482	Audiometrie	Win32::OLE::Variant=SCALAR(0x20d1274)
> 
> 
> #############################################################
> # start of sample
> # just paste and provide valid filename 
> 
> use Win32::OLE::Const 'Microsoft Excel';
> use strict;


   use warnings; # ***always*** use warnings when debugging!!!


> 
> my $excelfile = "test.xls";
> 
> sub readexcelfile {
> 	my $source = $_[0];
> 	
> 	my @all;
> 	my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
> 	    || Win32::OLE->new('Excel.Application', 'Quit');  
> 	my $Book = $Excel->Workbooks->Open("$source"); 	     
> 	my $Sheet = $Book->Worksheets(1);                      
> 	
> 	my $rows = $Sheet->UsedRange->Rows->Count;
> 	my $blatt = $Sheet->Range("A1:K$rows")->{'Value'};   
> 	$Book->Close(0);
> 
> 	foreach my $ref_zeile (@$blatt) {                    
> 		my $line = "";
> 		for my $item (@$ref_zeile) {


Here, $item is not necessarily a string.  It could be a 
Win32::OLE::Variant object, which could be a variety of things, one of 
which is a reference to a scalar.  You get the message you got because 
$item was a blessed reference to a scalar.  A "quick fix" is to test to 
see if $item is a reference, and, if it is, assume it is a reference to 
a Win32::OLE::Variant Date object, and stringify the date.  This can be 
done with:

          use Win32::OLE::NLS qw(:LOCALE :DATE); #to get the constant
          $line.=(ref($item)?$item->Date(DATE_LONGDATE):$item)."\t";

That will stringify an Excel date to something that prints useful info. 
    But if the $item is a Variant which is not a Date, this will mess up.

To treat the full range of possible $item's will involve testing the 
item to see if it is a Win32::OLE::Variant object (hint:  ref() ), and, 
if it is, using a couple of methods from Win32::OLE::Variant, such as 
the ->Type method to figure out what type of Variant it is, and then 
calling an appropriate method to convert it according to an appropriate 
format.  I leave that as an exercise for the reader.


> 			$line.=$item."\t"; 
> 		}
> 		push(@all,$line);
> 	} 
> 	#@all = reverse sort buildvgl @all;
> 	return @all;
> }
> 
> 
> #dummy main to read the file and dump the lines:
> {
> 	my @lines = readexcelfile($excelfile);
> 	foreach(@lines) {
> 		print "$_\n";
> 	}
> }
> 
> # end of sample
> #############################################################
> 
> If there is a better way, or an easy way to directly access the file
> (without excel needed to be installed on that particular workstation)
> please let me know.


There are many ways to go, most of which are a lot less hassle than 
using Win32::OLE with all the foibles of OLE.  One would be to look on 
CPAN for Excel-related modules.  Spreadsheet::ParseExcel might do the 
trick, and shouldn't require the presence of Excel (so you can use it on 
any OS, even one for which Excel is not available).  I know nothing 
about this module other than that is exists.

Another would be to treat your spreadsheet as a database and use the DBI 
module with DBD::Excel to access it.  That is probably the easiest.

HTH.
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: 30 Nov 2003 04:27:52 -0800
From: bskorepa@yahoo.com (bruno)
Subject: Re: Reading Dates from Excel-file
Message-Id: <f542e1ac.0311300427.70e37d17@posting.google.com>

>A "quick fix" is to test to 
> see if $item is a reference, and, if it is, assume it is a reference to 
> a Win32::OLE::Variant Date object, and stringify the date.  This can be 
> done with:
> 
>           use Win32::OLE::NLS qw(:LOCALE :DATE); #to get the constant
>           $line.=(ref($item)?$item->Date(DATE_LONGDATE):$item)."\t";


Thanks, got it.

BTW, for some reason I get the answers via mail hours before they
appear on the board. That's the reason why I had not referred to your
first posting, because I thought, that you had written me an e-mail.

thanks, bruno.


------------------------------

Date: 30 Nov 2003 05:06:58 -0800
From: bskorepa@yahoo.com (bruno)
Subject: Re: Reading Dates from Excel-file
Message-Id: <f542e1ac.0311300506.6176252b@posting.google.com>

I just downloaded it, looks good,
thanks, bruno.


------------------------------

Date: Sun, 30 Nov 2003 05:37:52 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: redirect using location header does not work from an already redirected doc.
Message-Id: <bqbsgn$21banl$1@ID-184292.news.uni-berlin.de>

Please note that your question is totally off topic in this group.

Will wrote:
> 
> redirect.pl
> sub DO_REDIRECT {
>  ...
>  print "Location: /index.html \n\n"; 
>  ...
> }
> 
> this works when I access the script directly by its url.
> but when its forwarded to by the 404 error it does not work.

I would try the full URL instead of just /index.html.

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



------------------------------

Date: Sun, 30 Nov 2003 12:37:10 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: redirect using location header does not work from an already redirected doc.
Message-Id: <Pine.LNX.4.53.0311301230480.16880@ppepc56.ph.gla.ac.uk>

On Sun, 29 Nov 2003, Will wrote:

> interesting situation:

Would be on-topic for comp.infosystems.www.authoring.cgi

>  print "Location: /index.html \n\n";

Check the CGI specification.  That form of CGI response is mandated to
return its results with status 200 (sometimes known as an internal
redirection).

To get a redirection by means of an external HTTP redirection
transaction (HTTP status 30x and HTTP location header), the CGI
specification calls for a complete URL in the CGI Location: response.

> Any one has any idea how to make it work, please reply.

Perlfaq9 points you at appropriate resources (and the appropriate
newsgroup for discussing the topic).  Use the FAQs, Luke.


------------------------------

Date: Sat, 29 Nov 2003 22:05:40 -1000
From: "dominix" <dominix"at"despammed.com>
Subject: Re: subnets eating each other?
Message-Id: <3fc9a4d5$0$18453$626a54ce@news.free.fr>

Matija Papec wrote:
> X-Ftn-To: Matija Papec
>
> Matija Papec <perl@my-header.org> wrote:
>>>> I would like to discover situations when one ip/mask is able to
>>>> cover another one, eg. does 22.122.0.0/16 cover 122.0.0.0/24?
>>>
>>> *If* you wanted to use a module, you could use the Net::Netmask
>>> module (http://search.cpan.org/~muir/Net-Netmask-1.9004/Netmask.pod)
>>
>
> Unfortunately Netmask.pm does not what I want, it can't tell if
> 22.3.0.0/16 can "eat" 22.3.1.0/24
>

I suggest you look at  NetAddr::IP
it has a contain method ...

-- 
dominix




------------------------------

Date: Sun, 30 Nov 2003 00:13:51 -1000
From: "dominix" <dominix"at"despammed.com>
Subject: Re: subnets eating each other?
Message-Id: <3fc9c2e1$0$18445$626a54ce@news.free.fr>

dominix" <dominix"at wrote:
> Matija Papec wrote:
>> X-Ftn-To: Matija Papec
>>
>> Matija Papec <perl@my-header.org> wrote:
>>>>> I would like to discover situations when one ip/mask is able to
>>>>> cover another one, eg. does 22.122.0.0/16 cover 122.0.0.0/24?
>>>>
>>>> *If* you wanted to use a module, you could use the Net::Netmask
>>>> module
>>>> (http://search.cpan.org/~muir/Net-Netmask-1.9004/Netmask.pod)
>>>
>>
>> Unfortunately Netmask.pm does not what I want, it can't tell if
>> 22.3.0.0/16 can "eat" 22.3.1.0/24
>>
>
> I suggest you look at  NetAddr::IP
> it has a contain method ...

and off course Net::Subnet


-- dominix




------------------------------

Date: Sun, 30 Nov 2003 10:57:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: subnets eating each other?
Message-Id: <bqci4n$tre$1@ichaos.ichaos-int>

Matija Papec <perl@my-header.org> said:
>I would like to discover situations when one ip/mask is able to cover
>another one, eg. does 22.122.0.0/16 cover 122.0.0.0/24?
>I made integer conversion for ip/mask but don't know what to do further..

Can't think this in proper code just now, but what should be correct
approach is that you take the "wider" mask and apply that to the net
address of the network with the "tigter" mask. If this brings you the
net address of the network with the "wider" mask, then the smaller
network is completely within the larger one.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


------------------------------

Date: Sun, 30 Nov 2003 13:45:22 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: subnets eating each other?
Message-Id: <b8pjsvg6ufkef1f455lklgrrmqtbtsqs09@4ax.com>

X-Ftn-To: Juha Laiho 

Juha Laiho <Juha.Laiho@iki.fi> wrote:
>>I would like to discover situations when one ip/mask is able to cover
>>another one, eg. does 22.122.0.0/16 cover 122.0.0.0/24?
>>I made integer conversion for ip/mask but don't know what to do further..
>
>Can't think this in proper code just now, but what should be correct
>approach is that you take the "wider" mask and apply that to the net
>address of the network with the "tigter" mask. If this brings you the
>net address of the network with the "wider" mask, then the smaller
>network is completely within the larger one.

Yes! That would be,
if ((4294901760 & 369165056) == 369164288) ...

for 22.1.3.0/24 and 22.1.0.0/16 subnets.


$VAR1 = {
          '_source' => {
                         'ip' => 369165056,
                         'pr' => 0,
                         'mask' => 4294967040
                       },
          'source' => '22.1.3.0/24'
        };
$VAR2 = {
          '_source' => {
                         'ip' => 369164288,
                         'pr' => 0,
                         'mask' => 4294901760
                       },
          'source' => '22.1.0.0/16'
        };


-- 
Matija


------------------------------

Date: Sun, 30 Nov 2003 13:45:24 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: subnets eating each other?
Message-Id: <rjojsvkbi858gmm78cgi0tqt5bq93t2bm4@4ax.com>

X-Ftn-To: "dominix" <dominix"at"despammed.com> 

>>> Unfortunately Netmask.pm does not what I want, it can't tell if
>>> 22.3.0.0/16 can "eat" 22.3.1.0/24
>>
>> I suggest you look at  NetAddr::IP
>> it has a contain method ...
>
>and off course Net::Subnet

Tnx, I'll take a look.


-- 
Matija


------------------------------

Date: 29 Nov 2003 22:55:16 -0800
From: s99999999s2003@yahoo.com (mike)
Subject: Syntax checking of user input
Message-Id: <dfd17ef4.0311292255.1dd98048@posting.google.com>

hi

i need to get user input and filter the input like this :
pass(func1) (OR|AND) pass(anyinput) (OR|AND) pass(func) 

the conditions to be met are
1) check for any number of the word "pass"
2) only OR and AND can be used. Therefore the following are valid:
   - pass(anywords) AND pass(anywords2) OR pass(anyany) 
   - pass(anywords) AND pass(anywords3)
   - pass(anywords)
3) any number of words and digits can be inside the parenthesis
   eg pass(abcd) or pass(1d2ad) etc
4) cannot have a "runaway" OR or AND, like this
   - pass(asdfa) OR
 
an initial attempt is 

my $input = <STDIN>;
chomp($input);
if ( $input =~ /(OR|AND)$/  )
{   failed() ; }
elsif ( $input =~ /^pass\((.*)\)$/ )
{ dosomething(); }



but i am stuck with this input condition whereby user keys in many
"pass" ,
something like this: 
pass(args1) OR pass(args2) AND pass(args3) OR pass(args4) AND
pass(args5) OR pass(1234) AND pass(args6) OR pass(aafs)

in a situation like this, how can i perform input validation using
regular expressions in perl?

thanks


------------------------------

Date: Sun, 30 Nov 2003 17:22:52 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Syntax checking of user input
Message-Id: <1137654.I1l3SevATi@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and mike managed to scribble:

> hi
> 
> i need to get user input and filter the input like this :
> pass(func1) (OR|AND) pass(anyinput) (OR|AND) pass(func)
> 
> the conditions to be met are
> 1) check for any number of the word "pass"
> 2) only OR and AND can be used. Therefore the following are valid:
>    - pass(anywords) AND pass(anywords2) OR pass(anyany)
>    - pass(anywords) AND pass(anywords3)
>    - pass(anywords)
> 3) any number of words and digits can be inside the parenthesis
>    eg pass(abcd) or pass(1d2ad) etc
> 4) cannot have a "runaway" OR or AND, like this
>    - pass(asdfa) OR
>  
> an initial attempt is
> 
> my $input = <STDIN>;
> chomp($input);
> if ( $input =~ /(OR|AND)$/  )
> {   failed() ; }
> elsif ( $input =~ /^pass\((.*)\)$/ )
> { dosomething(); }
> 
> 
> 
> but i am stuck with this input condition whereby user keys in many
> "pass" ,
> something like this:
> pass(args1) OR pass(args2) AND pass(args3) OR pass(args4) AND
> pass(args5) OR pass(1234) AND pass(args6) OR pass(aafs)
> 
> in a situation like this, how can i perform input validation using
> regular expressions in perl?
> 
> thanks

You really want a parser - check out Parse::RecDescent in www.cpan.org .
You need to consider the operator precidence of AND and OR.

gtoomey



------------------------------

Date: 29 Nov 2003 21:16:18 -0800
From: altalingua@hotmail.com (David Morel)
Subject: trouble with DBI/CGI
Message-Id: <60c4a7b1.0311292116.670c439f@posting.google.com>

Hi,

I am having trouble combining DBI and CGI.

Consider the following program:

#!/usr/local/bin/perl -w
use strict;
use DBI;
use CGI ':standard';

print "Content-type: text/plain\n\n";
print "abc\n";
my $dbh = DBI->connect("dbi:Oracle:ORCL", "username", "password");
print "123\n";


When I run the above program from a web browser, I get the output:
abc

When I run the above program from the command line, I get the output:
abc
123

In other words, it seems that when I run the script from the web it
stops immediately after it creates the database handle... but works
properly when run from the command line.

What gives?

Thank you,
David Morel


------------------------------

Date: Sun, 30 Nov 2003 06:27:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: trouble with DBI/CGI
Message-Id: <bqbvee$20ob4e$1@ID-184292.news.uni-berlin.de>

David Morel wrote:
> Consider the following program:
> 
> #!/usr/local/bin/perl -w
> use strict;
> use DBI;
> use CGI ':standard';
> 
> print "Content-type: text/plain\n\n";
> print "abc\n";
> my $dbh = DBI->connect("dbi:Oracle:ORCL", "username", "password");
> print "123\n";
> 
> When I run the above program from a web browser, I get the output:
> abc
> 
> When I run the above program from the command line, I get the
> output:
> abc
> 123
> 
> In other words, it seems that when I run the script from the web it
> stops immediately after it creates the database handle... but
> works properly when run from the command line.

Seems like a permission problem to me. (CGI scripts are probably run
as some other user.)

But why guess? Why not ask Perl about it?

     my $dbh = DBI->connect("dbi:Oracle:ORCL", "username", "password")
       or die $dbh->errstr;

See more about capturing DBI errors in the docs for DBI.pm.

You may also want to include this line in the beginning of the script:

     use CGI::Carp 'fatalsToBrowser';

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



------------------------------

Date: 30 Nov 2003 06:06:52 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: trouble with DBI/CGI
Message-Id: <slrnbsj27s.ptk.sholden@flexal.cs.usyd.edu.au>

On 29 Nov 2003 21:16:18 -0800, David Morel <altalingua@hotmail.com> wrote:
> Hi,
> 
> I am having trouble combining DBI and CGI.
> 
> Consider the following program:
> 
[snip program and output description]
> 
> In other words, it seems that when I run the script from the web it
> stops immediately after it creates the database handle... but works
> properly when run from the command line.

Check the error message that should be logged somewhere by the web server.

Or add "use CGI::Carp 'fatalsToBrowser';" to the top.

-- 
Sam Holden


------------------------------

Date: Sun, 30 Nov 2003 10:57:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: trouble with DBI/CGI
Message-Id: <bqcib9$tre$2@ichaos.ichaos-int>

altalingua@hotmail.com (David Morel) said:
>I am having trouble combining DBI and CGI.
 ...
>print "abc\n";
>my $dbh = DBI->connect("dbi:Oracle:ORCL", "username", "password");
>print "123\n";
>
>When I run the above program from a web browser, I get the output:
>abc
>
>When I run the above program from the command line, I get the output:
>abc
>123
>
>In other words, it seems that when I run the script from the web it
>stops immediately after it creates the database handle... but works
>properly when run from the command line.

My best guess from this information is that the ORACLE_HOME environment
variable isn't set when you're running your script as a CGI. Verify
this with the means provided in the other response.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


------------------------------

Date: Sun, 30 Nov 2003 05:04:50 -0700
From: Ron Reidy <r_reidy@comcast.net>
Subject: Re: trouble with DBI/CGI
Message-Id: <3FC9DCE2.9020007@comcast.net>

The problem is malformed header.  Check the CGI docs and look in the web 
browser's error log.

David Morel wrote:
> Hi,
> 
> I am having trouble combining DBI and CGI.
> 
> Consider the following program:
> 
> #!/usr/local/bin/perl -w
> use strict;
> use DBI;
> use CGI ':standard';
> 
> print "Content-type: text/plain\n\n";
> print "abc\n";
> my $dbh = DBI->connect("dbi:Oracle:ORCL", "username", "password");
> print "123\n";
> 
> 
> When I run the above program from a web browser, I get the output:
> abc
> 
> When I run the above program from the command line, I get the output:
> abc
> 123
> 
> In other words, it seems that when I run the script from the web it
> stops immediately after it creates the database handle... but works
> properly when run from the command line.
> 
> What gives?
> 
> Thank you,
> David Morel


-- 
Ron Reidy
Oracle DBA



------------------------------

Date: Sun, 30 Nov 2003 07:32:23 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: trouble with DBI/CGI
Message-Id: <Xns944356F977B24sdn.comcast@216.196.97.136>

Ron Reidy <r_reidy@comcast.net> wrote in news:3FC9DCE2.9020007@comcast.net:

> The problem is malformed header.  Check the CGI docs and look in the web 
> browser's error log.

What's wrong with the OP's header?

    print "Content-type: text/plain\n\n";

-- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5874
***************************************


home help back first fref pref prev next nref lref last post