Re: Installing and Using Perl Modules

2004-03-25 Thread Hacksaw
using cpan: invoke cpan, either by running perl -MCPAN -e shell; or, if it's set up, just cpan You will get a prompt. If you are trying to find a particular module, but you aren't sure of the whole name, you can search for it as so: cpan> i /someModuleName/ It will look it up, and spit o

Re: Using Getopt::Std

2004-01-13 Thread Hacksaw
> > > > Hi, > > i am using the Getopt::Std package in my code. > > > > > > use Getopt::Std; > > > > getopts('s:'); > > > > $a = $opt_s By the way, you don't really need to assign the $opt_x variables to a new variable. $opt_s will be persistant, unless you run getopt again, which would b

Re: Please help me! Thanks.

2003-12-15 Thread Hacksaw
> now, a stupid solution is: > > for (my $value = -1000; $value <= 1000; $value += 100) { > print $value/1000, "\n"; > } > > hehe, > Sadly, it's not as stupid as you think. Unless I misunderstand things, what you are seeing here is a problem called IEEE 754 floating point. I'm sure th

Re: Using print to overwrite a line

2003-11-25 Thread Hacksaw
This is not the most elegant solution, but it did only take me five minutes. The salient part is the backspace and printing blanks bit. A more elegent solution would figure out how to destructively clear the line using something from ncurses. #!/usr/bin/perl -w $|=1; @reports = ("starting", "

Re: Regular Exprections

2003-11-25 Thread Hacksaw
I'm betting you don't get to dictate that the string has no newlines in it. -- A principle is an instruction in qualitative endeavour. http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: Regular Exprections

2003-11-25 Thread Hacksaw
t.pl: #!/usr/bin/perl -w my $str = 'aaa --%% b%b %%-- ccc --%%ddd%%--'; $str =~ s/--\%\%.*?\%\%--/--\%\%\%\%--/sg; print $str, "\n"; ------ hacksaw > perl t.pl aaa ---- ccc ---- -- All the magic is in the matching operator. The ? after th

Re: using Getopt with subroutines

2003-11-20 Thread Hacksaw
I don't think you'll quite be able to have it be as modular as you would like since it creates globals. I'd recommend looking at the package, since it is in plain text, make a copy and modify it to your needs. But since you have to deal with the variables it sets anyway, it seems like you coul

Re: pagination of dbi results on html browser

2003-11-18 Thread Hacksaw
> A L wrote: > >> 1. How can I get to make results from mysql db to be displayed on web > Try this: > > Save the whole result set to a local temp file. You'll need a routine for > Read the file twenty or so lines at a time, doing nothing but getting the A simpler answer is to use the LIMIT

Re: selecting select as an option was Re: first steps with perl, a log reader

2003-11-16 Thread Hacksaw
>So my intention was to finish off the general discussion >of 'do you really need select' with that simple reminder >that when one does need select, one also needs to do some >basic defensive coding one place or the other. This post goes a ways to showing why unthinking operator overloading is a

Re: references and objects

2003-11-16 Thread Hacksaw
>Pettiness says that you mean the package is a /class/ :) That's pedantism. ;-) BTW, mail to [EMAIL PROTECTED] bounced. -- Establish the principle. http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [

Re: first steps with perl, a log reader

2003-11-16 Thread Hacksaw
Sander: I have an answer, and a comment: The answer: select wants a filehandle, so line 7 wants to read select EL; The comment: You are probably complicating things a great deal by using select. #!/usr/bin/perl -w open (ER, "/home/unicorn/Plscripts/ERROR.LOG"); #opening ERROR.LOG for writing

Re: What $| actually does?

2003-11-16 Thread Hacksaw
>Well, in the beginning of every script, the $|=1 should be placed. Am i >right? Only if you really want that behavior. The trade off here is that you will not really be buffering your writes. If you only have a few, it probably fine, but if you have a lot, like a complicated web page, your scri

Re: Perl interface

2003-11-09 Thread Hacksaw
There are a variety of library bindings to Perl for the well known GUI libraries, so you shouldn't have a problem finding something to work with. I know Perl has bindings to at least Tk, Gtk+ and Qt. I'd be shocked if most of the major libs aren't covered. I'm curious as to whether anyone has a

Re: alias in the shell

2003-10-18 Thread Hacksaw
> > Is it possible to create an alias in the shell from within Perl? > > > > I have a command I want to use in the shell after my Perl > > script executes. This command can vary, so what I would > > prefer to do is set up an alias to execute it. eval `perlscript` where perlscript puts out a l

Re: finding a blank line

2003-10-16 Thread Hacksaw
>If you think that's clearer then that's fine. You don't? More importantly, you think that would be clear to the next maintainer down the line? >build a bitmap for character classes and access it by character code. That >would make all character classes equally as fast. Very good point. >it's

Re: finding a blank line

2003-10-15 Thread Hacksaw
> Hacksaw wrote: > > > > > I know this is a no brainer, but this line of code does not always work: > > > last if( /^\n/ or /^\s+\n/ ); > > > > Why not > > > > last if /^\s*$/; > > > > You don't need the () in this version of the

Re: finding a blank line

2003-10-15 Thread Hacksaw
> I know this is a no brainer, but this line of code does not always work: > last if( /^\n/ or /^\s+\n/ ); Why not last if /^\s*$/; You don't need the () in this version of the construction. '*' matches zero or more of the preceding RE. -- The future is what the present can bear. http://www.ha

Re: eval and __LINE__

2003-09-07 Thread Hacksaw
> Rob> use CGI::Carp 'fatalsToBrowser' > > Just remember NEVER to leave that on in production code. EVER. Okay, I'll bite. Why? Obviously it'd look bad, but your reaction seems stronger than that. -- The creative impulse animates whatever instrument is placed at its disposal. http://www.hack

Re: eval and __LINE__

2003-09-07 Thread Hacksaw
> use CGI::Carp 'fatalsToBrowser' Ooo, cool. Thanks. Wow, two useful answers. I like this list. -- Commitments are to be honoured. http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: eval and __LINE__

2003-09-07 Thread Hacksaw
>1) use Carp; - it shows errors from the caller's >perspective. Look at the docs, but you car use >'carp' (warinig) or 'croak' (die). >2) the perl built-in function 'caller' gives line and >script name information for the caller, the caller's >caller, etc. Check the docs to roll you

eval and __LINE__

2003-09-06 Thread Hacksaw
Caveat: It's late and I'm tired and frustrated, i.e. I'm pissy. I want to have something like die, but for the web, so I want it to print out the error with a at the end, etc. How the F### do I get __LINE__ to be evaluated, not where it is in the program file, but where the function is called?