RE: Trouble with m///g

2004-09-30 Thread Hanson, Rob
I think this might work. /\b\d{4}\b/ Rob -Original Message- From: Chap Harrison [mailto:[EMAIL PROTECTED] Sent: Thursday, September 30, 2004 10:38 AM To: [EMAIL PROTECTED] Subject: Trouble with m///g Hi, I'm trying to extract all four-digit numbers from a string in one fell swoop,

RE: HTML::Template is choking

2004-09-28 Thread Hanson, Rob
The nested quotes in my attempt to put TMPL_VARs into the value field make me suspicious that I am misusing HTML::Template It may look odd, but the nested quotes are fine. If I had to guess I would say it is because there is a newline within the tag (as it seems to be in your example). I

RE: image manipulation (scaling)

2004-09-17 Thread Hanson, Rob
The best module that I know of for scaling is Image::Magick. I didn't find the docs very easy to navigate, but it does a very good job. [Very light documentation] http://search.cpan.org/~jcristy/PerlMagick-6.02/Magick.pm [Additional docs] http://www.imagemagick.org/www/perl.html The code you

RE: Perl modules path related

2004-09-09 Thread Hanson, Rob
Put this at the top of your script: use lib '/tmp/perlNew/lib'; Or you can set the environment variable PERL5LIB to that path. Rob -Original Message- From: Ajey Kulkarni [mailto:[EMAIL PROTECTED] Sent: Thursday, September 09, 2004 5:56 PM To: [EMAIL PROTECTED] Subject: Perl modules

RE: PHPerl

2004-09-08 Thread Hanson, Rob
There is embperl like was mentioned. Also Mason is very popular and well documented. Rob -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 08, 2004 11:57 AM To: [EMAIL PROTECTED] Subject: PHPerl Hi all, Is there a way to embed Perl

RE: Month-Year Links....

2004-09-07 Thread Hanson, Rob
The trick is to use Time::Local to find the first day of the month, then subtract 1 day. This prints: 09-2004 08-2004 07-2004 ### use Time::Local; use constant DAY = 86_400; $current = time; $previous = first_day($current) - DAY; $current_2 = first_day($previous) -

RE: Month-Year Links....

2004-09-07 Thread Hanson, Rob
first_day { my $time = shift; my @time = localtime($time); $time[3] = 1; return timelocal(@time); } sub get_date { my $time = shift; my @time = localtime($time); return sprintf('%02d-%04d', $time[4]+1, $time[5]+1900); } -Original Message- From: Hanson, Rob Sent: Tuesday

RE: Image::Magic / Perl::Magick

2004-08-25 Thread Hanson, Rob
Maybe this will help... maybe it won't. I just tried installing Image::Magick (on Win2K/AS perl 5.6.1 build 635), and had no issues. The install showed that it installed Magick.dll, and where it was installed to. Note that I used Image-Magick, which is how AS has it stored in the repository.

RE: Image::Magic / Perl::Magick

2004-08-25 Thread Hanson, Rob
[mailto:[EMAIL PROTECTED] Sent: Wednesday, August 25, 2004 5:42 PM To: Hanson, Rob; Beginners (E-mail) Subject: RE: Image::Magic / Perl::Magick Rob, Did you have any problems installing PerlMagick? Below is the error I received. Any suggestions? Thanks again for your help. ImageMagick is now

RE: Web Application with PERL or ASP.NET

2004-08-13 Thread Hanson, Rob
I need to prove that perl is better that ASP.NET for the project. This is like comparing apples and granola bars. Perl is a language and ASP.Net is a framework. What you should really be doing is comparing Perl vs. C# (or VB.Net). ASP.Net (and /Net in general) is a powerful tool, and although

RE: splitting large xml file

2004-07-22 Thread Hanson, Rob
Ideally, I would use SAX to parse things Optionally you could look at XML::RAX. Article on the RAX concept: http://www.xml.com/pub/a/2000/04/26/rax/index.html RAX allows you to specify a record seperator (a tag in the XML file), and splits into into chunks of that tag. It is stream based so

RE: Install modules locally

2004-07-22 Thread Hanson, Rob
I don't recall that thread, but basically you can do a few things. When you install, specify some local directory to install into: perl Makefile.PL PREFIX=/some/local/path LIB=/some/local/path /some/local/path is the root of your local library. For some modules that don't require

RE: Perl and XML::Simple

2004-07-19 Thread Hanson, Rob
results id=Quiz1 file=Quiz1.pdf n=3 This isn't well-formed XML. The n=3 must be n=3. All attributes in XML must be quoted, either single-quotes or double-quotes. Rob -Original Message- From: David Arnold [mailto:[EMAIL PROTECTED] Sent: Monday, July 19, 2004 2:04 AM To: [EMAIL

RE: Another Perl datatype headache ( scalars $, hashes %, and arr ays @ )

2004-07-19 Thread Hanson, Rob
I still don't know how to declare arrays using only '$' instead of '@' You can't. But you can store a *reference* to an array in a scalar. This will work: # the backslash (\) returns a reference to the # variable, so this doesn't actually pass the array, # it passes a reference (pointer sort

RE: Use of uninitialized value in string eq

2004-07-08 Thread Hanson, Rob
Use of uninitialized value This just means that you haven't given a value to $atmnb yet (which will happen unless /^XXX/ matches in your loop). To get rid of the warning you should initialize the variable when you create it. Instead of: my $atmnb; Use this: my $atmnb = ''; Rob

RE: where to put modules?

2004-07-08 Thread Hanson, Rob
To see what directories are in your Perl's path, you can run this at the command line. It should work on Win or *nix. perl -e print join(qq[\n], @INC) You might instead want to create your own private library by setting the PERL5LIB environment variable. It will add a directory to the

RE: Query Oracle, show results (need help!!)

2004-06-08 Thread Hanson, Rob
I think you should turn on errors... by debault DBI will supress them. After the DB connection, put this... $db-{RaiseError} = 1; Once you do this you will see that your prepare failed, your SQL syntax is not valid. select * from ban where row num 100 It should be rownum, not row num. Rob

RE: how to execute make command

2004-06-03 Thread Hanson, Rob
Thre ways... exec('make'); system('make'); `make`; The three differ slightly, you might want to check the docs. Breifly... exec - executes the command, but your Perl program ends where it is. system - executes the command, waits for it to finish, returns the return code. `` (backticks) -

RE: Loading Scalar Vars with Text - Readability

2004-06-01 Thread Hanson, Rob
You could do create the string then strip the space. I think there was something in the Perl Cookbook that was similar to this. my $longlist = no_space(END_OF_LIST); Clause1| Clause2| Clause3| Clause4 END_OF_LIST print $longlist; sub no_space { my $txt =

RE: regex alternation question

2004-05-20 Thread Hanson, Rob
Would this be correct: /foo|bar/ Yes. Should they be grouped thusly: /(foo|bar)/ This works too, but has the side effect of setting $1 to the matched value, either foo or bar. What about /(?:foo|bar)/ ? This is ok too, but the parens aren't necessary. If you wanted to search for foobar

RE: Making a linker/preassembler

2004-04-15 Thread Hanson, Rob
I don't know much about asm, but maybe this will help a little. A s/// should work, and as the replacement value it can call a function to do the work. # untested $code = handle_includes($code); sub handle_includes { my $code = shift; $code = s/^\s*include\s+([\w\.]+)/include_file($1)/eg;

RE: Simple regex

2004-04-15 Thread Hanson, Rob
Try this... # untested $text =~ s/\[[^\]]+?\]/$1/g; [^\]] - means anything but a closing bracket +? - means 1 or more times (as few as possible) Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, April 15, 2004 7:11 PM To: [EMAIL PROTECTED]

RE: Regex to match domain for cookie

2004-04-15 Thread Hanson, Rob
It might be easier to do it with a split. # untested foreach (@domains) { my @parts = split(/\./, $_); my $name; if (@parts 1) { shift @parts; $name = '.' . join('.', @parts); } print $name; } As a regex, this I think will work... foreach (@domains) { my $name = $_;

RE: Nothing executes after system.

2004-03-05 Thread Hanson, Rob
Any idea why print never gets executed? The su is probably waiting for you to enter in a password. ...And this probably doesn't do what you think anyway. Even though you su, it doesn't change who the current script is running under. Your program (as written) will spawn a new process, execute

RE: Nothing executes after system.

2004-03-05 Thread Hanson, Rob
spawned and su gets executed. Is there another way os saying su using perl? Thanks. On Mar 5, 2004, at 10:26 AM, Hanson, Rob wrote: Any idea why print never gets executed? The su is probably waiting for you to enter in a password. ...And this probably doesn't do what you think anyway. Even

RE: How to capture pid

2004-03-02 Thread Hanson, Rob
I'm not sure, probably by forking and execing. It won't return the result code from the other program though. $some_process = 'tcpdump -v -ieth0 file'; my $pid = fork(); unless ($pid) { exec($some_process); die Can't start $some_process: $!; } print Pid is $pid\n; -Original

RE: Count the number of lines in a file without actually iteratin g through the file

2004-02-25 Thread Hanson, Rob
Is there a way to determine the number of lines in a file without actually iterating through the file and incrementing a file? No. I found the following on perlmonks.org, it works great but this is command line syntax When you deparse that command (see below), you can see that all it does

RE: substitution

2004-02-23 Thread Hanson, Rob
Is it possible to do this No, at least not the way you are doing it. Something like this will work (untested) my %replacements = (ARE = 756, TYP = 978, SPE = 840); $marque =~ s/(ARE|TYR|SPE)/$replacements{$1}/; Rob -Original Message- From: Olivier Wirz [mailto:[EMAIL PROTECTED] Sent:

RE: lc

2004-02-20 Thread Hanson, Rob
then I tried this: lc($input); and I got the same error. This shouldn't give an error. ...It didn't give me one. so I tried this: lc(chomp($input = STDIN))); and I got an error message that said I couldn't use lc in that way - or something like that. The exact error would be helpful.

RE: quote marks in DBM

2004-02-08 Thread Hanson, Rob
Must I abandon trying to get double-quote marks into my hash element? No, it would be silly if the language didn't support that. And I want to apologize for my long winded answer that is to follow... I guess I just felt like typing. ... As for an answer I think some explanation is needed,

RE: :Writer beginner problems

2004-02-03 Thread Hanson, Rob
?xml version=1.0 encoding=ISO-8859-1? docnumPIP 189165/docnum greeting class=simpleHello, world!/greeting ... Attempt to insert start tag after close of document element at ./test.pl line 11 A rule of XML is that there MAY ONLY BE ONE ROOT ELEMENT. You have two. You need to put docnum and

RE: Writing to file

2004-02-01 Thread Hanson, Rob
but I can not retrieve the data into $newline with join. Is this bit wrong Yes, it is a little off. $member_array[$count] This *isn't* an array, it is an *array reference* [EMAIL PROTECTED] Same with this. Join takes a list of scalars, not a list of references. So you need to dereference

RE: What is eval?

2004-01-29 Thread Hanson, Rob
It evaluates the code that you give it. It can be used when you need to create code on the fly, like this... my $cmd = 'print'; my $arg = 'Hello World'; eval($cmd '$arg'); This is useful for allowing a user to pass code to the program (for whatever reason). The other use it to trap errors. my

RE: sort

2004-01-29 Thread Hanson, Rob
I have to run, otherwise I would elaborate a bit. The code is below. Check out the perldoc perlreftut for what the [EMAIL PROTECTED], @{$row}, and $a-[2] means. Check out perldoc -f sort for what the sort {...} @rows means. And of course ask questions if you get stuck (but take a look at the

RE: Placing handmade modules

2004-01-26 Thread Hanson, Rob
my ($update_path, $gallery_title) = Test::Template::choose(); Can I assume that your module has the line package Test::Template; at the top of the file? If not, that is why. use Test::Template; This says load {lib directory}/Test/Template.pm. Test::Template::choose(); This says execute

RE: name of calling function

2004-01-19 Thread Hanson, Rob
my $caller= You are so close. my $caller = caller; Look at perldoc -f caller for more info on the different ways to use it. Please note that sometime the info you get from caller isn't the real caller. If you call your debug() function right before a return statement it is

RE: Search and replace pattern in a file

2004-01-19 Thread Hanson, Rob
I think you will like this, it does exactly whay you described... perl -pi.bak 's|ReplaceThis|WithThis|' * This does everything you want, AND makes a backup of each file. You can only perform a substitution on a single line though (AFAIK). See perldoc perlrun for all of the details. WARNING:

RE: Search and replace pattern in a file

2004-01-19 Thread Hanson, Rob
Sorry, my bad. Forgot the -e switch... perl -pi.bak -e 's|ReplaceThis|WithThis|' * Rob -Original Message- From: Hanson, Rob Sent: Monday, January 19, 2004 8:04 PM To: 'Perl'; [EMAIL PROTECTED] Subject: RE: Search and replace pattern in a file I think you will like this, it does

RE: passing arguments to functions

2004-01-19 Thread Hanson, Rob
I want to send 2 arguments to a subroutine in the form of arrays I think what you want to use are references. Check out perldoc perlreftut. # WARNING: untested code ahead my @a = `/bin/cat /some/file`; my @b = `/bin/cat /another/file`; my @result = addArray([EMAIL PROTECTED], [EMAIL

RE: for loop not ending

2004-01-19 Thread Hanson, Rob
for ($day=$keeplogs+1;$day$keeplogs;$day++) { Hmmm... lets assume $keeplogs = 60 (right?). The problem is that $day is always going to e greater than $keeplogs, because you initialized day that way. So yes, you need to set an upper bounds. Maybe this. my $max_days_old = 120; # loops from 61

RE: Hidden field on a form in perl

2003-11-21 Thread Hanson, Rob
I'll see if I can explain it gently as you seem to be a gov't worker ;) There is no perl translation... you just aren't thinking about it in a web-app type of way. The sequence would look like this... 1. display page A to user 2. user submits page A with hidden form field 3. perl script process

RE: How does perl compile functions

2003-11-20 Thread Hanson, Rob
When the actual C code (or ASM equivalent or bytecode or whatever Perl uses) for a function is run, is there overhead to the function? I'm no internals expert, but I would say yes, there is some overhead. The overhead has to deal with pushing aliases of the passed params onto the @_ array

RE: When is Perl 6 coming out?

2003-11-12 Thread Hanson, Rob
When is it coming out The usual answer is when it is done. It is far from completion, but a lot of progress has been made. My guess is beta in a year... but nobody really knows, and there is no schedule for it. The goal is to do it right, even if it means a very long development cycle. and

RE: RFC on first perl script

2003-11-06 Thread Hanson, Rob
please have a look at the code below and give comments Here are some quick comments. #1. Always use strict #2. See #1. When you use strict it foeces you to do things the right way and will help catch errors because of the extra checks it makes. So something like this: @dataFile=; # read in

RE: Where is Apache::Session

2003-10-20 Thread Hanson, Rob
On CPAN. http://search.cpan.org/~jbaker/Apache-Session-1.54/ Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, October 20, 2003 6:15 PM To: [EMAIL PROTECTED] Subject: Where is Apache::Session I'm looking for the download of Apache::Session. There

RE: quotes problem

2003-10-20 Thread Hanson, Rob
I'm not sure if John or Greg from the previous answers understand the question... or maybe it is me that is misunderstanding it. You are receiving a string from the query string that includes quotes, but it isn't printing the whole value. Correct? If that is the case, I am not sure I know where

RE: How do you find out the size of a file

2003-10-20 Thread Hanson, Rob
Try stat(). It is a built-in function. From perldoc -f stat: stat FILEHANDLE stat EXPR statReturns a 13-element list giving the status info for a file, either the file opened via FILEHANDLE, or named by EXPR. If EXPR is omitted, it stats $_. Returns a null list if

RE: malformed header

2003-10-13 Thread Hanson, Rob
The short answer... Make sure this is the first print statement: print Content-type: text/html\n\n; The long answer... CGI scripts work by passing the web server a header part and a body part. The header part must contain AT LEAST the content type of the document (e.g. text/plain, text/html,

RE: Regular Expression question

2003-10-09 Thread Hanson, Rob
Like Jeff said, you can just use \w if you are allowing numbers as well. s/([A-Za-z]_*)/\n$1/g; This will take a little bit of explaining, so bear with me. [ ... ] - Brackets represent a character class. A char class will match a SINGLE char that is inside of it. So if I wanted to match a,

RE: Chopping off firstlast character in a string

2003-10-07 Thread Hanson, Rob
You could just use a regex... $string =~ s/.//; Or even substr()... substr($string, 0, 1, ''); Both look equally efficient. Rob -Original Message- From: Li, William [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 07, 2003 12:57 PM To: [EMAIL PROTECTED] Subject: Chopping off

RE: Chopping off firstlast character in a string

2003-10-07 Thread Hanson, Rob
$string =~ s/^.(.*).$/$1/; It's prettier, but it's very inefficient. It's probably 20+ times slower then doing it in two steps. It has to do with how Perl internally handled string data. When you s/// or substr() all it does is move a pointer. With your version it would need to rewrite the

RE: initialising a list of variables

2003-10-03 Thread Hanson, Rob
It's open to user error quite easily You can also use this... my $x = my $y = ''; ...Or... my ($x, $y); $x = $y = ''; ...Or... init(my ($x,$y)); sub init { $_ = '' for (@_); } This last one uses the fact that $_ is an alias to the array item in @_, and @_ contains aliases to the

RE: explain regex statement?

2003-10-02 Thread Hanson, Rob
Close, not quite. The quantifier (i.e. ?,+,*) appear AFTER the atom (i.e. char or special symbol). The syntax is also off a bit. It should be =~ and /../ (not single ticks). $result =~ /^ *-?[0-9]+[.]?[0-9]* *\$/; ^ = beginning of line (also called an anchor) * = zero or more spaces (not

RE: explicit vs implicit syntax

2003-10-02 Thread Hanson, Rob
My preference... showargs(); Ick. I use this one when it is required (references and overriding prototypes), otherwise it isn't what I mean. If I mean to just execute the method, then I don't use it. showargs; Yuk. It saves a few keystrokes, but I tend to avoid it. showargs(); I like

RE: explicit vs implicit syntax

2003-10-02 Thread Hanson, Rob
is compiled to be the same speed. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 6:15 PM To: Hanson, Rob Cc: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax I agree it looks like the best standardized

RE: Is there a function to see if something is an element of an a rray?

2003-09-30 Thread Hanson, Rob
I don't want the IP addresses to be printed if they are not unique. Unless you need to keep the ordering of the values you should use a hash like this. my %data; for (@list_of_ip) { $data{$_} = 1; } my @unique = keys %data; Rob -Original Message- From: Dan Anderson

RE: Pattern matching username

2003-09-30 Thread Hanson, Rob
That isn't quite right, you may get better milage with this... # untested if ($z =~ /^[a-zA-Z_\-\.][\w\-\.]{2,}$/) { # is ok } else { # failed } Yours should also work, except that... 1. \s isn't needed in the first regex since a space would fail in the second regex anyway. 2. You need to

RE: building module/package

2003-09-30 Thread Hanson, Rob
Besides the advice given below, there are a few other things you can do... To add the location of the Perl script to the lib path you can use this. The FindBin module finds your script, then sets $Bin to that location. use FindBin qw($Bin); use lib $Bin; Another way to do it is to set the

RE: building module/package

2003-09-30 Thread Hanson, Rob
To: Hanson, Rob Cc: 'Perl Newbies'; [EMAIL PROTECTED] Subject: RE: building module/package my redhat 9 is configured canned w/apache and mod_perl. The only configuration I know is in /etc/httpd/conf.d/perl: Alias /mp /var/www/mp Directory /var/www/mp SetHandler perl-script PerlHandler

RE: Look At This Package

2003-09-30 Thread Hanson, Rob
#this does NOT work #how do i reference these vars USER::fname=bob; USER::lname=Bingham; You need the $, like this... $USER::fname=bob; $USER::lname=Bingham; But this may be what you really want. It will allow you to create multiple USER objects, each with different values stored in them.

RE: Look At This Package

2003-09-30 Thread Hanson, Rob
James pretty much covered everything, but here are my two coppers. First thing is that this line is wrong... my $self = { fname, lname }; It should be this... my $self = {fname = '', lname = ''}; If you had use strict or warnings on it would have yelled about that one. The way you had it, it

RE: remove blanks

2003-09-29 Thread Hanson, Rob
I ran some benchmarks. The two-liner outperformed the one-liners by a 10 to 1 ratio. Code and results below. Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines... OneLine: 41 wallclock secs (39.30 usr + 0.00 sys = 39.30 CPU) @ 2544.79/s OneLine2: 34 wallclock secs (32.58

RE: Should loops return a value?

2003-09-26 Thread Hanson, Rob
, 2003 10:18 PM To: Hanson, Rob; [EMAIL PROTECTED] Subject: RE: Should loops return a value? From: Hanson, Rob [EMAIL PROTECTED] If you really want a loop to return something, you can roll your own, even in Perl 5... but the syntax won't be as you gave. Ye - i'm not searching a way to solve

RE: How to pass parameters to a module

2003-09-26 Thread Hanson, Rob
Can someone explain how does one pass a parameter to a Perl Module? There are a few ways. #1 - On the use line use My::Module qw(foo bar); When you use a module it first loads the module and evaluates it. Second it runs the import() subroutine in the module (if there is one), passing the

RE: Basic question...

2003-09-25 Thread Hanson, Rob
I see two ways of writing this code. Hmmm, how about a third way. The following code dynamically loads a module based on the extension of the file. If it successfully loads the module it instantiates a new object and calls the handle_file() method of the object. This accomplishes a few

RE: How do ISTDIN to a stack until a pattern is matched, How do I

2003-09-25 Thread Hanson, Rob
How can I do this? You can do it like this... # tested my @stack; while (STDIN) { last if /QUIT/; push @stack, $_; } print @stack; Rob -Original Message- From: Dan Anderson [mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2003 8:23 PM To: Perl Newbies Subject: How do

RE: Should loops return a value?

2003-09-25 Thread Hanson, Rob
You want to extract numbers from an array if they are 4 and put an 'a'-letter after them. Try this... # tested @values = (1,3,5,7); @bigger_than_4 = map {$_.'a'} grep {$_4} @values; print @bigger_than_4; You need to escape a loop with a value. Not sure I understand what you are trying to

RE: How do ISTDIN to a stack until a pattern is matched, How do I

2003-09-25 Thread Hanson, Rob
[mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2003 8:40 PM To: Hanson, Rob Cc: Perl Newbies Subject: RE: How do ISTDIN to a stack until a pattern is matched, How do I First, thank you for your help. Second, please bear with me as I'm a perl noob. I assume

RE: Should loops return a value?

2003-09-25 Thread Hanson, Rob
Shortly, I think it might be good if loops (etc.) could return values. BTW - One of the goals for Perl 6 is that you will be able to build any Perl construct in Perl itself. So also although Perl5, and probably Perl6, won't let you return values from a loop, you should at least be able to

RE: Do BEGIN blocks and END blocks have priority?

2003-09-25 Thread Hanson, Rob
Will the inner BEGIN block take precedence over the outer one I dunno, but I guess I could check... print Done\n; BEGIN { print Top begin\n; } BEGIN { print Outer\n; BEGIN { print Inner\n; } } BEGIN { print Bottom begin\n; } This prints: Top begin Inner Outer Bottom begin Done

RE: Should loops return a value?

2003-09-25 Thread Hanson, Rob
[mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2003 9:36 PM To: Hanson, Rob; [EMAIL PROTECTED] Subject: RE: Should loops return a value? Rob, did You read my message at all :-) ? i just was wandering if there _could_ be more readable way to do this. Andnot only for to be readable

RE: Query string to LWP requests

2003-09-23 Thread Hanson, Rob
I wonder why GET wouldn't work? Any ideas of the reason? GET tells the receiving app to look at the query string (the part of the URL after the ?), POST tells it to look at the body content. You passed the data in the body content, NOT the query string... to the CGI module was looking in the

RE: GetOpts: boolean and argument value combos

2003-09-23 Thread Hanson, Rob
Since I want to treat -book like a boolean The problem is that you are telling Getopt::Long that book expects a string value: book=s =\$book, This is untested, but this should work. book =\$book, It sets the value of $book to 1 if the option is present. See the Getopt::Long docs, the

RE: instance variables?

2003-09-18 Thread Hanson, Rob
But I'm wondering if there is another way (like the Java private variable) to say all class variables declared here are unique to each instance? It sounds like you are trying to link how OO-Perl works with OO-Java... and that is only going to make your head spin. What you really need to do

RE: Conceptual -- Spam stopper script

2003-09-16 Thread Hanson, Rob
You will probably run into a few issues. First you need to fetch the MX record for the domain before you can even connect. After that you could use the SMTP verify user command to see if the user exists, but I think you might find that many SMTP servers will not give you a reliable answer. I

RE: load apache perl on a CD to run HTML documents?

2003-09-15 Thread Hanson, Rob
You will still need a webserver. Check out microweb, it does exactly what you need. I never tried it though, so I can't say if it is any good. http://www.indigostar.com/microweb.htm Rob -Original Message- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED] Sent: Monday, September 15, 2003

RE: :Mechanize -links() problem

2003-09-11 Thread Hanson, Rob
Each link returned is a WWW::Mechanize::Link object. You need to use the methods supplied to get the info. See: http://search.cpan.org/~petdance/WWW-Mechanize-0.59/lib/WWW/Mechanize/Link.p m Use it like this... @LINKS = $agent-links(); foreach (@LINKS) { print $_-url(), \n; print

RE: Module install

2003-09-10 Thread Hanson, Rob
Sure. Use this when running Makefile.PL. perl Makefile.PL LIB=~/myhomelib PREFIX=~/myhomelib This will install the modules to ~/myhomelib. To use the modules in a script you can either use lib '/myhomepath/myhomelib' (note the full path, no ~). Or you can set the environment var PERL5LIB to

RE: Modules Question

2003-09-10 Thread Hanson, Rob
I googles Julian and came up with two email addresses from this page: http://www.monkey.org/openbsd/archive/misc/9904/msg00077.html If that fails I'm not sure. The FAQ on CPAN doesn't help much with this specific case since the mails are bouncing:

RE: accessing a hash map...

2003-09-09 Thread Hanson, Rob
You have it slightly wrong... print $hashref{'disks'}-{'io'}; ...And the quotes are optional (usually)... print $hashref{disks}-{io}; Is there a more generic mailing list for the different perl modules? Thare are other lists/newsgroups, but most are geared to specific port (ActiveState), or

RE: perl error

2003-09-09 Thread Hanson, Rob
I have no hard answers, but here are some suggestions from my admin... I'd look to see which DBD connector he's trying to use. He's also using a multi-threaded perl which I believe is buggy under Solaris -- especially perl 5.6. I'd try re-compiling perl 5.8 and check that the DBD modules are

RE: authenticate module

2003-09-08 Thread Hanson, Rob
No extra module is needed. WWW::Mechanize is a subclass of LWP::UserAgent, which supports it. my $ua = new WWW::Mechanize(); $ua-credentials('www.myhostname.com:80', 'RealmName', 'user', 'pass'); $ua-get('http://www.myhostname.com'); print $ua-content; The params are host/port, realm,

RE: REPOST - print c:\program files\*.*;

2003-09-05 Thread Hanson, Rob
Windows is a little weird here because of the way long filenames are supported. You need to use the short name of the directory, which is the first 6 letters - a tilda - and a number (always 1, unless there multiple files with the same first 6 chars). This works for me: print c:/progra~1/*.*;

RE: REPOST - print c:\program files\*.*;

2003-09-05 Thread Hanson, Rob
This also works and is more portable... my $dir = 'C:/Program Files'; opendir DIR, $dir; print map {$dir/$_} grep {/.+\..+/} readdir(DIR); closedir DIR; Rob -Original Message- From: Hanson, Rob Sent: Friday, September 05, 2003 8:38 PM To: [EMAIL PROTECTED] Subject: RE: REPOST - print

RE: Stripping HTML from a text file.

2003-09-04 Thread Hanson, Rob
A simple regex will do the trick... # untested $text = ...; $text =~ s|head.*?/head||s; Or something more generic... # untested $tag = head; $text =~ s|$tag[^]*?.*?/$tag||s; This second one also allows for possible attributes in the start tag. You may need more than this if the HTML isn't

RE: Stripping HTML from a text file.

2003-09-04 Thread Hanson, Rob
with questions. There are also the base modules such as HTML::Parser, etc. that the one previously mentioned builds on, among others check CPAN. http://danconia.org Hanson, Rob wrote: A simple regex will do the trick... # untested $text = ...; $text =~ s|head.*?/head||s; Or something more

RE: WWW::Mechanize and Cookies

2003-09-04 Thread Hanson, Rob
mod_perl isn't a language, it is an application server. If the question is Is it mod_perl safe?, then that is a different question. I would think they are, both are OOP, and there is no state that I am aware of that is outside of the object properties. Rob -Original Message- From: rkl

RE: problems with installing CPAN modules

2003-09-02 Thread Hanson, Rob
If you are on Windows with AS-Perl, you should use there version of ReadKey. I might be wrong, but I think that module includes some C code. So unless you have C++ and compiled Perl yourself, you want to use the AS version of the module, which will be pre-compiled for you. The AS module list for

RE: base domain parsing www.mydomain.com

2003-09-02 Thread Hanson, Rob
Something like this should work... my $domain = 'www.station.fire.org'; if ($domain =~ /([^\.]+\.[^\.]+)$/) { print $1\n; } else { print Failed to find domain\n; } This is very lenient in the matching, so it should match all valid domain names as well as a lot of invalid ones. If there

RE: exact string match?

2003-09-02 Thread Hanson, Rob
Use eq (as well as lt, gt, ne, ge, le, cmp) for string matching. The operators == (as well as , , !=, =, =, =) for numeric matching. Perl will convert the values based on the operator used. So with ==, like you are using, Perl converts both arguments to numbers before comparing. So this is what

RE: :Mechanize and Cookies

2003-09-02 Thread Hanson, Rob
I run into this a lot. There is JavaScript in the page, and you need to emulate that in your script. Look at the source HTML for the page. It takes the password and look like it Base 64 encodes the password, then sets a hidden form field named encoded_pw to the value. It then clears the

RE: system call

2003-08-29 Thread Hanson, Rob
Use backticks. $result = `some command`; system() on the other hand returns the exit status code. $exit_code = system('some command'); ...Or... if (system('some command') != 0) { print Failed!; } Rob -Original Message- From: Imtiaz Ahmad [mailto:[EMAIL PROTECTED] Sent: Thursday,

RE: how to return all rows selected in subroutine?

2003-08-29 Thread Hanson, Rob
I'll skip over most of your mail, and go right to the heart of the matter... I am trying to return an array of all records in the subroutine below. # # ...WARNING: UNTESTED CODE AHEAD... # sub getcols { # I prefer this over the ($table) syntax... # but it has the same end result my

RE: Managing Pictures with Perl

2003-08-29 Thread Hanson, Rob
What is the best library to handle pictures? Image::Magick is a great tool for creating thumbnails, it is both easy and the shrunk images still look good. http://search.cpan.org/author/JCRISTY/PerlMagick-5.57/Magick.pm If you are running the ActiveState version of Perl, be sure to get it from

RE: grep with ftp

2003-08-28 Thread Hanson, Rob
Is this possible? I'm no expert of FTP software, so I can't say if that is generally possible, but it will depend on what the FTP server software allows you to do. So I would start there, find out what software they are running, then find some documentation on it. Rob -Original

RE: How to cate DBI error and pass the control to subroutine?

2003-08-27 Thread Hanson, Rob
Take a look at the Error module (although you can use eval as well). use DBI; use Error qw(:try); my $dbh = DBI-connect(...); $dbh-{RaiseError} = 1; try { $dbh-do(insert ...); } catch Error with { print STDERR Insert failed!; } $dbh-do(update ...); ...Or if you only want to update when

RE: Simulating VB Enum

2003-08-27 Thread Hanson, Rob
Remember these 3 words... search.cpan.org ;) http://search.cpan.org/search?query=enummode=all CPAN is always the best place to start looking for code. On the results page is looks like enum will do what you need. Rob -Original Message- From: Harter, Douglas [mailto:[EMAIL PROTECTED]

RE: Length() is bits/bytes or neither

2003-08-26 Thread Hanson, Rob
length() returns the length in characters, which for ASCII is also the number of bytes. To get the bits, just multiply by 8. If you are using a Unicode character set instead, I'm not too sure what will be returned, or how you can convert it to bits. Rob -Original Message- From: Dan

RE: Perl Codes Written in Windows Env

2003-08-25 Thread Hanson, Rob
If you ftp them in binary mode instead of ascii mode yes that will screw it up. I wanted to elaborate on this since this is a common issue for the unknowing. When you tell FTP to use binary mode it doesn't modify the file, it just copies it byte by byte. If you tell it to use ascii mode, then

RE: FILEHANDLE to print to nothing

2003-08-25 Thread Hanson, Rob
Sure, just use this without an open or close statement... print VOID 'test'; I'm not exactly sure how Perl handles this, but since there is no filehandle called VOID is just goes away. I wouldn't leave this in there when it goes into production, but it shouldn't cause any problems during

  1   2   >