Re: Win32::GUI crashing, burning -- fixed!

2003-10-08 Thread Eric Hillman
Tobias Hoellrich wrote:
> Try naming all your gui-objects and it'll do wonders:
> 
> $main->AddLabel(-text => $text, -name => "foobar");
> 
> HTH
>   Tobias
 
 
 Yay!  Thanks a million.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::GUI crashing, burning.

2003-10-08 Thread Tobias Hoellrich
Try naming all your gui-objects and it'll do wonders:

$main->AddLabel(-text => $text, -name => "foobar");

HTH
  Tobias

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Eric Hillman
> Sent: Wednesday, October 08, 2003 4:56 PM
> To: Perl-Win32
> Subject: Win32::GUI crashing, burning.
> 
> 
> Weird problem here...  I've been trying to move to Win32::GUI
> from Tk, and I can't even get as far as "Hello World" without 
> perl crashing with a "Perl.exe generated errors and will be 
> closed by Windows" Dr. Watson popup.
> 
> The error I'm getting happens when I try to add pretty much
> any widget. For example, right now I'm trying to do something like:
> 
> my $text = "Hello World";
> $main->AddLabel(-text => $text);
> 
> Looking at it with the debugger, it appears that the error
> occurs as I'm going through 
> Win32::GUI::WindowProps->FETCH($self, $key), with $key = 
> "-font".  Going by the tutorials I'm reading, there ought to 
> be a default value, but perl crashes on FETCH returning Undef.
> 
> Even weirder, when I defined a font, it died trying to
> process $key = "-handle", which went through just fine before 
> -- it doesn't even get as far as -font.
> 
> The only thing I could think of is maybe it had something to
> do with the fact that I had Cygwin's perl on this box as 
> well, so I uninstalled that, and reinstalled the Win32::GUI 
> module.  Still no dice.
> 
> Any ideas?  Am I missing something important here?
> 
> --
> Eric Hillman
> Sr System Administrator
> Balogh Becker, LTD.
> 
> 
> here's the code:
> 
> 
> use strict;
> use Win32::GUI;
> use vars qw( $main );
> 
> 
> $main = Win32::GUI::Window->new(-name => 'Main', -text => 'Perl',
> -width => 200, -height => 200);
> 
> my $text = "Hello World";
> my $textfont = Win32::GUI::Font->new(-name => "Comic Sans MS",
>  -size => 24);
> $main->AddLabel(-text => $text,  # <- If I comment this out,
> -font => $textfont); #the program works.
> $main->Show();
> Win32::GUI::Dialog( );
> 
> 
> sub Main_Terminate {
> -1;
> }
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Win32::GUI crashing, burning.

2003-10-08 Thread Eric Hillman
Weird problem here...  I've been trying to move to Win32::GUI from Tk,
and I can't even get as far as "Hello World" without perl crashing with
a "Perl.exe generated errors and will be closed by Windows" Dr. Watson
popup.

The error I'm getting happens when I try to add pretty much any widget.
For example, right now I'm trying to do something like:

my $text = "Hello World";
$main->AddLabel(-text => $text);

Looking at it with the debugger, it appears that the error occurs as I'm
going through Win32::GUI::WindowProps->FETCH($self, $key), with $key =
"-font".  Going by the tutorials I'm reading, there ought to be a
default value, but perl crashes on FETCH returning Undef.

Even weirder, when I defined a font, it died trying to process $key =
"-handle", which went through just fine before -- it doesn't even get as
far as -font.

The only thing I could think of is maybe it had something to do with the
fact that I had Cygwin's perl on this box as well, so I uninstalled
that, and reinstalled the Win32::GUI module.  Still no dice.

Any ideas?  Am I missing something important here?

--
Eric Hillman
Sr System Administrator
Balogh Becker, LTD.


here's the code:


use strict;
use Win32::GUI;
use vars qw( $main );


$main = Win32::GUI::Window->new(-name => 'Main', -text => 'Perl',
-width => 200, -height => 200);

my $text = "Hello World";
my $textfont = Win32::GUI::Font->new(-name => "Comic Sans MS",
 -size => 24);
