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/
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->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
$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/
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/
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
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
;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/
, 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
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
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/
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/
--- 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
hat prints:
$VAR1 = [
'50',
'100',
'150',
'200',
'300',
'50'
];
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http
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
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/
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
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
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>
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: [
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
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
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
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
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
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!
> 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
--- 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
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:
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
__
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
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
=
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
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
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
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
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
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
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
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
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
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
$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
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
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
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
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
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|,$_);@
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
--- 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
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
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
--- 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
--- 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
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-&
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
--- 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
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};
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
59 matches
Mail list logo