RE: Chomp to trim '\r'
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
Re: Chomp to trim '\r'
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: WWW::Mechanize question
- 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
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. R. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Filling an input file field
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
Re: Chomp to trim '\r'
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] Carl Jolley 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
RE: TK positioning viewable area of scrolled rotext
-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'
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: Chomp to trim '\r'
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
sub() or eval() ?
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: How to skip unwanted columns in CSV file?
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
Multiple 'do perlscript.pl' calls
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
Re: could not ODBC Sam-Test because -1044[Microsoft][ODBC Microsoft Access Driver] N
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
RE: Capturing the output of a system() command
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 21 |) or die Cannot run the command: $!\n; while (APP) { 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 ...
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:\tabab' 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
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
RE: Win32::GUI crashing, burning.
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
Re: Win32::GUI crashing, burning -- fixed!
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
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 (INPUT) { 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: newline...be gone
[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 (INPUT) { 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
RE: [SPAM] newline...be gone
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 (INPUT) { 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