Re: FW: Html within code

2007-07-25 Thread Ovid
code clean. It makes it easier to debug both the HTML *and* the Perl. If you *must* have self-contained HTML (not recommended), then at least encapsulate it into subroutines which don't obscure the main flow of the program. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Perl and CGI - http://users.easystreet.com/ovid/cgi_course/ Personal blog - http://publius-ovidius.livejournal.com/ Tech blog - http://use.perl.org/~Ovid/journal/

Re: Exception handling in perl

2007-07-12 Thread Ovid
r to export the throw_io() or throw_fatal() functions: use My::Exceptions 'throw_io'; open my $fh, '<', $file throw_io "Cannot open ($file) for reading: $!"; Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Perl and CGI - h

Test::Class fixture problem

2007-06-29 Thread Ovid
$test->SUPER::startup; $test->_make_test_servers( num_servers => 2, username=> 'Ovid', ); } As you can see, I called SUPER::startup instead of SUPER::setup. My base class has stubs for these methods to ensure that I never have a problem

Re: Is there a perl equivalent to PHP variables $_POST and $_GET?

2007-06-11 Thread Ovid
$id= param('id'); my $name = param('name'); my @sports = param('sport'); # e.g. sport=basketball;sport=football Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/

Re: Leaving this list.

2007-06-05 Thread Ovid
nd published archives didn't include addresses, this could make mailing list software more interesting. Cheers, Ovid -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: New to OO Perl

2007-05-03 Thread Ovid
your code realize this, they merely need to consult the Image::Magick documentation to understand what arguments are allowed. If that is not desirable, it's not too hard to change the above code to do what you want. You'd need a richer structure in your begin block to specify how

Re: how to know the object type

2007-04-04 Thread Ovid
h fixes the broken class or use a class which isn't broken. DO NOT pay attention to what type of reference it is. There are many, many years of collective wisdom in that* Cheers, Ovid * Yes, there are time you may need to know what the reference is, but this is usually with black magic

Re: how to know the object type

2007-04-03 Thread Ovid
;t peek inside objects! See also "Thou Shall Not Covet thy Object's Internals" for another horror story. http://www.perlmonks.org/?node_id=75578 Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Off-Topic: Is the Randall Schwartz of Perl Fame?

2007-03-05 Thread Ovid
, you've committed a felony. Randal (they misspelled his name) should never have been convicted. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: putting ";" as a replacement in the substitution.

2007-01-21 Thread Ovid
as suggested by someone is also good when I want to avoid > something being stored in $n... I have read about it and a lot > more(particularly the extended regexp features) in perlre but not quite > sure what they mean. Yes, that's correct. Sometimes you want to group something but

Re: putting ";" as a replacement in the substitution.

2007-01-21 Thread Ovid
The second version is good when you want to take action based upon a match and possibly extract data out of the string. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Get summery of a jpeg file

2007-01-16 Thread Ovid
rst hit off search.cpan.org for 'jpeg'. There are many more available. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: regex to split whitespace-separated values

2007-01-09 Thread Ovid
--- Rob Dixon <[EMAIL PROTECTED]> wrote: > The default behaviour can be invoked explicitly by using a single > space as the > separator parameter for split. So > > my @array = split ' ', $line; > > has the desired effect. Ah, thank you. I didn't kn

Re: regex to split whitespace-separated values

2007-01-09 Thread Ovid
hat prints: $VAR1 = [ '50', '100', '150', '200', '300', '50' ]; Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http

Re: php's __FUNCTION__ equivalent in Perl

2007-01-02 Thread Ovid
main::foo' (or whatever package the function is in): #!/usr/bin/perl print foo(); sub foo { return (caller(0))[3]; } See 'perldoc -f caller' for more information. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.ea

Re: Free Perl Editor

2007-01-02 Thread Ovid
s harder, but you can have exactly what you want. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Perl equivalent of PHP extract()?

2006-12-18 Thread Ovid
don't want to do that, read Mark Jason Dominus' series of articles entitled "Why it's stupid to `use a variable as a variable name'": Part 1: http://perl.plover.com/varvarname.html Part 2: http://perl.plover.com/varvarname2.html Part 3: http://perl.plover.com/varvarn

