RE: Could I put commands in a variable
For instance: sub launch_viewer { my $for_path = shift; $message_viewer = create_main_viewer_window(); add_main_menu($message_viewer); add_header_list($message_viewer, $for_path); add_message_area($message_viewer); print get_viewer_option('Files|References'), \n; MainLoop; } sub create_main_viewer_window { our $message_viewer = MainWindow-new( -title = get_viewer_option('source file')); $message_viewer-geometry('780x540+0+0'); return $message_viewer; } sub add_main_menu { my $message_viewer = shift; our $menu_bar = $message_viewer-Menu(-type = 'menubar'); $message_viewer-configure(-menu = $menu_bar); create_view_menu(); create_find_menu(); } Nice Joseph, If I'm looking at this right this is a GUI for viewing files? What module(s) are you using before this code? Tk; ? Or?? Or is this simply an example and Not to be tried at home? :) Thanks You notice something about the launch_viewer method? It does nothing technical at all, yet guides the entire process, and does so in plain language. Programming languages have eveolved to well support plain-language styles, and they help to minimize errors by minimize the distractions of detail. The details of each action specified can be fleshed out in the individual mthod definitions, without cluttering the main description of the process. It is a whole new world in programming. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Extracting data from html structure.
And I want to extract from it the chekbox values and their respective channel names (contained in the link beside the checkbox). I have checked a lot of modules on cpan but I haven't found one that does it just the way I want it to yet. Actually I havent found any that I can get to work at all. Any tips? If I were to do it by hand I'd do something like this: Assuming it always looks like this: (that's a pretty big assumption which is why modules are good, but anyway...) input type=checkbox name=kanal_id[] value=9 a href=index.html?kanal_id=9dag=0fra_tid=0til_tid=24kategori_id= my %value_channel = $html =~ /type\=\checkbox\ name=kanal_id[] value=(\d+) \ \a href\=\(.*)\/mg; Then the keys would be the checkbox value and the value would be the url! Isn't Perl sexxy? :) DMuey Christian... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: capture a website and process its data
Hi All, I am a beginner at perl and would need some valued advice in the following task. Then you'll love LWP::UserAgnet and LWP:Simple 1. I need to access a website like say, a pathway called http://www.biocarta.com/pathfiles/h_il10Pathwa y.asp Not sure why you need to work with Win32::Ole exactly but... #!/usr/bin/perl use strict; #and use warnings; # they will help you do better code and debug faster. use LWP::Simple; # see search.cpan.org for more info my $guts = get('http://www.biocarta.com/pathfiles/h_il10Pathway.asp'); 2. Store the navigable components found in the imagemap component. There are some links here, which lead to This is a little more tricky since parsing html is not the funnest thign to do. Look at search .cpan.org for HTML::Parser or somethgi like that. Or if you can reasonably gaurantee the way the data will look you can use regexes to grab it from $guts; my @links = $guts =~ /href=\(.*)\/mg; display of a further search result for certain genes. I need to extract and store the weblinks (to external websites) from this gene search into a set of txt files. You can use open() (See perldoc -f open) to write to a file. But if it's a simpelk text file of reasonable size you might want to use File::Slurp; use File::Slurp; write_file('/home/linksfrommypage.txt', join \n, @links); For this, I have written the following code ... and then cant go further. pls help. * use Win32::OLE; $browser = Win32::OLE-new('InternetExplorer.Application', 'Quit'); $website ='http://www.biocarta.com/'; $webpage ='pathfiles/prolinePathway.asp'; $URL=$website.$webpage; $browser-Navigate($URL, 1,'_BLANK'); #part 1 use LWP::Simple; $content=get($URL); #part 2 $content =~ tr/A-Z/a-z/; # lowercase everything $content =~ s/\/'/g; # double quotes to single $content =~ s/\n//g; # get rid of the linefeeds $content =~ s/\s+//g; # compress spaces/tabs $content =~ /startpathwayimage(.*)endpathwayimage/; print $1; $content=$1; # store this output into a file So there is only one match at the url? Take a look at open() (perldoc -f open) * How to go further?? Thanks a ton in advance. K. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: RE: capture a website and process its data
Hi thanks a lot for your inputs. I used Win32::OLE module as it opens up a new instance of internet explorer with my preferred webpage. now, i dont need to store all the html. i just need to store the html from $guts =~ /startpathwayimage(.*)endpathwayimage/; and then further process this into a file. so now i changed my code to: * #!/usr/bin/perl use strict; use warnings; use LWP::Simple; # see search.cpan.org for more info my $guts = get('http://www.biocarta.com/pathfiles/h_il10Pathway.asp'); $guts =~ tr/A-Z/a-z/; $guts =~ s/\/'/g; $guts =~ s/\n//g; $guts =~ s/\s+//g; my @links = $guts =~ /startpathwayimage(.*)endpathwayimage/; You could my $links_are_hiding_in_here = join '', @links; my @just_the_links_maam = $links_are_hiding_in_here =~ m/href=\'(.*)\'/ig; # or whatever regex you need to do this open(STORE, output.txt) || die Opening output.txt: $!; print STORE join (\n, @just_the_links_maam).\n; close (STORE); # now you should have one url per line in your file open(STORE, output.txt) || die Opening output.txt: $!; print STORE @links; close (STORE); Or parse the file after its written which doesn't make much sense because nowyou have to reopen it, read it Parse it and do what you want with it then if the file is to be used by another script you have to have the same file parsing code in another place. Write the file with the parsed out put and you life will be much easier :) *** This output.txt has all the desired links that i need to store. I need to parse this output.txt to yield me all links sequence like this: http://link1.html http://link2.html http://link3.html there are around 15 links in javapop-ups! awaiting your tips! K. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: [OT] Apache internal server redirects
I have an internal server that I need to pass external visitors to from a web page. The internal server isn't set up to go through the firewall so I am looking for a way to make web server (which does play nice) to access the other server via http and let a user access the files and programs on it. I've been looking through the FAQs and googling it, but have not found a way to do it yet. Well how about this: http://publicserver.com/privateserver.pl Then privateserver.pl could grab content from the local files/scripts. HTH Dmuey Any thoughts? Thanks! Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Import oddity
Hello, Weird thing here: I get a variable from a module via @EXPORT_OK like so: use Foo::Monkey '$howdy'; # import the variable $howdy print $howdy; Works perfect. Now if I add strict-import; to my module's import function like so: package Foo::Monkey;; [ standard goodies cut] use base qw(Exporter); sub import { strict-import; } our $howdy = 'Howdy'; our @EXPORT_OK = qw($howdy); [rest of goodies cut] Then the script gives me Global symbol $howdy requires explicit package name... since I'm not using 'my' (because the module should be Exporting it) I really really want to keep strict-import but need to be able to use @EXPORT_OK and friends like normal. Any ideas why /what is happening and what I can do to have my cake and eat it to? (IE Have my strict and Export it too) TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Import oddity
On Feb 17, 2004, at 7:56 AM, Dan Muey wrote: Hello, Weird thing here: I get a variable from a module via @EXPORT_OK like so: use Foo::Monkey '$howdy'; # import the variable $howdy print $howdy; Works perfect. Now if I add strict-import; to my module's import function like so: I think add is the wrong word here. You replaced the inherited import() method. package Foo::Monkey;; [ standard goodies cut] use base qw(Exporter); sub import { strict-import; } sub import { my $class = shift; $class-SUPER::import(@_); strict-import; } I believe that will fix it. Not 100% sure though. Never tried it. ;) I just tried it and no go. Any other thoughts anyone? Simply put sub import { strict-import; } breaks Exporter's @EXPORT_OK functionality. Hope that helps. It does help, we're getting there! Thanks :) James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Import oddity
Dan Muey wrote: sub import { my $class = shift; $class-SUPER::import(@_); strict-import; } I believe that will fix it. Not 100% sure though. Never tried it. ;) I just tried it and no go. Any other thoughts anyone? The problem here is that Exporter::import() looks at the calling package, which in this case is Foo::Monkey *itself*, not the user of Foo::Monkey. Makes sense, but it works without strict-import; in the package's sub import { } Does that make sense? I'm stuck! Try this (a more general solution): sub import { my ($class) = @_; $class-export_to_level(2, @_); strict-import; } Or this (simpler): sub import { strict-import; goto Exporter::import; } I tried both and no go. All is well (IE the thigns specified are Exported to the script) if I do not have strict-import; (Which makes the script act as if they had 'use strict;' in the script) I think we're getting there but I am missing somethgin that is probably simple and obvious. Thanks a bunch Dan -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Import oddity
Dan Muey wrote: I tried both and no go. All is well (IE the thigns specified are Exported to the script) if I do not have strict-import; (Which makes the script act as if they had 'use strict;' in the script) Did you use strict or require strict anywhere? package Foo::Monkey; use 5.006; use strict; use base qw(Exporter); sub import { strict-import; # makes script using package act as if it had done 'use strict;' itself # @EXPORT_OK symbols are Exported ok if strict-import; is not here, even if # I coment out use strict above and do not have use strict # in the script using the package (which I never did all along } Any thoughts? -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Import oddity
Dan Muey wrote: Any thoughts? Erm, it looks okay. Maybe if you showed a complete example and the error or warnings (or misbehavior) somebody would see the problem. Here's what I was using. BEGIN { package Foo; use base qw(Exporter); use strict; our @EXPORT_OK = qw($var); our $var = 'Foo!'; sub import { my ($class) = @_; $class-export_to_level(2, @_); strict-import; } $INC{'Foo.pm'} = __FILE__; } use Foo qw($var); print $var; The first code you posted didn't work because (as James pointed out) you were never calling Exporter::import. If you called strict-import but never loaded strict.pm, the import() would quietly fail to turn on strictures. But delegating to Exporter with export_to_level() or by using the magic goto() should work... I'll play around a bit and perhaps post more code. Thanks for the input very very helpful! Dan -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Import oddity [SOLVED!]
Dan Muey wrote: Any thoughts? Erm, it looks okay. Maybe if you showed a complete example and the error or warnings (or misbehavior) somebody would see the problem. Here's what I was using. BEGIN { package Foo; use base qw(Exporter); use strict; our @EXPORT_OK = qw($var); our $var = 'Foo!'; sub import { my ($class) = @_; ^^ This line (my version not Steve's) was keeping me from doing export_to_level() properly. I was doing my $class = shift; but I needed to keep $class in @_ like Steve did above Now it works!!! $class-export_to_level(2, @_); strict-import; } $INC{'Foo.pm'} = __FILE__; } use Foo qw($var); print $var; The first code you posted didn't work because (as James pointed out) you were never calling Exporter::import. If you called strict-import but never loaded strict.pm, the import() would quietly fail to turn on strictures. But delegating to Exporter with export_to_level() or by using the magic goto() should work... I wonder which one would be fastest export_to_level() or goto() ?? Thanks Steve and everyone for all the help! You guys, this list, and Perl all rock! -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Why does this keep happening?
I'm running perl under windows XP and I keep geting this error: syntax error at (Directory and filename) Line 6, near ) { syntax error at (directory and filename) line 9 near } The source code is below, but this happens with loops in general. Any ideas? #!usr/bin/perl $a=1000 NO semi colon here for one, plus $a and $b are special sometimes so I'd avoid those. Try this: #!/usr/bin/perl use warnings; use strict; # always a good idea and very helpful to keep you sane! my $cnt = 1000; until ($cnt == 0) { print print Counting down to 0 from $cnt; $cnt--; } print Blast off!; until ($a==0) { print Counting down to 0 from $a; $a--; } else (print Blast off!) This else needs an if to match I believe, perhaps not but it would make lots more sense. HTH Dmuey Joel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Getting croak or carp into variable ?
Hello List, I am using a module that does use Carp; and you can specify whther you want croak or carp on an error Which is cool. But there is no way to specify anythign else besides those two. So the way it is you just do: my $res = funktion('foobarmonkey',err_doer = 'carp'); And it will do carp('what the heck is foobarmonkey'); What I'd like to do is get any errors into a variable: my $err = ''; my $res = funktion('foobarmonkey',err_doer = 'puterrorinvar'); if($err) { print Error: $err\n; print Logging error...' if(logerror($err) { print Ok\n; } else { print Failed!\n; } print Emailing Admin...; if(emailadmin($err)) { print Ok\n; } else { print Failed!\n; } # and now that we did that we can go ahead and carp, craok die, whatever } Except I can't simply specify a new function for errors because it checks for what you enter to see if its in a hash and if not defaults to one or the other. (I could modify the module but then it won't work for all) SO I guess the question is, is there a way to get carp or croak into a variable? Something like this perhaps: ? my $err = ''; putcarpinvar_on(\$err); # this is an example to illustrate what I'm shooting for it is not real my $res = funktion('foobarmonkey',err_doer = 'puterrorinvar'); putcarpinvar_off(\$err); # this is an example to illustrate what I'm shooting for it is not real if($err) { ... Any ideas? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Getting croak or carp into variable ?
On Feb 10, 2004, at 9:56 AM, Dan Muey wrote: Hello List, I am using a module that does use Carp; and you can specify whther you want croak or carp on an error Which is cool. But there is no way to specify anythign else besides those two. So the way it is you just do: my $res = funktion('foobarmonkey',err_doer = 'carp'); And it will do carp('what the heck is foobarmonkey'); What I'd like to do is get any errors into a variable: my $err = ''; my $res = funktion('foobarmonkey',err_doer = 'puterrorinvar'); if($err) { print Error: $err\n; print Logging error...' if(logerror($err) { print Ok\n; } else { print Failed!\n; } print Emailing Admin...; if(emailadmin($err)) { print Ok\n; } else { print Failed!\n; } # and now that we did that we can go ahead and carp, craok die, whatever } Except I can't simply specify a new function for errors because it checks for what you enter to see if its in a hash and if not defaults to one or the other. (I could modify the module but then it won't work for all) SO I guess the question is, is there a way to get carp or croak into a variable? Something like this perhaps: ? Maybe. Check out this one liner: perl -MCarp -e '$SIG{__WARN__} = sub { $err = shift; }; carp Error!\n; print We caught $err;' Strangely though, this did not work for me, though I expected it to: perl -MCarp -e '$SIG{__DIE__} = sub { $err = shift; }; croak Error!\n; print We caught $err;' Oh yeah %SIG I've nvere really messed with it before. I'll check it out a bit more, thanks James! Dan James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Program close
Hi Howdy When I run a very simple Perl program, it closes immediately after it has done. So that I can't even see the output. How can I solve this? Don't use windows! :) Or try executeing it from a dos prompt directly. Thanks in advance! HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Getting croak or carp into variable ?
perl -MCarp -e '$SIG{__WARN__} = sub { $err = shift; }; carp Error!\n; print We caught $err;' This works great! And changing $SIG{__WARN__} to '' will return default behaviour correct? (Same thign with __DIE__ ??) Strangely though, this did not work for me, though I expected it to: perl -MCarp -e '$SIG{__DIE__} = sub { $err = shift; }; croak Error!\n; print We caught $err;' Anyone have any idea how to get $SIG{__DIE__} to act like the $SIG{__WARN__} ? I'm sure it has something to do with die doing an exit() or soemthing. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Getting croak or carp into variable ?
I am using a module that does use Carp; and you can specify whther you want croak or carp on an error Which is cool. But there is no way to specify anythign else besides those two. What I'd like to do is get any errors into a variable: You want Carp::shortmess(). perldoc Carp That would require modifying the module which I want to avoid. Inside a function of another package it calls either carp or croak. I'd like to get that error into a variable I can use and not die or warn from croak or carp. my $err = ''; $SIG{__WARN__} = sub { $err = shift; } $SIG{__DIE__} = sub {$err = shift; } my $res = function_that_carps_or_croaks_that_i_cant_modify(); if($err) { handle_error_my_way_instead_of_simply_carping_or_croaking($err); } $SIG{__WARN__} = ''; # or is undef or delete better?? $SIG{__DIE__} = ''; # or is undef or delete better?? That works like a charm but it does not work with $SIG{__DIE__} for some reason. It still just croaks as usual. Any ideas? -- Jeff japhy Pinyan [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Getting croak or carp into variable ?
Dan Muey wrote: [snip] $SIG{__WARN__} = ''; # or is undef or delete better?? $SIG{__DIE__} = ''; # or is undef or delete better?? That works like a charm but it does not work with $SIG{__DIE__} for some reason. It still just croaks as usual. Any ideas? there are at least a couple of ways of doing that: #!/usr/bin/perl -w use strict; BEGIN{ use subs qw(Carp::die); use vars qw($e); sub Carp::die{ $e = Carp::die: @_ } } use Carp; croak croaking; print after croak \$e is: $e; __END__ prints: after croak $e is: Carp::die: croaking at x.pl line 10 another way to accomplish the same thing: #!/usr/bin/perl -w use strict; BEGIN{ our $e; *CORE::GLOBAL::die = sub{ $e = CORE:GLOBAL::die = @_; }; } use Carp; use vars qw($e); croak croaking; print after croak \$e is: $e; __END__ prints: after croak $e is: CORE:GLOBAL::die = croaking at x.pl line 10 i don't have time to check out the source of Carp.pm but if you do, i would suggest you go take a look as there might be a better solution to it. out of the 2 methods i described, the second one is more natural, imo. Cool, I was wondering about if that was possible, overriding the function. I'll try that out a bit and see how iut can fit into my scheme. Thanks david! david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Getting croak or carp into variable ?
there are at least a couple of ways of doing that: #!/usr/bin/perl -w use strict; BEGIN{ use subs qw(Carp::die); use vars qw($e); sub Carp::die{ $e = Carp::die: @_ } } use Carp; croak croaking; print after croak \$e is: $e; __END__ prints: after croak $e is: Carp::die: croaking at x.pl line 10 another way to accomplish the same thing: #!/usr/bin/perl -w use strict; BEGIN{ our $e; *CORE::GLOBAL::die = sub{ $e = CORE:GLOBAL::die = @_; }; } use Carp; use vars qw($e); croak croaking; print after croak \$e is: $e; __END__ prints: after croak $e is: CORE:GLOBAL::die = croaking at x.pl line 10 i don't have time to check out the source of Carp.pm but if you do, i would suggest you go take a look as there might be a better solution to it. out of the 2 methods i described, the second one is more natural, imo. Thanks that helped out abunch I believe it has me up and running! I use the Carp::die so I won't effect any real die()s just the croak()s Thanks again! Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How to use the arguments to use() in the package being used
Dan Muey wrote: Howdy, The subject says it all believe it or not :) What I'm trying to figure out is how to pass an argument (pragma I believe is the proper term) to use() and do sonethign in the package based on it. I've looked at CGI.pm source but can't seem to track it down. But did you perldoc? Munging source may sometimes be useful, Shamefully, no :( I usually do but this time I was just backwards! but more often than not it throws you headlong into implementation details of someone ele's code without shedding much light on how to use it. By entering: perldoc -f use at the cmmand-line, you should get direct instruction on proper usage. I just checked, and the returned text proceeds immediately into a detailed explanation of the parameters and their use. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How to use the arguments to use() in the package being used
Howdy, The subject says it all believe it or not :) What I'm trying to figure out is how to pass an argument (pragma I believe is the proper term) to use() and do sonethign in the package based on it. I've looked at CGI.pm source but can't seem to track it down. (Similar idea as to CGIs -oldstyle_urls -newstyel_urls) http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm#PRAGMAS What I'd like to do is something like this: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); #then in Foo::Monkey: package Foo::Monkey; [mandatory module goodies snipped] if(?) { # IE if -doamazingthings was specified in the use statement # do some amazing things here } [mandatory module goodies snipped] How do I do that?? Are those arguments stored in a special array somewhere?? TIA DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How to use the arguments to use() in the package being used
On Feb 4, Dan Muey said: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); Well, depending on what you want to do with the arguments, you might want to use the Exporter module to handle exporting functions, variables, etc. perldoc perlmod (look for Perl Modules) perldoc Exporter I do use Exporter actually should've mentioned that sorry, I'll check out your perldocs to. Thanks When you say use Module qw( args go here ); this is translated into BEGIN { require Module; Module-import(qw( args go here )); } Thus, you need an 'import' method in Module::. package Module; sub import { my $class = shift; print You gave me (@_)\n; } Perfect! Exactly what I needed. It's up to you to do something with @_. Thanks Jeff -- Jeff japhy Pinyan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Module for Country/Country Codes Lists
We enumberated our needs here: http://benschmaus.com/cgi-bin/twiki/view/Main/WwwFormCountryList So, is there a good module for doing that on CPAN that is also actively maintained and updated? If not I'll include it my upcoming module perhaps (no not Foo::monkey ;p) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Different results Command Line/CGI
I have this script stolen and modified from somewhere Stealling is bad! :) #!/usr/bin/perl -w use strict; use File::Find; print Content-type: text/html\n\n; my $u=shift; my $sizes = 0; # replace this with your absolute path my $path = /home/$u/; find (sub {$sizes += -s ;}, $path); print $sizes\n; I am logged onto my machine as user owen and am root. From the command line I execute perl /var/www/cgi-bin/ff1.cgi owen with the result -- Content-type: text/html (warnings snipped) 504137000 --- with rcook as the user in /home the result is 988865 Now when I do 'links http://localhost/cgi-bin/ff1.cgi?owen' the result is 350200607 (vs 504137000 ???) and for user rcook the result is 0 (vs 988865) Permissions Permissions Permissions: The user the webserver is runnign at obvioulsy doesn't have permissions to see all the files that the user you where logged in as did. And it is not allowed to see the rcook directory at all aparently. HTH Dmuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: script problem
Hi everyone, Howdy. I am created this script to send e-mails (see below). I get this error when I try to run it: use strict; use warnings; Number found where operator expected at C:\scriptz\test\NEWSCR~1.CGI line 15, ne ar The IP address for the interface that caused the event, or 0 (Might be a runaway multi-line string starting on line 7) (Do you need to predeclare The?) String found where operator expected at C:\scriptz\test\NEWSCR~1.CGI line 16, ne ar The NNM management station ID: $ARGV[9] (Might be a runaway multi-line string starting on line 15) (Missing semicolon on previous line?) syntax error at C:\scriptz\test\NEWSCR~1.CGI line 15, near The IP address for t he interface that caused the event, or 0 BEGIN not safe after errors--compilation aborted at C:\scriptz\test\NEWSCR~1.CGI line 20. This is the script. I think it has something to do with the 's but I am not sure where I am going wrong. Any help would be great. Most likely, yes you need to escape quotes that are within quotes. So Becomes \ You could also use qq() or a HERE doc: my $var = TEXT; Blah Blah bla blah TEXT HTH DMuey Thx, Leon #!/usr/local/bin/perl #Send E-mail for Critical Alerts #Here we define our parameters $to = '[EMAIL PROTECTED]'; $from = Openview Server; $body = Interface Down: The ID of application sending the event is $ARGV[0] The hostname of the node that caused the event is: $ARGV[1] The HP OpenView object identifier of the node that caused the event is: $ARGV[2] The HP OpenView object identifier of the node that caused the event is: $ARGV[3] The database name is: $ARGV[4] A time stamp for when the event occurred is: $ARGV[5] The HP OpenView object identifier of the interface that caused the event is: $ARGV[6] The name or label for the interface that caused the event is: $ARGV[7] The IP address for the interface that caused the event, or 0 if unavailable is: $ARGV[8] The NNM management station ID: $ARGV[9] ; $subject = Major Failure segment $ARGV[0] is down; #Here we use the module pass more specific parameters use Net::SMTP; $smtp = Net::SMTP-new('10.11.1.134'); $smtp-mail($ENV{USER}); $smtp-to($to); $smtp-data(); $smtp-datasend(Importance: High\n); $smtp-datasend(From: $from\n); $smtp-datasend(To: $to\n); $smtp-datasend(Subject: $subject\n); $smtp-datasend(\n); $smtp-datasend($body); $smtp-dataend(); $smtp-quit; __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Zip using Perl
On Wed, 28 Jan 2004 15:37:12 -0500 RL [EMAIL PROTECTED] wrote: I would like to zip a file using perl script. I used following command:- system (zip zip name file name); However this command fails when the filename is more than 8 characters. Why not try Archive::Zip instead of shelling out. It works well for me and no worrying about paths and command format, etc etc via the shell. My main use is for unzipping a file and parsing it and creating sql inserts from it and then doing the sql. If I remember right the error code thign took me abit of getting used to but it's pretty straight forward once you look into it. There's lots of example also which is really nice. HTH Dmuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Use and Require
Mallik wrote: What is the difference between Use and Require. See perldoc -f use perldoc -f require Why do you ask? /R Wow such a civilized answer. Some would say... S R Q I R E Who is Senior Qire? This is such a nice list. Time to revisit: http://www.catb.org/~esr/faqs/smart-questions.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: New Perl User needs help with POST in perl
I have written my HTML code to where it uses POST to collect information. Where do I start to write a script that collects the data from the web site, places the input into a dbm file, use CGI 'param'; my $email = param('email'); dbm file?? perldoc -f open then places a 1 next to it like an array? Some of the data in A one next to what again? the file will have zeros, while the ones that are inputted in the site will have a 1. Here is the end of the HTML code that uses POST: Perhaps if you explain what you are trying to do with the email address we can help better. HTH Dmuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: can i do it with perl ?
I there, Ello! I need to write a web database application using perl, and i need a way that when the users logs into the system i download all the information regarding to the user to its local computer and make all the transaction locally. After that, when the user logs out of the system all the information and transaction that were made by that user are then updated to the database server. Can i do it with perl ?, which modules ?, thanks. Yes you can. Look at cpan for DBI (for database stuff) CGI (for handling form input) HTH Dmuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Help with options
Hi, I have a script that command options are taken and would like to know how print out the options when the options are missing from the command line. Or how to do a -h to print out the options. There are module sto help you process switches and what not. For really simple stuff I do: if($ARGV[0] eq '-h') { print Here is how to use this script; } elsif(!defined $ARGV[1]) { print You must specify the Foo for Monkey, try -h for help...; } Something like that anyway. HTH DMuey Thanks, Thomas Browner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Automated script to connect to a web site and change the Password
Dear Friends, I need to write a Perl CGI script that connects to a website (like Yahoo) and change the Password for my user. I don't want to do it manually. It should be handled by the script. I've done similar thigns using LWP::UserAgent to log in and submit forms with certain data. That's where I'd look first. HTH DMuey Please suggest any idea/code available. Thanks in advance, Mallik. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Best Encyption module for this task/goal
Howdy list, I made a script that use Crypt::OpenPGP to encrypt/decrypt some data. I was thinking about testing out some other Encryption modules to see if any worked faster/ were more portable. Since I'm not an encyption master I thoguht I'd ask for input from any experienced in the matter. What I need is to accomplish this: use Crypt::OpenPGP; my $pgp = Crypt::OpenPGP-new; my $ciphertext = $pgp-encrypt( Data = $string, Passphrase = $pass, Armour = 1 ); my $plaintext = $pgp-decrypt( Data = $ciphertext, Passphrase = $pass ); I am looking to accomplish the above: - running as quickly as possible - as portably as possible I'd like to get a few ideas so I can install any needed modules and benchmark them but there are so many to choose from! Any thoughts anyone? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Best Encyption module for this task/goal
Howdy list, I made a script that use Crypt::OpenPGP to encrypt/decrypt some data. I was thinking about testing out some other Encryption modules to see if any worked faster/ were more portable. Since I'm not an encyption master I thoguht I'd ask for input from any experienced in the matter. What I need is to accomplish this: use Crypt::OpenPGP; my $pgp = Crypt::OpenPGP-new; my $ciphertext = $pgp-encrypt( Data = $string, Passphrase = $pass, Armour = 1 ); my $plaintext = $pgp-decrypt( Data = $ciphertext, Passphrase = $pass ); I am looking to accomplish the above: - running as quickly as possible Benchmarking the above (as CGI not mod_perl)(including use and new)... 1000 times gives me: Crypt::OpenPGP: 83 wallclock secs (73.21 usr + 6.12 sys = 79.34 CPU) 100 times gives me: Crypt::OpenPGP: 9 wallclock secs ( 7.52 usr + 0.70 sys = 8.22 CPU) 10 times gives me: Crypt::OpenPGP: 1 wallclock secs ( 0.97 usr + 0.09 sys = 1.06 CPU) - as portably as possible I should have added that Crypt::OpenPGP is a pure perl implimentation of OpenPGP. So as long as you install it its pretty much as portable as you can get. I'd like to get a few ideas so I can install any needed modules and benchmark them but there are so many to choose from! Any thoughts anyone? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: search an replace
Hi This scripts sucks in a 109mb file and i'm trying to do a search and replace on unxtime to the format from strftime. Which is working... But I run this system call and it took allnight to run :( So I killed it... Any other suggestions to reach my goal. Yes it looks like you are slurping this 109MB file then for each line you -pie the file again for each match so if it has 1000 lines with 2 matches you're processing the file 200 times instead of once. Probably many more lines than that but it's easy to calculate. I was working on a solution for you but Steve's looks way cooler than my version so I'll let you use his. :) DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Upload files and directories (MORE INFO)
I am transferring the data from a Redhat 9 machine to an IIS There's your first mistake, moving *from* Redhat *to* IIS :) server run by my ISP. I just tried running rsync and it was Assuming it was using ssh, does the winblows server have ssh servce on it? not responsive (left it on overnight in fact to give it time Where their any errors at all or just a blank stare? There could be a zillion things, authentication, connection, the fact that windows sucks, etc, etc... If there were any errors use them. to try). :( What was the Perl question again? You might want to post to an rsync list, they'll probably be able to help better. Thanks! Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Calling SUPER::constructor in the constructor
Is it possible to call the constructor that a function inherits from its parent? I tried calling SUPER:: and SUPER- in a constructor and got errors. Am i correct in assuming that if I rewrite the constructor that a copy of the parent object won't be available? Perhaps some example of your code. Also I can do DBI-connect(..) or DBI::connect and it works. Why not look at that and see how DBI does it? Sorry it's not more helpful, but without more details HTH DMuey Thanks in advance, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Upload files and directories
Oohhh this is how its related to perl, sorry the new subject line threw me. I am in dire need of a script that will upload everything from one server to another one that I can cron. Right now I have to do it by hand and with more and more updates being done to the site, I need a way to do it seamlessly. One that checks dates against each other would be cool too. i.e.: if the web server date is the same as the design server, no uploading that file. I'd use Net::FTP; even IIS can have ftp enabled, and its pretty standard so even winblows has a hard time screwing it up. Does anyone have one or know where I can find one? Even multiple ones that I have to piece-meal or get the logic from and rewrite myself would be good to. I have googled and am starting to go through the first page of results but I was hoping someone here might already have one or might have come across one somewhere. Thanks!! Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: On import v. Just Do It.
On Jan 20, 2004, at 9:19 AM, Dan Muey wrote: Oops left out a sentence sorry for the delay. p0: yes, one can use an import() from a package to make something like the scam of 'require in line' Why is it a scam if that's what I want to do for myself? I presume we are talking about http://www.nntp.perl.org/group/perl.beginners/58676 eg: package Foo::Monkey; sub import { for my $pragma (qw(strict warnings)) { require $pragma.pm; $pragma-import; } } which does have the technical nit that it did not end with 1; so is not really ready to be rolled up as a perl module. cf: http://www.nntp.perl.org/group/perl.beginners/58551 Yes rather than starting with a code template of #!/usr/bin/perl use strict; use warnings; So the idea of learning about how to do an 'import' is a worthwhile crusade in itself. I'm just not convinced that it really has the voodoo one would want since it of course is doing the obligatory two step of first requiring the pragma and then invoking it's import method... cf the distinctions between 'require' and 'use'. So my notion of 'scam' derives from the politer approach to the comedy of someone coming up with a Way to solve a problem that seems fundamentally structurally more complex than the problem that it is trying to solve. for the twin pragma of 'use strict' and 'use warnings' { oye! } p1: But there is this minor technical overhead that comes with the process - 1.a: one needs to use h2xs to make sure that the module will conform with the current best practices and be appropriately installable in the CPAN way my module or strict and warnings? One would assume the the developer has a responsibility to make their code solid and as compatible and compliant as possible oh quite right. So why would one want to add in a module that had merely the importing of the two lines that are pragma? which is the target of my rant. I of course would not feel morally upright if I had constructed a perl module that did not contain a. the version of perl that was my minimum to bid use 5.006001; b. the canonical brace of caution: use strict; use warnings; c. the version value: our $VERSION = '1.3'; You forgot c.1: sub VERSION { return $VERSION; } of course sub VERSION could lead to anarchy :) and as you mentioned above: d. 1; at the end The target of my rant of your rant is that this is only one little part of Foo::Monkey (actual module names have been changed to protect the innocent), rarely does anyone need ot post the entire code when trying to figure out a single simple solution to one issue. And if that becomes necessary then the thread will request that eventually. The reason that I of course appeal to the h2xs approach is that it will include the base suite of files a. MANIFEST b. Makefile.PL c. foo.pm d. t/1.t So that I can have a basic framework for making sure that I can get the core steps done perl *.PL make make test make install So now the problem has evolved from merely two lines of pragma, to a minimum of four files that I need to keep under source code control. Except that you are assumming the module sole purpose is to do use strict and warnings for you. And the OP wasn't asking abou the proper way to build a module. 1.b: one has to maintain that module just to make the two lines of pragma readily available to all of one's perl code. If that's the point of the module and users know that, isn't the maintainer supposed to, well er maintain it properly? Also wouldn't the script author have to do the same thing except in all his scripts instead of one place? Oh yes... and that of course is where we are now up to the four files in the SCCS du jure, and 1.c: the count of lines of the perl module vice the simple inclusion of the two lines makes the process a bit Wonky if you know what I mean. Not really, if we are talking strictly line counts then do this: in 50 scripts: use Foo::Monkey; = 50 lines ( ok 100 if you count: sub import { for('strict',warnings') { if(gotmodule($_) { $_-import; } } } # gotmodule is a function in side Foo::Monkey that basically does eval(use $_[0
Survey : Max size allowable for slurping files
There are always comments like you can slurp the file as long as it's not too big or becareful not to slurp a really big file or you'll be in trouble. So what I'd like to survey is what would be what the safest max size of a file that one should ever slurp and why? (IE if you have 128 MB of RAM and try to slurp a 768MB file that'd cause issues) (IE if the max file size on your system is 2GB you may have isseus slurping a 4 GB file.) Thanks DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
On Jan 22, 2004, at 12:18 PM, Dan Muey wrote: There are always comments like you can slurp the file as long as it's not too big or becareful not to slurp a really big file or you'll be in trouble. So what I'd like to survey is what would be what the safest max size of a file that one should ever slurp and why? (IE if you have 128 MB of RAM and try to slurp a 768MB file that'd cause issues) (IE if the max file size on your system is 2GB you may have isseus slurping a 4 GB file.) I also found this article form the author of File::Slurp ,Uri Guttman http://www.perl.com/pub/a/2003/11/21/slurp.html Very informative indeed. This question is pretty hardware dependent. On my Dual G5 2 Ghz with 2 M Dual G5, ohhohohho I just got a 17 G4 PowerBook which lets me develop Perl stuff wherever I go and run it in apache right then and there. GB RAM, I don't have to worry too much about what I slurp. That won't be the case for a lot of machines though. I can even imagine situations where it wouldn't be wise to slurp big files, even if the machine could handle it. If I had to come up with a solid guideline to tell people, it would probably be don't worry too much about slurping a file that's a fourth of your RAM or less. I must stress that is a guideline though, not a safe rule. Generally, my decision process goes like this. Do I only need one line at a time? If yes, don't slurp. Could I read a group of lines at a time? (Generally with something like paragraph mode.) If yes, go that way. Is what I'm doing a lot easier if I slurp the file? If no, DON'T DO IT! There's no point. If yes, I finally examine if there is a good reason I shouldn't slurp the file? (Execution hardware not up to it. Multiple copies of the process will be run in parallel. Whatever.) By this point, if I haven't talked myself out of it, I slurp the file. How much you know can be a big factor too. If you're going to run the script on your machine, once every night as a cron job or as a one shot data munge, you know a lot and should feel pretty safe. If you're going to upload the script to the CPAN and encourage people to run it everywhere all the time, even on their toaster, try to keep the memory/processor footprint as reasonable as possible, which may rule out slurping. I think the important thing to stress is that it's a choice. It often makes things easier, so don't be ashamed to make that choice, when it does and won't hurt anything. However, be aware that it COULD be a bad choice. Think it through. Good info James. Thanks James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Newbie
Well, I'm a newbie. Just got started in Perl and was stunned by its power. The thing is i'm running the scripts in WinXP. Can you tell how to use CGI scripts in XP, because if ai try to set a CGI script as ACTION in a forme it just gets read and doesn't execute. I'm assuming you are talking about an html form and not a Tk or some other type of form correct? Usually to serve a script the same way as you would on a web server your computer needs to know how to handle the request. This involves running a web server locally, like apache. I run apache on my G4 PowerBook and can have an html form, say at :http://localhost/form.html and have it submitted to cgi-bin/formhandler.plx What is even better is to have the script generate the form and handle the form. Another tip for you since you say you are a newbie and you are tryin gto handle html forms Don't use formmail from matt's script archive, it is super insecure and a spam machine. HTH Dmuey I've heard about the bat wrapping, but i really wanted to use the scripts as they are. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Covert Date to week number
Is their a way in PERL to covert a date to a week number Sure , why not? You'd need to know the date format to start of course. I don't mess with dates personally a lot so I'd say have a look on search.cpan.org for a module to do that. Also perldoc may be able to help you. Sorry to be so vague, just wanted to givve you a place to start looking. DMuey Cheers Neill -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
On Thu, 2004-01-22 at 13:18, Dan Muey wrote: There are always comments like you can slurp the file as long as it's not too big or becareful not to slurp a really big file or you'll be in trouble. I'd like to add that some of it depends on swap space. I've slurped well past physical memory and most of it went to swap. Although the script was significantly lower it still ran. However, if you get to a certain point your machine -- no matter what OS you are running -- will crash and burn. Of course, this is *if* you can get to that level. Users of *BSD systems with limit installed know that if your process eats too much memory IT will die and not the system. Good info Dan, I'm surprised more folks aren't adding their .02 since it seems (to me anyway) like people are just as religious about slurping as they are strict and warnings. Thnakd Dan -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
On Thu, 2004-01-22 at 16:16, Dan Muey wrote: On Thu, 2004-01-22 at 13:18, Dan Muey wrote: There are always comments like you can slurp the file as long as it's not too big or becareful not to slurp a really big file or you'll be in trouble. I'd like to add that some of it depends on swap space. I've slurped well past physical memory and most of it went to swap. Although the script was significantly lower it still ran. However, if you get to a certain point your machine -- no matter what OS you are running -- will crash and burn. Of course, this is *if* you can get to that level. Users of *BSD systems with limit installed know that if your process eats too much memory IT will die and not the system. Good info Dan, I'm surprised more folks aren't adding their .02 since it seems (to me anyway) like people are just as religious about slurping as they are strict and warnings. I think a lot of it is a problem of how exactly to answer. There will always be situations where slurping is a great idea and situations where slurping is a horrible idea. I wish it were possible to give a better example like, Use formula _ to calculate whether or not you can slurp safely. But there are just too many variables that change from computer to computer and program to program then to say anything besides: If you slurp watch the resources your program is using and kill it off before it DOSes your computer. Yeah it's tough because it is so vague, that's what I was hoping to clarify. It's easy to say use strict because But I see a lot of don't slurp that and I was hoping for more clear reasons/situatuions to or not to slurp so people positn code can have a better idea why a perosn said: do(n't) slurp your file here Basically we need to expalin why more: - Don't slurp this because it's STDIN and it may be huge, so huge in fact it could overload your system. - If this is an html file you'd probably be safe slurping it up to ease it's processing. Oh well we'll see... -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
But I see a lot of don't slurp that and I was hoping for more clear reasons/situatuions to or not to slurp so people positn code can have a better idea why a perosn said: do(n't) slurp your file here Basically we need to expalin why more: - Don't slurp this because it's STDIN and it may be huge, so huge in fact it could overload your system. - If this is an html file you'd probably be safe slurping it up to ease it's processing. I think it's like using a no warnings or no strict pragma to do some dangerous things because you know what you're doing. It's there for people when they get advanced enough to need it, but it's not a good idea to encourage its use on a beginners list. Good comparison, I never see advice to use no warnigns and no strict though :) -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
Good comparison, I never see advice to use no warnigns and no strict though :) I've actually seen it a few times in code, but it's usually surrounded by: ## ## #WARNING!! ## # Warnings / Strict turned off here because you know what you're doing, right? :-D Tee hee hee :) -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
Here's another argument against slurping: When you slurp a file all at once, even if your program isn't using up much of the CPU, on many machines it will slow down performance considerably if you slurp a large file (large, of course, is still sometimes relative). If that is the only thing you are running at the time, it may not make much of a difference, but it is usually not a good idea to assume that. Good argument that's the kind of thign I was looking for. :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Survey : Max size allowable for slurping files
Dan Anderson wrote: Very true. But you also need to look at what you're doing. A spider that indexes or coallates pages across several sites might need to slurp up a large number of pages -- which even at a few kilobytes a piece would be costly on system resources. Ironically this is the one time I could see slurping as not working too. Has anyone hit the limit for open file descriptors? I know it is OS dependent and pretty damn high, but on a nice enough system with nice enough app I suspect you could hit it. At that point you would have to slurp or close a filehandle... Dan always comes up with the good discussion topics ;-)... I try! DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: format localtime()
Hi I have the following script that sucks in a file and converts unix timestamp to human readable.. The Goal is to do a search and replace of unix time to the format i need. But I'm just trying to get it to print in the format i need first... I cant get localtime to print in mm-dd- hh:mm:ss , I keep getting it like so Sun Dec 28 03:35:19 2003 That's what it returns in scalra context. You can call it in array context and get the specifc values you want. You may have to modify them a bit ( add 1900 to the year for instance) Take a look at perldoc -f localtime to seee which parts of the array are which values you want in which format. HTH Dmuey #!/usr/bin/perl use strict; # #my $timestring = localtime(); open (FILE, ip.txt) || die (Open Failed: $!\n); my @lines = FILE; # file into array foreach (@lines) { next if /^S/; next if /^-/; my @line = split(/\t/, $_); my @time = split(/\n/, $line[0]); foreach (@time) { my ($sec,$min,$hour,$mday,$mon,$year) = localtime($_); # need to print like mm-dd- hh:mm:ss my $timestring = localtime($_); # but prints like Sun Dec 28 03:35:19 2003 print $timestring\n; } } close FILE; # more ip.txt: Start header header - - - 1072611319 rrr 1072611319 rrr 1072611319 rrr 1072611319 rrr Thanks Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Terminating script if file does not exist
Perlwannabe wrote: Basically the script runs and looks for a file in a certain directory. If the file is there, the script continues to run and process the file, but if the file is not there the script should just exit. Any ideas on how to do this? open FILE, '', 'certain/directory/file' or exit $!; Actually die is probably better than exit as exit can have bad consequenses in certain circumstances (think mod_perl) open FILE, '', 'certain/directory/file' or die $!; HTH Dmuey John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How to send results to more than one recipient
Thanks for the response but that doesn't seem to work either. Maybe it would be easier just to create a distribution list on the email server and just put that address in my script. It doesn't work, looping over an array does not work? for(@emaillist) { # pipe $_ to qmail inject like you do now here } You might also want to try a module that doesn't rely on an external program's argument syntax but does an SMTP session directly. (don't get em wrong qmail rocks but you should avoid avoid external program when ever possible to make your code more portable, reliabel;, etc etc) Try Mail::Sender it is very sexxy. You can use a commas separated list of address in one variable as your To field. HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Terminating script if file does not exist
Basically the script runs and looks for a file in a certain directory. If the file is there, the script continues to run and process the file, but if the file is not there the script should just exit. Any ideas on how to do this? Beside die() you may also want to check it. if(-e $file) { # alos there are other tests tou can do on a file to see if it's readable,executable, etc... # open || die $!; #... # process it , etc... } else { print Sorry, $file does not exist, please enter an existing file or you shall be pummeled for along long time.\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Use strict inside module to apply to entire script?
On Saturday, January 17, 2004, at 06:21 PM, Dan Muey wrote: I was curious if it's possible to have a module like so: package Foo:Monkey; use strict; use warnings; You can call strict-import like this: package Foo::Monkey; sub import { for my $pragma (qw(strict warnings)) { require $pragma.pm; $pragma-import; } } Nice! I'm not familiar with import() but perldoc explains a bit. I guess I'm still not clear *how* it does it's magic but it does do it! Thanks Dan -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: On import v. Just Do It.
p0: yes, one can use an import() from a package to make something like the scam of 'require in line' Why is it a scam if that's what I want to do for myself? for the twin pragma of 'use strict' and 'use warnings' { oye! } p1: But there is this minor technical overhead that comes with the process - 1.a: one needs to use h2xs to make sure that the module will conform with the current best practices and be appropriately installable in the CPAN way my module or strict and warnings? One would assume the the developer has a responsibility to make their code 1.b: one has to maintain that module just to make the two lines of pragma readily available to all of one's perl code. If that's the point of the module and users know that, isn't the maintainer supposed to, well er maintain it properly? Also wouldn't the script author have to do the same thing except in all his scripts instead of one place? 1.c: the count of lines of the perl module vice the simple inclusion of the two lines makes the process a bit Wonky if you know what I mean. Not really, if we are talkking strictly line counts then do this: in 50 scripts: use Foo::Monkey; = 50 lines ( ok 100 if you count: sub import { for('strict',warnings') { if(gotmodule($_) { $_-import; } } } # gotmodule is a function in side Foo::Monkey that basically does eval(use $_[0]) # and returns true if it was able to be loaded, it works too I tested it # also it avoids killing the script if it can't be loaded since it only does $_-import # if the module could be use()ed ) you get strict and warnings plus thae many other nifty things about Foo::Monkey use strict;use warnings = 100 lines. So depending on how you look at it, there are less or the same amount of *lines* but many more advantages as far as I can tell. p2: clearly the fact has been established that it can be done, but it also notes the 'and you want this pain why?' problem I don't understand the pain you speak of, could you define more clearly why I don't want to do the import() to make it automatic so this module's users have to consciously turn off strict and warnings instead of consciously turn it on like we tell people to do over an over an over... I mean as long as I make it clear, and I would definitely blab about it as an advantage, that by doing use Foo::Monkey; # enables strict and warnings for your script for better scripting practice!! # If you don't like that use no warnigns and no strict.. But why would you do that? Thanks Dan ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: On import v. Just Do It.
Oops left out a sentence p0: yes, one can use an import() from a package to make something like the scam of 'require in line' Why is it a scam if that's what I want to do for myself? for the twin pragma of 'use strict' and 'use warnings' { oye! } p1: But there is this minor technical overhead that comes with the process - 1.a: one needs to use h2xs to make sure that the module will conform with the current best practices and be appropriately installable in the CPAN way my module or strict and warnings? One would assume the the developer has a responsibility to make their code solid and as compatible and compliant as possible 1.b: one has to maintain that module just to make the two lines of pragma readily available to all of one's perl code. If that's the point of the module and users know that, isn't the maintainer supposed to, well er maintain it properly? Also wouldn't the script author have to do the same thing except in all his scripts instead of one place? 1.c: the count of lines of the perl module vice the simple inclusion of the two lines makes the process a bit Wonky if you know what I mean. Not really, if we are talking strictly line counts then do this: in 50 scripts: use Foo::Monkey; = 50 lines ( ok 100 if you count: sub import { for('strict',warnings') { if(gotmodule($_) { $_-import; } } } # gotmodule is a function in side Foo::Monkey that basically does eval(use $_[0]) # and returns true if it was able to be loaded, it works too I tested it # also it avoids killing the script if it can't be loaded since it only does $_-import # if the module could be use()ed ) you get strict and warnings plus the many other nifty things about Foo::Monkey use strict;use warnings = 100 lines. So depending on how you look at it, there are less or the same amount of *lines* but many more advantages as far as I can tell. p2: clearly the fact has been established that it can be done, but it also notes the 'and you want this pain why?' problem I don't understand the pain you speak of, could you define more clearly why I don't want to do the import() to make it automatic so this module's users have to consciously turn off strict and warnings instead of consciously turn it on like we tell people to do over an over an over... I mean as long as I make it clear, and I would definitely blab about it as an advantage, that by doing use Foo::Monkey; # enables strict and warnings for your script for better scripting practice!! # If you don't like that use no warnings and no strict.. But why would you do that? Thanks Dan ciao drieux -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Why isn't perl used more in business and industry
Most of the scripts I see end in an extension like .jsp, .asp, .dll, or something which says that they aren't perl. Is there a reason more businesses and online companies don't use perl? - People like to spend money for stuff for no goods reason. - Are those on servers you work with? Those specific ones may use those for whatever reason. - Some people I know paid to go to school for years to learn crap like asp so if they don't use it they look kind of silly. - *nix systems come with perl installed and use perl for lots of stuff, - Mis informed people - Perl is run as .cgi a lot of times so you may not notice it's Perl like you would the other kinds. - People look at something shiny and think it must be good. IE(PHP people use CSS to make the utput of their scripts look very sharp, so people assume it must be good, but PHP has so many issues (Don't even get me started or I'll never shut up ;p) I can't stand to use it and when forced to (customer wants PHPBB or something) it ALWAYS a chore to make it work right. PHP people say IT runs fast well use mod_perl and Perl will be faster than PHP and still be way more flexable and usefull.) Same principle applies to most other kinds as well. Perl is all I use backend and frontend, and I mange a dozens of servers, networks, and services for variose isp's and internet service companies Around the united states. Perl can do about anythign you want, (I haven't found one practical job I needed to do I couldn't do with Perl) So the short answer is: There is no good reason, if they knew what was good for them and what could boost reliablity, productivity, etcc whiel decreasing costs, time, and resources. HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Why isn't perl used more in business and industry
Which has made me wonder more then once if in a security through obscurity approach sites pass perl scripts off as ASP, etc. Maybe, I don't see why I'd want to make people think I'm using insecure stuff when I'm really using the best, but maybe. For instance, Ebay's servers are run by IBM (hence the big blue IBM logo on their sites). But all the forms like through to files ending in .dll. That doesn't make much sense to me, I would think IBM would run AIX / *nix servers for Ebay. Yeah, Ebay's stuff is really screwy I think. - *nix systems come with perl installed and use perl for lots of stuff, Perhaps I should have better said, why isn't it used more on the web? - Perl is run as .cgi a lot of times so you may not notice it's Perl like you would the other kinds. Yes, but ASP and JSP end scripts in .asp and .jsp respectively, which makes me wonder why I don't see less JSP and ASP tags. To combat this I try to use .pl or .plx as of late. I also suggested before on this list that Perl developers focus on using CSS in their web site output to make their pages *look* nicer. (See my whole PHP rant earlier in the thread) IE - Basically that if a PHP/ASP/JSP/Whatever page *looks* nicer most people don't realize that PHP/ASP/JSP/Whatever have nothing to do with the way it looks, it's the HTML/CSS/XML that it outputs that determines the nice looks, So they never realize Perl is more flexible and powerful. For instance I was talking to a gentleman who was showing me his new web server ($$$ for Winders and IIS) with his new sexxy web app he was looking forward to using, and he was proud because He had connections that saved him 10% so he only paid $3000 for it. I was shocked so I looked at his site with him and got a list of it's awesome features. That night I did the same thing in Perl and used the html/css from his site for the looks and I showed him the next day and he about died because mine did everything his did, looked the same and it was free. The only differenece was now he had a sort of torn and bleeding feeling in his bottom ;p Thanks for all your comments, -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Why isn't perl used more in business and industry
In a job interview last year, I was talking to a company who was in the process of moving their big server application to Java from its current Perl base. They told me they felt like Perl was not ready for professional server environments, but they had had a lot of success with Java. I'm just passing on what the guy said, but I think it's representative of a common mindset. Perl's a subtle and powerful language. I love that about it, but I think it is pretty easy to do things in less than ideal ways because it gives you so much freedom. That's a strength and a weakness, I think. A little bit of knowledge can be dangerous. Think about it. How many times do we have to tell people on this list to use strict and warnings, get a module for that, don't slurp big files, etc. If even a percentage of that is happening in enterprise applications because the coders don't know better, perhaps we can see where some of the thinking comes from. Why is it that all the Java guys I talk to know about JSP, but when I mention mod_perl to people they say Mod what? Maybe Perl's public face isn't as strong as some of the alternatives. Maybe Perl lacks a marketing department, being open source, and that hurts it a little. Don't laugh, I'm serious. Good point, similar to my better looking argument but better looking market wise. That's what we need to do, use shinier words, Perl Secure Enterprise Edition - Leveraging the Power of Experience with Reliabilty , that would be the latest Perl that always has 'use strict' and 'use warnings' running no matter what the script has in it: IE #/usr/bin/perl print hi; Maybe a warning gets spit out if the file they are slurping is over a certain size, also. And You'd need to use shiny words for describeing it's features: Exponentially expand the ease and practicality of development, deployment, and use with many powerful modules that help you get the job done faster, and more securely. Complies with industry standards and functionality. You'd have to have a cli (running on our Perl S.E.E of course) for each platform that: - lists/upgrades/installs modules - upgrades to latest Perl S.E.E. with one click/command Have the binary be called perlSEE instead of perl or something. Looks like we have a busy weekend ahead! Of course, that's all just guess work on my part. I'm no expert. On the flip side, I believe Amazon.com uses a mostly Perl system, just to name a familiar name. There has to be others, I would think. Maybe a website listing should be made/found?? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Why isn't perl used more in business and industry
http://www.perl.com/pub/a/2004/01/09/survey.html Nice! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: JPG FILE DOUBTS
Hello i wanna know what Perl module can I use and what Howdy commands to do the folowing: 1-Check to see if the file is a 1) use Imager, GD, Image::Magick, search.cpan.org search for image,jpg, jpeg valid jpg file 2-Check the file size 2) perldoc -f stat Thanks in advance HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: redirect with cgi.pm
Hi, like this: #!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; print $q-header # do this - do that, using $q print $q-redirect(/thanks.html); - Jan redirect() does a header like header(), the first header that gets sent is the header, the rest is content, even if The contetn looks just like a header. If you run that in a browser you'll probably see Location: /thanks.html in your screen. Since that is content for the header() you did above it. Make sense? I also remember hearing it's a better idea to use absolute url's in your Location header. HTH DMuey jdavis wrote: Hello, I have been able to use redirects with cgi.pm as long as the redirect is the only thing in the script. i.e. #!/usr/bin/perl use CGI qw(:standard); print redirect('http://google.com/'); but what i need to do is print a bunch of html , have perl do a few jobs on my system, and then do a redirect when its done. is this possible? thanks, -- jdavis [EMAIL PROTECTED] -- Common sense is what tells you that the world is flat. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: decoding a base64 file?
Hello folks, If I encode a file with MIME::Base64 with the following script, encode_base64.pl. The question is; how do I decode the file? I use the following script, decode_base64.pl to decode back to the original source but that did not work. Thank you... [snip] while (read(FILE_R, $buf, 60*57 )) { $encoded = MIME::Base64::decode($buf); print FILE_W $encoded ; } Try decodeing the entire encoded data instead of a line at a time. HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: redirect with cgi.pm
redirect() does a header like header(), the first header that gets sent is the header, the rest is content, even if The contetn looks just like a header. Thanks for the correction, I have not found the time to read CGI Programming with Perl thoroughly and did not realize redirect *does* a header. No problem. I also remember hearing it's a better idea to use absolute url's in your Location header. Regarding this, I am proud of keeping all of my relative links intact. It's sort of a challenge. At least I use absolute relative links instead of entirely relative ones. ;-) Whatever you want, but it's more likely to cause a browser to choke, which would kind of defeat the purpose that's all. And that's not just true with Perl it's the http protocol and a browser's use of it. Best, Jan -- There are 10 kinds of people: those who understand binary, and those who don't -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: perl loan scripts/software
Hi there, I need to find out if there is a perl software, script for loans managament. Is for a client that give loans to their customers and want to have control over the payments, the interest receive, etc. Does anyone knows about any perl software for like that ? Do you mean a calculator type script or a whole loan document generator, tracker, customer db manager? Thanks. __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbo nus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
Dan Muey wrote: Howdy list. I'm trying to one lineify this: my $guts = $firstchoice || ''; if(!$guts $use_second_choice_if_first_is_empty) { $guts = $secondchoice; } Basically my $guts = $firstchoice || $secondchoic || ''; Would be perfect except I only want to let it use $seconchoice if $use_second_choice_if_first_is_empty has a true value. This does not work like I want but illustrates the goal if you read it our loud. my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || ''; Is that possible to do with one line? TIA Dan I don't know Dan, it looks like you already said it clearly in the first cnstruct above. I would not discard that It is clear but doesn't do what I'm getting at. The seconde one *reads* like it but does not function how it *reads*. I want to assign it a value. If that value is missing I want to assign a second value, and here's the tricky part, if a particular variable says it is ok to. Othyerwise it should be empty. clarity without good reason. Isn't it more important to say what you mean than to tuck it all up tightly? Except I need to do this to about ten variabels all in a row. Which gives me 10 lines with Bob's way and 40 with my very first example. Boo for that! :) Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
Dan Muey wrote: BTW - I'm not really using these variable names, only using them here ot help clarify my goal. Why not? They looked very good to me, at least in the context of the question at hand. One of the best aspects of In context yes, but the really really long was a bit much! Perl, IMHO, is that it allows you to just say what you mean. I think people take far too little advantage of this boon. It definitely does help, especially after you look at the code again a while later and you're trying to remember what you were doing, or Someone else is tryign to decifer it later. Thanks for bringing that point out. Bob's woprks perfect I agree. It is quite elegant, with no loss of clarity. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: printf sprintf
What is the difference. The only I see is that printf can One difference is printf prints it's output and sprintf returns it';s value. printf ... my $formatted_goodies = sprintf ... take a filehandle? But what use would that be. To format the contents of it. For instance, you might have a user enter a dollar amount from the command line. If you could printf STDIN the you could make sure 123.4567890 came out as $123.46 Just one quick idea.. DMuey Paul Kraus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: printf sprintf
What is the difference. The only I see is that printf can One difference is printf prints it's output and sprintf returns it';s value. printf ... my $formatted_goodies = sprintf ... take a filehandle? But what use would that be. To format the contents of it. For instance, you might have a user enter a dollar amount from the command line. If you could printf STDIN the you could make sure 123.4567890 came out as $123.46 Just one quick idea.. DMuey Paul Kraus Though you could try it, I did not, I don't think you can printf STDIN since it is an inbound IO pipe as opposed to outbound. This is a good demonstation of the all important comma operator. Notice the difference in the docs: printf FILEHANDLE FORMAT, LIST printf FORMAT, LIST In the first there is NO comma following the filehandle, this means it is interpreted in a different manner than the rest Oh right! I should have read that first before posting. Ooopss. Sorry everyone! of the argument list, or probably to be more precise isn't an argument at all... I am sure one of the gurus will chime in with the actual technical name of what this spot is actually called in this context since I either don't know or it escapes me currently. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
On Jan 8, 2004, at 7:45 AM, Dan Muey wrote: [..] Except I need to do this to about ten variabels all in a row. Which gives me 10 lines with Bob's way and 40 with my very first example. Boo for that! :) [..] Have you thought about a simplification process? One of the tricks I do is say my ($var1,$var2,$var3,$var4) = ('' , '' , '', ''); This way I have declared them and initialized them, so that they will not bounce with that 'use of undefined var at line X error. This way when you get down to my $guts = ($use_second_choice)? $var2:$var1; you don't need to worry about the additional bit of making sure that it is my $guts = ($use_second_choice)? $var2: $var1 || ''; Wouldn't the || '' apply to $guts and not the use of uninitialized $var1,$var2,etc... Anyway? Just a thought to think... The vars to be assigned ($var1, $var2,etc...) come from a database query so they are handled already earlier. So how they are declared are irrelevant to the issue. (Yes they must be initialized for a warnings safe environment and they are, just assume that they are so the issue is not clouded by where they come from.) The other thing the tricky part is: I only want to assign it $var2 if($use_second_choice !$var1) I think the way you're doing it will asign it $value2 if $use_second_choice regardless of if $var1 has a value or not. So : No matter what if $var1 has a value then assign $guts that value. If $var 1 is empty and $use_second_value then assign it $var2 Other wise it shoufl be empty. Bill's method work perfectly, namely: $var1,$var2 and $ues_2 are declared and set earlier via a DB query. So don't worry about where they are coming from. my $value = $var1 || ($use_2 $var2) || ''; So $value gets set to $var1 no matter what if($var1). If it's not then it goes to the next step and is asking :Ok $var1 has no value do you want to use $var2 ? if Yes give it $var2 if not say sorry I can't help you and on the the next || which says ok you shall receive from the variable gods '' nothing! OR in longer terms: my $guts = ''; # so that at least it has something assigned even if it's nothgin. :) if($var1) { $guts = $var1; } elsif($use_var2_if_var1_is_empty) { $guts = $var2; } See what I'm trying to get at? Bob's example does this quite perfectly, thanks again Bob!\ Dmuey ciao drieux -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
I think I better see the context at this point. note, as I presume you did The issue is resolved, but for the die hards here goes... I'm wanted to figure out my method of attack before I did the whole thing but here is an example that will illustrate the basic idea hopefully: #!/usr/bin/perl -w use strict; use DBI; my $dbh-connect(...) or die ; my ($def_foo,$def_bar,$def_joe,$def_mama) = $dbh-selectrow_array(SELECT Foo,Bar,Joe,Mama FROM Default_Settings); for(@{$dbh-selectall_arrayref(SELECT Foo,Bar,Joe,Mama,Use_Def FROM Whatsits WHERE Blah=1234)}) { my ($foo,$bar,$joe,$mama,$use_def) = @{$_}; my $foo_use = $foo || ($use_def $def_foo) || ''; my $bar_use = $bar || ($use_def $def_bar) || ''; my $joe_use = $joe || ($use_def $def_joe) || ''; my $mama_use = $mama || ($use_def $def_mama) || ''; print $foo_use - $bar_use $joe_use $mam_use\n; # or do whatever with it } $dbh-disconnect(); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Drawing an Arc at an angle.
On Thu, 08 Jan 2004 09:44:31 -0500, [EMAIL PROTECTED] (Zentara) wrote: On Wed, 7 Jan 2004 10:53:20 -0600, [EMAIL PROTECTED] (Dan Muey) wrote: Thanks! Even more to add to my look into list! Yeah upon futher thought, you probably could use the Tk::Canvas and actually plot your curve point-by-point from the equation of an ellipse, rather than using the Oval function. Then export the postscript. Run the widget demo, there are 2 examples for plot, one of them exports ps. I'm not trying to hijack your thread, but the idea of No sweat! I can use all the ideas I can get. I think this is a pretty good one you have. rotated ellipse sort of appeals to me. So here is a simple postscript file to make a rotated ellipse. Just save as a .ps file and look at it with ghostview. Now all you have to do, is play with it to see how to align it up, to your needs, then in your perl script, use a here doc to write it out to a file. Then use Image Magick or Imager to convert it to .jpg or whatever. I got this from this page: http://www.redgrittybrick.org/postscript/ellip se.html %!PS-Adobe %%Pages: 1 %%BoundingBox: 60 420 490 740 % % canonical ellipse routine % credit: Holger Gehringer % /inch { 72 mul } def /ellipse { /endangle exch def /startangle exch def /yrad exch def /xrad exch def /y exch def /x exch def /savematrix matrix currentmatrix def x y translate xrad yrad scale 0 0 1 startangle endangle arc savematrix setmatrix } def %%Page: One 1 1 0 0 setrgbcolor 4 inch 8 inch translate 30 rotate 0 0 2.8 inch 1.4 inch 0 360 ellipse 16 setlinewidth stroke showpage %%EOF -- When life conspires against you, and no longer floats your boat, Don't waste your time with crying, just get on your back and float. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Drawing an Arc at an angle.
On Tue, 6 Jan 2004 11:03:14 -0600, [EMAIL PROTECTED] (Dan Muey) wrote: Dan Muey wrote: I've made a funtion to calculate the Fresnal zone for wireless connections. What I'd like to do is generate an image based on that. Something like the example at: http://ydi.com/calculation/fresnel-zone.php However the two connected points are rarely going to be at the same level so I'd need to draw the elipse At an angle instead of horizontally. GD's elipse or arc function will probably do what I want but it seems all I can specify are the center point and width and height. Is there a way to also specify the x/y of each point on the left and right side of the elipse? Make sense? Yes, but you're out of luck I'm afraid Dan. The best I can suggest is that you use the 'filledPolygon' method and do the maths yourself. (Sorry, that's 'math' over there isn't it.) Have you thought about trying to do this on a Tk canvas? The oval item lets you specify the diagonal corners of the oval's bounding box. Tk::canvas can export itself as postscript, so you could do your drawing, export it as ps, then convert it to whatever format you want. Interesting I'm really workign on a dynamic system though, enter data into form and image is generated. I wonder if those steps would be a bit rough that way.. I don't know, I'll look into it for sure. Actually I guess I could do Tk::canvas save it to a temp .ps file and open the tmep file with GD or Imager or somethgin and conevrt it on the fly I guess it's not too impossible after all, I'll add this to my list of trick to try. Thanks! Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Using File::Find to generate playlists
Ok, please don't laugh. This is my very first shot at Perl and if I learn something, I'll be putting it to use for more important tasks. Thanks in advance for any comments. #!/usr/bin/perl # A dorkey little perl script using File::Find. The idea is to recurse # subdirectories and write an .ASX file (sequenced playlist of file # names) to each subdirectory for the files located there. # Aside from the slight This doesn't work as expected problem ... # the following I haven't yet figured out: # # 1. The 'outfile.asx' needs to take its name from the current directory #name and not be arbitrarily set to some predefined name #(outfile.asx in this case). Maybe munge the fully qualified path #somehow, or go back to READDIR? g # # 2. How does one set the top directory for File::Find to the directory #in which the script is run? use strict; use warnings; ^^^ Excellent!! Bravo! :) If I can I'll look at your questions in a bit. use File::Find; find ( { wanted = \wanted, preprocess = \preprocess, }, @ARGV); sub wanted { if (-f _) { # check for avi, mpg, mpeg, divx, etc.? open( OUTFILE, $File::Find::dir/outfile.asx ) or die( Cannot open $File::Find::dir/ .outfile.asx: $! ); print( OUTFILE Entry\n ); print( OUTFILERef href = \$File::Find::name\\n ); print( OUTFILE Entry \n\n ); close( OUTFILE ) or die( Cannot close $File::Find::dir/ . outfile.asx: $! ); } } sub preprocess { print Processing directory $File::Find::dir ...\n; open( OUTFILE, $File::Find::dir/outfile.asx ) or die( Cannot open $File::Find::dir/ . outfile.asx: $! ); print( OUTFILE Asx Version = \3.0\\n ); print( OUTFILE Title/Title\n ); print( OUTFILE Abstract/Abstract\n ); print( OUTFILE Copyright/Copyright\n ); print( OUTFILE Author/Author\n\n ); close( OUTFILE ) or die( Cannot close $File::Find::dir/ . outfile.asx: $! ); sort { uc $a cmp lc $b } @_; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Drawing an Arc at an angle.
On Wed, 7 Jan 2004 08:55:56 -0600, [EMAIL PROTECTED] (Dan Muey) wrote: Have you thought about trying to do this on a Tk canvas? The oval item lets you specify the diagonal corners of the oval's bounding box. Tk::canvas can export itself as postscript, so you could do your drawing, export it as ps, then convert it to whatever format you want. Interesting I'm really workign on a dynamic system though, enter data into form and image is generated. I wonder if those steps would be a bit rough that way.. I don't know, I'll look into it for sure. Actually I guess I could do Tk::canvas save it to a temp .ps file and open the tmep file with GD or Imager or somethgin and conevrt it on the fly I guess it's not too impossible after all, I'll add this to my list of trick to try. Thanks! Oops, I just tried it. The plain Tk::Canvas dosn't support rotation yet. And the Oval bounding box only does x-y alignment. The Tk::Zinc canvas does do rotation, but outputting postscript is still on the planned to do list. ;-( Zinc can make just about anything you want, with clipping, zooming, and rotations. But without the ps output, you would have to capture it manually. Just for fun, I tried tuxpaint, and it does make ellipses which can be rotated with the mouse, but I don't think it has a programming interface. Maybe something in script-fu with Gimp? There is an enormous number of scripts for script-fu. I did a groups.google.com search for rotate ellipse GD and there seems to be alot of C code to do it with the real GD c libs. Maybe you could get one to compile and call it from your perl script, passing your parameters to it? Or maybe you could do it programmatically by learning to write postscript directly from perl? Zinc makes it real easy to do it, and as a matter of fact, someone on the Zinc maillist today, just asked the developer to get going on the postscript output. I've even made a lobe shape programmatically with Zinc, and it's bezier curves. Good luckall my ideas are done. :-) Thanks! Even more to add to my look into list! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: stop
I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail. You've sent 50 emails to [EMAIL PROTECTED] I get no spam from this list ever, maybe it's coming from someone who harvested your email address from a web site or something? I will now report all mail sent to me by you as SPAM What are the headers and ip addresses, I doubt it's coming from the real beginners list or else I'd have gotton spam also since I've subscribed for a while now. Stop sending me spam. I never have and the list hasn't either. It's got to be a harvesting bot, virus, etc... Maybe your IncrediMail or Kazaa or somethgin has spyware in it? HTH DMuey 2003 www.hushport.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: putting $1 into a var
Thanks to everyone who helped me with this one, I had a deadline to meet that is now met. It was a missing ~ and me failing to use s on the end of my pattern may be of use to other users but for some reason my Linux server needs s///s; to match over newlines and my OSX set up doesn't, that didn't help ;) OSX! Yummy! It probably has something to do with the Unix/Mac/Winders newline character issue. They all use different characters for that so it can cause issues. Dmuey Angie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: PERL debuggers
Are there any free PERL debuggers? Have you tried use strict and use warnigns in your scripts? Also perl -c script.pl is helpfule and then the perl debugger itself: perl -d I'm sure their's thrid party stuff but I never use any, the above does plenty for my needs. HTH Dmuey I once came across pvdb (a vi-aware front-end for the PERL debugger developed by Tom Christainsen), but I never got it to work. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: stop
Please tell me this thread will stay in the archives! It's hilarious! I feel kinda bad for Mr. Kapp though, but if you're rude for no good reason what can you expect. - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 14:31 Subject: stop I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail. I will now report all mail sent to me by you as SPAM Stop sending me spam. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
One line variable declaration with multiple conditions
Howdy list. I'm trying to one lineify this: my $guts = $firstchoice || ''; if(!$guts $use_second_choice_if_first_is_empty) { $guts = $secondchoice; } Basically my $guts = $firstchoice || $secondchoic || ''; Would be perfect except I only want to let it use $seconchoice if $use_second_choice_if_first_is_empty has a true value. This does not work like I want but illustrates the goal if you read it our loud. my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || ''; Is that possible to do with one line? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
On Jan 7, 2004, at 2:20 PM, Dan Muey wrote: Is that possible to do with one line? technically no, because you needed my ($firstchoice, $use_second_choice_if_first_is_empty); my $secondchoice = 's2'; Sorry, I figured we could assume they were declared earlier so as not to muck up the screen and it wouldn't really change the question or answer. then you can do my $guts = ($use_second_choice_if_first_is_empty)? $secondchoice : $firstchoice || ''; Nice. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
Howdy list. I'm trying to one lineify this: my $guts = $firstchoice || ''; if(!$guts $use_second_choice_if_first_is_empty) { $guts = $secondchoice; } Basically my $guts = $firstchoice || $secondchoic || ''; Would be perfect except I only want to let it use $seconchoice if $use_second_choice_if_first_is_empty has a true value. This does not work like I want but illustrates the goal if you read it our loud. my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || ''; Is that possible to do with one line? TIA Dan Seems like the ternary operator should set you up... perldoc perlop look for Conditional Operator... my $guts = (($firstchoice ne '') ? $firstchoice : (($firstchoice eq '') ? $secondchoice : '')); Thanks! I'll try each of these suggestions and maybe Benchmark them for grins. Though there may be a better way using some combination of ||= or am I misunderstanding you completely? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
Dan Muey wrote: Howdy list. I'm trying to one lineify this: my $guts = $firstchoice || ''; if(!$guts $use_second_choice_if_first_is_empty) {$guts = $secondchoice; } Basically my $guts = $firstchoice || $secondchoic || ''; Would be perfect except I only want to let it use $seconchoice if $use_second_choice_if_first_is_empty has a true value. This does not work like I want but illustrates the goal if you read it our loud. my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || ''; Is that possible to do with one line? $first || ($use_second $second) || ''; Short and sweet! Thanks Bob! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: One line variable declaration with multiple conditions
Howdy list. I'm trying to one lineify this: my $guts = $firstchoice || ''; if(!$guts $use_second_choice_if_first_is_empty) { $guts = $secondchoice; } Basically my $guts = $firstchoice || $secondchoic || ''; Would be perfect except I only want to let it use $seconchoice if $use_second_choice_if_first_is_empty has a true value. This does not work like I want but illustrates the goal if you read it our loud. my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || ''; Is that possible to do with one line? TIA Dan Seems like the ternary operator should set you up... perldoc perlop look for Conditional Operator... my $guts = (($firstchoice ne '') ? $firstchoice : (($firstchoice eq '') ? $secondchoice : '')); Except I only want to assign $secondchoice to it if $use_second_choice_if_first_is_empty is true. BTW - I'm not really using these variable names, only using them here ot help clarify my goal. Bob's woprks perfect and I havn';t tied Driex's as I have to leave right now. I'm going to benchmark them and see if there is any performance gain in either, though I doubt it. Thanks Though there may be a better way using some combination of ||= or am I misunderstanding you completely? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: coping txt files over a peer to peer.
Hello folks, Howdy, Funny I was just thinking about Sockets today. I don't use them nitty gritty like this but I would assume you need to do multiple send/receive/accept in a little session via your own prtocol. Something like: Client hello Server howdy Client NAME fred.txt Server NAMEIS fred.xt Thanks - SENDFILE Client FILE Server Thanks Writing file...FILEOK Client bye I am done Server bye hava good one I'm interested in seeing how to do this, sorry it probably wasn't much help. How do I send the file name used by the client so that the server uses the same file name When it is writing it own file. thank you. here's the client: use IO::Socket; my $server = IO::Socket::INET-new( PeerAddr = 'localhost', PeerPort = 5050, Proto= 'tcp' ) or die Can't create client socket: $!; open FILE, original_file_name; while (FILE) { print $server $_; } close FILE; Here's the server: use IO::Socket; my $server = IO::Socket::INET-new( Listen = 5, LocalAddr = 'localhost', LocalPort = 5050, Proto = 'tcp' ) or die Can't create server socket: $!; my $client = $server-accept; open FILE, copy_file_name or die Can't open: $!; while ($client) { print FILE $_; } close FILE; -- -- __ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: taking my vbscript to perl
Hello, now I am a newbie to perl would like to migrate my existing knowledge... Would anypone give me a crash course here... how would my following short vbscript correspond in perl. Bravo for dumping vbscript! You'll find Perl much easier, platform independent, and just generally more cool! So are you copying a directory(s) basically? Instead of translating line by line (which would be confusing and a lot of unnecessary work and code) Determine what you need to do and do it fresh. I'd recommend looking at search.cpan.org for one of the File:: modules. (search.cpan.org is your friend and so is perldoc: perldoc -h) For instance take your vbscript version and compare to this: (doesn't seem to copy directory structures but a liitle more involved will) use File::Copy; copy('/home/file1','/home/file2') or die Copy failed: $!; HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Drawing an Arc at an angle.
Dan Muey wrote: I've made a funtion to calculate the Fresnal zone for wireless connections. What I'd like to do is generate an image based on that. Something like the example at: http://ydi.com/calculation/fresnel-zone.php However the two connected points are rarely going to be at the same level so I'd need to draw the elipse At an angle instead of horizontally. GD's elipse or arc function will probably do what I want but it seems all I can specify are the center point and width and height. Is there a way to also specify the x/y of each point on the left and right side of the elipse? Make sense? Yes, but you're out of luck I'm afraid Dan. The best I can suggest is that you use the 'filledPolygon' method and do the maths yourself. (Sorry, that's 'math' over there isn't it.) Where is your over there in relation to my over hear (St. Louis , MO USA)? I'm doing all the math(s) :), I'm only seeing a way to draw the elipse or arc with a horizontal and vertical orientation only. I'll test some things out a bit more and show the group what's happening and have some url's. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: (I wish there was a) cpan user's guide
I keep feeling I should learn more before I post here (lest I look like a lazy idiot who can't RTFM), but I'm getting too old to wait! Anyway, first post: Surely there's a module (or many) with a method to parse URL's down to TLD. I just can't find nice lists of them. I need to see if some files came from the same host. Here's what I'm doing now (just to show I'm writing _some_ code): my $link = $result-{URL}; my $slink = substr($link, 10, 7); if($slink eq $temp){ ...do stuff... $temp=$slink } No. Look away. It's hideous. I have a module I'm putting on cpan soon that has a grabdomain function. Part of the trouble is the country part, to illustrate: domain.com and domain.com.uk are both the main domain. so my function takes into account those and lets you add and remove which far right \w+ would be two or three sections. Then each section has to be properly formatted also. RFC can get sticky! Keep your eye out on cpan for the SimpleMood module. It will have lots of handy things to simplyify development. (But it usually works). OK, obviously I haven't gotten regexes down (or gotten to their chapter at all). My question is: how can I find (not just this but any) methods available on cpan? Must I muck through google every time I want to q=learn+some+new+damn+perlbtnG=Google+Search? It's such a wasteland of usenet postings from 1995! http://search.cpan.org perldoc -h HTH Dmuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: ActiveState ActivePerl 5.8 - system call
Hi, Howdy We have a perl/cgi script (ActivePerl 5.8) which calls a executable (C code) using the system command. Ex: . @args = (C:\\perlcode\\sample.pl, arg1, arg2); system(@args); $exit_value = $? 8; $signal_num = $? 127; $dumped_core = $? 128; print $exit_value, $signal_num, $dumped_core\n; . sample.pl is the C prog or it calls the c prog? How does sample.pl set the values you're looking for? The above code works fine from the command prompt and exit_value, signal_num and dumped_core are all 0. The same perl /cgi script when called from a web page (IIS server) returns exit_value to be 128 (what does it mean)? i.e. C Ask bill gates :) Just kidding (sort of). Hard to say without knowing what/where/how/who/when these values are being set. Also IIS is, with all due respect and apologies for being OT, crap. I'd refer to IIS manual and see what 128 means to it. Or does 128 come from your c prog, if so what does 128 mean to it? Or does 128 come from sample.pl, if so what does it mean to it? code fails. What could be wrong. Is there any IIS setting required, I did add the .pl extension to IIS. Please help We need to see your sample.pl code and know what the c prog is all about to help you with why the current script is acting a certain way. Atul DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: ActiveState ActivePerl 5.8 - system call
Hi, Howdy I am no fan of Bill Gates either :) but the client needs to use his crap. The simplified version of code is: Ok, some thigns I'd do is: 1) use strict; and use warnings; if winders has them. 2) Make you variabels my() variables; (IE my $arg1 ... Instead of $arg1 ...) 3) changeg system() line to : system(C:\\perlcode\\validate.exe $arg $arg2) or die System call failed $!; . $arg1=userid; $arg2=password; @args = (C:\\perlcode\\validate.exe,$arg1,$arg2); system(@args); $exit_value = $? 8; $signal_num = $? 127; $dumped_core = $? 128; Just curious, what is happening here with the and the . I see there's a 128 there, perhaps that's where it is coming from? print $exit_value, $signal_num, $dumped_core\n; . validate.exe is the C executable, that validates the credentials against a database on some other machine. When called from IIS, system call never makes it to the validate.exe. $exit_value is 128 (instead of 0). Since it's comign from a webserver do you have an apropriate contetn type header before any output? What do your logs say about it? Thanks Atul On Tue, 6 Jan 2004 12:56:50 -0600, Dan Muey wrote: Hi, Howdy We have a perl/cgi script (ActivePerl 5.8) which calls a executable (C code) using the system command. Ex: . @args = (C:\\perlcode\\sample.pl, arg1, arg2); system(@args); $exit_value = $? 8; $signal_num = $? 127; $dumped_core = $? 128; print $exit_value, $signal_num, $dumped_core\n; . sample.pl is the C prog or it calls the c prog? How does sample.pl set the values you're looking for? The above code works fine from the command prompt and exit_value, signal_num and dumped_core are all 0. The same perl /cgi script when called from a web page (IIS server) returns exit_value to be 128 (what does it mean)? i.e. C Ask bill gates :) Just kidding (sort of). Hard to say without knowing what/where/how/who/when these values are being set. Also IIS is, with all due respect and apologies for being OT, crap. I'd refer to IIS manual and see what 128 means to it. Or does 128 come from your c prog, if so what does 128 mean to it? Or does 128 come from sample.pl, if so what does it mean to it? code fails. What could be wrong. Is there any IIS setting required, I did add the .pl extension to IIS. Please help We need to see your sample.pl code and know what the c prog is all about to help you with why the current script is acting a certain way. Atul DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: case and functions
Yo. What's up dog? :) I read in Learning Perl that there are no such constructs like a case statement. Is there Yes, there is. Do you mean: if(this) { do this } elsif(that) { do that } else { do the other } something similar or did I misread this? Also what about functions and function calls, do these exits or does the subroutines replace these? Functions and subroutines are *basically* the same thing. Perldoc perlsub I believe addresses this. HTH DMuey thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: ActiveState ActivePerl 5.8 - system call
Dan Muey wrote: Also IIS is, with all due respect and apologies for being OT, crap. Not the case, Dan. While I would never expose IIS to the public Internet, it is an excellent tool for debugging CGI scripts. It puts a minimum of extraneous configuration grief into the process, and usually passes error messages back through in its web content: qq/ The specfied application did not return the required eader. What it returned instead was: [your debug info here] / Clearly not something to display to the public, but it can be very useful in working out program logic. I think the OP's problem has more to do with the problems inherent in shelling out than in the server platform. I agree, that was why I said it was OT (IE not related to his issue), just letting off a little steam about MS :) I just got a PowerBook so I'm all excited about finally being MS free 100% Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: mass-replacing large block of text
I don't understand why you include $split in the new file. The text I want to get replace is from and including that line to the end of the file. Because you said you want to replace the stuff after $split. And in your modified version it seemed like you were writing the data you split on in the variable $newhtml which now it seems was simply an html comment. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Drawing an Arc at an angle.
Hello List, I've made a funtion to calculate the Fresnal zone for wireless connections. What I'd like to do is generate an image based on that. Something like the example at: http://ydi.com/calculation/fresnel-zone.php However the two connected points are rarely going to be at the same level so I'd need to draw the elipse At an angle instead of horizontally. GD's elipse or arc function will probably do what I want but it seems all I can specify are the center point and width and height. Is there a way to also specify the x/y of each point on the left and right side of the elipse? Make sense? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: $_
The lines will always be defined but I need to process that previous line. I am still kinda in the closet on what you mean. He means the variable $last he used. I've tried to do an exqample that may help clear it up for you: my $prev; for(qw(a b c d e f g)) { print Previous item was $prev\n if defined $prev; print Current item is $_\n; $prev = $_; } HTH DMuey .. On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote: On Dec 30, 2003, at 10:36 AM, Eric Walker wrote: I am going through a file and when I enter a certain routine, I am entering a while loop with the IN construct. Is there a way to back the counter up or back up one line before I go into the while loop? a b c d Instead of seeing b when I enter the while loop, adjust some option and see the a. How about adding: my $last; while (IN) { # use $last here, but watch for undef on the first iteration, for example: do_something( $last ) if defined $last; $last = $_; } Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: $_
Once I get into the while loop the previous line I had is lost. As this while is underneath another while that I am using in another routine. It doesn't make any sense to read. Why? Please don't top post. :) I was using an array and for() in my example so you could see the principle in action. Using your file handle with while() will work the same way. (Just don't do an array with while, that could make for a long running program!) No matter how many loops within loops you have you need to save the current item in a variable inside the current block and use the variable inside you loop, like we did in the examples given. Dmuey The lines will always be defined but I need to process that previous line. I am still kinda in the closet on what you mean. He means the variable $last he used. I've tried to do an exqample that may help clear it up for you: my $prev; for(qw(a b c d e f g)) { print Previous item was $prev\n if defined $prev; print Current item is $_\n; $prev = $_; } HTH DMuey .. On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote: On Dec 30, 2003, at 10:36 AM, Eric Walker wrote: I am going through a file and when I enter a certain routine, I am entering a while loop with the IN construct. Is there a way to back the counter up or back up one line before I go into the while loop? a b c d Instead of seeing b when I enter the while loop, adjust some option and see the a. How about adding: my $last; while (IN) { # use $last here, but watch for undef on the first iteration, for example: do_something( $last ) if defined $last; $last = $_; } Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: $_
ok with that can I still continue through the loop and process the next line? You can use $_ : for(qw(1 2 3)) { print Processing files - iteration number $_\n; my @files = qw(foo.txt bar.html); for(@files) { open(FH,$_) or die Can not open $_ : $!; my $prev; while(FH) { print Previous item was $prev\n if defined $prev; print Current item is $_\n; $prev = $_; } close(FH); } } What happens when you do something like that? will I not loose the second line now? On Tue, 2003-12-30 at 09:49, Dan Muey wrote: The lines will always be defined but I need to process that previous line. I am still kinda in the closet on what you mean. He means the variable $last he used. I've tried to do an exqample that may help clear it up for you: my $prev; for(qw(a b c d e f g)) { print Previous item was $prev\n if defined $prev; print Current item is $_\n; $prev = $_; } HTH DMuey .. On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote: On Dec 30, 2003, at 10:36 AM, Eric Walker wrote: I am going through a file and when I enter a certain routine, I am entering a while loop with the IN construct. Is there a way to back the counter up or back up one line before I go into the while loop? a b c d Instead of seeing b when I enter the while loop, adjust some option and see the a. How about adding: my $last; while (IN) { # use $last here, but watch for undef on the first iteration, for example: do_something( $last ) if defined $last; $last = $_; } Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: mass-replacing large block of text
I have ~97 HTML documents that I need to strip the footer (about 15 lines) from and replace with a different block of text. The footer is formatted differently in some of the HTML files, but they all start with the line: table border=0 width=100% height=5% How can I replace everything after that particular line with a custom block of text? Thanks. Here's one way, you say the files are html so slurping shouldn't hurt: [untested - for principle demo only] #!/usr/bin/perl -w use strict; use File::Slurp; my $newhtml = '/table/body/html'; my $split = 'table border=0 width=100% height=5%'; my @files = qw(index.html contact.html); # populate this by hand or automatially if you want my $count = 0; for(@files) { print Starting $_ ...; my $html = read_file($_); my ($firstpart) = split $split, $html; # may need to tweak around with this write_file($_, $firstpart$split$newhtml); print Done!\n; $count++; } print \nFinished : $count files processed.\n; -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
My stupidity! (WAS RE: Mail::Sender weirdness)
The thing is I get Sending...Done everytime but never a dleivery and no hinf tof it in the logs. On one server I needed to use smtp authentication but that set $@ and said connection This part of it was completely stupid on my part: I was doing if($@) { ... I added if($@ || $Mail::Sender::Error) { ... And guess what? It gave me the error message. Duh, what a moron! So now it said Connection not established for the local sending to remote, which I would think would be the easiest one, especially since: Local to local is ok. Remote to local is ok. I'm not doing any remote to remote. But authentication made my mail servers start sending it but I'm still not sure why my mail server would insist on authentication in one case but not the other. Oh well, whaddayado! Dan couldn't be made. Any ideas what I'm missing would be awesome! By default Mail::Sender does not raise exceptions. It returns negative error codes. Right on! I'll take a look at your cpan page again and redo my problem handling angle. As usual you rock! Jenda -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: My stupidity! (WAS RE: Mail::Sender weirdness)
They are doing the Right Thing and not being an open relay. Basically the server says *one* of the persons involved has to be In both cases one is always a local user. But only in one case is authentication required. known to it. If the email is for a local user it knows that person. If it isn't, you have to authenticate as someone it knows. Otherwise Joe Spammer can come and ask the server to please deliver these 10k messages to random people. Right, but my question is why do I need to authenticate local to remote and not remote to local not why do I have to authenticate at all. I'm well aware of the spam relay fun! :) I could spam all the local users as [EMAIL PROTECTED] all day long without any knowledge of there settings. So I guess, why not authenticate both ways? Just a pondering, no big deal since they'd have to get a scirpt on the server and that'd make them trackable pretty quick. Daniel T. Staal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: mass-replacing large block of text
Dan Muey wrote: I have ~97 HTML documents that I need to strip the footer (about 15 lines) from and replace with a different block of text. The footer is formatted differently in some of the HTML files, but they all start with the line: table border=0 width=100% height=5% How can I replace everything after that particular line with a custom block of text? Thanks. Here's one way, you say the files are html so slurping shouldn't hurt: [untested - for principle demo only] #!/usr/bin/perl -w use strict; use File::Slurp; my $newhtml = '/table/body/html'; my $split = 'table border=0 width=100% height=5%'; my @files = qw(index.html contact.html); # populate this by hand or automatially if you want my $count = 0; for(@files) { print Starting $_ ...; my $html = read_file($_); my ($firstpart) = split $split, $html; # may need to tweak around with this write_file($_, $firstpart$split$newhtml); print Done!\n; $count++; } print \nFinished : $count files processed.\n; This slightly modified version of your script seems to work just fine: Cool. #!/usr/bin/perl -w use strict; use File::Slurp; my $newhtml = '! Old footer snipped here\n/body/html'; The only problem I see here you have enter the same data twice leaving room for mistakes you have to fix. So by leaving it out of $newhtml and using print $firstpart$split$newhtml\n; # or add some newlines for readability You gaurantee the same data with no mistakes. DMuey my $split = 'table border=0 width=100% height=5%'; my @files = qw(uc.html); # populate this by hand or automatially if you want for(@files) { print Starting $_ ...; my $html = read_file($_); my ($firstpart) = split $split, $html; # may need to tweak around with this # write_file($_, $firstpart$split$newhtml); print $firstpart$newhtml\n; print Done!\n; } -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response