RE: PPM3 - libwww-perl

2002-07-03 Thread Hanson, Robert
I didn't see any libwww on their site... are you sure that they have it for download? ActiveState only has a limited module repository. http://www.activestate.com/PPMPackages/5.6plus/ Rob -Original Message- From: Nigel Peck [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 03, 2002 5:54

RE: debug function for use?

2002-07-02 Thread Hanson, Robert
I'm a debugger newbie, so I'm not sure what "x" does... but "pretty-printing" can be done with Data::Dumper. use Data::Dumper; my %hash = ( foo => 1, bar => [1,2,3,4], baz => {a => 1, b => 2} ); print Dumper \%hash The output of Dumper will be nicely formatted Perl code to recreate the data str

RE: Beginner with a somewhat advanced question.....

2002-07-02 Thread Hanson, Robert
The script looks ok to me, so you might need to debug the input values and the data it is drawing from. This is probably where the problem is: $sql = "select * from product,order_line where prod_num = product_id and order_num = $order_id"; If you can, print the value of $sql and then run the qu

RE: URGENT. Re: multi-line regex question, please help!

2002-07-02 Thread Hanson, Robert
> ...how to execute a ***multi-line*** match. > $_ =~ s/^(M\d+)\n^(.*)/A $1\nB $2/mi; > ...i am trying to match the first line, beginning > with M followed by consecutive digists... You are confused about what a "multi-line" match is. A "multi-line" match will attempt a match on ONE line at a ti

RE: Object-Oriented DBMS

2002-07-02 Thread Hanson, Robert
The Perl Journal had a nice article on an OODBMS engine used by the Human Genome project called "Ace". It's free and has a Perl interface. http://www.samag.com/documents/s=1290/sam04010004/ Rob -Original Message- From: anthony [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 30, 2002 1:36

RE: Saving in RTF

2002-06-27 Thread Hanson, Robert
RTF is just plan text with a lot of markup, it isn't a binary file like a Word doc. You should be able to just drop it into a "text" (or is it called "memo" in MySQL?) field. Rob -Original Message- From: João Paulo [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 12:41 PM To: [E

RE: Regex question again

2002-06-27 Thread Hanson, Robert
> But how do I let it make : > $dir = "/IPlib/and/many/other/dirs"; ## But now on the first dir $dir =~ s!^[^/]*!!; ^ = Beginning of the string. Rob -Original Message- From: David vd Geer Inhuur tbv IPlib [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 11:15 AM To: [EMAIL PRO

RE: Perl Win32 Application.

2002-06-27 Thread Hanson, Robert
wxPerl looked pretty good, but I never did more than just play around with it. The thing I like it that it will use the builtin Windows widgets, so it looks like an ordinary windows app (Win32::GUI will as well). Here is an article on it, decide for yourself. http://www.perl.com/pub/a/2001/09/1

RE: getting data from one table, putting it into another...

2002-06-26 Thread Hanson, Robert
Always use placeholders, this should help... my @abfrage = $sth->fetchrow_array; # build placeholders based on num of fields my $placeholders; $placeholders .= ($placeholders ? ",?" : "?") for (@abfrage); my $sth2 = $dbh->prepare("INSERT INTO board $placeholders"); $sth->execute(@abfrage); The

RE: CPAN Modules

2002-06-26 Thread Hanson, Robert
The biggest reason (for me) is that you want the module to test itself. It will also inform you if you don't have all of the prerequisite modules. Besides that, it's easier than copying it once you get used to it, and don't forget that copying won't autosplit the module if that is what the author

RE: Pattern Matching

2002-06-25 Thread Hanson, Robert
This will work... /\[.*?\]/ The ".*?" means "match any character any number of times... BUT be non-greedy about it". The "?" is what makes it non-greedy, and that means it will attempt to match as few characters as possible. ...So in essence this says "match an open bracket up to the first clo

RE: parsing a variable

2002-06-14 Thread Hanson, Robert
How about this? # untested my @mac = map {/((?:[a-fA-F0-9]{4}\.){2}[a-fA-F0-9]{4})/ and $1} ( @offline ); Rob -Original Message- From: Tucker, Ernie [mailto:[EMAIL PROTECTED]] Sent: Friday, June 14, 2002 11:37 AM To: Hanson, Robert; Tucker, Ernie; [EMAIL PROTECTED] Subject: RE: parsing