Re: Devel::Dprof

2006-12-15 Thread Ovid
most people use Devel::Profile. It works fairly well (and you can get per-line profiling with Devel::SmallProf). Ironically, in trying to profile some code recently, Devel::Profile was segfaulting and Devel::Dprof was not, so your mileage may vary. Cheers, Ovid -- Buy the book -- http://www.oreil

Re: Conditional sorting across two arrays

2006-12-12 Thread Ovid
hor's desire to earn a living. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: CYGWIN Uninstall

2006-12-11 Thread Ovid
he simple fact is that trying to keep a list focused on the topic can be *hard*. Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [

Re: Analize Java source file with perl?

2006-10-26 Thread Ovid
quoted strings into account. It could probably use tweaking. Wasn't sure why I had to diddle Regexp::Common like that. I couldn't use both {quoted} and {comment} in the same program without that. I probably misread the docs somewhere. Cheers, Ovid #!/usr/bin/perl -l use

Re: use strict and local variables

2006-10-16 Thread Ovid
d no parentheses because the current value of @_ is then passed to the calling subroutine. It's then very easy, when refactoring, to use &subname instead of &subname(). Avoid that ampersand unless you know exactly why you're using it :) Cheers, Ovid -- Buy the book

Re: how do i list the methods connected to a object?

2003-08-14 Thread Ovid
ing design flaw that needs to be addressed. Of course, people seem to get mad when I say that :) Cheers, Ovid = Silence is Evil http://users.easystreet.com/ovid/philosophy/indexdecency.htm Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming w

Re: how do i list the methods connected to a object?

