Unix time
Hi all, Can some one please tell me how I would go about printing Unix time with Perl. I figured it would go something like this... $unixtime = localtime(); print $unixtime; Cheers, Daniel Falkenberg == VINTEK CONSULTING PTY LTD (ACN 088 825 209) Email: [EMAIL PROTECTED] WWW:http://www.vintek.net Tel:(08) 8523 5035 Fax:(08) 8523 2104 Snail: P.O. Box 312 Gawler SA 5118 == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Inserting into the middle of arrays
[EMAIL PROTECTED] wrote: > > What about... > > $old_pos = 1; > $new_pos = 1; > > while ($old_pos <= @old_array) { > if ($old_pos < $insert_pos) { > @new_array[$new_pos - 1] = @old_array[$old_pos - 1]; > $new_pos = $new_pos + 1; > } else { > @new_array[$new_pos - 1] = $insert_str; > $new_pos = $new_pos + 1; > @new_array[$new_pos - 1] = @old_array[$old_pos - 1]; > $new_pos = $new_pos + 1; > } > > $old_pos = $old_pos + 1; > } > It's right, but not the Perl Way, I believe. A simple problem like inserting into the middle of arrays should be less than 15 lines. Greetings, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Interesting TOP results
Hi all, I have just created a perl script that daemonizes itself and runs as a process in the background (Hence daemon :) ). I just ran a TOP on my server and noticed that the perl script uses 8.8% memory. and about 1% CPU. Now the script continually runs through a while loop. Before I try it would it be a good idea to have this while loop sleep for about 20 seconds (sleep 20;) and then have it run again. Would this place less strain on the server? Daemonize(); while (1) { #Do stuff and put lots of strain on my server } OR while (1) { #Do stuff but after this make the while loop sleep for 20 seconds sleep 20; } Would this make any difference. Or has any one done any thing like this b4? Kind regards, Daniel Falkenberg == VINTEK CONSULTING PTY LTD (ACN 088 825 209) Email: [EMAIL PROTECTED] WWW:http://www.vintek.net Tel:(08) 8523 5035 Fax:(08) 8523 2104 Snail: P.O. Box 312 Gawler SA 5118 == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: very basic regexp question
Great stuff. Regexp objects rock. It worked perfectly and helped with some other things too. Thanks a lot Jeff. CC >From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: claement claementson <[EMAIL PROTECTED]> >CC: [EMAIL PROTECTED] >Subject: Re: very basic regexp question >Date: Wed, 26 Sep 2001 22:54:33 -0400 (EDT) > >On Sep 27, claement claementson said: > > >1. I'm trying to pass a regexp in $bandNameRE through to a while loop, >but > >it keeps bailing complaining about an "unrecognised escpape \S", but when >I > >put the regexp directly into the condition it's happy. Why is this? > >That's because you're using a double-quoted string. Regexes are a >slightly different form of "string". If you use a string to hold a regex, >you'll need to use single quotes, or use backslashes in double quotes: > > $re = '\w+-\d+'; > # or > $re = "\\w+-\\d+"; > >You'd probably want double-quotes since you want to put a variable in the >regex. But there's another way... > > >2. The other thing is that $name could be upper or lower case. I know I >need > >to chuck \i into the regexp, which I assumed would be >(^$bandName\i)(\S)(.*) > >but quite clearly isn't. > >You can add the /i, /m, /s, and /x modifiers to a part of the regex by >using the (?i) construct: > > $re = '(this)((?i)that)'; # matches thisTHaT but not THISTHaT > >or the (?i:) construct, which does both grouping (not capturing) and sets >a modifier at the same time: > > $re = '(this)(?i:that)'; # like above > >But you want to use qr//. This creates a regex object. > > $re = qr/(^$name)(\S)(.*)/i; > >Ta da! Looks like a regex in action, kinda. And you can use it like so: > > if (/$re/) { ... } > >or > > if ($str =~ /$re/) { ... } > # or > # if ($str =~ $re) { ... } > >-- >Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ >RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ >** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** > > _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: very basic regexp question
On Sep 27, claement claementson said: >1. I'm trying to pass a regexp in $bandNameRE through to a while loop, but >it keeps bailing complaining about an "unrecognised escpape \S", but when I >put the regexp directly into the condition it's happy. Why is this? That's because you're using a double-quoted string. Regexes are a slightly different form of "string". If you use a string to hold a regex, you'll need to use single quotes, or use backslashes in double quotes: $re = '\w+-\d+'; # or $re = "\\w+-\\d+"; You'd probably want double-quotes since you want to put a variable in the regex. But there's another way... >2. The other thing is that $name could be upper or lower case. I know I need >to chuck \i into the regexp, which I assumed would be (^$bandName\i)(\S)(.*) >but quite clearly isn't. You can add the /i, /m, /s, and /x modifiers to a part of the regex by using the (?i) construct: $re = '(this)((?i)that)'; # matches thisTHaT but not THISTHaT or the (?i:) construct, which does both grouping (not capturing) and sets a modifier at the same time: $re = '(this)(?i:that)'; # like above But you want to use qr//. This creates a regex object. $re = qr/(^$name)(\S)(.*)/i; Ta da! Looks like a regex in action, kinda. And you can use it like so: if (/$re/) { ... } or if ($str =~ /$re/) { ... } # or # if ($str =~ $re) { ... } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Cookie and redirecting.
Dear Folks, I am currently working on cookies for tesing out. Although a lot of people had disabled the function on their browsers, I would just like to try it. I got few knotty problems : 1) I could set the cookie's parameters and retrieve it. But how I can make use of the returned parameters to realise the concept of cookie. 2) Upon detecting that the cookie is not valid using if statement, I would like to use the command in the CGI script to immediate load another URL page. I had tried the redirect command for cookie but could not help. E.g. if ($cookieID eq '12345') { #load new web page. } Thanks, Andrew Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Capturing STDOUT of system launched process
> "Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]> said: > Of course, all of these should have error-checking: > > $x = `...` or die "can't run ...: $!"; > > open OUTPUT, "... |" or die "can't run ...: $!"; Don't forget to check the close for errors. If the pipe fails for some reason close returns 0 and $? has the exit value. -- Smoot Carl-Mitchell Consultant -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
very basic regexp question
Hello again, This is so basic I'm embarrassed to ask. Sorry. 1. I'm trying to pass a regexp in $bandNameRE through to a while loop, but it keeps bailing complaining about an "unrecognised escpape \S", but when I put the regexp directly into the condition it's happy. Why is this? 2. The other thing is that $name could be upper or lower case. I know I need to chuck \i into the regexp, which I assumed would be (^$bandName\i)(\S)(.*) but quite clearly isn't. I think I need a new book. $name = ; chomp $name; $nameRE = "(^$name)(\S)(.*)"; while ($_ = readdir(LISTFILES)){ if (/$nameRE/){ #DO SOME STUFF } } Thanks in advance for your time. CC _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Capturing STDOUT of system launched process
On Sep 27, Matthew Blacklow said: >What I need to do is capture the screen output of this process into a string >variable so that it can latter be manipulaterd. ie. capture the STDOUT. Several options: # qx() and `` are the same $output = `prog arg1 arg2`; $output = qx(prog arg1 arg2); # get lines of output, not one lone string @output = `prog arg1 arg2`; @output = qx(prog arg1 arg2); # open a pipe, and go line-by-line open OUTPUT, "prog arg1 arg2 |"; while () { ... } close OUTPUT; # or get it all at once open OUTPUT, "prog arg1 arg2 |"; { local $/; # read all the content at once $output = ; } close OUTPUT; Of course, all of these should have error-checking: $x = `...` or die "can't run ...: $!"; open OUTPUT, "... |" or die "can't run ...: $!"; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Capturing STDOUT of system launched process
I am writing a script at the moment which among others things creates another process using the system call. What I need to do is capture the screen output of this process into a string variable so that it can latter be manipulaterd. ie. capture the STDOUT. Any help, suggestions or sample code would be appreciated. Thanks, Matthew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Inserting into the middle of arrays
In a message dated Mon, 24 Sep 2001 10:07:45 AM Eastern Daylight Time, "Pete Sergeant" <[EMAIL PROTECTED]> writes: > How do I insert $scalar into position $x of @array, where $x is smaller than > $#array? What about... #!/perl # Script: insert # Author: Nelson Fleet # Date: 09/26/2001 # Purpose: Insert scalar into an array print "Enter strings on separate lines to populate array with scalars\n"; print "CTRL-Z on new line to signal EOF\n"; chomp(@old_array = ); print "\n"; # Workaround for ActivePerl bug print "\nYour array: \n"; foreach $element (@old_array) { print $element . "\n"; } print "\n"; print "Enter a string to insert into array: "; chomp($insert_str = ); print "Enter position of insert: "; chomp($insert_pos = ); $old_pos = 1; $new_pos = 1; while ($old_pos <= @old_array) { if ($old_pos < $insert_pos) { @new_array[$new_pos - 1] = @old_array[$old_pos - 1]; $new_pos = $new_pos + 1; } else { @new_array[$new_pos - 1] = $insert_str; $new_pos = $new_pos + 1; @new_array[$new_pos - 1] = @old_array[$old_pos - 1]; $new_pos = $new_pos + 1; } $old_pos = $old_pos + 1; } print "\nYour array with inserted element: \n"; foreach $element (@new_array) { print $element . "\n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New Project, Design Thoughts appreciated
At 03:51 PM 9/26/01 -0400, Derrick (Thrawn01) wrote: >I've been the task of designing a remote maintenance system, for several > maybe hundreds ) of computers across a WAN. >It would preferably be a web application so multiple users can operate the >maintnce on several systems simultaneously. > >The problem I have is with running commands on the remote system. >Hoping to pool from the wealth of experience displayed on this List. >Does anyone have a suggestion as to how I could easily, ( WITH OUT TONS OF >CODING ) This may be a premature optimization that costs you dearly in the long run. Design it right to begin with. That may or may not involve what you consider to be a lot of coding, but you shouldn't shy away from the possibility that that would be the best way to do it. >Run command line programs on a remote computer, and get the output returned >to the calling Web app? I'd suggest SOAP myself, to minimize authentication issues. There's also Stem (http://www.stemsystems.com) which could be easier. >Via Telnet of some kind? >RPC ? ( I looked at RPC, but it seams I'd have to program a server app, with >a server running on each > Remote computer, Would this be difficult? Would Telnet be > practical ? ) > >I'm a novice perl programmer, but I've done some web apps with sql. using >DBI. Not any Server network type apps or >anything. > > >THANK's For any advice. > > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New Project, Design Thoughts appreciated
Hi Derrick, I would consider using Net::SSH::Perl, or XML-RPC (RPC::XML). I've had to do similar things, and have been happy with XML-RPC. You can have it run as a server, however, with some trickery, you can also have it 'embedded' in another server or script. I haven't personally used Net::SSH::Perl for anything more than trying it out, but it may be a viable option for you. I would suggest not using telnet, or even having it running. You also may want to consider if things need to be, or should be, encrypted. If so, the SSH, or SSL should be part of the puzzle. Cheers, Kevin On Wed, Sep 26, 2001 at 03:51:51PM -0400, Derrick (Thrawn01) ([EMAIL PROTECTED]) said something similar to: > I've been the task of designing a remote maintenance system, for several > maybe hundreds ) of computers across a WAN. > It would preferably be a web application so multiple users can operate the > maintnce on several systems simultaneously. -- [Writing CGI Applications with Perl - http://perlcgi-book.com] You drank beer, you played golf, you watched football - WE EVOLVED! -- Frank Zappa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting *nix file to dos
Thanks If anyone is interested, Robert's suggestion worked: $line =~ 's#\012#\015\012#g; Thanks so much Robert !!! > > one way (non perl) would be to get hd2u-0.7.1 from www.freshmeat.net > I am sure there is a perl way... > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: New Project, Design Thoughts appreciated
NO gui. Oh. sure I could telnet to all the remote systems, But that is what we are tring to avoid. I'd hate to telnet into 80+ systems just to preform a HD usage check. eh ? Thanks for the SSH thought I'll look into it. Also found a module File::Remote Looking into that. -Original Message- From: Bill Jones [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 26, 2001 4:07 PM To: Derrick (Thrawn01) Subject: Re: New Project, Design Thoughts appreciated On 9/26/01 3:51 PM, "Derrick (Thrawn01)" <[EMAIL PROTECTED]> wrote: > I've been the task of designing a remote maintenance system, for several > maybe hundreds ) of computers across a WAN. > It would preferably be a web application so multiple users can operate the > maintnce on several systems simultaneously. Not a Perl question, per se... SSH Tunnel. It works on both Unix and NT. BTW - Have you seen VNC? I used it to control an X Desktop from a PDA. HTH; -Sx- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting *nix file to dos
It is part of a perl module I am writing in UNIX. one of the methods in the module converts any file to dos text, html, or unix text. Thanks > > > No problem, are you writing on Windows or Unix? > > Either way, the code will be retained in the script - so long > as you don't > edit it with a Word-Processor... > > :) > -Sx- > > > On 9/26/01 4:11 PM, "Kipp, James" <[EMAIL PROTECTED]> wrote: > > > SOrry > > I should have stated I was looking for a perl way, not > involving calling > > external commands. > > > > Thanks > >>> rid of the hard return (^M) > > >> your current ^M > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting *nix file to dos
Thanks Robert I will give that a shot > -Original Message- > From: Robert Citek [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 4:13 PM > To: 'Kipp, James ' > Cc: '[EMAIL PROTECTED] ' > Subject: RE: Converting *nix file to dos > > > > Hello James, > > Here's a perl way that seems to work: > perl -ne 's#\012#\015\012#g; print' filename > > Regards, > - Robert > > -- > > At 03:02 PM 9/26/2001 -0500, Gibbs Tanton - tgibbs wrote: > >Many unix systems have both a dos2unix and unix2dos > command...you might try > >that. > > > >-Original Message- > >From: Kipp, James > > > >Hi > > > >When I bring win32 files over to Unix I use 'tr/\015//' on > the file to > >get rid of the hard return (^M). anyone know how to convert > it back the > >other way? I tried some sed commands but none seems to work. > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pad Number with Leading Zeros
On Wed, 26 Sep 2001, Schoeneman, Carl wrote: > Is there a way to pad a number with leading zeros with 1 command rather than > the 2 I used below? It looks like you're supposed to be able to zero-fill > with sprintf but I couldn't figure it out. $x = 1234; printf "%06d\n", $x prints 001234 -- Brett http://www.chapelperilous.net/ "I have to convince you, or at least snow you ..." -- Prof. Romas Aleliunas, CS 435 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting *nix file to dos
SOrry I should have stated I was looking for a perl way, not involving calling external commands. Thanks > -Original Message- > From: Bill Jones [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 4:10 PM > To: Gibbs Tanton - tgibbs; 'Kipp, James '; '[EMAIL PROTECTED] ' > Subject: Re: Converting *nix file to dos > > > On 9/26/01 4:02 PM, "Gibbs Tanton - tgibbs" > <[EMAIL PROTECTED]> wrote: > > > rid of the hard return (^M) > > > Of course, the easiest NON-Perl way, would be to use VI or > PICO to just save > your current ^M char in a file for safe keeping - like when > you need it > again. > > It's what I do; But some say I'm crazy... > > :) > -Sx- > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting *nix file to dos
Hello James, Here's a perl way that seems to work: perl -ne 's#\012#\015\012#g; print' filename Regards, - Robert -- At 03:02 PM 9/26/2001 -0500, Gibbs Tanton - tgibbs wrote: >Many unix systems have both a dos2unix and unix2dos command...you might try >that. > >-Original Message- >From: Kipp, James > >Hi > >When I bring win32 files over to Unix I use 'tr/\015//' on the file to >get rid of the hard return (^M). anyone know how to convert it back the >other way? I tried some sed commands but none seems to work. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: New Project, Design Thoughts appreciated
If one is in a Unix shop, this is very straightforward. Telnet would not be practical, that is for interactive connections. Something like the following could be called from the crawler. There are some security issues for you to think through here. !#/bin/perl $SCRIPT = "/home/joesmoe/somescript"; open(SYS,"$DIR/systems"); chomp $_; $HOST = $_; while(){ system("rsh $HOST $SCRIPT"); } Returns can be added on, but this is the basic idea. Caveat here is that rsh, or something similiar has to run, and you have to have a trusting login to use. SSH might be used. Without this, one has more (maybe a lot more) work to do. . Greg -Original Message- From: Derrick (Thrawn01) [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 26, 2001 3:52 PM To: Perl Beginners Subject: New Project, Design Thoughts appreciated I've been the task of designing a remote maintenance system, for several maybe hundreds ) of computers across a WAN. It would preferably be a web application so multiple users can operate the maintnce on several systems simultaneously. The problem I have is with running commands on the remote system. Hoping to pool from the wealth of experience displayed on this List. Does anyone have a suggestion as to how I could easily, ( WITH OUT TONS OF CODING ) Run command line programs on a remote computer, and get the output returned to the calling Web app? Via Telnet of some kind? RPC ? ( I looked at RPC, but it seams I'd have to program a server app, with a server running on each Remote computer, Would this be difficult? Would Telnet be practical ? ) I'm a novice perl programmer, but I've done some web apps with sql. using DBI. Not any Server network type apps or anything. THANK's For any advice. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting *nix file to dos
I am looking for a way in Perl to do it without calling external commands. This will part of a larger program. the tr/\015// works great for dos2unix, but I can't get the unix2dos to work correclty. > -Original Message- > From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 4:03 PM > To: 'Kipp, James '; '[EMAIL PROTECTED] ' > Subject: RE: Converting *nix file to dos > > > Many unix systems have both a dos2unix and unix2dos > command...you might try > that. > > -Original Message- > From: Kipp, James > To: [EMAIL PROTECTED] > Sent: 9/26/2001 2:54 PM > Subject: Converting *nix file to dos > > Hi > > When I bring win32 files over to Unix I use 'tr/\015//' on the file to > get > rid of the hard return (^M). anyone know how to convert it back the > other > way? > I tried some sed commands but none seems to work. > > Thanks > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Converting *nix file to dos
On 9/26/01 4:02 PM, "Gibbs Tanton - tgibbs" <[EMAIL PROTECTED]> wrote: > rid of the hard return (^M) Of course, the easiest NON-Perl way, would be to use VI or PICO to just save your current ^M char in a file for safe keeping - like when you need it again. It's what I do; But some say I'm crazy... :) -Sx- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Pad Number with Leading Zeros
Change %6s to %06s and it will pad with zeros. Wags ;) -Original Message- From: Schoeneman, Carl [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 26, 2001 12:40 To: Perl Beginners (E-mail) Subject: Pad Number with Leading Zeros Hello. Is there a way to pad a number with leading zeros with 1 command rather than the 2 I used below? It looks like you're supposed to be able to zero-fill with sprintf but I couldn't figure it out. #!/bin/perl -wd $f = 1234; $g = sprintf "%6s", $f; $g =~ s/ /0/g; print "$f\n"; print "$g\n"; ~Carl
Pad Number with Leading Zeros
Hello. Is there a way to pad a number with leading zeros with 1 command rather than the 2 I used below? It looks like you're supposed to be able to zero-fill with sprintf but I couldn't figure it out. #!/bin/perl -wd $f = 1234; $g = sprintf "%6s", $f; $g =~ s/ /0/g; print "$f\n"; print "$g\n"; ~Carl
RE: Converting *nix file to dos
Many unix systems have both a dos2unix and unix2dos command...you might try that. -Original Message- From: Kipp, James To: [EMAIL PROTECTED] Sent: 9/26/2001 2:54 PM Subject: Converting *nix file to dos Hi When I bring win32 files over to Unix I use 'tr/\015//' on the file to get rid of the hard return (^M). anyone know how to convert it back the other way? I tried some sed commands but none seems to work. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: New Project, Design Thoughts appreciated
> -Original Message- > From: Derrick (Thrawn01) [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 3:52 PM > To: Perl Beginners > Subject: New Project, Design Thoughts appreciated > > > I've been the task of designing a remote maintenance system, > for several > maybe hundreds ) of computers across a WAN. > It would preferably be a web application so multiple users > can operate the > maintnce on several systems simultaneously. > > The problem I have is with running commands on the remote system. > Hoping to pool from the wealth of experience displayed on this List. > Does anyone have a suggestion as to how I could easily, ( > WITH OUT TONS OF > CODING ) > Run command line programs on a remote computer, and get the > output returned > to the calling Web app? > > Via Telnet of some kind? > RPC ? ( I looked at RPC, but it seams I'd have to program a > server app, with > a server running on each > Remote computer, Would this be difficult? Would Telnet > be practical ? ) > > I'm a novice perl programmer, but I've done some web apps > with sql. using > DBI. Not any Server network type apps or > anything. Is this a Unix environment? I would investigate using Net::Rexec, available on CPAN. I use it for some simple things, and it's extremely easy to use. (Of course, the servers have to have rexec service enabled.) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Converting *nix file to dos
Hi When I bring win32 files over to Unix I use 'tr/\015//' on the file to get rid of the hard return (^M). anyone know how to convert it back the other way? I tried some sed commands but none seems to work. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
New Project, Design Thoughts appreciated
I've been the task of designing a remote maintenance system, for several maybe hundreds ) of computers across a WAN. It would preferably be a web application so multiple users can operate the maintnce on several systems simultaneously. The problem I have is with running commands on the remote system. Hoping to pool from the wealth of experience displayed on this List. Does anyone have a suggestion as to how I could easily, ( WITH OUT TONS OF CODING ) Run command line programs on a remote computer, and get the output returned to the calling Web app? Via Telnet of some kind? RPC ? ( I looked at RPC, but it seams I'd have to program a server app, with a server running on each Remote computer, Would this be difficult? Would Telnet be practical ? ) I'm a novice perl programmer, but I've done some web apps with sql. using DBI. Not any Server network type apps or anything. THANK's For any advice. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date comparing and difference?
On Sep 26, Bob Showalter said: >Is it your policy to eschew the use of such "non-standard" >modules? What do you do about DBI, say? There's nothing built-in that does what DBI does at anywhere near the speed, flexibility, and power. My date code works because it's built off a module that works (and is fast) and is rather simple code. >I can see the validity of preferring a "lightweight" module >over a "heavy" one such as Date::Manip, but I don't see the >point of distinguishing between "core" and "non-core" >modules. Date::Manip is KNOWN to be a big module. If it doesn't use Time::Local internally, I'd say it should. While I don't doubt that it does day difference via conversion to seconds, I've not looked at it to see HOW it derives the seconds. Time::Local uses a common method, and employs caching and other goodies. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date comparing and difference?
> -Original Message- > From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 2:39 PM > To: Bob Showalter > Cc: '[EMAIL PROTECTED]' > Subject: RE: Date comparing and difference? > > > On Sep 26, Bob Showalter said: > > >> use Time::Local; # for the timelocal() function > > > >How is it that Date::Calc and Date::Manip aren't "standard" > >modules? Because they aren't in the base distribution? > > Correct. Is it your policy to eschew the use of such "non-standard" modules? What do you do about DBI, say? I can see the validity of preferring a "lightweight" module over a "heavy" one such as Date::Manip, but I don't see the point of distinguishing between "core" and "non-core" modules. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date comparing and difference?
On Sep 26, Bob Showalter said: >> use Time::Local; # for the timelocal() function > >How is it that Date::Calc and Date::Manip aren't "standard" >modules? Because they aren't in the base distribution? Correct. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date comparing and difference?
> -Original Message- > From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 1:20 PM > To: John Grimes > Cc: [EMAIL PROTECTED] > Subject: Re: Date comparing and difference? > > ... > > I'm an advocate of using the STANDARD modules and a bit of > brains to do > this -- I don't need Date::Calc or Date::Manip. > > use Time::Local; # for the timelocal() function How is it that Date::Calc and Date::Manip aren't "standard" modules? Because they aren't in the base distribution? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Reusing same output line
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 26, 2001 12:05 PM > To: [EMAIL PROTECTED] > Subject: Reusing same output line > > > Is it possible when writing to the console with print to > continue using > the same line rather than have each message appear after the > previous one? > > Anyone is familiar with ncftp knows that the program shows > the up/download > status updating on the same line. I'm curious if the same thing is > possible with perl. Not really a perl issue at all. It's a function of the terminal driver. Typically you would send a carriage-return "\r" to move the cursor to the beginning of the current row instead of moving to a new row. print("$_\r"), sleep 1 for (1..5); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Looking for Info
Sorry to bother you guys with this completely unrelated subject but I have had no luck finding much needed information. Does anyone know of a good resource for RPC and NFS? I have been trying to mount to a remote filesystem but have had no luck. The information I found on linuxdoc.org was helpful but incomplete. I would really appreciate it if anyone can help out with info or a good resource. Again, sorry to bother you with this but I am getting desperate. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date comparing and difference?
John, Try Date::Simple very simple interface for calculations between two dates. use Date::Simple ('date', 'today'); # Difference in days between two dates: $diff = date('2001-08-27') - date('1977-10-05'); Jeffl On 2001.09.26 12:55 John Grimes wrote: > OK, this may seem rather simple, but I can't for the life of me find an > answer... > > Let's say I've got two dates. The current date, and a date in the past. > What's the scripting module that I'm going to need to compute the > difference > between the two dates? I've gone to perl.com, but nothing seems quite > exactly what I'm looking for... > > (If it's any help, the dates are in MM/DD/YYY format...) > > Thanks ahead of time for the patience with a total newbie, and any help > or > direction you can point me in... > > John > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date comparing and difference?
On Sep 26, John Grimes said: >Let's say I've got two dates. The current date, and a date in the past. >What's the scripting module that I'm going to need to compute the difference >between the two dates? I've gone to perl.com, but nothing seems quite >exactly what I'm looking for... I'm an advocate of using the STANDARD modules and a bit of brains to do this -- I don't need Date::Calc or Date::Manip. use Time::Local; # for the timelocal() function my $this = "11/09/1981"; # my birthday my $that = "04/03/1982"; # my girlfriend's birthday my $seconds_diff = date_to_sec($that) - date_to_sec($this); my $days_diff = int($seconds_diff / 86400); print "I am $days_diff days older than my girlfriend.\n"; sub date_to_sec { # split up date, and remove leading zeroes my ($mon, $day, $year) = map { s/^0+//; $_ } split '/', shift; # return the day at 12:00 noon return timelocal(0,0,12, $day, $mon - 1, $year - 1900); } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date comparing and difference?
Date-Manip is a fantastic date manipulation module. It's quite a bit slower than date-calc but, it offers a lot more flexibility. Ron -Original Message- From: John Grimes [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 26, 2001 11:55 AM To: [EMAIL PROTECTED] Subject: Date comparing and difference? OK, this may seem rather simple, but I can't for the life of me find an answer... Let's say I've got two dates. The current date, and a date in the past. What's the scripting module that I'm going to need to compute the difference between the two dates? I've gone to perl.com, but nothing seems quite exactly what I'm looking for... (If it's any help, the dates are in MM/DD/YYY format...) Thanks ahead of time for the patience with a total newbie, and any help or direction you can point me in... John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with Referenzes
same way you did with teh scalar: dereference it: %$hash_reference; there's a tutorial on this at http://japh.nu hope that helps Jos - Original Message - From: "Ulle Siedentop" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 26, 2001 3:30 PM Subject: Problems with Referenzes > I try to understand references in perl. > > $try = "test"; # Scalar $try conains value test > print $try; # prints test > > $try_ref = \$try; # Scalar $try_ref contains reference to > $try > print $try_ref; # prints SCALAR(0x1234567) > > print $$try_ref; # prints test > > Now I would like to do something similar with a hash. For > example: > > $name{"Jackson"} = "Michael"; # key = Jackson, value = > Michal > $name{"Wilder"} = "Billy"; # key = Wilder, value = Billy > print %name; # prints JacksonMichalWilderBilly > > $try_ref = \%name; # Scalar $try_ref contains reference to > hash %name > print $try_ref; # prints HASH(0x7654321); > > Now I don't know how or I don't understand how to get any > key or value back from the reference $try_ref??? > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Date comparing and difference?
OK, this may seem rather simple, but I can't for the life of me find an answer... Let's say I've got two dates. The current date, and a date in the past. What's the scripting module that I'm going to need to compute the difference between the two dates? I've gone to perl.com, but nothing seems quite exactly what I'm looking for... (If it's any help, the dates are in MM/DD/YYY format...) Thanks ahead of time for the patience with a total newbie, and any help or direction you can point me in... John
Windows drive mapping in perl
Recently I had a problem where I had to loop through a set of shares (actually NetWare servers and volumes), map a drive, execute a program (that requires a drive mapping, UNC will not work), delete the drive mapping. I could not find a way to map/unmap a drive in Perl. I ended up calling a batch file and passing server and volume to it. The batchfile then mapped the drive, called the program , and deleted the drive. I had to use the same basic system for another purpose and really would like to eliminate the batch file. Under the current setup, the success/failure of the program is not available, nor any other debugging info. Is there a call to map a drive for Windows in Perl ? I am using ActivePerl v5. Chris D. Garringer LAN/WAN Manager Master Certified Netware Engineer Microsoft Certified Systems Engineer Certified Solaris Administrator Red Hat Certified Engineer [EMAIL PROTECTED] fax 713-896-5266
Reusing same output line
Is it possible when writing to the console with print to continue using the same line rather than have each message appear after the previous one? Anyone is familiar with ncftp knows that the program shows the up/download status updating on the same line. I'm curious if the same thing is possible with perl. Thanks Greg
Re: Windows programming in Perl
On Tuesday 25 September 2001 05:01 pm, Gary Luther wrote: > I have just had an interesting problem brought into me by the Director of > CIS (Computer Information Systems). > > From an existing windows program the idea is to do some auxillary > processing of data that is retrieved from an imaging system. > > The thought was to add an item to one of the menus in the windows program > (written by a vendor) that would trigger(execute) a perl program that was > home grown(thats where I come in, a perl newbie). This program would pick > up the filename from a previously executed "Save As.." and do some rather > simplistic processing and then send the formatted output to the default > workstation printer. > > At this point I am not sure what, if any, interface needs to be presented > to the user. The question that presented itself was... "What > modules/routines, etc. are available to perlers to present decent user > interfaces in a windows environment. As this project is more in the > thinking phase than the planning phase, I am trying to mentally identify > resources and tools that would be available. > > Any ideas, suggestions, etc. would be greatly welcomed. Comments about my > mental faculties can be discarded. :-) > > TIA > > -- > - > "They that can give up essential liberty >to obtain a little temporary safety >deserve neither liberty nor safety." > > -- Benjamin Franklin > - > RGary Luther > RR RR SAF > RR RR UTABEGAS 2500 Broadway > RR RRHelena, MT 59602 > [EMAIL PROTECTED] > RR RR ULE !! > RR RR Visit our website at > RR RR http://www.safmt.org I have found that there are 2 options as far as a GUI for perl on Windows is concerned: 1. Perl/Tk (available from CPAN as Tk) 2. wxPerl (available from wxperl.org) Tk is a decent enough GUI, but wxPerl (which is a Perl port of wxWindows) provides a more Window(ish) feel to it, and provides a richer widget set. -- Michael D. Risser Software Engineer = Machine Vision Products, Inc. www.visionpro.com [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FW: rmdir
>From the faq list: 1.2 - How do I unsubscribe? Now, why would you want to do that? Send mail to <[EMAIL PROTECTED]>, and wait for a response. Once you reply to the response, you'll be unsubscribed. If that doesn't work, find the email address which you are subscribed from and send an email like the following (let's assume your email is [EMAIL PROTECTED]): <[EMAIL PROTECTED]> "Porter, Chris" wrote: > Please remove me from the mailing list. > > Thank you. > > Chris > > -Original Message- > From: Michael Fowler [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 27, 2001 5:27 PM > To: Me > Cc: Porter, Chris; [EMAIL PROTECTED] > Subject: Re: FW: rmdir > > On Wed, Jun 27, 2001 at 03:51:43PM -0500, Me wrote: > > Basically, you have to write a sub that does the > > following sort of thing (ignoring your wrinkle that > > you don't want to delete all the files in the initial > > directory): > > Or you could use File::Path::rmtree. I'm surprised no one has given this > answer yet. > > Michael > -- > Administrator www.shoebox.net > Programmer, System Administrator www.gallanttech.com > -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with Referenzes
On Sep 26, Ulle Siedentop said: > $try_ref = \%name; # Scalar $try_ref contains reference to >hash %name > print $try_ref; # prints HASH(0x7654321); > >Now I don't know how or I don't understand how to get any >key or value back from the reference $try_ref??? Read the 'perlref' documentation, and 'perlreftut' too (probably first). I wrote something for perl.com a year ago or so that you might find useful: http://www.pobox.com/~japhy/docs/using_refs In any case, here's a summary of what to do with references (to scalars, arrays, and hashes). Scalar references are dereferences with an extra '$': $x = \$y; print $$x; Array references are dereferenced (as a whole) with an extra '@': $x = \@y; print @$x; Individual elements can be accessed in many ways: $x = \@y; print $$x[0]; print $x->[1]; print @$x[2,3,4]; Braces can be used for readability (and precedence, too): $x = \@y; print ${$x}[0]; print @{$x}[2,3,4]; Hash references are dereferences (as a whole) with an extra '%': $x = \%y; print %$x; Individual elements can be accessed in many ways: $x = \%y; print $$x{jeff}; print $x->{jon}; print @$x{'jen','andrea'}; Braces can be used for readability (and precedence, too): $x = \%y; print ${$x}{jeff}; print @{$x}{'jen','andrea'}; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with Referenzes
On Wed, 26 Sep 2001, Ulle Siedentop wrote: > $try_ref = \$try; # Scalar $try_ref contains reference to > $try > print $try_ref; # prints SCALAR(0x1234567) > > print $$try_ref; # prints test Right... this last line is called 'dereferencing' -- getting the value referred to. > Now I would like to do something similar with a hash. For > example: > > $name{"Jackson"} = "Michael"; # key = Jackson, value = > Michal > $name{"Wilder"} = "Billy"; # key = Wilder, value = Billy > print %name; # prints JacksonMichalWilderBilly > > $try_ref = \%name; # Scalar $try_ref contains reference to > hash %name > print $try_ref; # prints HASH(0x7654321); Hashes an arrays also must be dereferenced. To dereference a scalar, above, you had to prepend it with $. The same works for hashes: print %$try_ref; That looks a little icky, so we usually make it look a little nicer: print %{$try_ref}; Note also to get the individual values out you would do something like: print $try_ref->{'Wilder'}; perldoc perlred will tell you a lot more on this topic. -- Brett http://www.chapelperilous.net/ Gravity brings me down. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problems with Referenzes
I try to understand references in perl. $try = "test"; # Scalar $try conains value test print $try; # prints test $try_ref = \$try; # Scalar $try_ref contains reference to $try print $try_ref; # prints SCALAR(0x1234567) print $$try_ref; # prints test Now I would like to do something similar with a hash. For example: $name{"Jackson"} = "Michael"; # key = Jackson, value = Michal $name{"Wilder"} = "Billy"; # key = Wilder, value = Billy print %name; # prints JacksonMichalWilderBilly $try_ref = \%name; # Scalar $try_ref contains reference to hash %name print $try_ref; # prints HASH(0x7654321); Now I don't know how or I don't understand how to get any key or value back from the reference $try_ref??? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to change the prompt in perl
>Is their any function is available Are you talking about your shell prompt? If that's the case, then that's a capability of the shell itself, and you'd want to look into the appropriate docs (for example, there's a Bash Prompt HOWTO). Technically, yes, you could use Perl to edit the relevant shell file to insert the configuration of your desire. That, however, is kinda innane. -- Morbus Iff ( i am your scary godmother ) http://www.disobey.com/ && http://www.gamegrene.com/ please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RTF to HTML or text conversion
Jonathan, Try AbiWord an open source cross-platform word processor: http://www.abiword.org/ Darlene Wallach Jos Boumans wrote: > > Jonathan Macpherson wrote: > > > > Hi; > > > > Im trying to write a perl script that will pull > > newspaper stories out of a sybase database and > > post them on the web. I can connect to sybase, > > pull stories, but they are in Rich Text Format. > > I would like to convert the RTF to text or html. > > Could anyone point me in the right direction ? > > > > Thanks > > jon > > -- > Do a search for 'RTF' on search.cpan.org > there are quite a few modules that are looking > interesting in regard to your problem.. perhaps > somebody already invented the wheel for you > > regards, > Jos > > -- How do I prove I am not crazy, to people who are? > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Darlene Wallach Lockheed Martin M&DS 3200 Zanker Road San Jose, CA 95134-1930 [EMAIL PROTECTED] phone (408)473-4178 fax (408)473-7278 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to change the prompt in perl
Is their any function is available
PPM Errors after update
I am running Windows 98, a rebuild of my machine after total failure. I found discrepancies between the modules that I had installed and what was showing in the on line docs. In an attempt to tidy up my configuration in PPM I ran verify --upgrade This seems to have broken PPM. It is reporting missing .pm files, which I found in my temp directory and copied into place by hand but now i get C:\WINDOWS>ppm HTML::Parser object version 3.19 does not match bootstrap parameter 3.13 at D:/P erl/lib/DynaLoader.pm line 225. Compilation failed in require at D:/Perl/site/lib/HTML/Entities.pm line 79. Compilation failed in require at D:/Perl/site/lib/HTML/HeadParser.pm line 70. BEGIN failed--compilation aborted at D:/Perl/site/lib/HTML/HeadParser.pm line 70 . Compilation failed in require at D:/Perl/site/lib/LWP/Protocol.pm line 47. Compilation failed in require at D:/Perl/site/lib/LWP/UserAgent.pm line 103. BEGIN failed--compilation aborted at D:/Perl/site/lib/LWP/UserAgent.pm line 103. Compilation failed in require at D:/Perl/site/lib/PPM.pm line 12. BEGIN failed--compilation aborted at D:/Perl/site/lib/PPM.pm line 12. Compilation failed in require at D:\PERL\BIN/ppm line 8. BEGIN failed--compilation aborted at D:\PERL\BIN/ppm line 8. Any suggestions how to proceed, other than delete D:\PERL and start again?? Rod CROWDER Mailto:[EMAIL PROTECTED] Tel: +44-1293-584145 Mob: +44-7711-553080 Fax: +44-1293-584994 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash
On Wed, 26 Sep 2001, walter valenti wrote: > There's a method for delete a element in a hash ??? > (for example in a hash contains 10 elements after deleting a element, it > shall contains 9 elements). Yes, it's called delete! :-) perldoc -f delete -- Brett http://www.chapelperilous.net/ First law of debate: Never argue with a fool. People might not know the difference. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: separating an array into sets of n elements
--On Dienstag, 25. September 2001 15:44 -0800 Michael Fowler <[EMAIL PROTECTED]> wrote: > It would? Your variables are off by one. Element 2 in @hitsarray is > 'the', not 'is'. $fieldnumber is set to 4, but you clearly have > groupings of 5 words: true; apologies for late night sloppiness. > > @hitsarray = qw( > this is the first hit > this is the second hit > this is the third hit > ); > > > Also, $fieldnumber seems to me misnamed; it should be a length, not a > number. > > So, given that, one solution is: > > $excerpt_len = 5; > $search_pos = 1; > > @hitsarray = qw( > this is the first hit > this is the second hit > this is the third hit > ); > > for (my $i = 0; $i < @hitsarray; $i += $excerpt_len) { > my $val = $hitsarray[$i + $search_pos]; > > for (my $j = $i + $excerpt_len; $j < @hitsarray; $j += > $excerpt_len) { if ($hitsarray[$j + $search_pos] eq $val) { > print( > "Match! ", > "\"@hitsarray[$i .. $i + $excerpt_len - 1]\" and ", > "\"@hitsarray[$j .. $j + $excerpt_len - 1]\"\n", > ); > } > } > } > > See? It's a simple matter of math, using indices rather than manually > splitting up the array. Thank you very much for the code. The reason why I thought to manually split up the array was that I then want to print out elements of @hits WITHOUT printing those instances where there's such a duplicate. I don't know, whether, and if so, how this could be done just using indices. This is for a CGI script that I am using to search flatfile databases and that prints out results in HTML. I don't want to do such a "selective duplicate check" whenever a search takes place, but only when a particular name-value-pair is present in the query-string. Therefore I thought to code a subroutine: sub view_success { my @hits = @_; if ($in{'duplicate_check'}) { my @hits = &duplicate_check(@hits); } # print out @hits } > Given the oddity of this request, and the previous request, what is it > this whole thing is intended to accomplish? As the above might have revealed, I am trying to add new facilities to a script that already exists. The presumably odd nature of my queries results from the fact that I am trying to operate within the restrictions presented by already extant code. I don't have enough confidence in my perl skills yet to rewrite the script on a larger scale. At present I am therefore trying to solve problems on a "micro-scale", finding answers to "how can I process sets of n elements of an array" rather than "how can I carry out a search operation and check for duplicate values in one particular field". I am taking note of simpler large-scale approaches for eventual future re-coding of the entire script, so your suggestsion to pass array references rather than arrays has been duly taken note of. But I cannot implement it at the present stage, due to competence and also time restrictions. Birgit Kellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hash
Hi, There's a method for delete a element in a hash ??? (for example in a hash contains 10 elements after deleting a element, it shall contains 9 elements). Thanks Walter èbj(ër¢êßç²j(ruÚÞ²ÆÛiÿù\¢
RE: FW: rmdir
Please remove me from the mailing list. Thank you. Chris -Original Message- From: Michael Fowler [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 5:27 PM To: Me Cc: Porter, Chris; [EMAIL PROTECTED] Subject: Re: FW: rmdir On Wed, Jun 27, 2001 at 03:51:43PM -0500, Me wrote: > Basically, you have to write a sub that does the > following sort of thing (ignoring your wrinkle that > you don't want to delete all the files in the initial > directory): Or you could use File::Path::rmtree. I'm surprised no one has given this answer yet. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --
Re:dynamic Progress bar
Hi I would like to make a dynamic Progress bar which could grow up with the number of string ftpd received in a log file.Each square means that a ftpd arrived on the log file. How can I do this? My code is: open INFILE, "< $_Globals{SYSLOG}" or die "Cannot open $_Globals{SYSLOG} for reading: $!"; while () { chomp(); /ftpd/ && do { #i.e ftpd $_Globals{PROGRESS_VALUE} += 10; $_Globals{PROGRESS_STRING} = "FTPD"; }; my $pb = $_Globals{TOP_WINDOW}->ProgressBar(-bd => 3, -relief => "sunken", -fg => "green", -width => 40, -length => 300, -variable => \$_Globals{PROGRESS_VALUE}, -colors => [0, "green", 40, "orange", 50, "red"] ) ->pack(-side => "left",-anchor => "w"); $pb->Scale(-from => 0, -to => 150); Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::FTP module
If you use Debian Linux there's tha packege .deb, and you can install with dselect. Otherwise look for in CPAN. Walter Sofia wrote: > >From where can I download the Net::FTP module? > > Thanks in advance > > __ > Do You Yahoo!? > Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. >http://im.yahoo.com > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] èbj(ër¢êßç²j(ruÚÞ²ÆÛiÿù\¢
Re: Please solve the problem
At 07:14 AM 09/25/2001 -0700, parvatam jagannadh rao wrote: >Hi > > >I want to call a system command (linuxconf module >dnsconf) to pass parameters to console but i am unable >to do from a cgi program. if i execute from console >it is working fine. The reason why it wont work via CGI is because the webserver runs as a non-privledged user, and linuxconf requires root privs. Whatever you're trying to do sounds rather dangerous. If you are intent on doing system administration via a web-browser, I would recommend you take a look at the "Webmin" package instead of trying to re-invent this particular wheel. I personally dont use Webmin, cause it still freaks me out to be doing root-level configurations using a webbrowser, unless you restrict access only to localhost. HTH, Aloha, mel -- mel matsuokaHawaiian Image Productions Chief Executive Alphageek (vox)1.808.531.5474 [EMAIL PROTECTED] (fax)1.808.526.4040 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: printing out yesterdays date
At 12:45 PM 09/26/2001 +0530, Rahul Garg wrote: >is there any command in linux to get yesterdays date -mm/dd/yy > >or can a program be written for it in perl...any suggestions One way to do it is to get the time(), subtract 86400 from it, then feed the result to localtime(). Or you could just use Date::Calc, but thats just not as fun ;) Aloha, mel -- mel matsuokaHawaiian Image Productions Chief Executive Alphageek (vox)1.808.531.5474 [EMAIL PROTECTED] (fax)1.808.526.4040 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re:Win32::EventLog and Open issue
HI, folks I am under NT and my problem is that my file cygwin_syslog.txt is always growing with the same informations that is boring.If I append with open(LOGFILE >...) the file is always destroyed and I have only one information and I want the whole logs informations I want to use open(LOGFILE >>...) I have this code : open (READ,"$_Globals{TIME}")or die "Can't open READ: $!\n"; $timewritten = ; close (READ) or die "Can't close READ: $!\n"; $x = 0; $handle=Win32::EventLog->new("Application") or die "Can't open Application EventLog\n"; $handle->GetNumber($recs) or die "Can't get number of EventLog records\n"; print "No. of records = $recs\n"; $handle->GetOldest($base) or die "Can't get number of oldest EventLog record\n"; print "Oldest record is record no. $base\n"; #POur écrire à la suite du fichier les infos de log mais bug fait grandir le fichier # To append: open (LOGFILE,">>C:\\cygwin_syslog.txt") or die "Can't open LOGFILE: $!\n"; # Or to overwrite (in which case you don't have to create the file). #mais détruit les infos ultérieures génants. #open (LOGFILE,">$_Globals{SYSLOG}") or die "Can't open LOGFILE: $!\n"; my $time; foreach (0 .. $recs - 1) { $handle->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ, $base + $_, $hashRef) or die "Can't read EventLog entry #$x\n"; my %deref; %deref = %$hashRef; # Next line is new # next if ($timewritten > $deref{TimeGenerated}); foreach (qw{Cygwin dhcpd ftpd}) { if ($deref{Source} eq $_) { print LOGFILE "$deref{TimeGenerated}: $deref{Strings} ($_)\n"; } } # Next 2 lines are new # $time = $deref{TimeGenerated} if ($time < $deref{TimeGenerated}); } close (LOGFILE) or die "Can't close LOGFILE: $!\n"; # Next 3 lines are new # open (WRITE, ">$_Globals{TIME}") or die "Can't open WRITE: $!\n"; print WRITE $time; close (WRITE) or die "Can't close WRITE: $!\n"; 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success 1001423509:44CGMB0114.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat: success -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]