RE: Pacify user.
>> print "$animation[$counter++]\b"; > >I think you got this backwards. The backslash should be before the counter, >otherwise the animation won't look right, particularly for slower loops. I didn't test slower loops - the above code worked with no noticeable uglies on a dual 450mhz machine. >> $counter = 0 if $counter == scalar(@animation); > >Wouldn't it have been easier (well, at least more >succinct) to move this logic into the print statement: > >print "\b$animation[$counter++ % scalar(@animation)]"; It's certainly more succinct, but the book was designed as a "teaching hospital", and that's some ugly damn code ... (or, at least, more "compacted" and less Englishy/readable then a "lesson" should be). -- Morbus Iff ( i put the demon back in codemonkey ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ My book, Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/ icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Pacify user.
> >> print "$animation[$counter++]\b"; > > > >I think you got this backwards. The backslash should be > before the counter, > >otherwise the animation won't look right, particularly for > slower loops. > > I didn't test slower loops - the above code worked > with no noticeable uglies on a dual 450mhz machine. The speed of the machine doesn't matter. Put a "sleep 1" in the loop (or any statements that take up time). You'll see a big difference. > > >> $counter = 0 if $counter == scalar(@animation); > > > >Wouldn't it have been easier (well, at least more > >succinct) to move this logic into the print statement: > > > >print "\b$animation[$counter++ % scalar(@animation)]"; > > It's certainly more succinct, but the book was designed as > a "teaching hospital", and that's some ugly damn code ... > (or, at least, more "compacted" and less Englishy/readable > then a "lesson" should be). OK, then I say change the last line to $counter = $counter % scalar(@animation); or $counter %= scalar(@animation); #more perlish There's nothing ugly about the modulus operator. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: HTML::TableExtract
> The HTML doc and its jpeg images are stored on LAN drive (in > the same directory), and I can not determine how to use > LWP::UserAgent or WWW::Mechanise to do this from a network drive. Makes no difference. file:// URLs work exactly like http:// URLs. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: HTML::TableExtract
The HTML doc and its jpeg images are stored on LAN drive (in the same directory), and I can not determine how to use LWP::UserAgent or WWW::Mechanise to do this from a network drive. Thanks Ross Clunie > If I was to do it, I might use WWW::Mechanize or LWP::UserAgent to > download > the img after retrive the img url. > -- Wenjie Wang(a.k.a. William)[EMAIL PROTECTED] WANG Infonology Systems Ph:(02)-98712018; mob:0412688380 http://users.bigpond.net.au/WISeAgent > : > : > :I am using HTML::TableExtract to obtain the text data from a table in an > :HTML doc. However the table also contains image files in each row that I > :want to obtain along with the text data. Does anyone know what / how I > can > :use achieve this. > : > :Thanks > :Ross Clunie > : > :> > :> > :> > :___ > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Pacify user.
Morbus, Looks like an interesting book. I have some comments about the code in question: > print "$animation[$counter++]\b"; I think you got this backwards. The backslash should be before the counter, otherwise the animation won't look right, particularly for slower loops. > $counter = 0 if $counter == scalar(@animation); Wouldn't it have been easier (well, at least more succinct) to move this logic into the print statement: print "\b$animation[$counter++ % scalar(@animation)]"; -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Pacify user.
I do this, and it pacifies users pretty well: my $line=1; print "Processing line: "; foreach (1..1000) { print "\b" x length($line-1), $line++; # do stuff } Adapted to your script: > # Parse input file > print "Parsing $ARGV[0], line #: "; > my $linecount = -1; > while (1) { > $linecount++; > print "\b" x length($linecount), $linecount + 1; > last unless (defined $input[$linecount]); > > block1() if ($input[$linecount] =~ /Block1/i); > block2() if ($input[$linecount] =~ /block2/i); > } > print "\n"; > etc. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Pacify user.
> So, rather than taking some 2x4 to the user, can anyone come up with a > reliable way of printing a dot every 10 seconds, or something else that > makes users feel all warm and fuzzy about one's scripts? Why not just, on every ten loops, print a backspace-forward-slash, then after the next ten loops, print a backspace-dash, next ten - print a backspace-back-slash, etc, etc. So they have a little spinner going? (just like the good ol' days =) !c === Discreet Packaging: www.dronecolony.com C. Church === ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Pacify user.
>So, rather than taking some 2x4 to the user, can anyone come up with a >reliable way of printing a dot every 10 seconds, or something else that >makes users feel all warm and fuzzy about one's scripts? I've written about progress bars within Perl in my second book, SPIDERING HACKS. The hack in question, happily, is freely available: http://www.amazon.com/exec/obidos/ASIN/0596005776/disobeycom http://www.oreilly.com/catalog/spiderhks/chapter/hack18.pdf -- Morbus Iff ( i put the demon back in codemonkey ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ My book, Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/ icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Pacify user.
You could change print "." to print "($linecount/100)\r" perhaps? -Original Message- From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 25, 2003 11:37 AM To: '[EMAIL PROTECTED]' Subject: Pacify user. Guys, I've just completed a fantastic script that parses log files. ;-) I sent it it to a user to test, and he thought that his PC had hung, whereas in fact he'd just given it a huge file to parse. So, he ended it, despite the fact that I printed "Parsing log232.txt, please wait. This may take some time for large files!". So, to make the users I modified my main loop, thusly: # Parse input file print "Parsing $ARGV[0], please wait"; my $linecount = -1; while (1) { $linecount++; print "." if ($linecount =~ /00$/); last unless (defined $input[$linecount]); block1() if ($input[$linecount] =~ /Block1/i); block2() if ($input[$linecount] =~ /block2/i); } print "\n"; etc. This seems like a good idea, printing a dot every hundred lines, but I have found that with certain log files, because the subroutines parse from the start of a block for several lines, incrementing the linecount as they go, it can be quite a while before the main loop sees a linecount ending in 00, and yes, you've guessed it, the user assumed it had hung again!! So, rather than taking some 2x4 to the user, can anyone come up with a reliable way of printing a dot every 10 seconds, or something else that makes users feel all warm and fuzzy about one's scripts? Thanks, R. ___ 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: Endless Loops in Perl
Below is a pretty way to display the values in a web page Enjoy! Barry print < EOD my %system = (); $system{PROCESS_ID} = "$$"; $system{REAL_USER_ID} = "$<"; $system{EFFECTIVE_USER_ID} = "$>"; $system{REAL_GROUP_ID} = "$("; $system{EFFECTIVE_GROUP_ID} = "$)"; $system{PROGRAM_NAME} = "$0"; $system{PERL_VERSION} = "$]"; $system{DEBUGGING} = "$^D"; $system{SYSTEM_FD_MAX} = "$^F"; $system{HINTS} = "$^H"; $system{OSNAME} = "$^O"; $system{PERLDB} = "$^P"; $system{BASETIME} = "$^T"; $system{WARNING} = "$^W"; $system{EXECUTABLE_NAME} = "$^X"; print ''."\n"; foreach (sort keys %system) { print "$_$system{$_}\n"; } foreach (sort keys %ENV) { print "$_$ENV{$_}"; } print < EOD ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Pacify user.
Guys, I've just completed a fantastic script that parses log files. ;-) I sent it it to a user to test, and he thought that his PC had hung, whereas in fact he'd just given it a huge file to parse. So, he ended it, despite the fact that I printed "Parsing log232.txt, please wait. This may take some time for large files!". So, to make the users I modified my main loop, thusly: # Parse input file print "Parsing $ARGV[0], please wait"; my $linecount = -1; while (1) { $linecount++; print "." if ($linecount =~ /00$/); last unless (defined $input[$linecount]); block1() if ($input[$linecount] =~ /Block1/i); block2() if ($input[$linecount] =~ /block2/i); } print "\n"; etc. This seems like a good idea, printing a dot every hundred lines, but I have found that with certain log files, because the subroutines parse from the start of a block for several lines, incrementing the linecount as they go, it can be quite a while before the main loop sees a linecount ending in 00, and yes, you've guessed it, the user assumed it had hung again!! So, rather than taking some 2x4 to the user, can anyone come up with a reliable way of printing a dot every 10 seconds, or something else that makes users feel all warm and fuzzy about one's scripts? Thanks, R. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: automate web login
Thank you all for your responses. It turns out, as specified by [e]agLØrT, there was a hidden value that was tripping me up. With that fix & POST, I was able to login. Thanks again! --- "[e]agLØrT" <[EMAIL PROTECTED]> wrote: > Hi.. > Well, your method POST is not allowed for index.html > but as you are > trying to log in, you should POST to > http://www.gene-regulation.com/login address which > can be found within > the source code of the web page. > So, you should write this: > > my $req = HTTP::Request->new(POST => > 'http://www.gene-regulation.com/login'); > > > As you sohuld not forget that there is a hidden > value within the page. > > value="/index.html"> > > You should also POST this value with variables user > id and password by > writing: > > $req->content('request_uri=/index.html&user=gratner&password=motley'); > > > Hope this works.. > > > > David Byrne wrote: > > >Greetings experts, > > > >I generated the following script (trying 'content' > >as well as 'authorization_basic' for user id & pw) > to > >automate login, but kept getting "405 Method Not > >Allowed". > > > >I would very much appreciate any suggestions. > > > >Cheers, > >David > > > >#!perl -w > >use LWP::UserAgent; > >use HTTP::Cookies; > > > >$ua = LWP::UserAgent->new; > >$ua->cookie_jar(HTTP::Cookies->new(file => > >"lwpcookies.txt", autosave => 1)); > > > ># Create a request > >my $req = HTTP::Request->new(POST => > >'http://www.gene-regulation.com/'); > >$req->content_type('application/x-www-form-urlencoded'); > > > ># Login > ># $req->content('user=gratner&password=motley'); > >$req->authorization_basic('gratner', 'motley'); > > > ># Pass request to the user agent and get a response > >back > >my $res = $ua->request($req); > > > ># Check the outcome of the response > >if ($res->is_success) { > >open (OUT, ">out.html"); > >print OUT $res->content; > >} > >else { > >print $res->status_line, "\n"; > >} > > > >__ > >Do you Yahoo!? > >Free Pop-Up Blocker - Get it now > >http://companion.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 __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: just installed ActivePerl on my win98 - what's next
Ted, you coding logic is faulty. Here is a much more compact way to write it right way. :-) my @adj = qw( totally really truly awesomely ); my @verb = qw( rules rocks dominates ); for my $y (0..20) # No need to loop 500 times :-) { print "ViM"; print ' ', ( $_ < $y ? $adj[int(rand @adj)] . ($_ < $y-1 ? ',' : '') : $verb[int(rand @verb)] . "!\n" ) for 0..$y; } Enjoy! :-) -- Mike Arms > -Original Message- > From: Ted Schuerzinger [mailto:[EMAIL PROTECTED] > Sent: Friday, November 21, 2003 9:54 PM > To: [EMAIL PROTECTED] > Subject: RE: just installed ActivePerl on my win98 - what's next > > > Messenger, Mark graced perl with these words of wisdom: > > > ...and shame on you for continuing it! :) > > Well, if we're going to continue it, we should at least do it > in a way > that's actually related to Perl. Here's a small script I > cooked up late > on a Friday evening: > > #! perl -w > > use strict; > > my ($x, $y); > > foreach $y (0 .. 500) { >print "vim"; >foreach $x (0 .. $y) { > if ($x == $y) { > print " sucks!\n"; > } > else { > print " really"; > if ($x+1 != $y) { > print ','; > } > } >} > } ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Fw: Removing double spaces from a file
Try one of these: $_=~ s/\s+//sg; $_ =~ s/^\s+//; #Removing leading spaces Nicu Ionita wrote: > > > > while () > > { > > s/\s\s/\ /g; > > print OUT $_; > > } > > > > > > (Assuming IN is an already open filehandle to the source file, and OUT is > one to a destination file.) > > This doesn't work. It's better: > > while () > { > s/\s{2,}/ /g;# these is a space > print OUT $_; > } > > Nicu > > ___ > 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: Perl and authentication using LDAP
Install perl-ldap module. use net::ldap $ldap = Net::LDAP->new('your-server-here', port => 389, version => 3) || die "failed: $@"; $mesg = $ldap->bind('[EMAIL PROTECTED]', password => $pw); $mesg->code && die "bind failed: $mesg->error"; More to it than the above, but that will bind you to the server. (hint... install perl-ldap then run 'perldoc net::ldap') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kraaijer Ronald Sent: Tuesday, November 25, 2003 8:29 AM To: perl-win32-users Subject: Perl and authentication using LDAP Hello everybody, I want to authenticate a particular user using LDAP, any ideas how this is done? Disclaimer - Winterthur Europe Assurances - Avenue des Arts/Kunstlaan 56 - 1000 Brussels - Belgium. This e-mail is intended solely for the above-mentioned recipient and it may contain confidential or privileged information. If you have received it in error, please notify the sender immediately and delete the e-mail. You must not copy, distribute, disclose or take any action in reliance on it. This e-mail message and any attached files have been scanned for the presence of computer viruses. However, you are advised that you open any attachments at your own risk. ___ 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
Geting user information
I am using perl 5.8 and trying to get user attributes from the domain server. Since the package AdminMisc will not work with 5.8 or at least I get an error message when I try to. Are there any other packages I can use to extract that information from the domain server(example last login time, etc)? I am also trying to query the mail server to get the same sort of info so I can compare the two. Would appreciate any help Thanks Terry Do you Yahoo!? Free Pop-Up Blocker - Get it now
Re: Gettind rid of control chars again.
On Tuesday, November 25, 2003, at 09:04 AM, Beckett Richard-qswi266 wrote: However, I've got some files to parse, with all sorts of odd control chars in them. I tried getting rid of them with: $var =~ s/\c.//g; but it didn't do anything. Is there a clever way to get rid of all of them in one swell foop? On page 174 of the camel book, version 3, they talk about POSIX-style character classes. It looks (completely untested) as though you should be able to do: $var =~ s/[[:cntrl:]]//g; Another alternative might be the Unicode character classes on page 168, which make it look like you could do: $val =~ s/\p{IsC}//g; HTH, Ricky ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Perl and authentication using LDAP
Hello everybody, I want to authenticate a particular user using LDAP, any ideas how this is done? Disclaimer - Winterthur Europe Assurances - Avenue des Arts/Kunstlaan 56 - 1000 Brussels - Belgium. This e-mail is intended solely for the above-mentioned recipient and it may contain confidential or privileged information. If you have received it in error, please notify the sender immediately and delete the e-mail. You must not copy, distribute, disclose or take any action in reliance on it. This e-mail message and any attached files have been scanned for the presence of computer viruses. However, you are advised that you open any attachments at your own risk. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Asking for password
Cool, works like a breeze, thanks very much :-)) (Huge smile) -Original Message- From: $Bill Luebkert [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 25, 2003 3:21 PM To: Kraaijer Ronald Cc: perl-win32-users Subject: Re: Asking for password Kraaijer Ronald wrote: > Works, but I would like to still echo a character representation "*", any > ideas on that? Try something like: binmode STDIN; print "Password: "; ReadMode ('cbreak'); while (defined (my $ch = ReadKey ())) { last if $ch eq "\x0a" or $ch eq "\x0d"; if ($ch eq "\x08") {# backspace print "\b \b" if $pwd; # back up 1 chop $pwd; next; } if ($ch eq "\x15") {# ^U print "\b \b" x length $pwd;# back 1 for each char $pwd = ''; next; } $pwd .= $ch; print '*'; } ReadMode ('restore'); -- ,-/- __ _ _ $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) Disclaimer - Winterthur Europe Assurances - Avenue des Arts/Kunstlaan 56 - 1000 Brussels - Belgium. This e-mail is intended solely for the above-mentioned recipient and it may contain confidential or privileged information. If you have received it in error, please notify the sender immediately and delete the e-mail. You must not copy, distribute, disclose or take any action in reliance on it. This e-mail message and any attached files have been scanned for the presence of computer viruses. However, you are advised that you open any attachments at your own risk. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Gettind rid of control chars again.
Beckett Richard-qswi266 wrote: > Guys, > > If you know which control character you're looking for (eg CNTRL@), it's > easy enough to get rid of with: > > $var =~ s/\c@//g; > > However, I've got some files to parse, with all sorts of odd control chars > in them. I tried getting rid of them with: > > $var =~ s/\c.//g; > > but it didn't do anything. > > Is there a clever way to get rid of all of them in one swell foop? Use the hex escape in a range: s/[\x00-\x08\x0b-\x1f]//g; (or similar) or tr/\x00-\x08\x0b-\x1f//d; # keep TAB and LF -- ,-/- __ _ _ $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
RE: Asking for password
> Works, but I would like to still echo a character > representation "*", any ideas on that? This seems to work: --- #!perl -w $|++; use Term::ReadKey; my $pw; while (1) { while (! ($key=ReadKey(-1))) {} last if ord($key)<32; $pw .= $key; print "*"; } print "\nPassword=$pw\n"; -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Asking for password
Kraaijer Ronald wrote: > Works, but I would like to still echo a character representation "*", any > ideas on that? Try something like: binmode STDIN; print "Password: "; ReadMode ('cbreak'); while (defined (my $ch = ReadKey ())) { last if $ch eq "\x0a" or $ch eq "\x0d"; if ($ch eq "\x08") {# backspace print "\b \b" if $pwd; # back up 1 chop $pwd; next; } if ($ch eq "\x15") {# ^U print "\b \b" x length $pwd;# back 1 for each char $pwd = ''; next; } $pwd .= $ch; print '*'; } ReadMode ('restore'); -- ,-/- __ _ _ $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