2003-08-08 Thread Ovid
talled in the symbol table } A slightly more robust version of that syntax: if (UNIVERSAL::can($object, $method_name) { # almost the same thing, but doesn't die a horrible death if, for example, # $object is undef } If you explain the problem you're tryi

Re: print <<"HTML code"; in NETSCAPE

2003-08-04 Thread Ovid
e HTML to a variable and then use something like HTML::Entities to properly encode it and then print it out as HTML. Many people have been bitten by Microsoft deciding to second-guess us. (It's also opened up some nasty security holes). Cheers, Ovid = Silence is Evil

Re: eleminating dupes in a 2-D @list

2003-07-25 Thread Ovid
s get undefined or shifted, perhaps? For example, in the diagram above, replacing the duplicates with spaces gives us: 3 r s 8 a d 8 4 h w w a 4 9 Is that what you are looking for, or do things get shifted left or up, or some combination of that? Cheers, Ovid ===== Hire me!

Re: help needed

2003-06-29 Thread Ovid
> Anyone p[lease tell me from where can i download Net::FTP module Hi Uday, Net::FTP is part of libnet which you can download at http://search.cpan.org/author/GBARR/libnet-1.16/. Cheers, Ovid = Hire me! http://users.easystreet.com/ovid/personal/resume.html O

Re: Using Print -strange behavior

2003-03-24 Thread Ovid
--- Jose Luis Martinez <[EMAIL PROTECTED]> wrote: > Hello Ovid > > This is the code that I am trying to run > > #!/usr/bin/perl > > my $a="Hello World"; > > print $a; There is nothing wrong with this code. Thoughts: * what is the result of

Re: Using Print -strange behavior

2003-03-22 Thread Ovid
gt; > I checked it the script using > perl -c script_name and it return OK Hello Jose, While that sounds simple enough to be error free, if you could show us the code, it would be helpful to at least rule out obvious problems. Cheers, Ovid = "Ovid" on http:

Re: Getting a variable back

2002-12-16 Thread Ovid
ith you better methods of approaching this situation. Cheers, Ovid = "Ovid" on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt __

RE: Excel

2002-12-16 Thread Ovid
ks.org/index.pl?node_id=215093 Cheers, Ovid = "Ovid" on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt __ Do

Re: Guestbook script problem

2002-11-27 Thread Ovid
you are printing your content-type header multiple times. You'll only need to print in once. You can also use your CGI object for this: print $q->header; See my CGI course for more information on this (link at bottom of email). Good luck with your programming! Cheers, Ovid =

Re: OOP

2002-11-26 Thread Ovid
x27;, 'Portland', 'Oregon', '[EMAIL PROTECTED]' ); print Dumper $myPerson; In reality, I would use named arguments to the constructor and test them for validity before assigning them. They should be tested for validity in the constructor, though, and

Re: html in my script

2002-11-25 Thread Ovid
bly shorter than the text that is entered to ensure I don't have apparent whitespace at the end. It's not an optimal solution, but neither is using a browser as a GUI client. Cheers, Ovid = "Ovid" on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystr

Re: HTML::TokeParser/Parsing problem

2002-11-25 Thread Ovid
is a drop-in replacement. If you use HTML::TokeParser extensively in your code, you can then use the Simple version instead and only change the bits you need to. The rest of the code should still work fine. Cheers, Ovid Cheers, Ovid = "Ovid" on http://www.perlmonks.org/ Web Progr

Re: Determining when a file was created???

2002-11-20 Thread Ovid
g upon what you need to do, you could perhaps check when the file was last altered or accessed. my ($last_read,$last_written) = (stat($filename))[8,9]; Cheers, Ovid = "Ovid" on http://www.perlmonks.org/ Web Programming with Perl: http://users.easystreet.com/ovid/cgi_course/ Silen

Re: query string into hash?

2002-11-13 Thread Ovid
need to change that in the future (using POST and reading from standard input), CGI.pm will handle that transparently for you and you won't have to update your code. Cheers, Ovid Cheers, Ovid = "Ovid" on http://www.perlmonks.org/ Web Programm

Re: map EXPR, LIST

2002-11-12 Thread Ovid
rint Dumper \@a' abc$VAR1 = [ '1', '1', '1' ]; You can see the 'abc' prior the Data::Dumper output, and you can see that a list of ones has been created. The map only confused things. The cod

Re: basename / path question

2002-11-09 Thread Ovid
ow are they called, where might I want start > reading? Hi Kris, What you're looking for is File::Basename. [ovid@ovid ovid]$ perl -MFile::Basename -le 'print basename("/usr/bin/perl")' perl [ovid@ovid ovid]$ perl -MFile::Basename -le 'print dirnam

Re: Reading from mulitple files

2002-11-04 Thread Ovid
l be processing the extra 12 lines from the first file *after* the three lines from the second file. It should be noted that this program doesn't tell you which file is which as you didn't necessarily specify that in your email. It should be fairly easy to add, though. Cheer

Re: Calculate PI

2002-11-04 Thread Ovid
st, $second); }; return $sub; } If you want to see some "fun" implmentations, check out this thread on Perlmonks: http://www.perlmonks.org/index.pl?node_id=159377. One of my favorites: sub _{$---&&4/$&_}print- _$-=1e5 Cheers, Ovid = "Ovid&q

Re: html regular expressions

2002-10-12 Thread Ovid
my $attributes = $token->return_attr; unless ( exists $attributes->{ alt } ) { print $token->return_text; } } The documentation provides plenty of additional examples. This module can be found on the CPAN. Cheers, Ovid = "Ovid" on http://www.perlmonks.o

Re: Promoting to a Subclass

2002-10-09 Thread Ovid
$class; } sub not_in_parent { print "We're ok!\n"; } package main; use Data::Dumper; my $object = Foo->new; eval { $object->not_in_parent }; print "\nWarning: $@\n"; $object->promote; $object->not_in_parent; $object->inherited_method; print Dumper $obj

Re: Perl Profiler?

2002-10-07 Thread Ovid
ing what code changes will gain you maximum benefit, using the Benchmark module will allow you to concretely demonstrate what *really* works. For some good information on using Benchmark, see http://perlmonks.org/index.pl?node_id=8745 Cheers, Ovid = "Ovid" on http://www.perlmonks.org

Re: Advanced Users in The Beginners List

2002-06-29 Thread Ovid
ate. In short, concensus will not be had on this issue, so compromise is the way to go. Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=un

