Re: macthing question...

2002-12-30 Thread John W. Krahn
Mike Burnard wrote: > > Hi, Hello, > I'm in the midst of writing my first useful perl script. It's designed to > pull text out of a plain text file and write a xml plist. > > The only trouble I'm having (so far) is getting the text out the way I want > it. > > The file I'm pulling data out of

Re: macthing question...

2002-12-30 Thread Shawn B
- Original Message - From: "Mike Burnard" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 30, 2002 11:40 PM Subject: macthing question... > Hi, > > I'm in the midst of writing my first useful perl script. It's designed to > pull text out of a plain text file and wri

Re: Regexp with //x

2002-12-30 Thread Shawn B
- Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 30, 2002 11:36 PM Subject: Regexp with //x > > Can anyone tell me where to find out what the x does when used at the end > of a pattern match? (i.e. $tag =~ /abc/x) Everywhere I've looked gi

Re: macthing question...

2002-12-30 Thread George P.
On Mon, 30 Dec 2002, Mike Burnard wrote: > > The file I'm pulling data out of is formatted like this: > > 010 "red" > > 011 "diamond" > > 012 "lion" > > 010 "blue" > > 012 "blue whale" > > 011 "emerald" > > So, I've got this to get specific groups out at once: > > while () { > if(/^010/) {

Re: macthing question...

2002-12-30 Thread perl
Interesting, I'm working on a similar thing. I've found it useful to use the $1, $2, etc variables. So try something like: if( $line =~ /\"([\w\s]*)\"/ ) { $array[i] = $1; } I'm not sure if all that (like the escaped ") is necessary; I'm just starting myself. On Mon, 30 Dec 2002, Mi

macthing question...

2002-12-30 Thread Mike Burnard
Hi, I'm in the midst of writing my first useful perl script. It's designed to pull text out of a plain text file and write a xml plist. The only trouble I'm having (so far) is getting the text out the way I want it. The file I'm pulling data out of is formatted like this: 010 "red" 011 "diamo

Regexp with //x

2002-12-30 Thread perl
Can anyone tell me where to find out what the x does when used at the end of a pattern match? (i.e. $tag =~ /abc/x) Everywhere I've looked gives me the helpful information that it means "Use extended regular expressions," but I've yet to find a definition of what that *means*. Thanks... -

RE: Sorting hash "values"

2002-12-30 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I takes the keys from the %hash and uses them to compare the the data within the hash and since it is $b vs $a and not $a vs $b it is in descending vs ascending sequence. For each key in %hash it then gets assigned to key and you now have the key and data sored by value of the hash and not

Re: two questions

2002-12-30 Thread Paul Johnson
On Mon, Dec 30, 2002 at 10:10:50PM +0100, Adriano Allora wrote: > 1 - Perl vs. AWK > I'm learning Perl to use it in text processing. Recently I start to > argue with a friend of mine about the best language to process texts > (clear them, or markup them, tokenize them or parse them), he says awk

more socket stuff - 2nd part

2002-12-30 Thread Mat Harris
i have sorted the two-way communication stuff but no I am having trouble doing the multithreaded version. I have no experience using fork or anything to do with spawing or pid's. Looking at the multithreaded server example on the sockets page on perldoc.com, please could someone help me convert th

RE: Sorting hash "values"

2002-12-30 Thread Rajendra Babu, Praveen
Hello /\/\ark, Thanks for your reply. The below code does exactly what I wanted to do and guess where did I get it ?! - perldoc -f sort !!! %hash = ( "h" => 100, "a" => 200, "z" => 50, "b" => 600 ); foreach $key ( sort { $hash{$b} <=> $hash{

Re: Sorting hash "values"

2002-12-30 Thread Dave K
$ perl -e ' %hash = ( "h" => 100, "a" => 2000, "z" => 50, "b" => 600 ); for(sort { $hash{$b} <=> $hash{$a} } keys %hash) { print $hash{$_}, " = $_\n"; }' 2000 = a 600 = b 100 = h 50 = z HTH "Rajendra Babu" <[EMAIL PROTECTED]> wrote in message [EMAIL PROT

RE: Sorting hash "values"

2002-12-30 Thread Mark Anderson
It helps to answer your question if you show us what you've already done, and tell us what you know... perldoc -f keys perldoc -f sort /\/\ark -Original Message- From: Rajendra Babu, Praveen [mailto:[EMAIL PROTECTED]] Sent: Monday, December 30, 2002 3:16 P

Sorting hash "values"

2002-12-30 Thread Rajendra Babu, Praveen
%hash = ( "h" => 100, "a" => 200, "z" => 50, "b" => 600 ); For the above %hash, I want to sort them by "values"(rather than keys) and print-out the sorted key-value pair. Can it be done ?? The output needs to look like the below: b 600 a 20

Re: two questions

2002-12-30 Thread Wiggins d'Anconia
Hanson, Rob wrote: Just because Awk shaves off a few seconds on a job doesn't make it better. If that were the case we would all code directly in C. Or assembly...ick http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: two questions

2002-12-30 Thread Hanson, Rob
> 1 - Perl vs. AWK > (my friend also forwarded me a mail of AWK > mailing list in which someone who did a > benchmark demonstrated the speed of awk...) Did he benchmark the time it took to write it? :) I'm not an authority on Awk, but it seems to me that Awk has one purpose, and it isn't good at

Re: two questions

2002-12-30 Thread Wiggins d'Anconia
Adriano Allora wrote: hi to all, I'd like to know two things: 1 - Perl vs. AWK I'm learning Perl to use it in text processing. Recently I start to argue with a friend of mine about the best language to process texts (clear them, or markup them, tokenize them or parse them), he says awk is be

two questions

2002-12-30 Thread Adriano Allora
hi to all, I'd like to know two things: 1 - Perl vs. AWK I'm learning Perl to use it in text processing. Recently I start to argue with a friend of mine about the best language to process texts (clear them, or markup them, tokenize them or parse them), he says awk is better - quicker than perl,

Re: process managing in Perl

2002-12-30 Thread david
Zentara wrote: > On Thu, 12 Dec 2002 17:43:34 +0100, [EMAIL PROTECTED] > (Olivier Moulene) wrote: > >>I have the pid of one running process and i want to kill it and all its >>children. What can i do to know the pids of every children ? > > This untested code from perlmonks.org, it might give yo

Re: Hooking a perl script to xinetd

2002-12-30 Thread Todd W
"Michael Weber" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have a script that listens on a port for a connection, receives some > data over that connection, and writes it to a file. > > This works, but it takes up CPU cycles, RAM etc. when it waits. I am

Re: Does Perl have to be installed ?

2002-12-30 Thread Mark Goland
It can probebly be done. I did something of this sort on my freebsd box. It would probebly be more difficult, since perl probebly install's its dll's in windows directory. Mark - Original Message - From: <[EMAIL PROTECTED]> To: "Craig Williams" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent

Re: Directory help, AS

2002-12-30 Thread Mark Goland
> But, it looks like he's just checking that $ARGV[0] is a directory. This can > be accomplished with a simple -d test. ...exactly. I used opendir because I find that sometimes flags fail on windows machines. I think this is documented some where in the stat(), having to do with NTFS. Mark - O

RE: Does Perl have to be installed ?

2002-12-30 Thread Russ Foster
It should work, assuming you're not doing anything funky with installed packages. You might also look into Perl2Exe (http://www.indigostar.com/perl2exe.htm) which bundles your Perl script and all necessary support files (aka packages) into a single executable to be used for the purpose you describ

RE: Directory help, AS

2002-12-30 Thread Bob Showalter
> -Original Message- > From: Steve Few [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 30, 2002 11:34 AM > To: [EMAIL PROTECTED] > Subject: Directory help, AS > > > [activeperl 5.6.1 NT] > > Folks. > > I have an 'error' question about lexical scoping. > > This is a followup to the

RE: two-way socket troubleshooting

2002-12-30 Thread Bob Showalter
> -Original Message- > From: Mat Harris [mailto:[EMAIL PROTECTED]] > Sent: Saturday, December 28, 2002 10:27 PM > To: [EMAIL PROTECTED] > Subject: two-way socket troubleshooting > > > i have a client and server which I want to be able to have > communicate in > full-duplex. I need the cl

Directory help, AS

2002-12-30 Thread Steve Few
[activeperl 5.6.1 NT] Folks. I have an 'error' question about lexical scoping. This is a followup to the Mark Goland's reply to help someone. I have a question about an error I'm not familiar with using his {opendir local} statement. After I run the below on my NT box, AS build 622, I get: '...

Re: More structure to my code

2002-12-30 Thread Rob Dixon
Both use and require will do the job. The @INC array by default includes the current directory, '.', as its last entry, so you can split your program into Perl modules in the same directory. 'use' is more appropriate as it happens at compile time (whereas 'require' pulls the file in at run time). '

RE: two-way socket troubleshooting

2002-12-30 Thread Kipp, James
might also want to turn on buffer flusing: $|=1; # somewhere before the read operation, might want to use select to make sure # you ar working with the correct FH > -Original Message- > From: Mark Goland [mailto:[EMAIL PROTECTED]] > Sent: Sunday, December 29, 2002 10:52 PM > To: Ma

Re: More structure to my code

2002-12-30 Thread R. Joseph Newton
Hi Craig, Just put it in a file with a ./pm extension in the same directory as your calling program, then use either the use or require statements: file: rjnWeb.pm in my program file: use rjnWeb; works like a charm on my ActivePerl on Win2k and on one of the unix servers I telnet to. It does

Re: Newbie question in Perl

2002-12-30 Thread R. Joseph Newton
Hi Anand, Look at your logic: until (($test ne 'Y') && ($test ne 'N') && ($test ne 'y') && ($test ne 'n')) {...} #until BAD input This says that as long as there is good input, keep cyckling until you get bad input. You should either use while here, or change the condition to refle

RE: single quote and substitutions

2002-12-30 Thread Dan Muey
Actually what I meant was, does the regex itself work. If the regex structure is bad then using it in vars won't work either. Always a good principle of programming : If you can't do it dynamically make sure it works static. Instead of trying to use(1|2) type you could create a hash fro

RE: ANDing IP addresses

2002-12-30 Thread Kipp, James
> > I wrote this a while ago, it may give you some ideas. well if you saw my post a week ago about my troubles with vec(), playing with this will give me a chance to practice. thanks for the code, when i get a free moment i will have some fun with the this bit twiddling gem :-) seriously, this is

Re: More structure to my code

2002-12-30 Thread Todd W
"Craig Williams" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I don't want to keep all my code for a script in one file. > > Do I have to use modules to break apart the code ? Is there anyway to just > include a .pl file ? Modules used this way are a > pain b

Re: Does Perl have to be installed ?

2002-12-30 Thread wiggins
Because of the nature of the client OS, aka Win 2000, it should be capable since you don't have to deal with differences in architectures, etc. You might check out the active state project, if you haven't already. Sorry I can't be of more assistance but I have very little experience with Windo

RE: ANDing IP addresses

2002-12-30 Thread Kipp, James
> Hi Kipp, > > I'd say don't bother pack()ing. At the moment, I think the > function pretty much s**ks. use eval() instead. The > following doesn't have that one-liner compactness of the > others, but it shows you what is going on. The bitwise & > does a real cute little trick with its ope

RE: ANDing IP addresses

2002-12-30 Thread Kipp, James
> > > > > > $ perl -e 'printf "%vd\n", 192.168.1.1 & 255.255.0.0' > > > 192.168.0.0 > > > > > > > quoting the string in anyway seems to break it. i am trying > to read in the > > strings from like this: > > print "Enter the IP address: "; > > $ip = ; > > print "Enter the Subnet address: "; > >

Re: Does Perl have to be installed ?

2002-12-30 Thread Craig Williams
<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Are you guaranteed of a certain operating environment, that is, on the customer side? Yes. Always Windows 2000. > http://danconia.org > > > > On Mon, 30 Dec 2002

RE: Does Perl have to be installed ?

2002-12-30 Thread wiggins
Are you guaranteed of a certain operating environment, that is, on the customer side? http://danconia.org On Mon, 30 Dec 2002 02:44:55 -, "Craig Williams" <[EMAIL PROTECTED]> wrote: > Sounds crazy I know but if I'm on a customers side with m

RE: More structure to my code

2002-12-30 Thread wiggins
What you want is 'require'. perldoc -f require You should also check your books in the index for 'require' as this topic should be covered, otherwise you might consider new books ;-)... If you have the time you might also have a look at Find::Bin and consider developing modules anyways... htt

Does Perl have to be installed ?

2002-12-30 Thread Craig Williams
Sounds crazy I know but if I'm on a customers side with my CD of pl scripts I don't want to have to install Perl on their servers just to run my code. Can I just put the binary files on the CD and run them ? thanks Craig -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-

Re: setting up mysql and DBI package on win98

2002-12-30 Thread Craig Williams
You can't install mysql as a service on 98 so you must run the daemon from the command prompt. Not even sure it works on 98 to start with. C "Patricia Hinman" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have set up mysql application server on my pc, and >

More structure to my code

2002-12-30 Thread Craig Williams
I don't want to keep all my code for a script in one file. Do I have to use modules to break apart the code ? Is there anyway to just include a .pl file ? Modules used this way are a pain because they must be put into /site/lib to work ..? I have searched google and docs and even my books on perl

Re: Newbie question in Perl

2002-12-30 Thread John W. Krahn
Anand Ramakrishna wrote: > > > Hi, Hello, > I am a beginner to perl. I have written a simple program in Perl > # This Program will copy the contents of a file named file.txt to another file > # newfile.txt. If newfile.txt is already existing, the user is given an option > # to overwrite the

Re: Newbie question in Perl

2002-12-30 Thread George P.
On Mon, 30 Dec 2002, Anand Ramakrishna wrote: > if (-e "newfile.txt") > { > print "WARNING !! FILE newfile.txt already exists\n"; > print "Do you want to destroy all the contents and overwrite the file\n"; > print "Type Y for Yes or N or NO\n"; > $test = ; >

Newbie question in Perl

2002-12-30 Thread Anand Ramakrishna
Hi, I am a beginner to perl. I have written a simple program in Perl # This Program will copy the contents of a file named file.txt to another file # newfile.txt. If newfile.txt is already existing, the user is given an option # to overwrite the file and chose a new file name to write the ou