$main->AddLabel(-text => $text,  # <- If I comment this out,
-font => $textfont); #the program works.
$main->Show();
Win32::GUI::Dialog( );


sub Main_Terminate {
-1;
}

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: could not ODBC Sam-Test ...

2003-10-08 Thread Eric Promislow
For those who found the earlier response hard to read due to
raw HTML, the quick answer is that you've specified that the directory
is 'c:\ab' by using double-quotes.  Change

$Dir = "c:\temp";

to

$Dir = 'c:\temp';

so Perl won't treat the '\' as an escape character.

- Eric

"Blame me for having to type the backslash in DOS" - Paul Allen, Wired 2.08

On Wed, Oct 08, 2003 at 12:04:06PM -0700, [EMAIL PROTECTED] wrote:
> From: "S Taylor" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Subject: could not ODBC Sam-Test because -1044[Microsoft][ODBC Microsoft Access 
> Driver] N
> Date: Tue, 7 Oct 2003 20:26:13 -0500
> 
> This assignment:
> 
> $DriverType = 'Microsoft Access Driver (*.mdb)';
> $DSN = "Sam-Test";
> $Dir = "c:\temp";
> $DBase = "db1.mdb";
> .
> .
> .
> LN27  -  $db=new Win32::ODBC($DSN) or die "could not ODBC $DSN because ",
> Win32::ODBC::Error()," \n";
> 
> Produces the following error message:
> 
> "Use of uninitialized value in die at c:\cgi-bin\perl\test9.pl line 27.
> could not ODBC Sam-Test because -1044[Microsoft][ODBC Microsoft Access
> Driver] N
> ot a valid file name."
> 
> What is the probable cause of this error ?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: newline...be gone

2003-10-08 Thread Joe Youngquist
your 'newline' character might be chr(13)

so a chop might do better for you or

my $newline = chr(13);

$line =~ s/$newline//;

...



HTH

JY
- Original Message - 
From: "David Byrne" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 08, 2003 3:08 PM
Subject: newline...be gone


> Greetings,
> 
> I have a question that probably easy to many...
> 
> How can I get rid of the newline at the end of $line
> (which transfers to $remainder after splitting)?
> 
> foreach $filename (@filelist) {  
> open(INPUT,"$filename");
> foreach $line () {
>   chomp($line);
>   my ($gene,$remainder) = split(/\t/,$line,2);
>   chomp ($remainder);
>   $genedex{$gene} .= "$remainder\t";
> }
> }
> 
>  
> I've tried substituting, chomping, but the newline
> remains.  It's gotta be something obvious...
>  
> Thank you very much,
> David
> 
> __
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [SPAM] newline...be gone

2003-10-08 Thread Craig Cardimon
I would try: 

s/\n//g;

This should replace every newline with nothing, globally.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
David Byrne
Sent: Wednesday, October 08, 2003 4:09 PM
To: [EMAIL PROTECTED]
Subject: [SPAM] newline...be gone


Greetings,

I have a question that probably easy to many...

How can I get rid of the newline at the end of $line
(which transfers to $remainder after splitting)?

foreach $filename (@filelist) {  
open(INPUT,"$filename");
foreach $line () {
  chomp($line);
  my ($gene,$remainder) = split(/\t/,$line,2);
  chomp ($remainder);
  $genedex{$gene} .= "$remainder\t";
}
}

 
I've tried substituting, chomping, but the newline
remains.  It's gotta be something obvious...
 
Thank you very much,
David

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: newline...be gone

2003-10-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> Subject: newline...be gone
> 
> 
> Greetings,
> 
> I have a question that probably easy to many...
> 
> How can I get rid of the newline at the end of $line
> (which transfers to $remainder after splitting)?
If it is not off your system and you are getting the data from Unix, then 
their end of line and the end of line for Windows are different. So when you do chomp, 
chomp uses the variable $/ and what it has for doing the chomp. Otherwise if win to 
win, does not make sense. Chomp works like a champ at what it does.