RE: parsing a variable

2002-06-14 Thread Hanson, Robert
Here is one solution... For each item in @offline the MAC will be captured in the variable $1. # untested... for ( @offline ) { if ( /((?:[a-fA-F0-9]{4}\.){2}[a-fA-F0-9]{4})/ ) { print "MAC: $1\n"; } else { print "No MAC here\n"; } } Rob -Original Message- From: Tucker

RE: RegEx to match Valid IP Address

2002-06-14 Thread Hanson, Robert
You could either roll your own or use Regexp::Common. http://www.cpan.org/modules/by-module/Regexp/Regexp-Common-0.01.readme It might look like this... (?:[1]?\d{1,2}|2[0-4]\d|25[0-5]\.){3}[1]?\d{1,2}|2[0-4]\d|25[0-5] Or something like that. Rob -Original Message- From: Tim Muss

RE: Using ARGV

2002-06-12 Thread Hanson, Robert
@ARGV contains all of the arguments passed, and you only want to print the first, so you need to specify that. $test = "$2 $ARGV[0]"; # 0 is the first element Rob -Original Message- From: phumes1 [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 9:49 AM To: [EMAIL PROTECTED] Sub

RE: Spaces...

2002-06-10 Thread Hanson, Robert
Try /\s+/ >From the perlre manpage: \s Match a whitespace character + Match 1 or more times Rob -Original Message- From: Fontenot, Paul [mailto:[EMAIL PROTECTED]] Sent: Monday, June 10, 2002 1:02 PM To: Perl - Beginners (E-mail) Subject: Spaces... I have a logfile that has the fo

RE: regex

