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, bu

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 pat

RE: Image::Magic / Perl::Magick

2004-08-25 Thread Hanson, Rob
e). Rob -Original Message- From: Brian Volk [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 suggest

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: 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: 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 pre-process

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 i

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 sor

RE: Perl and XML::Simple

2004-07-19 Thread Hanson, Rob
> 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 PROTECTED] Subject: Perl and XML::Simple

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 begi

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 -Origi

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".

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) - execut

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(

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

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: 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] Subject:

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; r

RE: Nothing executes after system.

2004-03-05 Thread Hanson, Rob
, since another process gets 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. >

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: 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 Mess

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 d

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] Se

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 = ))); > 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: :Writer beginner problems

2004-02-03 Thread Hanson, Rob
> > PIP 189165 > Hello, world! > ... > 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 and inside a single element. The following would be well-formed XML. PIP 1891

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 dereferen

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 l

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. m

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 "ex

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 6

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 PROTEC

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 wil

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: M

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 pos

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. > an

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=<>; #

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 i

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/ht

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 first&last 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 w

RE: Chopping off first&last 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 first&la

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 variabl

RE: explicit vs implicit syntax

2003-10-02 Thread Hanson, Rob
imized when the code 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

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 lik

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 (no

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,

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

RE: building module/package

2003-09-30 Thread Hanson, Rob
eptember 30, 2003 3:12 PM 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 SetHandler perl-script

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 enviro

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 s

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 [mailto:[E

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 us

RE: remove blanks

2003-09-29 Thread Hanson, Rob
That is what you want to use. You could do it in a single regex: ## NOT RECOMMENDED - SEE NOTE BELOW ## $username =~ s/^\s+|\s+$//g; The downside is that this is not efficient and actually takes Perl longer to perform the operation. If you want to know why you need to know a little about how Per

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: Should loops return a value?

2003-09-26 Thread Hanson, Rob
[mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 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...

RE: Should loops return a value?

2003-09-25 Thread Hanson, Rob
return @ret; } Rob -Original Message- From: Ville Jungman [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

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 be

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 bui

RE: How do I 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 I 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 that $_ is the l

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 tryin

RE: How do I 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 () { 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 I to a

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 things

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

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: 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

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 thi

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 $_->te

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: http://www.cpan.org/misc/cpan-faq.html#How_mainta

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: 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 ins

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, userna

RE: using subroutine from another file

2003-09-08 Thread Hanson, Rob
Try this... require 'code1.pl'; call_your_sub(); This will also execute the code in code1.pl (if there is anything outside of a sub block), which may not be what you want. Rob -Original Message- From: Ling F. Zhang [mailto:[EMAIL PROTECTED] Sent: Monday, September 08, 2003 8:33 PM To:

RE: REPOST - print ;

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]

RE: REPOST - print ;

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 ; Rob -Origina

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: :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 passw

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 t

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 th

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: 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: 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 $t

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: 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 Message---

RE: Simulating VB Enum

2003-08-27 Thread Hanson, Rob
Remember these 3 words... search.cpan.org ;) http://search.cpan.org/search?query=enum&mode=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: 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 upda

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 Muey

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 testing

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,

RE: Spreadsheet::WriteExcel Column width

2003-08-21 Thread Hanson, Rob
> Its still to short. >From the WriteExcel docs: "The width corresponds to the column width value that is specified in Excel. It is approximately equal to the length of a string in the default font of Arial 10." So if you are using a different font or different size it could be way off. You just

RE: Split on white space from `command` return?

2003-08-21 Thread Hanson, Rob
I'm not well versed in awk, but you could use cut instead... command | grep bf1 | cut -d ' ' -f 1 ...Or just use Perl # untested my @var = map {/^\w+/;$&} grep {/bf1/} `command`; > on the command line I get exactly what I > need, why doesn't this work during an > external call? Hmmm... my gues

RE: unexpected runtime error

2003-08-19 Thread Hanson, Rob
> $addr4=$abbrevs{$addr4} if (defined $abbrevs{$addr4}); I think you might want to use "exists" instead of "defined" in this case, or maybe both depending on what you are trying to do. $addr4=$abbrevs{$addr4} if (exists $abbrevs{$addr4} and defined $abbrevs{$addr4}); Rob -Original Message

RE: Variable instaed of GLOB REF

2003-08-18 Thread Hanson, Rob
There are ways to fake a filehandle by tieing it to a module, but that is a bit cumbersome. Looking at the Mail::Internet docs it seems that you can pass it an array reference instead of a filehandle ref. Try this, I think it will work... my $mio = Mail::Internet([$data]); Rob -Original M

RE: Input Regex (error checking)

2003-08-18 Thread Hanson, Rob
chomp (my $ans=); $ans =~ /^\d{6}$/ or die "Bad input!"; # ...or... unless ($ans =~ /^\d{6}$/) { # blah, blah, blah } # Or loop until correct input received... my $ans = undef; do { print "Invalid response\n" if defined $ans; print "Enter your answer: "; chomp($ans = ); } while $

RE: Split NewLines

2003-08-18 Thread Hanson, Rob
Like this... $string="1 blabla"; my @lines = split("\n", $string); # testing... print "1: $lines[0]\n"; print "2: $lines[1]\n"; See perldoc -f split if you want more info on the command. Rob -Original Message- From: Pablo Fischer [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003

RE: need help decompose word

2003-08-18 Thread Hanson, Rob
Just to throw out another idea, you can also do this... my $name = "Anthony Bob"; my @letters = grep {!/\s/} split('', $name); # to test print "@letters"; It also looks like you wanted upper case. You can do that with this... my $name = "Anthony Bob"; my @letters = grep {!/\s/} split('', uc($n

RE: Day of the week

2003-08-18 Thread Hanson, Rob
Time::Local, and the internal localtime(). use Time::Local; my @days = qw(Sun Mon Tue Wed Thu Fri Sat); my $time = timelocal(0,0,0,23,4,103); my @parts = localtime($time); print "$days[$parts[6]]\n"; Rob -Original Message- From: Nigel Peck - MIS Web Design [mailto:[EMAIL PROTECTED] Se

RE: Hash of Hash

2003-08-18 Thread Hanson, Rob
I think you mean this... use strict; my %thief_opt; my @name = ("one", "two", "three"); foreach my $layer (@name) { $thief_opt{$layer} = { type => "solid", origin => "datum", use_arcs => "yes", }; } # test with this. prints out structure to console. use Data::Dumper; pri

RE: Simple question

2003-08-14 Thread Hanson, Rob
This seems to work... use strict; # two lists for the comparison my @orders = (1,5,7,9,3,1,55,23); my @stash = (4,12,8,0,2,7,9,3,4,13); # hash of unique numbers my %join; # add all of the numbers from both lists to %join. # turn on the 1 "bit" for @orders, and "2" for @stash. # this will give n

  1   2   3   4   >