Wags ;)
> 
> foreach $filename (@filelist) {
> open(INPUT,"$filename");
> foreach $line () {
>   chomp($line);
>   my ($gene,$remainder) = split(/\t/,$line,2);
>   chomp ($remainder);
>   $genedex{$gene} .= "$remainder\t";
> }
> }
> 
> 
> I've tried substituting, chomping, but the newline
> remains.  It's gotta be something obvious...
> 
> Thank you very much,
> David
> 
> __
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


newline...be gone

2003-10-08 Thread David Byrne
Greetings,

I have a question that probably easy to many...

How can I get rid of the newline at the end of $line
(which transfers to $remainder after splitting)?

foreach $filename (@filelist) {  
open(INPUT,"$filename");
foreach $line () {
  chomp($line);
  my ($gene,$remainder) = split(/\t/,$line,2);
  chomp ($remainder);
  $genedex{$gene} .= "$remainder\t";
}
}

 
I've tried substituting, chomping, but the newline
remains.  It's gotta be something obvious...
 
Thank you very much,
David

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Capturing the output of a system() command

2003-10-08 Thread Erich C. Beyrent
> Am I able to capture the output of a system call?
> Currently, I route the output to a temporary file,
> then read the contents in when the call is done.
> I'd rather not make a temp file.
> George

Hi there,

Here is what I do:

my $cmd = `base64 -e ASCIIFILE -`; 
 }

 open(APP, "$cmd 2>&1 |") or die "Cannot run the command: $!\n"; 
 while ()
 {
  print;
  $output .= $_;
 }
 close (APP);
 print "\n";

-Erich-

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: could not ODBC Sam-Test because -1044[Microsoft][ODBC Microsoft Access Driver] N

2003-10-08 Thread tanman