2002-06-07 Thread Hanson, Robert
I think what you want is [^']* , meaning "anything except single quote = zero or more times". Like this... my $line = "'here is a quote'. Autor (birth year - death year); occupation nationality."; $line =~ /'([^']*)'/; print $1; Rob -Original Message- From: Eduardo Cancino [mailto:[EMA

RE: :CSV

2002-06-07 Thread Hanson, Robert
As an alternative you could use Text::CSV to split the fields. Rob -Original Message- From: Jason Frisvold [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 9:36 AM To: Beginners@Perl. Org (E-mail) Subject: DBD::CSV Is anyone here familiar with DBD::CSV? I seem to be hitting a li

RE: debugging statements and such

2002-06-07 Thread Hanson, Robert
Well you could toy around with source filters. A source filter allows you to manipulate your code after it is read into memory but before it is executed. Here is a good article on it, and even has an example of handling debug output. http://www.samag.com/documents/s=1287/sam03030004/ You could

RE: Regex Problem - please help

2002-06-05 Thread Hanson, Robert
Here is my solution, others will differ... # always print $! on error so you can see the cause open( INFILE,"books.txt" ) || die "Cann't Open: $!"; while( ) { chomp; # remove the newline next unless ($_); # skip blank lines # split the line by the seperator my @

RE: Day Month Issues

2002-06-03 Thread Hanson, Robert
You are running with warnings turned on, and Perl is just warning you that you *might* have made a mistake by creating a variable then not using it. In this case it isn't a mistake, but it will still warn you about it. Snippet from perldoc perlrun -w prints warnings about variable names

RE: Storing variable names in strings

2002-06-03 Thread Hanson, Robert
I think the general answer you will get is "don't do it that way" for various reasons. It is only ever a good idea if there are absolutely no alternatives, and even then you should always rethink doing it that way. This code will do exactly the same thing except it uses keys in a hash to give yo

RE: Reverse sort?

2002-05-21 Thread Hanson, Robert
To expand on that, the "<=>" operator is for numeric comparisons and "cmp" are for string comparisons... make sure you use the right one. This may also work for what you need... @items = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); @sortedItems = reverse( sort(@items) ); Rob -O

RE: simple array question

2002-05-21 Thread Hanson, Robert
Sure. @main = (@data1, @data2, @data3); Rob -Original Message- From: A Taylor [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 21, 2002 10:05 AM To: [EMAIL PROTECTED] Subject: simple array question Hi all, I have a very simple and probably stupid question to ask. If I have a set of array

RE: Pattern Matching...again...

2002-05-20 Thread Hanson, Robert
A few things... If ($var1 =~ /\b$var2?\b/I) { ^^ it should be "if" not "If" If ($var1 =~ /\b$var2?\b/I) { ^ The switch is "i" not "I" Print "cannot contain that word.\n"; ^ the "p" in print is lower case (are you using Win32::ASP?) if ($var1 =~ /\b$var2?\b/i) {

RE: Calling subroutines...

2002-05-20 Thread Hanson, Robert
There are lots of ways to do this, but this is an easy one to understand... Calling_sub($var1, $var2); sub Calling_sub { my ($subvar1, $subvar2) = @_; print $subvar1; print $subvar2; } Explaination - When you call a sub the parameters are passed via a special array named @_. Perl puts

RE: Perldoc

2002-05-16 Thread Hanson, Robert
The "perldoc" manpage is about the perldoc utility... "perlpod" talks about the Plain Old Documentation (pod) format. So I think "perldoc perlpod" is what you are looking for. Rob -Original Message- From: Jackson, Harry [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 16, 2002 9:48 AM To

RE: Help with my first package??

2002-05-15 Thread Hanson, Robert
What is the error? Rob -Original Message- From: Miretsky, Anya [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 15, 2002 4:16 PM To: '[EMAIL PROTECTED]' Subject: Help with my first package?? I am trying to write a package that will execute a sql statement for me in my cgi pages, the fol

RE: Books

2002-05-14 Thread Hanson, Robert
If you are still learning, the second edition is sufficient as a resource, although the 3rd edition is a better read (IMO). As far as what has changed from then to now, it really isn't anything that would be covered in Learning Perl anyway. Perl 5 is basically Perl 5, especially when it comes to

RE: 'my' variables

2002-05-14 Thread Hanson, Robert
> what about variables used just within the function Unless there is a good reason for it, all variables inside a function should be declared inside of the function by using 'my'. ...If you can't think of a good reason not to use 'my', then you should use it. > What do you mean 'pass by global

RE: Different ways of declaring variables

2002-05-13 Thread Hanson, Robert
To add what Chas mentioned, it also changes the context of the expression. One good example is the localtime() function. In "scalar" context it returns a date string, and in "list" context it returns a list of the date parts. When you use the parens on the left side of the assignment you are fo

RE: apache::session

2002-05-09 Thread Hanson, Robert
The short version... 1. get the cookie from the user (using CGI.pm or other mod). 2. tie hash to Apache::Session passing a database handle and the cookie val. 3. set or refresh the cookie with the session ID (from Apache::Session). 4. store and fetch to the tied hash. Rob -Original Message-

RE: @INC

2002-05-06 Thread Hanson, Robert
There are a few ways listed in the FAQ's. "perldoc -q " will search the FAQ's on a specific word. Below is what was found when I searched on the word "library". Depending on your needs using the PERL5LIB environment variable might be the best option (Just create a new environment variable in Wi

RE: simple problem

2002-04-29 Thread Hanson, Robert
> if ( $tablename > 1){ Why would $tablename be a number? Is this really what you want? Maybe you really wanted to check the length? if ( length($tablename) > 1 ) Or a little better if ( length($tablename) ) Or better yet if ( $tablename ) Rob -Original Message- From: Sun

RE: RegEx question

2002-04-23 Thread Hanson, Robert
tr/// "translates" from one character to another. So fo each "+" it finds it "translates" it to a space. The purpose of tr/// is to be able to give it one or more characters in the left part of the match and one or more characters on the right side, and it will translate each char on the left to

RE: variable interpolation

2002-04-19 Thread Hanson, Robert
I prefer using a placeholder, you don't need to quote anything that way which avoids mistakes. my $sth = $dbh->prepare('SELECT something FROM some_table WHERE some_key = ?'); $sth->execute( CGI->param('NAME') ); Did you also print out the variable to prove that it does indeed contain some data?

RE: How to test if a module is installed ?

2002-04-19 Thread Hanson, Robert
Something like this should work... if ( eval "require Image::Size" ) { Image::Size->import(); print "The module is installed!"; } else { print "It's not installed!"; } Rob -Original Message- From: Dennis Senftleben [mailto:[EMAIL PROTECTED]] Sent: Friday, April 1

RE: extra space

2002-04-10 Thread Hanson, Robert
> I can't figure out what this is doing... > my @sorted = map { $_->[2] } > sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } > map { [ (split /\t/)[3,2], $_ ] } > @lines; Hmmm... let's see. > @lines; 1. Iterate over @lines > map { [ (split /\t/)[3,2]

RE: why wont html templates work with perl ???

2002-04-10 Thread Hanson, Robert
It probably means that they don't have it installed. You can create your own library directory by putting the files in a directory and adding that directory to your library path (i.e. @INC). See the lib pragma docs on how to add a library path. http://www.perldoc.com/perl5.6.1/lib/lib.html Rob

RE: Search & Replace Issue

2002-04-09 Thread Hanson, Robert
I'm sure that this can be done is less steps, but it works... #!/usr/bin/perl -w use strict; my $line = " stuff\n"; print chgSpace($line); sub chgSpace { my $line = shift; my ( $spaces ) = $line =~ /^(\s+)/; $spaces =~ s/ /_/g; $line =~ s/^\s+/$spaces/; return $line; }

RE: Perl 6?

2002-04-03 Thread Hanson, Robert
Here is the dev site. http://dev.perl.org/perl6/ The Apocalypses are written by Larry Wall and describe the way things will work in Perl 6, the Exegeses are written by Damian Conway where he gives examples of what Larry is taking about. The RFC's are proposed changes submitted by the Perl commu

RE: Newbie reference question

2002-03-25 Thread Hanson, Robert
> Is this the best way to make two dimentional arrays... > ...and then I can reference it @{@y[$i]}[$j}; That is a little icky. You can access individual elements like this: $y[0]->[1] Or $y[0][1] > I was wondering if I can construct the array without a variable x. > I tried: > push(@y, \f

RE: How I can do logout?

2002-03-25 Thread Hanson, Robert
There's a lot more to it than that, there is no real concept of "connected" when you talk about Web apps and HTTP. In *general* a browser will connect to a web server, grab a single page (or image), then disconnect. When the user clicks a link it connects again, gets the one page, and disconnect

RE: arithmetic operators

2002-03-25 Thread Hanson, Robert
Look at CGI.pm for grabbing form data... use CGI qw/:standard/; my $diff = param('val1') - param('val2'); Rob -Original Message- From: Matthew Harrison [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 9:20 AM To: [EMAIL PROTECTED] Subject: arithmetic operators in short, how ca

RE: DBI really quick question

2002-03-19 Thread Hanson, Robert
"How do I CREATE a database from within perl with MySQL?" I don't think you can... but you can run the mysql interface from the script. Actually I think that you can pipe a list of commands to mysql. Rob -Original Message- From: James Taylor [mailto:[EMAIL PROTECTED]] Sent: Tuesday, M

RE: time calculation

2002-03-19 Thread Hanson, Robert
Like Timothy said, you didn't give enough info. Check out the perldoc for localtime first to see if that solves your problem, and if not please post a code example. You can get the localtime docs by either typing the following from the command like or navigating to the perlfunc manpage in your H

RE: Perl Modules

2002-03-19 Thread Hanson, Robert
You installed it wrong. First of all the module is Net::Telnet, so it needs to be in the Net/ subdirectory, like this... /usr/perl5/5.00503/sun4-solaris/Net Second, some modules (not all) need to be compiled or have some other things that need to be done during the installation. So if copying

RE: regular expressions in rindex function

2002-03-18 Thread Hanson, Robert
You can remove the whitespace at the end of a line with this regex... $text =~ s/\s+$//; It matches one or more whitespace chars at the end of the line and replaces them with nothing. Rob -Original Message- From: Richard Pfeiffer [mailto:[EMAIL PROTECTED]] Sent: Monday, March 18, 2002

RE: LWP binary file retrievals?

2002-03-18 Thread Hanson, Robert
The problem might be that the getstore() expects character data, I'm not sure. What you can do is store it yourself, and force binary mode for the filehandle. #!/usr/gin/perl -w use strict; use LWP::Simple; # untested my $bin_data = get ('http://www.netcdf_url'); open OUT, '> filename'; binmod

RE: printf and archive questions

2002-03-15 Thread Hanson, Robert
I don't know of a searchable archive. To format the number you can either roll your own, grab the solution in the Perl Cookbook, or use Number::Format. http://search.cpan.org/search?mode=module&query=Number%3A%3AFormat use Number::Format; my $commaNum = new Number::Format(-thousands_sep => '.

RE: session id

2002-03-12 Thread Hanson, Robert
I usually use Session::Apache for that. It will allow for the creation of session ID's, storing data, and retreival of data. You will need to set up a table in a database, and then put some code in each page to fetch the session ID from the querystring or cookie so that it can initialize the ses

RE: Perldoc question

2002-03-12 Thread Hanson, Robert
perldoc isn't in your path most likely. Check your path environment variable (echo $PATH), and make sure that perldoc is in one of those directories. If I had to guess you probably have a symlink to the perl executable in your path, but not the actual bin/ directory of perl. Rob -Original

RE: Regex Help

2002-03-12 Thread Hanson, Robert
Maybe something like this: @line = split /:/, $theLineOfData; @line = map { s/^'(.*)'$/$1/ } (@line); # removes the ticks And to match the whole word: if ( $field =~ /\bBRANCH\b/ ) { # matches word boundary } Or you could remove the whitespace as well to simply things... @line = split

RE: How long can $_ be?

2002-03-12 Thread Hanson, Robert
There is no limit on the length of a scalar in Perl other than the amount of memory you have. It is possible that it is splitting the newline because you are using a multi-byte character set, or the global variable $/ (input record seperator) was changed in the script, or you are working with bin

RE: days calculation

2002-03-11 Thread Hanson, Robert
Even easier is to use Date::Parse. use Date::Parse; $var1 = '2002-02-01'; $var2 = '2002-02-28'; print abs( str2time($var1) - str2time($var2) ) / 86400; Rob -Original Message- From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 4:19 PM To: '[EMAIL PROTECTED]' Su

RE: days calculation

2002-03-11 Thread Hanson, Robert
I only tested it real quick, but it seems ok. I would test it a little more though, and maybe add some error checking. use Time::Local; $var1 = '2002-02-01'; $var2 = '2002-02-28'; print daysDiff($var1, $var2); sub daysDiff { $d1 = dateToTime($_[0]); $d2 = dateToTime($_[1]); return abs(

RE: Newbie Question

2002-03-11 Thread Hanson, Robert
Some versions of PPM had some problems, and your config file might have been messed up. I haven't seen this problem lately, but I have had it happen to myself a while ago. There should be a file called ppm.xml in your Perl library. You will need to check it out, and see if it is still a well-fo

RE: Browser navigation with cgi

2002-03-11 Thread Hanson, Robert
You can't do that server side, you would need to use client side JavaScript in the page to do that. What it sounds like though it that you have a user filling in a form, and if there is a problem with it you want to send them to the form again, right? If so, what you want to do is show them

RE: Assigning part of a string to a variable using the filehandle.

2002-03-11 Thread Hanson, Robert
I think you want something like this (or some derivation)... while () { if( /DisplayName(.*)/ ) { print $_; # print the full line $mytext = $1; # assign trapped text } } Rob -Original Message- From: Allison Ogle [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 2:29 PM

RE: command line arguments

2002-03-06 Thread Hanson, Robert
--Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 5:08 PM To: Hanson, Robert; Nikola Janceski; Beginners (E-mail) Subject: RE: command line arguments I was hoping for some way to capture it in perl instead with out having to change the co

RE: command line arguments

2002-03-06 Thread Hanson, Robert
You should be able to just escape the *. Single quoting them should also work. script.pl file\* names\* script.pl 'file*' 'names*' Rob -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 5:03 PM To: Beginners (E-mail) Subject: command lin

RE: unusual character splitting

2002-03-06 Thread Hanson, Robert
"perldoc perllocale" has a lot of info and explains everything. It depends on a lot of things including your OS, and how it is setup. (at least that is what it says, I don't know enough about it to refute it) Rob -Original Message- From: Chris Ball [mailto:[EMAIL PROTECTED]] Sent: Wedne

RE: finding example scripts

2002-03-05 Thread Hanson, Robert
I think it is unlikely that you will find any samples on the web like this (but ya never know). Frankly though it sounds like a simple problem, maybe less than 10 lines of code depending on the complexity. You might want to look at the docs for File::Find and File::Copy to get some ideas. http:

RE: Simple question need ans

2002-03-04 Thread Hanson, Robert
As usual there are many ways to do it. I haven't done much with opening files for read and write at the same time, so someone else will have to provide ideas for that. I would either read in the whole file, then rewrite the whole file... or use DBI (assuming the file is CSV). If you read in the

RE: appending to rows

2002-03-01 Thread Hanson, Robert
I would use the second approach. I would think that it would be better performance-wise, not to mention I always like to have a backup in case things don't work the way I expected. Alother thing you have to try to do is only read in as much data at one time as you need to, because a million rows

RE: Dereferencing a referenced hash.

2002-02-28 Thread Hanson, Robert
The trick is to use {$ref} where you would normally put the variable name: So $array[0] becomes ${$ref}[0] (not @$ref[0] which is a "slice"). And $hash{key} becomes ${ref}{key}. Or you can use the little arrow syntax... ${$ref}[0] is the same as $ref->[0]. And ${$ref}{key} is the same as $ref->

RE: Checking Perl load

2002-02-15 Thread Hanson, Robert
Then how about "dir /s perl.exe"? Rob -Original Message- From: Ned Cunningham [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 2:25 PM To: Hanson, Robert; Ned Cunningham; '[EMAIL PROTECTED]' Subject: RE: Checking Perl load Yes, except I load the path sep

RE: Getting the proper info from an INI file...

2002-02-15 Thread Hanson, Robert
My preference is Config::IniFiles. You can see others by searching on CPAN. http://search.cpan.org/doc/WADG/Config-IniFiles-2.27/IniFiles.pm You also can't load files from CPAN using PPM. PPM loads from the ActiveState repositiory only! If you want to use CPAN modules you need to find nmake.e

RE: Checking Perl load

2002-02-15 Thread Hanson, Robert
You can check to see if its in your path by typing "perl -v" at the command line, otherwise just use the search finction, and search for "perl.exe". Rob -Original Message- From: Ned Cunningham [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 2:19 PM To: '[EMAIL PROTECTED]' Su

RE: Differences in DBM

2002-02-15 Thread Hanson, Robert
There is some info on the AnyDBM_File manpage. http://www.perldoc.com/perl5.6.1/lib/AnyDBM_File.html Rob -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 2:05 PM To: '[EMAIL PROTECTED]' Subject: Differences in DBM Hello, I was wondering

"Learning Perl" Question

2002-02-13 Thread Hanson, Robert
[Sorry if this isn't the place to post this, but I thought it might be interesting. Flaming will be accepted] I'm teaching a Perl class from the Learning Perl book, and noticed an inconsistency with the way certain constructs work. In chapter 2 it mentions a rule in Perl: "any time that you nee

RE: Time conversion question

2002-02-12 Thread Hanson, Robert
My favorite way is to use Date::Parse (http://search.cpan.org/doc/GBARR/TimeDate-1.10/lib/Date/Parse.pm) use Date::Parse; my $epoch = str2time("02/05/2002 02:31:14"); It comes with the Time-Date bundle (http://search.cpan.org/search?dist=TimeDate) which also includes the method time2str() for

RE: Syntax of Messages

2002-02-12 Thread Hanson, Robert
$_ is the default scalar variable (sort of). Perl will sometimes set this variable for you so that you don't need to create your own. It's just a shortcut of sorts. Here is an example... foreach ( @list ) { print $_; } For each item in the array @list Perl will set the variable $_ to

RE: Password Generator

2002-02-08 Thread Hanson, Robert
To do what? Just generate random passwords? How about this. my @c = (a..z,A..Z,0..9,qw|! @ # $ % ^ & * ( ) [ ]|); for (1..8) { print $c[int(rand(@c) + 1)]; } Rob -Original Message- From: Mike [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 4:47 PM To: [EMAIL PROTECTED] Subj

RE: multiple quotes

2002-02-07 Thread Hanson, Robert
Two different ways. Use the qq operator or escape the quotes. print qq[\n]; print "\n"; Rob -Original Message- From: Mike Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 2:02 PM To: [EMAIL PROTECTED] Subject: multiple quotes How do I get this to work? (too many quo

RE: Execute perl Script

2002-02-06 Thread Hanson, Robert
It depends on exacly what you are trying to do. "do" executes a script. `perl foo.pl` runs the script and returns the output. "system" runs the script, no output returned. "eval" runs a piece of code (usually for dynamic code). Rob -Original Message- From: Mike [mailto:[EMAIL PROTECTED

RE: Text block switching or HTML Templating

2002-02-06 Thread Hanson, Robert
I always prefer using templates (actually HTML::Template like Scot mentioned), but it won't make you pages dynamic, each page would need to be accessed through a script. You could though use HTML::Template to create templates on your "dev" server (which would be your own PC, and then write a scri

RE: Perl and CGI

2002-02-05 Thread Hanson, Robert
Here is a tutorial that will help you get started writing CGI scripts in Perl... if that was your goal. http://www.webdesigns1.com/perl/tutorial.html Rob -Original Message- From: Naveen Parmar [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 5:31 PM To: [EMAIL PROTECTED] Subj

RE: Perl and CGI

2002-02-05 Thread Hanson, Robert
According to www.pcwebopaedia.com, a CGI program is defined as: "A CGI program is any program designed to accept and return data that conforms to the CGI specification" In short Perl is a language and CGI is not. CGI is an interface that allows you to transfer information between a CGI program

RE: Using =~ with a list

2002-02-04 Thread Hanson, Robert
Ahhh, I see. So this would work as well. map {s/foo/bar/} @data; But the "for" seems to be a little bit faster which makes sense. Benchmark: timing 100 iterations of FOR, MAP... FOR: 16 wallclock secs (15.84 usr + 0.00 sys = 15.84 CPU) @ 63119.36/s (n=100) MAP: 19 wallclock secs

RE: Using =~ with a list

2002-02-04 Thread Hanson, Robert
You probably want to use "map". This should work. @body = map { s/foo/bar/; $_ } (@body); Rob -Original Message- From: Lysander [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 1:17 PM To: [EMAIL PROTECTED] Subject: Using =~ with a list I need to replace all the occurances

RE: make a executable with a perl file in windows

2002-02-01 Thread Hanson, Robert
In windows it uses the file association only, and in recent installs of ActiveState Perl where I work, the installer sets all of this up for you. So try it out, it might already be set up. Otherwise create a file extension .pl (or whatever) and set the "Open" action to "C:\Perl\bin\perl.exe" "%1

RE: Hash Question

2002-02-01 Thread Hanson, Robert
Better yet you could use 'tie' and create your own hash implementation like the code below. You will be able to set and retreive values normally except for the fact that if you want a single value to be linked to two keys you will need to store the value in one key and reference that key in anoth

RE: Hash Question

2002-02-01 Thread Hanson, Robert
n $hash->{$key}; } } Rob -Original Message- From: Hanson, Robert Sent: Friday, February 01, 2002 1:04 PM To: 'Balint, Jess'; '[EMAIL PROTECTED]' Subject: RE: Hash Question Just one unless you use references. Here is an example with references... %hash =

RE: Hash Question

2002-02-01 Thread Hanson, Robert
Just one unless you use references. Here is an example with references... %hash = ( one => 1, two => 2 ); $hash{oneagain} = \$hash{one}; foreach my $key ( keys %hash ) { my $value = (ref $hash{$key}) ? ${$hash{$key}} : $hash{$key}; print "$key => $value\n"; } And when you

RE: simple commenting question ...

2002-02-01 Thread Hanson, Robert
Yes. ...Sort of. =pod $x = 1; ... $y = 2; =cut The =pod and =cut are usually used for documentation but works for commenting out chunks of code as well. Currently there are no other mechanisms (unless you want to put it all in a if(0){} block :). Rob -Original Message- From: Pfeiffe

RE: change all files in directory

2002-02-01 Thread Hanson, Robert
Oh, you're on Windows, it may not work because of the shell ("cmd"). In Windows the single quotes around the code usually need to be double quotes, and it doesn't seem to be expanding *.cpp when on Unix (types) it will expand that to all of the individual file names. I guess you need to write a

RE: difference between MSI and AS package

2002-02-01 Thread Hanson, Robert
The MSI uses the Microsoft installer, which means you can uninstall it. Use that one if you can. The AS package does not include an installer (well maybe a batch script, but I'm not sure). Rob -Original Message- From: Booher Timothy B 1stLt AFRL/MNAC [mailto:[EMAIL PROTECTED]] Sent: F

RE: change all files in directory

2002-02-01 Thread Hanson, Robert
From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] > If you keep your code do not forget to add the /g option Oops! perl -pi -e 's|satellite|target|g' *.cpp *.hpp *.asc perl -pi -e 's|Satellite|Target|g' *.cpp *.hpp *.asc perl -pi -e 's|SATELLITE|TARGET|g' *.cpp *.hpp *.asc Rob -- To unsubscrib

RE: change all files in directory

2002-02-01 Thread Hanson, Robert
Yeah, here is an easy solution, run it right at the command line... (Make a backup of the files first!!) perl -pi -e 's|satellite|target|' *.cpp *.hpp *.asc perl -pi -e 's|Satellite|Target|' *.cpp *.hpp *.asc perl -pi -e 's|SATELLITE|TARGET|' *.cpp *.hpp *.asc Rob -Original Message- Fr

RE: PERL and XML Parser

2002-02-01 Thread Hanson, Robert
There are tons of XML modules, many of which make that sort of thing easy... but it depends on exactly what you want to do. Here are some snippets: use XML::EasyOBJ; my $obj = new XML::EasyOBJ('killme.xml'); foreach ( $obj->albums ) { print $_->owner->getString . "\n"; } -- OR -- use

RE: pulling file name into perl

2002-01-31 Thread Hanson, Robert
Use backticks, not system(). $date = `ls -al | grep filename.txt`; Or if you want it in an array like you mentioned, do this... @date = `ls -al | grep filename.txt`; Rob -Original Message- From: Russell Boyd [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 3:17 PM To: < Su

RE: Debug some simple code

2002-01-31 Thread Hanson, Robert
You are using the assignment operator in your "until" and "if" blocks, and *not* the comparison operator. You need to use the double equals for what you want... until ($number == 999) And if ($number == 999) Rob -Original Message- From: Rambog [mailto:[EMAIL PROTECTED]] Sent: Thursd

RE: join

2002-01-31 Thread Hanson, Robert
The question mark is a special character in a regular expression meaning "zero or one" and *must* follow a character or character class. If you want to split on the question mark character you need to escape it so that it no longer has special meaning. Like this: split(/\?/,$testdata); Rob --

RE: split and extraction

2002-01-30 Thread Hanson, Robert
Actually it was "[split /\s+/]->[8]" not "split[/\s+/]->[8]", and you only need to do it like that if you are using it in a "print" statement (I couldn't get it to work otherwise). Otherwise you can use the method Nikola explained or using the method you use below (the one that works). Rob --

RE: How do I read a web page from within perl?

2002-01-30 Thread Hanson, Robert
If all you want to do is grab the text you could use the code below. If you also need to parse it you will need to look into using a parser as the other mentioned. use LWP::Simple; my $html = get('http://www.cnn.com'); # If you need to split it into lines, this should work my @lines = split(/\

RE: newbie question

2002-01-29 Thread Hanson, Robert
"make" is a utility for managing programming projects. The "Makefile" is a script that tells make how to do stuff. When you install a Perl module it looks like this: perl Makefile.PL >> This is a perl script that creates a file called "Makefile" based on your configuration. make >> The progr

RE: 2 questions

2002-01-29 Thread Hanson, Robert
All variables are global in nature unless you declare them in a lexical scope. $foo = "Hello Naveen"; if ( 1 ) { my $x = 1; } In this example $foo is global, and $x is local to the if-block only. And yes, -> is used quite often when you start using references or classes (a module that acts l

RE: Perl path for windows 98

2002-01-29 Thread Hanson, Robert
The shebang line (#!) is ignored in Windows*, but if the file association of Perl is set up correctly Windows should be able to run it just by typing "myscript.pl" at the command line. * Any flags on the shebang line will be used. Like warnings (-w) and such. Rob -Original Message- Fro

RE: dir/file from ftp site

2002-01-29 Thread Hanson, Robert
The ls -l is the only way I can think of, and it is pretty easy to parse the output. # Your @data will come from the FTP server, mine came from # the command line. my @data = `ls -l`; for ( @data ) { my $idDirectory = (/^/) ? 1 : 0; my $filename = [split /\s+/]->[8];

  1   2   >