Re: Running shell script as root from Perl

2002-03-11 Thread David Gray
> "su root adsl-start". My problem is how to pass the root > password which the user enters into the GUI to this command. > Is it possible? Not sure, anyone? (you might want to look into using an expect script...) > I tried opening a perl pipe > Is there a way to pass the password with being pr

RE: Browser navigation with cgi

2002-03-11 Thread David Gray
It's not possible to do that server-side... You could use your cgi script to write some javascript to the page that would simlulate the user clicking the back button, i.e. print << HTML; edit form HTML Or something... I'm not too current on my javascript syntax, but I think that's what you want.

RE: How long can $_ be?

2002-03-12 Thread David Gray
> Is there some limit in how long the contents of the variable $_ can > be? Not that I'm aware of, no. > I encounter this problem on Solaris machines running Perl 5.005. > On Windows with Perl 5.6.1. no such problem was encountered. > > What could cause the problem? I suppose it might be a

RE: uploading without using forms :(

2002-03-12 Thread David Gray
> Thanks Timothy. However, I'm not sure if I understand... > constraining to html? I said I wanted to avoid html and the > need to supply the path of the file via form. Below is my > short script; all I want to do is to be able to specify the > path of the file within the script, instead of wa

RE: Multiline searching -

2002-03-12 Thread David Gray
> OPERATION, FOO, AND BAR. I want to read in this one section > at a time. I think it would be simpler to read the entire thing in at once, like so: open FILE,'; } > I want to know how to read this in by > section (as oposed > to line) that ends with (*ENDS). And split on *ENDS, like so

RE: how to pass 2 variables

2002-03-13 Thread David Gray
Hi Jorge, It looks like you want to create a reference data structure to create your links from. I would suggest something like: # filename of link to create on disk my $path1 = "$RegValue\\InstallOXE.lnk"; # LINK attribute to set => value my %lnk1 = ( 'Path' => "$CMPath/Active_Perl/Bin/", 'W

RE: Parsing CGI data to another page...

2002-03-15 Thread David Gray
> Just wondering how I would go about having this URL > www.mydomain.com/cgi-bin/test.cgi?data=test > > Would be parsed to... > > www.mydomain.com/cgi-bin/test2.cgi > > From test2.cgi I would like to be able to read that data = test from test.cgi. In test.cgi, do the following =code use C

RE: interesting question about variables

2002-03-15 Thread David Gray
> if ( ( $hash -> { $paragraph } ) =~ > s/###(\w+.*\.jpg)###/($text_link)/ ) { > $figure_name = $1; > > $text_link = $cgi -> a({-href => "javascript: > window.open('$pix_dir/$figure_name'," > . " '', " > . " 'status=yes, " >

RE: Re-displaying data back into forms

2002-03-15 Thread David Gray
Hi Troy, > Then I have the following code to re-assign it to variables: > > --- > unless ($action) { > open (TEMP,"$filename2") or die "Can't Open $filename2: > $!\n"; $line = ; close(TEMP); ($dt, $time, $topic, > $eurom) = split(/\|/, $line); $e

RE: Can I use html templates with perl ???

2002-03-15 Thread David Gray
> What I want to do is use different html > templates (the location if which can be stored on the > database) to display > the relevant information. For example: if i read data off a > database that > has 3 pictures i would use 1 template, if the page has 4 pics > i would use > another temp

Help on debugging

2002-03-18 Thread David Gray
Hi all, Please don't respond directly to that last email I sent. It has an incorrect email address on it that isn't checked that often. Please post back to the list directly or to [EMAIL PROTECTED] Thanks, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

RE: strange error message on exiting script

2002-03-18 Thread David Gray
> I am receiving a strange error on exiting a script: Attempt > to free unreferenced scalar during global destruction. It > only occurs after I make a DBI connection and run an SQL > statement. I am undefing the statement handle and > disconnecting the database handle. Does anyone have a cl

RE: Bit reversal of MAC Address bytes...

2002-03-18 Thread David Gray
> 1. How do I brake the MAC Address up into bytes? I'm not exactly sure what format you're getting the MAC address in, but it looks like you're just splitting it into two-character chunks... To split that, you could do: my $c = 0; while($mac =~ /(.{2})/g){ $mac[$c++] = $1; } > 2. How to c

RE: Since when is $_ a read-only variable?

2002-03-20 Thread David Gray
> I'm trying to process a list like so: > foreach ("photoshare", "mmc", "popline", "popline/www", "popline/db", > "netlinks") { > ... > s#/#.#g; > system("$apath/analog -m +g${acfgpath}/${_}.analog.cfg > +F$YY${MM}01 +T$YY${MM}31 +O${aout > path}/index.html"); >

RE: how to sort, in to out

2002-03-21 Thread David Gray
> I am trying to figure out an easy way to sort out a array of numbers: > 2 20 38 56 75 93 -17 -35 -53 -72 -90 > Into the following: > -90 -72 -53 -35 -17 2 20 38 56 75 93 > I have done the following: > @x_step = grep { ! $x_step_t{ $_ } ++ } @x_step_t; > @x_step = sort {$a == $b} @x_step;

RE: how to sort, in to out

2002-03-21 Thread David Gray
> >> I am trying to figure out an easy way to sort out a array > of numbers: > >> 2 20 38 56 75 93 -17 -35 -53 -72 -90 Into the following: > >> -90 -72 -53 -35 -17 2 20 38 56 75 93 > >> I have done the following: > >> @x_step = grep { ! $x_step_t{ $_ } ++ } @x_step_t; > >> @x_step = sort {

RE: precompile regular expressions?

2002-03-21 Thread David Gray
Do you mean: my ($c,@compiled) = (); for(@accept) { $compiled[$c++] = qr/$_/; } ? then you can loop over @compiled instead of @accept, and it should be quite a bit faster. It sounds like that's what you're looking for. There is a big section on compiling regular expressions in O'Reilly Progra

Regex peculiarity

2002-03-21 Thread David Gray
I'm matching a list of 4 measurments (i.e. 4pc,4pc,4pc,4pc) that all have to have some sort of unit specification (i.e. 4pc6,4in,4px,4pt) and I'm running into a bit of an oddity... If I use the regular expression: /^(?:\d+\w+\d*,?){4}$/ to match the above sequence, it matches the string '10,10,

RE: Regex peculiarity

2002-03-21 Thread David Gray
> I'm not clear on what you're trying to match for. Is it: > Exactly one digit, followed by exactly any two characters, > followed by zero or more digits? One or more digits, followed by one or more characters, followed by zero or more digits, followed by zero or more commas, four times. (does

RE: Regex peculiarity

2002-03-21 Thread David Gray
> 10,10,10,10 > nope.. \d+ matches the first digit \w+ matches the second > digit nothing for > \d* then , > > > try this: > /^(?:\d+[a-z]+\d*,?){4}$/ *ack* thanks :) \w matches alphaNUMERIC and _ Silly me. -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-m

RE: Printing frequency of word occurence in paragraph

2002-03-22 Thread David Gray
> In the program below I don't know when to stop the loop. > (CTRL + d ) will just terminate the program, leaving the > data via STDIN unattended, this is my problem. > > Lets define what I want to do: > I want to print the frequency of every word at the beginning. > and every word at the end

RE: Printing frequency of word occurence in paragraph

2002-03-22 Thread David Gray
I think this is a prime example of TMTOWTDI (There's More Than One Way To Do It) - you now have two choices for how to indicate the end of input to your while() loop: 1) pressing ^Z instead of ^D 2) breaking out of your loop when you see certain input indicating end of input -dave ps - I think

RE: remove part of a string - unterminated tags

2002-03-25 Thread David Gray
> I have strings like the following one: > my $s="The Library of > I want to truncate the string, to become > "The Library of ..." > (that is remove 'unterminated' html tags - tags that open but > there is no > '>' at the end, and add "..." if necessary) > > By using the following: > $s=~s/<(

RE: remove part of a string - unterminated tags

2002-03-25 Thread David Gray
> >> I have strings like the following one: > >> my $s="The Library of >> > >> I want to truncate the string, to become > >> "The Library of ..." > >> (that is remove 'unterminated' html tags - tags that open but > >> there is no > >> '>' at the end, and add "..." if necessary) > >> ... > > >

RE: Newbie reference question

2002-03-25 Thread David Gray
> I am trying to make a two dimentional array. I have a > function that returns an array. The following code works: > > @x = f(); > push(@y, \@x); > > and then I can reference it @{@y[$i]}[$j}; > > Is this the best way to make two dimentional arrays; I.e., > using push and reference to arrays

RE: remove part of a string - unterminated tags

2002-03-26 Thread David Gray
> I understand that by using: > > $s=~s/<[^>]*(?!.*?>)// > > the negative character class ( [^>]* ) seems redundant... > > But, strange, If I remove it (then we go to the one I wrote > on my first > message): > > $s=~s/<(?!.*?>)// > > it only removes the last orphan "<" character without

RE: extraction of filenames in a string

2002-03-26 Thread David Gray
> > I have a string for example: > > > > "directory/subdirectory/subsubdirectory/filename.gz" > > > > How do I extract the filename.gz part for testing, > > the number of subdirectories is not fixed? > > use File::Basename; > > my $file = "directory/subdirectory/filename.gz"; > print basename($

RE: Regex sub moron problem

2002-03-26 Thread David Gray
> I have a file with some settings, and I want to change some > of them. But when I write the file, I lose everything after a > certain point. > > Can someone point out my moronic mistake? > Everything after "ROOT =" is lost but it changes "ROOT =" to > the correct value. > > # perl here >

RE: using search backreferences in a variable

2002-03-28 Thread David Gray
> Why does this segment not work properly? > > $match = "cat(\d+)"; > $replace = "\1dog"; > $_ = "cat15"; > s/$match/$replace/g; > print $_; # prints --> \1dog > > Any ideas? Try replacing the "\1dog" with '${1}dog' in the line where you define $replace. That should solve your problem. -dav

RE: counter script and chmod 755

2002-03-28 Thread David Gray
> I am putting a counter on a website for the first time. I > undstand that because the server is Unix that I will need to > se permission for the counter. > > I believe this can be done within the Perl script using the line: > > chmod (0755, "counter.cgi"); > > right within the counter.cgi s

RE: html to perl vars

2002-03-29 Thread David Gray
Hi Jerry, > How does one convert html: > > > > to a Perl? > > $value_1 = T1; You're going to want to look into the CGI module. (perldoc cgi) Hope that helps, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Substitution: How do I say ...

2002-03-29 Thread David Gray
> er... > s/\t(?!454354)//g; > > > > s/\t454354//g; > > > > replace every \t (tab character) which is NOT > > immediately proceeded > > by '454354' with ''? > > > > Thanks. I suspect this is any easy one, but I've been staring > > at it for > > an hour, and I can't figure it out. Brain

RE: Writing Dir Names into a File

2002-04-01 Thread David Gray
Good morning, > So I have modified my script a bit and it works. However, now > I want to not > read in the "." and ".." directories. How can I do this?? I am having > problems with this part. I usually use the following code to do this: opendir DIR,'$mydir' or die "couldn't open dir [$myd

RE: Limit floating point numbers?

2002-04-02 Thread David Gray
> > > I have got most everything working ok. Now I need to go back over > > > almost 2500 lines of code and fix my floating point > number so they > > > read 1.25 instead of 1.2556. Which should round out to 1.26 > > > > What text editor are you using? Can you just do a search > and replace?

RE: Creating variables of a string

2002-04-02 Thread David Gray
> Michael Stearman wrote: > > > > Right now it is not working and I was wondering if I sent the code > > maybe someone with more experience with this will see the > problem. I > > am very new to this. The line I am trying to create the variables > > from is > > > > C6xxxSimulator(TI)

RE: Filehandles named with a variable

2002-04-02 Thread David Gray
> So, I'm trying to 'open ($1,">>$file")', where $1 is a string > like "cbQosCMPrePolicyPktOverflow". > > Obviously, with use strict this does not work. How can I make > it work? I need arbitrarily named filehandles. I know, it > could get rended with gobbleworts if the data gets out of hand..

RE: file handles in cgi

2002-04-03 Thread David Gray
> this is the perl script : abc.pl(say) -- this is in my cgi-bin... > > #!/usr/bin/perl > print "content-type: text/html\n\n"; > > open (IN, ">abc.txt"); > $x = ($inputs{name}); > print IN $x; > close (IN); > > open (IN, "abc.txt"); > @arr = ; > print @arr; > close (IN); > > and this is th

RE: file handles in cgi

2002-04-03 Thread David Gray
> > this is the perl script : abc.pl(say) -- this is in my cgi-bin... > > > > #!/usr/bin/perl > > print "content-type: text/html\n\n"; > > You need to print html headers when you're printing to a browser, i.e. > > print "Content-type:text/html\n\n"; > > -dave I must be blind this morning...

Win32 Perl editors (was: Perl 6?)

2002-04-03 Thread David Gray
For all you win32 perl hackers, I've been using a really cool editor called Code-Genie: for about a month now, which allows customizable nested syntax highlighting! I definitely recommend it, and I'll post my syntax customization file if anyone's interested. Cheers, -da

RE: Variable question

2002-04-08 Thread David Gray
> I believe it is as simple as: > > $count = () = $string =~ /,/g; I can't seem to get my brain around what's happening here... would someone be kind enough to explain? -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: How to remove 3 lines from a file

2002-04-08 Thread David Gray
> Hi, I have a file like this: > > . > # PXE Class > vendor-class "PXEClient" { > default-lease-time 1800; > max-lease-time 1800; > option dhcp-class-identifier "PXEServer"; > > filename "/bootp/linux/3.0/alize/startup.txt"; > option vendor-encapsulate

RE: Variable question

2002-04-08 Thread David Gray
> $count = () = $string =~ /,/g; > >> > >> $string =~ /,/g; > >> > >> assigns the result in a list context - the anonymous list '()'. by > >> assigning this to a scalar, $count, we get a value that is > the size > >> of the list, which is the number of matches that the regex > made. that

RE: rewrite without using two functions?

2002-04-09 Thread David Gray
> is there a way to write this without using map AND grep AND > without making > it longer than it is? > @must = map { m/(.*)\/\*/; $1 } grep m/\/\*/, @recomp; > > where @recomp = qw( stuff/stuff.c > crap/* > morestuff/* > stuffy/stuff_stuff.c >

RE: rewrite without using two functions?

2002-04-09 Thread David Gray
> map returns the result of the last evaluated statement... > @must would have ones and zeros... I want the $1 portion but > only if it ends in '/*' there really isn't a speed issue... > it's more a "can i make this line look sweeter?" > > > > is there a way to write this without using map AND

RE: rewrite without using two functions?

2002-04-09 Thread David Gray
> Why are there still no empty elements in the returned array > for the items that didn't match the pattern? @must == 2 > > I am just befuddled but this "paradox" > > > > Thus, map { m!(.*)/\*! } LIST will return $1 or () for each > > element of the > > LIST. When you have LIST2 = map { m!^(.

RE: Execute .bat file from perl?

2002-04-10 Thread David Gray
> New to this - need to execute a .bat file from a perl script. > > Any suggestions? Look into the system command: perldoc -f system Hope that helps, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: default value

2002-04-10 Thread David Gray
> $question = $default if $question eq ''; You could possibly shorten this last line to: $question ||= $default; This will set $question to $default if $question logically evaluates to false (which includes the case where $question is the empty string). If you only want to reset $question whe

RE: File Paths and file names

2002-04-10 Thread David Gray
> I would like to write a perl program to run on NT to go > through a list of files, with full path and extract just the > file name. The path is random in length likewise so is the file name. You could use a regular expression like: $filename =~ s/[\\\/]([^\\\/])$/$1/; To replace the full pa

RE: Oracle sequences

2002-04-10 Thread David Gray
> I'm attempting to load an oracle database and am struggling > with how to retrieve a sequence for a table. > > in SQL, the value is net_seq.nextval > how do i use this in a perl script?? Do you have DBI installed? What have you tried? Can we see some code? AFAIK, you can't directly retrieve

RE: Scope of my() declared variables WAS( Re: -e $filename...)

2002-04-10 Thread David Gray
> Here's the part I still don't understand, and maybe some of > you can show me the light. What is the difference between > local() and my()? I have never used local(), the only > examples I've ever been given involve scoping $_, and if I am > ever tempted to do that, I can usually trace it

RE: use of package in a script

2002-04-10 Thread David Gray
> Unless someone can come up with a really HOT idea as to why > one would want to put a 'package declaration' in an > application - and I have tried, but for the life of me, can > not come up with a good reason to go there... How about as a mnemonic device, or to sort variables by category? Co

RE: Problem with replacing text in a variable...

2002-04-11 Thread David Gray
> I have a problem with substitutions... > In the piece of code, here below, > "display $var1, $var"' should be "display val1, val2"; > I don't see why, but the if condition doesn't seems to > work... and if I remove the if condition, the replacement > doesn't occur... Does any of you know why?

RE: Problem with replacing text in a variable...

2002-04-11 Thread David Gray
> An update on previous post... > It seems that I typed some errors :-( > > This is a small rewrite of my script... > #!/usr/bin/perl > > use warnings; > > my $var = "test"; > my $rvar = "\$interface"; > my $cmd = "int \$interface\n"; > > print "$var\n"; > print "$cmd\n"; > > $cmd =~ s/$rva

RE: splitting / regex / trend etc

2002-04-12 Thread David Gray
> If I only want to get the numbers sold for lets say apples, > oranges and > grapefruit, for both stores How would I go about it? > > > apples, oranges, pears, lemons, grapefruit > 5, 0, 4, 6, 2 > 2, 6, 2, 0, 0 > 4, 7, 2, 1, 0 > > > apples, melon, oranges, pears, coconut, lemons, grape

RE: Problem with replacing text in a variable...

2002-04-12 Thread David Gray
> OK! > > my script works! But when I use: > > my $rvar = ; > > I have the same problem! Jesus, that's a hard one :-) After you read it in, do you have a '$' in the string? If so, you need to escape it like so: $rvar =~ s/\$/\\\$/g; That should fix the problem. If it doesn't, could you paste

RE: Help with MIME::Lite module

2002-04-12 Thread David Gray
> my $msg = MIME::Lite->new( >From => '[EMAIL PROTECTED]' > , >To => '[EMAIL PROTECTED]' > , >Cc => '[EMAIL PROTECTED]' , >Subject=> 'Morning Trouble Call report', >Type => 'text/html', >Data => '$rhtmlpage' > > ); > > $msg->se

RE: Find and replace a word or characater in a the same file.

2002-04-12 Thread David Gray
> I would like to find a word or character in a file and > replace it with another word or character, while > leaving others untouched. Currently, I am using the > following method > > #!/bin/perl -Dr -w > open(FILE,"$ARGV[0]") || die "Can't open $ARGV[0]: > $!\n"; > open(FILE2,">$ARGV[0].spi")

RE: splitting / regex / trend etc

2002-04-12 Thread David Gray
> @fruitname = split /[,\s]+/ => ; > ... >@fruit{ @fruitname } = split /[,\s]+/ => $_ ; Mr. Big "Fancy Comma" Man ;) That's cool, an extra step of simplification... Very nicely done. -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: pattern match

2002-04-12 Thread David Gray
> for e.g : > > (not showing the new lines..) > > > word1.word1.word1word2word1...word2wor > d2word2 > . You're gonna want to check out (in the perldoc perlre manpage) (??{ code }), which is an example of a recursive regular expression. They have an exampl

RE: Errors Running Learning Perl in Win32 Scripts

2002-04-16 Thread David Gray
> Hi! I have version 5.005_03 and I'm using the Win32 version > of the Learning Perl book. I'm having trouble running a few > scripts. For example, when I run the following: > > Exercise 16.1 > > foreach $host (@ARGV) { > ($name, $aliases, $addrtype, $length, @addrs) = > gethostbyname($host

RE: grep a array element..

2002-04-16 Thread David Gray
> uh... > > my $lookfor = qr/car/; # this is faster and you don't even > need to put in the // > > --- > > use strict; > > > > my @array = qw(car bus caravan bike cart); > > > > my $lookfor = "car"; > > > > foreach my $element (@array) { > > if ($element =~ /$lookfor/) { > > prin

RE: Errors Running Learning Perl in Win32 Scripts

2002-04-16 Thread David Gray
> Thanks! I think your advice may apply to the following code > that I'm having trouble with: > > use Win32::NetAdmin; > $username = Win32::LoginName; > Win32::NetAdmin::UserGetAttributes("", $username, $password, > $passwordage, $privilege, $homedir, $comment, $flags, > $scriptpath); > print "

RE: Need help getting started using hashes

2002-04-16 Thread David Gray
> First let's let the other list member in on the code: > > use DBI; > use strict; > my $dbname = "test"; > my $host = "localhost"; > my $dbuser = ''; > my $dbpw = ''; > my $mscs = "dbi:mysql:dbname=$dbname;host=$host;"; > my $dbh = DBI->connect($mscs, $dbuser, $dbpw) or die "Connect fails to > $

RE: Need help getting started using hashes

2002-04-16 Thread David Gray
> > my $sql = "select * from method"; > > #replace prev. line with: > my $sql = 'select methodid,method,sname from method'; >$sql .= 'order by methodid'; #second line should be $sql .= ' order by methodid'; -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

RE: Errors Running Learning Perl in Win32 Scripts

2002-04-16 Thread David Gray
> Change this line > >($name, $aliases, $addrtype, $length, @addrs) = > gethostbyname($host); > > To > >(undef, undef, undef, undef, @addrs) = gethostbyname($host); I think mine is prettier, at least (see below)... Is there a reason why this might be considered "Better" than doing: @

RE: Errors Running Learning Perl in Win32 Scripts

2002-04-16 Thread David Gray
> > > Change this line > > > > > >($name, $aliases, $addrtype, $length, @addrs) = > > > gethostbyname($host); > > > > > > To > > > > > >(undef, undef, undef, undef, @addrs) = gethostbyname($host); > > > > I think mine is prettier, at least (see below)... Is there a reason > > why this

RE: how to return an array reference from a subroutine

2002-04-18 Thread David Gray
> But, the script below does not work. I get an error message : > Not an ARRAY reference at > /usr/local/ActivePerl-5.6/lib/site_perl/5.6.1/i686-linux-threa > d-multi/Tk/Menu.pm > line 69. The cause of this is the subroutine sub_menu. As I > understand things, the argument to -menuitems must b

RE: remove duplicate values from array

2002-04-22 Thread David Gray
> Can anyone tell me the best method for removing duplicate > array values. > > eg: > > @array = qw( a a a b b b c); > > becomes after some operation I cant seem to figure: > > @new_array_or_same = (a b c); In this situation, I usually use a hash instead of an array so I can create highly

RE: Complicated RegEx

2002-04-22 Thread David Gray
> I have the following line in a text file > > Total 3250 5 0 0 0 0 879717 > 0 0 0 > 0 926418 0 0 0 0 920714 > 0 0 0 > 0 692510 0 0 0 0 > > (this is the entire line, but

RE: sort regex trouble!

2002-04-24 Thread David Gray
> > im trying to sort out this sort routine: > > the sub by_number_of_citations works > > but if i try to make a sort alphabetically, my regex fails? > > how should it be done? > > > > # sting to match: 1212Cited > > Work121232< /td>1999 > > > > # sort routine > > # > > sub by_number_of_citations

RE: question

2002-04-24 Thread David Gray
> When I put this in my script I get an error > > Name "main::NAME" used only once: possible typo at > ubrstate2.pl line 521. That's not an error, that's a warning. It should go away once you have another statement in your program that uses the filehandle (main::NAME) you're defining. HTH,

RE: sort regex trouble!

2002-04-24 Thread David Gray
> >May I suggest: > >(my $A = $a) =~ s/^(\d+)<\/td>/$1/; > >(my $B = $b) =~ s/^(\d+)<\/td>/$1/; > > That's not what he's doing. He's doing: > > my ($A) = $a =~ m{^(\d+)}; > my ($B) = $b =~ m{^(\d+)}; > > Yours leaves everything after the tacked onto the end > of $A; mine and his only sto

RE: Patterm Matching

2002-04-24 Thread David Gray
> Actually, \n's are the one thing that the $ anchor doesn't > work exactly right on. Usually it's not a huge deal, but > Perl will still match a line that has a \n after the part > that you are trying to match if you use $ to anchor. This is > normally very useful, as in the case of a line

RE: Parsing a line - part 2

2002-04-24 Thread David Gray
> Thank you, John. This code does exactly what I want. Problem > is, I only understand about 30% of what's going on. I can > figure out the use of the hash, some of the pattern matching > & $1/$2. But can someone elaborate on: > > @keys{ qw/P ST U SL D/ } = \( $Proc, $Start, $Url, $Sleep, $Dri

RE: Parsing a line - part 2

2002-04-25 Thread David Gray
> > > @keys{ qw/P ST U SL D/ } = \( $Proc, $Start, $Url, > $Sleep, $Drive ); > > > > This is a shortcut for defining the values of a hash -- it creates > > $keys{P} == $Proc, $keys{ST} == $Start, etc. > > $keys{P} = \$Proc, $keys{ST} = \$Start, etc. Okay... Fair enough. Maybe I'm missing some

RE: Parsing a line - part 2

2002-04-25 Thread David Gray
> How about: > > /(\S+)=(.+?)(?=\s+\S+=|\s+|\z)/g > > > To catch trailing whitespace at the end of the line of data? Actually, I meant: /(\S+)=(.+?)(?=\s+\S+=|\s*\z)/g ^^^ -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

RE: associative array not looking like I thought it would

2002-04-26 Thread David Gray
> This was all written by a vendor and I am trying to learn > PERL to modify what they did. When you say I must print it > explicitly, what exactly do you mean? You have to _sort_ it explicitly. In Timothy's example, he was sorting the hash alphabetically based on the keys. The keys function r

RE: array numerical name...

2002-04-30 Thread David Gray
> Hi all - should be simple - but I cannot figure it out > > basically i want to name an array with a subscript ie > world0[0] and world1[0] the 0/1 being a variable, i have tried to > produce a simple example > > For any help - thanks.. > ---

RE: Beyond Book Learning - the problem of Re: array numerical name...

2002-04-30 Thread David Gray
> On Tuesday, April 30, 2002, at 07:32 , David Gray wrote: > [..] > > my $fred = 'one,two,three,four'; > > my $a = 0; > > @{"array$a"} = split ',', $fred; > > > > for(0..3) { > > print ${"array$a"}[$b] >

RE: Please Help

2002-04-30 Thread David Gray
> I am a student an I'm new to Perl. For a university > assignment I need to read the contents of a text file in an > array. I am using Windows. The code I am writing is: > > $file = "/test.txt"; > open (INFO, "$file"); Always check to make sure your filehandle was actually opened: open (INFO

RE: Brand New Perl Beginner - trouble using activePerl

2002-04-30 Thread David Gray
> I am learning perl now for use with CGI. > > I installed active Perl on both windows Millenium AND windows > XP systems. > > Both of the fail to run a .pl file. I see a window flash on > the screen for a part of a second and then disappear.the > window looks like it is a DOS command wi

RE: Sorting

2002-04-30 Thread David Gray
> John, > Could you please comment/explain the following lines please? > >my @sorted = map { (split/\0/)[1] } > > sort > > map { "@{[(split)[1,0,2]]}\0$_" } > > @array; It's fun trying to figure out what the heck John's code does :) Split each element of @a

RE: dynamic variable declaration?

2002-05-02 Thread David Gray
> I'm trying to do something that i'm not sure is even > possible. I want to cycle thru an array of MySQL fieldnames > and dynamically declare variables based on those fieldnames. > > I can create the array of fieldnames no problem, by just > using "describe" with DBI. > > But I can't figur

RE: rmtree

2002-05-06 Thread David Gray
> I have a directory "Abs" with a file "abc" in it. > I am using rmtree to rm this dir as follows > > use File::Path; > rmtree("Abs",1,1) or die "dir not del"; > print "done"; > > > The output is > > unlink ../htdocs/store/newpages/Abstract/abc > > > It neither prints the die stateme

RE: A very beginner

2002-05-06 Thread David Gray
Good Lord, you're gonna scare away the beginners who have questions about perl! > > Hi, > > I'm a beginner that doesn't even have perl yet. > > I woul like to know whether Perl is faster or Java for business > > applications. > > Paul has already provided the correct Party Line from the > typ

RE: Running PubDrills - Re: dynamic variable declaration?

2002-05-06 Thread David Gray
> > To appease the powers that be, does anyone know if you can bind > > columns to a hash: > > > > i.e. $sth->bind_columns(undef,\$val{a},\$val{b},\$val{c}); # ? > All of which leaves me scritching my head as to why that would be > a case of 'dynamic variable declaration' If I didn't ask a

RE: Sorting problem-part2

2002-05-06 Thread David Gray
> Now I've got an array of hashes, where each hash can have > different keys e.g., > > @aoh = ( {H3 =>234, H1 =>127, DNA =>1, p135 =>167}, > {H4=>24, H3=>1550, DNA =>25, p39 =>67}, > {H3 =>34, H2A =>125, DNA =>5, p32 =>7}, > {H3 =>24, H4 =>156, DNA =>123, p1

RE: How to a parse a string in perl

2002-05-10 Thread David Gray
> I want to slice up this variable into a single variable and > loop until its empty The variable is seperated via ! > explnation points and I want the numbers. This string can be > various in length ? Note it doesnt end with that delimiter. Help > > example > > $jims = "!23!45!67 Ho

RE: File Search - String Match - String Count

2002-05-13 Thread David Gray
> I am trying to accomplish the following and have been unable > to find a good > routine (or build one) which does an adequate job. > > 1. Paste a big text file into an html text box which contains email > addresses scattered throughout. You can use the CGI module for this. I'm not sure of

RE: Unicode to ansi conversion (or normalization)

2002-05-13 Thread David Gray
> I'm going to be working with XML files on Windows. Notice > that in Notepad (on > W2K+) you can save a file with different encodings, including > Unicode. > W2K+These > XML files are Unicode. Opened directly in Notepad, they take > on an appearance of having extra spaces between character

RE: kill NT process

2002-05-13 Thread David Gray
> I am stuck on windows working with a process that runs > as a service. There's a bug in the process (vendor > code) and it doesn't show up in the output of net > start, so net stop can't stop it. > > I need to have a script that kills this process using > kill PID, but I am not aware of any

RE: CGI QUESTION

2002-05-13 Thread David Gray
> I have a question regarding passing variables from a HTML > form to a CGI script. I have never worked with CGI in the > past and assumed that if I included the variables with in the > form and on submit called the CGI script that the variable > would be amiable to it. That doe not see, to

RE: Perl IDE

2002-05-14 Thread David Gray
> Well, Mr. Subscriber (if that _is_ your real name)- > If you just want syntax highlighting, you can check out VIM. Or code-genie or nedit > I am looking for a freeware Perl IDE for wind0ze. I have done > a search and > so far only ca

RE: Help!

2002-05-15 Thread David Gray
> Please help me! > I'm going crazy! For cocoa puffs? > It's perfect but I need something more.I need also the > qw001234 with the > passwd that's in another file in format: > > qw001234 rfvcde > > And I want it for all lines of all files. Of ALL files? > I'm obviously a beginner in perl so

RE: Help!

2002-05-15 Thread David Gray
> %uid0s{$uid0} = ''; # each time through your loop Should be: $uid0s{$uid0} = ''; # till v6 *sigh* -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: RFC for the three levels of beginnerNeff

2002-05-22 Thread David Gray
> { my other OCD is formalization of systems } Just because of you, drieux, I have a new appreciation for my bookmarklets that send me racing off across the web in search of these new and intriguing acronyms and words that

RE: Need help in Regular Expression

2002-05-24 Thread David Gray
> > ... > > Date: Thu, 23 May 2002 19:47:50 +0530 > > ... > > $header = $1 if /^Date: (.*)/; > This should do what you want. Two things: 1) should anchor this regex to the end of the line to make sure you get the entire line in $1 2) should use the //m switch to treat your string as multiple

RE: pattern matching

2002-05-28 Thread David Gray
> I have a list of the following format that I want to > parse:- > > ((sa1 da1 sp1 dp1 p1) (sa2 da2 sp2 dp2 p2) (saN daN > spN dpN pN) ) > > there are N entries. There are many such lists and N > varies in each list. One way to parse this is to use > brute force and use sth like the

RE: union of times algorithm

2002-05-30 Thread David Gray
> I'm trying to come up with an algorithm that seems like it > ought to be really easy, but it's turning out to be pretty tough... > > Basically I have three pairs of start/stop times, e.g.: > >3, 5 >4, 10 > 15, 20 > > I want the total time covered by all these ranges. I can't > ju

RE: Help with parsing output

2002-05-30 Thread David Gray
> >> while () { > >> chomp; > >> s/^\s+//; > >> next if (m/^$/ || (1 .. /^NPROC/)); > > > > what does the range thing do? > > wouldn't just ... || /^NPROC/ be enough? > > ok. opposite sense: || ! /^NPROC/ So that would be: next if (m/^$/ || ! /^NPROC/); Which means skip proces

  1   2   >