Check perldoc win32::odbc. Try (UNTESTED):
$DSN='DSN=Microsoft Access Driver (*.mdb);DBQ=c:\temp\db1.mdb'
then
$db=new Win32::ODBC($DSN) or die ...
Also note the distinction between double quotes (") and single quotes (') which you've confused in your code.
 
- Original Message -
From: S Taylor <[EMAIL PROTECTED]>
Date: Tuesday, October 7, 2003 9:26 pm
Subject: could not ODBC Sam-Test because -1044[Microsoft][ODBC Microsoft Access Driver] N

> This assignment: > > $DriverType = 'Microsoft Access Driver (*.mdb)'; > $DSN = "Sam-Test"; > $Dir = "c:\temp"; > $DBase = "db1.mdb"; > . > . > . > LN27 - $db=new Win32::ODBC($DSN) or die "could not ODBC $DSN > because ", > Win32::ODBC::Error()," \n"; > > Produces the following error message: > > "Use of uninitialized value in die at c:\cgi-bin\perl\test9.pl > line 27. > could not ODBC Sam-Test because -1044[Microsoft][ODBC Microsoft Access > Driver] N > ot a valid file name." > > What is the probable cause of this error ? > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


HTML::Parse question

2003-10-08 Thread Craig Cardimon
I'm trying to parse an HTML file for eventual importation into SQL
Server 2000. 

I've heard great things about HTML::Parse, but that module is not
available for ActiveState Perl 5.8.0 running on Windows XP Pro.

Any hint, tips, or suggestions on how to parse an HTML document into
ASCII would be appreciated.



Sincerely,

Craig Cardimon, Programmer
AUS Inc.
(Knowledge Express Data Systems; 1-800-529-5337, ext. 24)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Chomp to trim '\r'

2003-10-08 Thread Randy Kobes
On Wed, 8 Oct 2003, Richard Morse wrote:

> To the best of my knowledge, binmode isn't a
> "Windows-only" function.  It's just that the most common
> operating systems besides windows don't make distictions
> between text and binary files, so it isn't useful on *nix
> and its variants.  Apparently some older operating systems
> did make such a distinction (some made others as well),
> and it would be a necessary call on those systems.
>
> Further, I think you do need binmode to handle non-text files properly.
>   Even sysread/read will stop reading a text-mode file
> when they hit the control-D character (I had this happen
> to me) -- you have to put the file in binary mode to
> continue reading past the character.

That's a good point that binmode() in principle isn't
Windows specific, especially when one throws the use
of io layers into the mix. For example,
==
use strict;
use warnings;
my $scratch = 'scratch.dat';
my $utf8 = "\x{042F} \x{0432}\x{0430}\x{0441} \x{043B}\x{044E}";
open my $wfh, ">", $scratch
or die "Cannot open $scratch for writing: $!";
binmode($wfh, ':utf8');
print $wfh $utf8;
close $wfh;
open my $rfh, "<", $scratch,
or die "Cannot open $scratch for reading: $!";
binmode($rfh, ':utf8');
my $text;
{
local $/;
$text = <$rfh>;
}
close $rfh;
binmode(STDOUT, ':utf8');
print $utf8, "\n", $text, "\n";
==
needs the binmode calls, even on unix.

-- 
best regards,
randy kobes
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: file parsing

2003-10-08 Thread Lori
Thanks Carl  !
you were right - I was bitten by using $next line =<> not  $next line = 
...


I did finally get the following code to work, but Im sure it could be done more
consisely,
Im going to send you all my code followed by my teachers code. Just in case
someone finds
it interesting. Both my code and my teachers produce the same desired results but
I dont really like
either method. I guess I will get a lot of practice, because this months asg's all
deal with parsing
badly formatted html code.

Here is mine:  ( I made a lot more work for myself by not removing white space
from the line before
doing my reg ex.


my $source = "Whatsnew.html";
my $destination = "hw5.txt";

open IN, $source or die "Can't read source file $source: $!\n";
open OUT, ">$destination" or die "Can't write on file $destination: $!\n";

print "Copying $source to $destination\n";

my $base_url ="http://www.nanpa.com";;
my $rel_url ="";
my $new_url ="";

while(){

  if(/^\s+ (\d\d\/\d\d:)#match 1st line
   \s*   #zero,one or more spaces before a href
   (] #now get all chars up to but not including the end
tag
   +>)   #get the end tag
   (.*?)\s*$ #get all chars and don't save spaces at end of
line
   /isx  #used i to allow both upper and lower case, use s
for single line capture

  )

  {
   my $str_len =length($3);

if($str_len > 0){
  print OUT "$1" ," $3 " ;
  $rel_url = $2;
  $rel_url =~ s/\s*/ /;
  $rel_url =~ s/\s*//;
}
elsif(length($3)==0){  #if 1st ,subject is empty then dont insert a space
  print OUT "$1";
}
}
elsif(/^\s*(.*?)<\/a>\s*$/) #match 2nd line
{
 my $ab_url = $base_url.$rel_url;
 my $subject = $1;
 print OUT " $subject"  ;   #insert one space then subject
 print OUT " ( $ab_url )";
 print OUT "\n";
 last if /Planning Letter PL\-329/; #ends section I care about

  }

}
#***
Here is my teachers: Im not sure if it's good to mess with the Input Record
Separator



#   AUTHOR  DATEMODIFICATION
#   --  
#   Jim Kovacs  01 Oct 03   New.
#

my $url_absolute = 'http://www.nanpa.com';

while ( <> )
{
# Skip lines preceding the section of interest
next unless / >
> > my attempts follow but first here is a example of what Im parsing:
> >  09/26:  > href="../number_resource_info/carrier_id_codes.html">DCIC
> > Carrier Codes Updated
> >
> > --
> > my $source = "Whatsnew.html";
> > my $destination = "hw5.txt";
> >
> > open IN, $source or die "Can't read source file $source: $!\n";
> > open OUT, ">$destination" or die "Can't write on file $destination:
> > $!\n";
> >
> > print "Copying $source to $destination\n";
> >
> >
> > while(){
> >
> > #this first part works fine , I can get the date but the subject is half
> > on the 1st line and half on #the second.
> >
> >
> > if(/^\s+ (\d\d\/\d\d:)
> >   \s*
> >>   [^>]
> >   +>
> >   (.*?)\s*
> >   /isx
> >
> > ){
> >
> >   print OUT $1 ,$2 ;
> >   print OUT "\n";
> >  }
> >
> >  #now I want to get the next line in the file
> >  # adding this part creates an endless loop ?
> > my $next_line = <>;  # This line will have the 2nd half of the
> > subject
> > if ( $next_line =~ /(.*?)$/ )
> >   {
> > print OUT $next_line;
> >}
> >
> > }
>
> Your basic problem is that you try to read in the next record after
> you've found the matching one by doing <> instead of .
>
> I would just read the file looking for the matching record chomp it
> and then concatenate the data from the next record to it. Chomping
> the record provided by the following record if necessary.
> Now all your data items are contained in one variable. Although there are
> several ways to do these actions, one way would be:
>
> open(IN,"Whatsnew.html") || die "Can not find Whatsnew.html: $!\n";
> while($line=) {
>last if $line=~ /^\s+ (\d\d\/\d\d:)
>\s*
>[^>]
>+>
>(.*?)\s*
>/ix;
> }
> die "matching record not found in Whatsnew.html  unless defined $line;
> #See if there is a next record, i.e. is the size of the file in
> #characters greater than the current(relative to 1) position of the file
>
> unless (-s IN > tell(IN)+1) {
>#an attempt to read another record from IN would have resulted in an
>#eof.
>die "The matching record was the last record in Whatsnew.html, no next
> record is available\n";
> }
> #remove the terminating new-line character of the matching record
> chomp($line);
> $line.=; #co

Multiple 'do perlscript.pl' calls

2003-10-08 Thread Electron One
I have three questions and would really appreciate any help.

1. I am running a perl script that calls other perl scripts etc. All using 
the 'do perlscript.pl'
method. Apparently these perl scripts have gotten so long that after a
certain amount of  'do perlscript.pl' commands, the script crashes.
Is there a way to extend this, and make it able to call multiple 'do 
perlscript.pl' calls
 than it currently can handle?

2. When I run Multiple 'do perlscript.pl' calls , after the third or fourth 
call,
the error reporting seems to crap out. Is there a way to improve the error
reported of multiple 'do perlscript.pl' calls?

3. How do I change directories inside of a perl script such that 'do 
perlscript.pl' calls(inside that same perl script)
perlscript.pl inside the new directory, not the one that originally called 
the first perl script?

I am running on a Win2K system.

Thanks for all your help. 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


sub() or eval() ?

2003-10-08 Thread Burak Gürsoy
Which one is better (equal?)? why?

%some_hash = (
blah => sub { bleh() },
foo  => sub { $bar - $baz / 100 },
.
.
.
);

$some_hash{foo}->();

[or]

%some_hash = (
blah => 'bleh()',
foo  => '$bar - $baz / 100',
.
.
.
);

eval { $some_hash{foo} };

Well... I'm curious about sub()...
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Chomp to trim '\r'

2003-10-08 Thread Will of Thornhenge


Carl Jolley wrote:

After all, all binmode is, is a way
to turn off perl's default way of handling the "\r" for you.
It's your way of saying to perl "Thanks, but no thanks for your
offer of assistance, For this file, I can handle this issue without
your help".


While this is true within the context of this discussion (newline 
conversions), binmode does other things that can also be very important. 
For instance, I found out several years ago that it was necessary to use 
binmode when opening some Word97 files in Perl scripts (under Win98), or 
some of the files would be truncated in the proprietary MS header. As I 
recall, the specific problem was a \000 byte early in the header that 
Perl would treat as an eof (unless binmode was in use), but I understand 
that binmode also turns off Perl's default handling of embedded Ctrl-Z 
and other control characters.

So I'm not disagreeing with you, but simply pointing out that whenever 
the input file is in a proprietary format that mixes text with binary 
segments, binmode is something to think about. At least under Windows, 
DOS, and related OSs.

And then there's the whole disciplines thing that can be done with 
binmode (or a 3 argument open). But I don't go there; it is my fervent 
hope that Perl 6.0 will fix up all that stuff before I have to deal with 
any multibyte unicode data.  :-)

--
Will Woodhull
[EMAIL PROTECTED]
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Chomp to trim '\r'

2003-10-08 Thread Richard Morse
On Wednesday, October 8, 2003, at 12:52 AM, Carl Jolley wrote:

Anyway that's why binmode is a Windows-only function. A common
mis-conception among windows perl'ers is that somehow binmode
is needed to properly handle a binary/non-text mode file.
To the best of my knowledge, binmode isn't a "Windows-only" function.  
It's just that the most common operating systems besides windows don't 
make distictions between text and binary files, so it isn't useful on 
*nix and its variants.  Apparently some older operating systems did 
make such a distinction (some made others as well), and it would be a 
necessary call on those systems.

Further, I think you do need binmode to handle non-text files properly. 
 Even sysread/read will stop reading a text-mode file when they hit the 
control-D character (I had this happen to me) -- you have to put the 
file in binary mode to continue reading past the character.

Ricky

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How to skip unwanted columns in CSV file?

2003-10-08 Thread Richard Morse
On Monday, October 6, 2003, at 07:01 AM, Carl Jolley wrote:

On Fri, 26 Sep 2003, Ken Cornetet wrote:

I suppose you could get fancy and use DBI and DBD-CSV.

Why complicate a simple task? Unless of course, you're trying to
deliberatly make life difficult for the next person who will have
to maintain your code. Unnecessary "fancy" is rarely appreciated
by other than the party of the first part OTOH, simplistic elegance
is widely admired.
Yes, but in this case there may be a reason to use modules.  If the 
files that his is parsing have text data other than numbers it can get 
very complicated to parse CSV files.  As I recall, CSV does allow 
commas to be included in text strings -- so first, you have to figure 
out where the strings are (ie, break on the '"' character, then 
determine which are opening and closing quotes, and which may just be 
quotes inside a string, via escaping or duplicating), then you can 
figure out where the columns are.  This is why I prefer tab-delimited, 
because I can think of _very_ few situations where a tab character is 
valid data.  However, if he is going to use CSV, using a module which 
has dealt with all of the special cases may make sense.

In addition, by bulding around DBI, if he suddenly needs to start 
getting input from some other data source, he may find it much easier 
to modify his code...

Ricky

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: TK positioning viewable area of scrolled rotext

2003-10-08 Thread Lynn. Rickards
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Beckett Richard-qswi266
> Sent: Wednesday, October 08, 2003 6:52 AM
> To: '[EMAIL PROTECTED]'
> Subject: TK positioning viewable area of scrolled rotext
> 
> 
> Guys,
> 
> I am using a scrolled rotext widget with 2 lines as a status 
> bar, so that
> the user can scroll backwards over the messages.
> 
> How do I make the widget display the bottem of the scrolled 
> area, rather
> than the top?
> 
> Thanks.
> 

$t->see('end') ? - works on text widget.

-Lynn.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Chomp to trim '\r'

2003-10-08 Thread Carl Jolley
On Wed, 8 Oct 2003, Sisyphus wrote:

> Lee Goddard wrote:
>
> >
> > Why not use a regular expression?
> >
>
> I can't find an answer to that question - and, judging by the responses
> so far received, nor can anyone else !!
>
> ;-)
>