Re: security check

2002-06-23 Thread Ovid
t to rely on HTTP_REFERER for security as it is very easy to fake. If you really need security, you will need to have some sort of authorization to accomplish this (such as a username/password combination). Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.o

Re: slectively load modules

2002-06-22 Thread Ovid
e Win32::Service; # if any functions are imported into your namespace or you need # to specify an import list: Win32::Service->import; } } Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: p

Re: Effective Bad Coding Habits

2002-06-20 Thread Ovid
a hash slice. Not fun. I'd drop the notation. Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@

RE: C from Perl

2002-06-18 Thread Ovid
e Inline::C that XS or SWIG, so this is a good choice, if you can make it work for you. Two quick points: make sure your C compiler is the same one that you compiled Perl with (gcc is fine on a Linux box, for example) and have a copy of make. Cheers, Curtis "Ovid" Poe = "Ovid&q

Re: Remove CRLF

2002-06-15 Thread Ovid
--- Michael Pratt <[EMAIL PROTECTED]> wrote: > Whats the command for removing the CRLF? > > Mike I assume you want to remove the input record separator from a variable. If so, you can read perldoc -f chomp Cheers, Curtis "Ovid" Poe = "Ovid" o

Re: Formatting output

2002-06-13 Thread Ovid
ure exactly what you are wanting for formatting, so I would recommend reading perldoc -f sprintf In the meantime, this will get what you have asked for: my @nums = qw/ 1.38 .0396 .0076 /; printf("%.2f, %.4f, %.4f", @nums); Cheers, Curtis "Ovid" Poe = &qu

Re: What am I doing wrong... I want to increment a number in a DB

2002-06-03 Thread Ovid
story2 = $dbh2->quote( $history5 + 1 ); $num = $dbh2->quote( $num ); my $rc = $sth2->execute( $history2, $num ); # do something with return code... } Hope this helps. Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.org

RE: union of times algorithm

2002-05-31 Thread Ovid
--- Bryan R Harris <[EMAIL PROTECTED]> wrote: > > Thanks Ovid, Timothy... > > You mention checking out perlref in the perldocs-- I'm familiar with > "perldoc -f keyword", but how would I find information on these things if I > didn't know the

RE: union of times algorithm

2002-05-31 Thread Ovid
--- Ovid <[EMAIL PROTECTED]> wrote: > > 3. and this?: $somevar = \@somearray; > > Putting a backslash in front a a sigil creates a returns a reference to it... That was coherent. :) I have come to the conclusion that I will be a better programmer if I can only lea

RE: union of times algorithm

2002-05-31 Thread Ovid
my @somearray = qw/ Red Gold Green /; my $somescalar = 'Ovid'; my $somevar = [ @somearray, $somescalar ]; Now, to get to the third item in the anonymous array, you must dereference it with the arrow operator (remembering that arrays start with zero): print $somevar-&

Re: How to get single scalar to function cleanly

2002-05-21 Thread Ovid
my ($user, @date) = (split)[9,0..2]; my $date = join ", ", @date; $date = ParseDate($date); $user =~ s/:$//; #cleans the username who logged in $ftpLogins{$user} = $date; } Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.org/ Someone asked me how to

Re: Type distinguishing

2002-05-21 Thread Ovid
--- drieux <[EMAIL PROTECTED]> wrote: > > On Tuesday, May 21, 2002, at 12:23 , Ovid wrote: > > > Use the 'ref' function for this: > > > > perldoc -f ref > > my complements. > > why can I never remember that one > once again t

Re: Type distinguishing

2002-05-21 Thread Ovid
u might want to give the code a second look. Cheers, Curtis "Ovid" Poe = "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};

Re: perl awk question

2002-05-20 Thread Ovid
a one-liner, pure Perl (assuming that I understood your question correctly), the the following should do the trick: $ perl -p -e '@t=localtime;$t[4]++;$t[5]+=1900;s/$/sprintf(",%4d-%02d-%02d",@t[5,4,3])/e' oldFile.txt >> newFile.txt Yeah, it's big and ugly and assu