You know that in perl "TAMTOWTDI". However usually there
are some ways that are more-or-less equivalent and then there
are ways that only a veteran of several obfuscated perl contests
could appreciate.

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Filling an input file field

2003-10-08 Thread Barry Dancis
Hi --

I am using formbuilder with template toolkit and ie6. One of my fields
is of type=file but IE6 won't let me set its value using
values => $file_name. Is there any way to set it with formbuilder and still
have the nice file search input? Do I have to write my own file browser?
Have a text field filled by formbuiler and a file field that on change also
fills the text field? Some other method?

Thanks,

Barry


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


TK positioning viewable area of scrolled rotext

2003-10-08 Thread Beckett Richard-qswi266
Guys,

I am using a scrolled rotext widget with 2 lines as a status bar, so that
the user can scroll backwards over the messages.

How do I make the widget display the bottem of the scrolled area, rather
than the top?

Thanks.

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: WWW::Mechanize question

2003-10-08 Thread mail admin

- Original Message -
From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: "mail admin" <[EMAIL PROTECTED]>
Cc: "WIN32-PERL" <[EMAIL PROTECTED]>
Sent: Wednesday, October 08, 2003 9:03 AM
Subject: Re: WWW::Mechanize question
+
{$res = $ua->click(); # retrieve the content)
I found funny looking URL {$ur1) and  repeated get;
this URL probably holds packed responses from 1-st form params
=
my $rr=$res->{_headers};
my %ha=%$rr;
$_=$ha{refresh};
my $ur1;
if (/(.)URL\=/){$ur1=$';};
$res = $ua->get($ur1);

after this $res contains needed  page !


> mail admin wrote:
>
> > In browser I see login form ;
> > after filling login & passwd and clicking submit button I see html page.
> > here is the code snippet:
> > 
> > use WWW::Mechanize;
> > my $agen=WWW::Mechanize->new();
> > my $url=...
> > $agen->get($url);
> > die "can't get start page: ",$agen->response->status_line unless
> > $agen->success;
> > my $uri=$agen->uri;
> > print "uri=$uri\n";
> > my $fm1=$agen->current_form();
> > my $logi=...
> > my $pwd=...;
> > #$agen->set_fields('login'=>$logi  'passwd'=>$pwd);
> > $agen->set_fields('login'=>$logi);
> > $agen->set_fields('passwd'=>$pwd);
> > $agen->click();
> > $uri=$agen->uri;
> > print "uri=$uri\n";
> > +
> > What is next step ?
> > how I am to access html form (which I see in browser after clicking
> > SUBMIT ?)
>
> # get first page (I'm using a cookie jar to handle any cookies)
>
> my $cookie_jar = HTTP::Cookies->new(File => $cookiefile, autosave => 1);
> $ua = new WWW::Mechanize;
> $ua->cookie_jar($cookie_jar);
> $ua->agent('Mozilla/4.0');
> $res = $ua->get($url);
> if (not $res->is_success) {
> die "Error retrieving first page: $!";
> }
>
> # now fill in the third form on the page (change the 3 to the correct form
> # on your page
>
> $ua->form(3);
> $ua->field('login', $login);
> $ua->field('password', $password);
> $res = $ua->click(); # retrieve the content
> if ($res->is_success) {
> my $content = $res->content(); # do something with content (parse it)
> } else {
> die "Error retrieving form page: $!";
> }
>
>
> --
>   ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
>  (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
>   / ) /--<  o // //  Castle of Medieval Myth & Magic
http://www.todbe.com/
> -/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Chomp to trim '\r'

2003-10-08 Thread Sisyphus
Lee Goddard wrote:

Why not use a regular expression?

I can't find an answer to that question - and, judging by the responses 
so far received, nor can anyone else !!

;-)

Cheers,
Rob
--
Any emails containing attachments will be deleted from my ISP's mail 
server before I even get to see them. If you wish to email me an 
attachment, please provide advance warning so that I can make the 
necessary arrangements.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Chomp to trim '\r'

2003-10-08 Thread Beckett Richard-qswi266
> > Why not use chop? That removes the last character.
> >
> 
> Yes, it certainly does even if the last character is not a 
> "\r" character.
> So to do the work of one good regex substitute operator as 
> Lee suggested
> you would have to determine some how (a regexp match operator?, a
> substring to get the last character followed by a compare to see if it
> was a "\r", etc.). Those two distinct operations combined 
> with a separate
> compare step  should be evaluated as an alternative to using a single
> substitute operator which will remove the last character if it is
> there and tell you if it did or didn't remove a "\r". Hmmm, which of
> those seems like the better alternative? Do I want my script to
> use four or five obtuse op codes to perform a minor function point or
> do I want to use just one elegant operator do accomplish the exact
> same minor function point?

Oh. I thought all the lines ended in a "\r". Sorry.

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs