make CPAN::Shell->i; print to a filehandle
How do I go about making the output from CPAN::Shell->i; go into a file handle Instead of STDOUT like it does in this formulation: $target = "somefile"; if($opt_r){ open(FH,">$target") or die "Cannot open $target: $!"; print FH CPAN::Shell->i; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Always on Top.. TK
Voodoo Raja wrote: > Hi all.. > > Just a quick one.. > > Is it possible to force my TK application to on top of all the windows that > are present on the screen.. or rather set the window to be always visible > ... Possibly with bad [ie Win 9x] operating systems. On better operating systems there are full-screen display modes, vut there are also always ways to get around any program and bring others to the front.. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hmm....is a hot directory possible?
david <[EMAIL PROTECTED]> writes: >> This is not what the OP asked. But I wondered if one can determine >> if a file has been writen to or changed inside a directory by looking >> at a stat on the directory. > > if i am not dreaming, OP asks for whether there is new files adding to the Maybe why I said `This is not what the OP asked...' .. hehe. Thanks for the other tips about the cache stuff and loop speed. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Why "Global symbol require explicit package name"
Babale Fongo wrote: > > Hello guy! Hello, > I would like to know why I need to declare global variables with "my". So that they won't be global. Using global variables is not bad per se, however most professional programmers try to avoid using them. > My script looks something like thing: > Use strict; > $strg = "A string"; > $strg2 = "a second string"; > > I get a warning: > "Global symbol require explicit package name." The warning is telling you to add the package name to the variable which in this case is probably main. use strict; $main::strg = 'A string'; $main::strg2 = 'a second string'; Which can be shortened to: use strict; $::strg = 'A string'; $::strg2 = 'a second string'; > unless I declare the variables like: > my $strg = "A string"; > my $strg2 = "a second string"; Perhaps this article may help you understand. http://perl.plover.com/FAQs/Namespaces.html John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hmm....is a hot directory possible?
Harry Putnam wrote: > david <[EMAIL PROTECTED]> writes: > >> >> you could take a look at the stat function provided by Perl to see if the >> directory's last modified time or inode change time changed: > > This is not what the OP asked. But I wondered if one can determine > if a file has been writen to or changed inside a directory by looking > at a stat on the directory. if i am not dreaming, OP asks for whether there is new files adding to the directory, not that if a file change inside a directory. yes, both mtime and inctime reflect that and stat report that as well if new files are added or delete. no, stat won't report that if a file only changes. that has very little to do with the parent directory. > > File changes don't seem to be reflected in mtime, unless a new file > is added or one taken away. Ditto for atime and ctime. correct. OP doesn't care about file change (again, if i am not dreaming). only additon and deletion from the directory. > > So is stat not able to determine if a file has been written to by > looking at the parent dir? not sure what you mean but: #-- #-- stat report mtime and inctime change in /tmp for the first touch but not #-- the second because it only touches it. #-- rm -f /tmp/file touch /tmp/file touch /tmp/file the various posters' comment on hooking is your best bet if your OS supports it. otherwise a combination of cache/compare/mtime is needed because: touch /tmp/file rm -f /tmp/file touch /tmp/file rm -f /tmp/file fakes the cache/compare method by not seeing the file as they come-and-go. the tricky part is you have to do the checking really fast to make the algr. reliable. otherwise, the race condition thingy is going to get you. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Why "Global symbol require explicit package name"
perldoc strict look at 'use strict vars' in particular. George On Friday, June 27, 2003, at 08:51 PM, Babale Fongo wrote: Hello guy! I would like to know why I need to declare global variables with "my". My script looks something like thing: Use strict; $strg = "A string"; $strg2 = "a second string"; I get a warning: "Global symbol require explicit package name." unless I declare the variables like: my $strg = "A string"; my $strg2 = "a second string"; Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- George Schlossnagle -- Principal Consultant -- OmniTI Computer Consulting, Inc. -- +1.410.872.4910 x202 -- 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Why "Global symbol require explicit package name"
Hello guy! I would like to know why I need to declare global variables with "my". My script looks something like thing: Use strict; $strg = "A string"; $strg2 = "a second string"; I get a warning: "Global symbol require explicit package name." unless I declare the variables like: my $strg = "A string"; my $strg2 = "a second string"; Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: checking OS support for flock
[EMAIL PROTECTED] wrote: I'm learning on a win98 machine and my webserver is a unix OS. win98 doesn't support flock and of course unix does. How can I code to test if the function is supported? I tried conditionals but it still throws the error. What conditionals did you try? Some common code (stolen from DBI::File): my $locking = $^O ne 'MacOS' && ($^O ne 'MSWin32' || !Win32::IsWin95()) && $^O ne 'VMS'; if ($locking) { # do locking here } Or the other option if flock is calling 'die' is to wrap the construct in an eval and catch the exception, and examine [EMAIL PROTECTED] perldoc -f eval http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hmm....is a hot directory possible?
Gary Stainburn wrote: On Thursday 26 Jun 2003 10:38 pm, Jenda Krynicky wrote: From: Chris Zimmerman <[EMAIL PROTECTED]> Is there some way that I can write a bit of code that will watch a directory and as soon as a file is written to that directory, something is run against that file? What would be the best way to turn this into a daemon? Depends on the OS. Under windows it'd be Win32::ChangeNotify and Win32::Daemon(::Simple)? I know a while back (12 months?) a talk was given at our local LUG - http://www.wylug.org.uk - about hooks being placed in the Linux kernel so that user mode processed could register an interest in a file or directory and would receive a SIG if any change occured. FAM provides something similar and I believe uses hooks in the linux kernel on that system and other means on other *nixes. There even exists a Perl module to hook into it (SGI::FAM) good luck getting it to work though, I have had some problems in the recent past as have other posters. If someone is looking for a non-blocking way to detect new files or changes to files, etc. and doesn't mind a somewhat steep learning curve I would suggest POE, and possibly its pre-built PoCo::DirWatch component. The OP should see my posts here for somewhat on the subject: http://nntp.x.perl.org/group/perl.beginners/44639 http://nntp.x.perl.org/group/perl.beginners/44673 I would also suggest using MD5 or SHA1 hashing or something similar to detect true changes to a file, mtime can be faked, and checking a directory mtime on an interval may not lead to any reliable way to determine if the contents of said directory has changed. Combining the hash caching manner suggested previously with using a checksum hash of the files in the directory should give better results in detecting individual file changes. http://danconia.org The idea was so that progs like 'top' could become much more efficient by sleeping instead of polling, but I don't know how far along this is, or whether anyone's written a perl module for it yet. Gary Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Linux, Perl, [open,star]office
I've found these modules work well for creating excel spreadsheets. Spreadsheet::ParseExcel Spreadsheet::WriteExcel I recently wrote a script that converts csv files into worksheets in a workbook. Makes it easier for a client to review their different reports. Tom On Fri, Jun 27, 2003 at 11:55:56AM -0400, Paul Kraus wrote: > I have a windows app that reads a bunch of text files and then using > Win32::OLE it inserts that data into an excel spreadsheet. Is there > something similar I can do with an open office document in Linux? > > I am trying to switch my workstation over to all Linux but need to be > able to generate the same reports that I then send to my boss. Which has > to be an excel file. Which open office is able to open/write/create. > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Always on Top.. TK
Hi all.. Just a quick one.. Is it possible to force my TK application to on top of all the windows that are present on the screen.. or rather set the window to be always visible ... best regards Sam _ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple question on splice
Sitha Nhok wrote: > Hi, if I have a multidimensional array like : > > @AoA = ( > ["ABC", "BCD"], > ["CDE", "DEF"], > ["EFG", "FGH"], > ); > > > then do: > > @var = splice @AoA, 2, 1; # to delete the last row > > print @var; #print what was returned from splice > > > > The print statement prints an address. I like it to print the contents > that was removed. How do I do that? Hi Sitha. As Rob Anderson points out, @AoA is an array of array references, not an inherently two-dimensional array. However it may be worh pointing out that @var = splice @AoA, 2, 1; is, as you say, removing the last element of @AoA and returning it. This is the same as @var = pop @AoA but this will give you a new array with one element that looks like @var = ( ["EFG", "FGH"], ); What you may want is to dereference this before you assign it to the array like this my @var = @{pop @AoA}; which leaves @var = ( "EFG", "FGH" ); so you can say print "@var\n"; getting EFG FGH as output. I hope this helps. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple question on splice
Sitha Nhok wrote: > Hi, if I have a multidimensional array like : > > @AoA = ( > ["ABC", "BCD"], > ["CDE", "DEF"], > ["EFG", "FGH"], > ); > > > then do: > > @var = splice @AoA, 2, 1; # to delete the last row > > print @var; #print what was returned from splice > > > > The print statement prints an address. I like it to print the contents > that was removed. How do I do that? Hi Sitha. As Rob Anderson points out, @AoA is an array of array references, not an inherently two-dimensional array. However it may be worh pointing out that @var = splice @AoA, 2, 1; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Socket question
> -Original Message- > From: Gabor Urban [mailto:[EMAIL PROTECTED] > Sent: Friday, June 27, 2003 6:13 AM > To: [EMAIL PROTECTED] > Subject: Socket question > > > Hi, > > I am still working on a socket problem at low level, and there is > something I wander. Are Perl socket bidirectional? I am currently work > to test an Apache module, that processes HTTP POST requests. I thought > at the beginning, that a Perl script would do perfect for me. > > Code fragment: > > send SOCK, "$lines\n",MSG_OOB ; > > > $res = recv SOCK, $line,1024,MSG_OOB ; > while ( defined($res) ) > { > print $line ; > $res = recv SOCK, $line,1024,MSG_OOB ; > } > > print "Closed\n" ; > close SOCK ; > > So, the request is sent correctly, I could verify from the acces-log, > and it is processed properly by the module· It seems, the script > closes down before anything is recevied from Apache. > > The socket was opened by the following code: > > socket(SOCK, PF_INET, SOCK_STREAM, $proto)|| die > "socket: $!"; > connect(SOCK, $paddr)|| die "connect: $!"; > > print "Host reached\n-\n" ; > > I would appreciate any idea. I believe all you do is something like: $ret = ; which reads a line from the socket. -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Linux, Perl, [open,star]office
I have a windows app that reads a bunch of text files and then using Win32::OLE it inserts that data into an excel spreadsheet. Is there something similar I can do with an open office document in Linux? I am trying to switch my workstation over to all Linux but need to be able to generate the same reports that I then send to my boss. Which has to be an excel file. Which open office is able to open/write/create. Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple question on splice
"Rob Anderson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Sitha Nhok" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi, if I have a multidimensional array like : > > > > @AoA = ( > > ["ABC", "BCD"], > > ["CDE", "DEF"], > > ["EFG", "FGH"], > > ); > > > > > > then do: > > > > @var = splice @AoA, 2, 1; # to delete the last row > > > > print @var; #print what was returned from splice > > > > > > > > The print statement prints an address. I like it to print the contents > > that was removed. How do I do that? > > > > Just to make sure you understand, when you create an array of arrays like > this, your actually creating one top level array (ie @AoA) each element of > which is a reference to an anonymous (created by your ["ABC... declaration). > > What you're printing is the reference removed from the top level array. So > you need to dereference it, perhaps like this... > > my $inner_array_ref = $var[0]; > print @$inner_array_ref; > > This is long winded, but explains what's going on. We take the first element > of the array (which we assume exists) and then print it out, put deferencing > it to an array by prefixing it with a @. > > You could also do this... > > my $inner_array_ref = $var[0]; > print $$inner_array_ref[1]; > > Which will print the second element from the inner array. > > You'd be well advised to read up on references, and de-referencing stuff. of course, it would have been helpful to let you know the easy way into your array, which is just... print $var[0][1]; which does your deferencing for you, but where's the fun in that? > > HTH > > Rob Anderson > > > ~Sitha > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple question on splice
"Sitha Nhok" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, if I have a multidimensional array like : > > @AoA = ( > ["ABC", "BCD"], > ["CDE", "DEF"], > ["EFG", "FGH"], > ); > > > then do: > > @var = splice @AoA, 2, 1; # to delete the last row > > print @var; #print what was returned from splice > > > > The print statement prints an address. I like it to print the contents > that was removed. How do I do that? > Just to make sure you understand, when you create an array of arrays like this, your actually creating one top level array (ie @AoA) each element of which is a reference to an anonymous (created by your ["ABC... declaration). What you're printing is the reference removed from the top level array. So you need to dereference it, perhaps like this... my $inner_array_ref = $var[0]; print @$inner_array_ref; This is long winded, but explains what's going on. We take the first element of the array (which we assume exists) and then print it out, put deferencing it to an array by prefixing it with a @. You could also do this... my $inner_array_ref = $var[0]; print $$inner_array_ref[1]; Which will print the second element from the inner array. You'd be well advised to read up on references, and de-referencing stuff. HTH Rob Anderson > ~Sitha > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using whence
Excellent. That explains why the pipe made it work. Thanks! - DAP > -Original Message- > From: Jeff Westman [mailto:[EMAIL PROTECTED] > Sent: Friday, June 27, 2003 11:04 AM > To: beginners > Subject: Re: using whence > > > > David Parker wrote: > > > Hi. I have a perl script that calls various programs. I > would like to be > > able to verify that a given program is being called from > the right place - > > what I would use "whence" for in the korn shell. > > > > > > I tried > > > > > >$path = `whence $cmdname`; > > > > > > but I don't get anything in $path. I'm undoubtedly > missing something - > > I'm a beginner! > > > > > > Thanks in advance for any clues > > > > There's no 'whence' command in ksh that I know of... I > think you want > > 'which' > > > > -- Brett > > > http://www.chapelperilous.net/ > > I recently asked this question myself on another "builtin" > ksh command. > Steve, a regular contributer to this list told me the reason > why my 'set' > would not work: > > === begin cut == > Actually, the shell isn't involved at all. Since there are no shell > metacharacters in the string "set", perl tries to exec "set" directly, > using the C library function execvp(), which uses $PATH. > > $ strace -f perl -e 'qx(set)' 2>&1 |grep exec > execve("/usr/bin/perl", ["perl", "-e", "qx(set)"], [/* 22 > vars */]) = 0 > [pid 10527] execve("/bin/set", ["set"], [/* 22 vars */]) > = -1 ENOENT > [pid 10527] execve("/usr/bin/set", ["set"], [/* 22 vars > */]) = -1 ENOENT > [pid 10527] execve("/usr/X11R6/bin/set", ["set"], [/* 22 > vars */]) = -1 > ENOENT > [pid 10527] execve("/opt/bin/set", ["set"], [/* 22 vars > */]) = -1 ENOENT > > If you add a shell metacharacter, then perl will use the shell: > > $ strace -f perl -e 'qx(set;)' 2>&1 |grep exec > execve("/usr/bin/perl", ["perl", "-e", "qx(set;)"], [/* > 22 vars */]) = 0 > [pid 10594] execve("/bin/sh", ["sh", "-c", "set;"], [/* > 22 vars */]) = 0 > > The same thing goes for system(), which is where this subtlety > is documented. > > $ perldoc -f system > === end cut > > So, in order to force the shell to be called using a builtin > such as "whence" > or "set", simply add a ';' to the end of your string: > > #!/bin/perl > use strict; > use warnings; > my $cmdname = "date"; > my $path = `whence $cmdname;`; # note the embedded ';' > print "path - $path\n"; > > And BTW, "which" checks your path only... "whence" checks the > to see if the > command is a builtin, a function, an alias (and finally) the > path. "which" > only checks the path > > -Jeff > > __ > Do you Yahoo!? > SBC Yahoo! DSL - Now only $29.95 per month! > http://sbc.yahoo.com > > -- > 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: using whence
> David Parker wrote: > > Hi. I have a perl script that calls various programs. I would like to be > able to verify that a given program is being called from the right place - > what I would use "whence" for in the korn shell. > > > > I tried > > > >$path = `whence $cmdname`; > > > > but I don't get anything in $path. I'm undoubtedly missing something - > I'm a beginner! > > > > Thanks in advance for any clues > > There's no 'whence' command in ksh that I know of... I think you want > 'which' > > -- Brett >http://www.chapelperilous.net/ I recently asked this question myself on another "builtin" ksh command. Steve, a regular contributer to this list told me the reason why my 'set' would not work: === begin cut == Actually, the shell isn't involved at all. Since there are no shell metacharacters in the string "set", perl tries to exec "set" directly, using the C library function execvp(), which uses $PATH. $ strace -f perl -e 'qx(set)' 2>&1 |grep exec execve("/usr/bin/perl", ["perl", "-e", "qx(set)"], [/* 22 vars */]) = 0 [pid 10527] execve("/bin/set", ["set"], [/* 22 vars */]) = -1 ENOENT [pid 10527] execve("/usr/bin/set", ["set"], [/* 22 vars */]) = -1 ENOENT [pid 10527] execve("/usr/X11R6/bin/set", ["set"], [/* 22 vars */]) = -1 ENOENT [pid 10527] execve("/opt/bin/set", ["set"], [/* 22 vars */]) = -1 ENOENT If you add a shell metacharacter, then perl will use the shell: $ strace -f perl -e 'qx(set;)' 2>&1 |grep exec execve("/usr/bin/perl", ["perl", "-e", "qx(set;)"], [/* 22 vars */]) = 0 [pid 10594] execve("/bin/sh", ["sh", "-c", "set;"], [/* 22 vars */]) = 0 The same thing goes for system(), which is where this subtlety is documented. $ perldoc -f system === end cut So, in order to force the shell to be called using a builtin such as "whence" or "set", simply add a ';' to the end of your string: #!/bin/perl use strict; use warnings; my $cmdname = "date"; my $path = `whence $cmdname;`; # note the embedded ';' print "path - $path\n"; And BTW, "which" checks your path only... "whence" checks the to see if the command is a builtin, a function, an alias (and finally) the path. "which" only checks the path -Jeff __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl help ftp
Hi, In article <[EMAIL PROTECTED]>, Vemulakonda Uday Bhaskar wrote: > hi all > > can anyone tell me from where i can download Net::FTP from > www.cpan.org > > with regards > uday bhaskar (Your messages are being sent twice for some reason) After you've found the module, near the top of the page is a link called "Source" - click on it. Still I prefer using (from the command line) "perl -MCPAN -e shell" (do a Google search of this newsgroup for more details). -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: help perl ftp
when you see the outcome of your search for Net::FTP on search.cpan.org you see something like : Net::FTP FTP Client Class perl-5.8.0 - Date - author Net::FTP FTP Client Class libnet-1.16 - Date - author DON'T click on Net::FTP, that is where you're finding the **theorotical explanation** click on perl-5.8.0 \ libnet-1.16 placed directly below it and you'll be transferred to the download page. -Original Message- From: vemulakonda uday bhaskar [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 6:05 PM To: [EMAIL PROTECTED] Subject: help perl ftp Hi AALL thoughi searched http://search.cpan.org/, i couldnot get the p[lace from where i can download NEt::FTP. I on;y got is a theorotical explanation of Net::FTP please help me in this regads with regards uday bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- 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: Count Function?
Hi Paul, In article <[EMAIL PROTECTED]>, Paul Johnson wrote: > > Kevin Pfeiffer said: [...] >> But what I can't figure out (and have tried several variants) is how to >> get the count when using a variable (ala' from inside an eval). This is >> the closet I got: >> >> my $sentence = "Here is my test sentence.\n"; >> my $letter = 'e'; >> my $count; >> >> eval {$count = $sentence =~ tr/$letter//}; >> die $@ if $@; >> >> print "The letter $letter appears $count times in the sentence..."; >> >> It produces "The letter e appears 10 times..." but the answer should be >> "6". >> :-( > > You didn't follow the example - you changed the quotes for the eval. > > You need this: > > eval "\$count = \$sentence =~ tr/$letter//"; > > or even better: > > $count = eval "\$sentence =~ tr/$letter//"; mumble, mumble... :-) I did try the example first, exactly has given in perlop, but it didn't work. What I didn't try was the escape you use before the string symbol. > Read up on the two different types of eval, then you should be able to > find out why you got 10. Will do! It sounds like this might be a case of not having read far enough (and I distantly remember having once read about two types of eval, but it apparently hasn't sunken in, yet). Thanks for the tips. -K -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Simple question on splice
Hi, if I have a multidimensional array like : @AoA = ( ["ABC", "BCD"], ["CDE", "DEF"], ["EFG", "FGH"], ); then do: @var = splice @AoA, 2, 1; # to delete the last row print @var; #print what was returned from splice The print statement prints an address. I like it to print the contents that was removed. How do I do that? ~Sitha
checking OS support for flock
I'm learning on a win98 machine and my webserver is a unix OS. win98 doesn't support flock and of course unix does. How can I code to test if the function is supported? I tried conditionals but it still throws the error.
Re: Count Function?
Kevin Pfeiffer said: > Thanks to Sudarshan & Janek! > > I found this as suggested... > > # NOTE: (from perlop) > # Because the transliteration table is built at com > # pile time, neither the SEARCHLIST nor the REPLACE > # MENTLIST are subjected to double quote interpola > # tion. That means that if you want to use vari > # ables, you must use an eval(): > # > # eval "tr/$oldlist/$newlist/"; > # die $@ if $@; > # > # eval "tr/$oldlist/$newlist/, 1" or die $@; > > But what I can't figure out (and have tried several variants) is how to > get the count when using a variable (ala' from inside an eval). This is the > closet I got: > > my $sentence = "Here is my test sentence.\n"; > my $letter = 'e'; > my $count; > > eval {$count = $sentence =~ tr/$letter//}; > die $@ if $@; > > print "The letter $letter appears $count times in the sentence..."; > > It produces "The letter e appears 10 times..." but the answer should be > "6". > :-( You didn't follow the example - you changed the quotes for the eval. You need this: eval "\$count = \$sentence =~ tr/$letter//"; or even better: $count = eval "\$sentence =~ tr/$letter//"; Read up on the two different types of eval, then you should be able to find out why you got 10. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: help perl ftp
-Original Message- ... >>>thoughi searched http://search.cpan.org/, i couldnot get the >>>p[lace from where i can download NEt::FTP. I on;y got is a >>>theorotical explanation of Net::FTP ... Try http://search.cpan.org/, then search for Net::FTP, choice the second one in the list, click (LMB) on libnet-1.16, click on Download button near "This release" ... Save this file to disk ... E. CONFIDENTIALITY NOTICE This message and its attachments are addressed solely to the persons above and may contain confidential information. If you have received the message in error, be informed that any use of the content hereof is prohibited. Please return it immediately to the sender and delete the message. Should you have any questions, please contact us by replying to [EMAIL PROTECTED] Thank you -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Count Function?
In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: > Nelson Ray wrote: > >>Does anyone know of any sort of a function or method in perl that returns >>the number of times a search string exists in a scalar. Say, how many >>"a's" >>are there in this sentence? I am able to write it myself, but I was >>wondering if Perl had an inherent function for cleaner operation. I tried >>looking through the list of functions at www.perldoc.com without success. >>Thanks a lot for any help. >> > > tr/// is what you need, perldoc perlop > Assuming your string is in $_, the number of a's will be > my $acnt = tr/a//; Thanks to Sudarshan & Janek! I found this as suggested... # NOTE: (from perlop) # Because the transliteration table is built at com # pile time, neither the SEARCHLIST nor the REPLACE # MENTLIST are subjected to double quote interpola # tion. That means that if you want to use vari # ables, you must use an eval(): # # eval "tr/$oldlist/$newlist/"; # die $@ if $@; # # eval "tr/$oldlist/$newlist/, 1" or die $@; But what I can't figure out (and have tried several variants) is how to get the count when using a variable (ala' from inside an eval). This is the closet I got: my $sentence = "Here is my test sentence.\n"; my $letter = 'e'; my $count; eval {$count = $sentence =~ tr/$letter//}; die $@ if $@; print "The letter $letter appears $count times in the sentence..."; It produces "The letter e appears 10 times..." but the answer should be "6". :-( -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Socket question
Hi, I am still working on a socket problem at low level, and there is something I wander. Are Perl socket bidirectional? I am currently work to test an Apache module, that processes HTTP POST requests. I thought at the beginning, that a Perl script would do perfect for me. Code fragment: send SOCK, "$lines\n",MSG_OOB ; $res = recv SOCK, $line,1024,MSG_OOB ; while ( defined($res) ) { print $line ; $res = recv SOCK, $line,1024,MSG_OOB ; } print "Closed\n" ; close SOCK ; So, the request is sent correctly, I could verify from the acces-log, and it is processed properly by the module· It seems, the script closes down before anything is recevied from Apache. The socket was opened by the following code: socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; connect(SOCK, $paddr)|| die "connect: $!"; print "Host reached\n-\n" ; I would appreciate any idea. BTW I tried higher level socket solution, but could not even contact Apache server :-() Gabaux Linux is like a wigwam: no gates, no windows, and an apache inside! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
help perl ftp
Hi AALL thoughi searched http://search.cpan.org/, i couldnot get the p[lace from where i can download NEt::FTP. I on;y got is a theorotical explanation of Net::FTP please help me in this regads with regards uday bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl help ftp
-Original Message- vemulakonda uday bhaskar wrote: ... >>>can anyone tell me from where i can download Net::FTP from >>> www.cpan.org ... Browse to http://search.cpan.org/ then search for Net::FTP. E. CONFIDENTIALITY NOTICE This message and its attachments are addressed solely to the persons above and may contain confidential information. If you have received the message in error, be informed that any use of the content hereof is prohibited. Please return it immediately to the sender and delete the message. Should you have any questions, please contact us by replying to [EMAIL PROTECTED] Thank you -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using whence
As it happens, on my platform (z/OS UNIX), the "sh" actually IS a form of korn shell (it was ported to the mainframe by MKS, apparently), so there is a 'whence'. What's weird is that doing something like $path = `whence $cmd | uniq` actually works, though the pipe to uniq is pointless. Something about piping it makes the value come back. Oh well, probably something weird in my UNIX environment. Thanks for the responses. - DAP > -Original Message- > From: Brandon Willis [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 26, 2003 9:36 PM > Cc: [EMAIL PROTECTED] > Subject: Re: using whence > > > `$cmd` or it identical twin qx($cmd) both shell out and actually do an > sh -c. So if you are looking for something specifically in ksh you'll > have to run ksh from within the qx(). > > |b > > On Thu, 2003-06-26 at 16:21, David Parker wrote: > > Hi. I have a perl script that calls various programs. I > would like to be able to verify that a given program is being > called from the right place - what I would use "whence" for > in the korn shell. > > > > I tried > > > >$path = `whence $cmdname`; > > > > but I don't get anything in $path. I'm undoubtedly missing > something - I'm a beginner! > > > > Thanks in advance for any clues > > > > - DAP > > > -- > > > David Parker > > Rocket Software > > (617) 614-2128 > > > > > > > -- > 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]
perl help ftp
hi all can anyone tell me from where i can download Net::FTP from www.cpan.org with regards uday bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
perl help ftp
hi all can anyone tell me from where i can download Net::FTP from www.cpan.org with regards uday bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help Net::FTP download
Hi All i searched for Net::FTP in http://search.cpan.org, but i could not find anyplace from where i can download it.i can got o that page where there is explanation about Net::FTP, but no where could i find the dowmload site could u help me in this regards With Regards V.V. uday Bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help Net::FTP download
Hi All i searched for Net::FTP in http://search.cpan.org, but i could not find anyplace from where i can download it.i can got o that page where there is explanation about Net::FTP, but no where could i find the dowmload site could u help me in this regards With Regards V.V. uday Bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: IPC with parent from mutiple children
I think I have found the problem. It turns out that the closing and opening of the pipe is in the wrong place. This code actually works: #!/bin/env perl # use strict; use FileHandle; # Global variables; my $child = 0; my $max_child = 60; # --- Sub routines - sub SpawnChild { my ($no, $child) = @_; my $pid = fork(); # Fork a new child process if ($pid) { # This is the parent process return; } else { # this is the child my $sleep = 0; #int(rand(3)+1); # a no use random work load sleep($sleep); print WRITE "Child $no Slept $sleep\n"; exit; } } sub Parent { my ($max_iterations) = @_; for (my $i = 1; $i < $max_iterations; $i++) { $child++; print STDOUT "Parent $i $child\n"; SpawnChild($i, $child); while ($child >= $max_child) { my $input = ; print STDOUT $input;# print the input from the child $child--; } } while ($child > 0) {# after the main loop has finished my $input = ; # some child processes are still running print STDOUT $input;# wait for them $child--; } } # Main code pipe(READ, WRITE); # open a pipe autoflush WRITE 1; Parent(1000); close READ; close WRITE; # End -- I have ran this dozens of time and it seems it always works. I hope somebody else can use this, might (s)he stumble upon multiprocessing Cheers, Jeroen > Sent: 26 June 2003 17:55 > To: '[EMAIL PROTECTED]' > Subject: IPC with parent from mutiple children > > > Hi all, > > Again, I drown in the muddy watters of child processes: > > What I want to achieve is: spawn up to $max_child processes > and setup pipes in such away that all child processes can > 'print' to the parent. This because I want to inform the > parent about the exit value of the process > (I know I can set up a signal handler for that, but I have > found them very unreliable, so I want to trry it using pipes) > > My output is not what I expected :( Can somebody help me?? > > This is the code: > > #!/bin/env perl > # > > use strict; > use FileHandle; > > # Global variables; > my $child = 0; > my $max_child = 4; > > sub SpawnChild > { > my ($no, $child) = @_; > > pipe(READ, WRITE); > autoflush WRITE 1; > > # Fork a new child process > my $pid = fork(); > if ($pid) { > # This is the parent process > close(WRITE); > return; > } > else { # this is the child > close(READ); > > my $sleep = int(rand(6)+1); # a no use random work load > sleep($sleep); > print WRITE "End $no Slept $sleep\n"; > exit; > } > } > > > sub Parent > { > my ($max_iterations) = @_; > > for (my $i = 1; $i < $max_iterations; $i++) { > $child++; > > print STDOUT "Spawn $i $child\n"; > SpawnChild($i, $child); > > while ($child >= $max_child) { > my $input = ; > print STDOUT $input; > $child--; > } > } > for (my $i = 1; $i < $max_child; $i++) { > my $input = ; > print STDOUT $input; > $child--; > } > } > > This is my output: > > Spawn 1 1 > Spawn 2 2 > Spawn 3 3 > Spawn 4 4 > End 4 Slept 6 > Spawn 5 4 > End 5 Slept 2 > Spawn 6 4 > End 6 Slept 1 > Spawn 7 4 > End 7 Slept 1 > Spawn 8 4 > End 8 Slept 2 > Spawn 9 4 > End 9 Slept 5 > > So I miss something like > End 1 Slept 6 > End 2 Slept 3 > End 3 Slept 2 > End 4 Slept 4 > > Where did the 'return print' for the first 4 children go > > Thanks for any suggestions > > Jeroen Lodewijks > > > > -- > 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: it seems impossible to me...
If you use Unix type of system, there a full shell solution: - print your array to a text file - sort the file with the unix command 'sort' - remove the multiple lines with the unix command 'uniq' You may find the details in the man Gabaux Linux is like a wigwam: no gates, no windows, and an apache inside! From: Adriano Allora <[EMAIL PROTECTED]> Subject: it seems impossible to me... Date: Fri, 27 Jun 2003 13:14:30 +0200 > Hi to all, > > I have to clean a huge array in wich every element is a text line. My > cleaning consists in deleting each item if it appears more than one > time. > > I cannot use hashes and I'd prefer avoiding foreach cycles (I have a > lot of arrays, and so...). > > I searched a function wich works in this way, but I did'n find it. It > ssems impossible to me, but it misses to perl? > > someone can help me? > > thanks! > > > all'adr > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
help perl+ftp
Dear all From where i can download Net::FTP module to install it in my system With Regards V.V. Uday Bhaskar ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
it seems impossible to me...
Hi to all, I have to clean a huge array in wich every element is a text line. My cleaning consists in deleting each item if it appears more than one time. I cannot use hashes and I'd prefer avoiding foreach cycles (I have a lot of arrays, and so...). I searched a function wich works in this way, but I did'n find it. It ssems impossible to me, but it misses to perl? someone can help me? thanks! all'adr -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help : Net::FTP
vemulakonda uday bhaskar wrote: Dear all Can u give me a site from where i can download and install "Net::FTP" For all you perl module download needs, go here http://search.cpan.org Please bookmark it. Regards uday bhaskar.v.v. ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help : Net::FTP
Dear all Can u give me a site from where i can download and install "Net::FTP" Regards uday bhaskar.v.v. ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help : Net::FTP
Dear all Can u give me a site from where i can download and install "Net::FTP" Regards uday bhaskar.v.v. ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: linefeed
The problem is that these characters are added when printing the output to file. Even if I remove these with chomp or chop they will be added again when I write the data to file. Regards, Charles Scheepers Pr.Eng. [EMAIL PROTECTED] (011) 324-9026 (084) 511-6164 -Original Message- From: McMahon, Christopher x66156 [mailto:[EMAIL PROTECTED] Sent: 26 June 2003 17:08 To: Charles Scheepers; [EMAIL PROTECTED] Subject: RE: linefeed I just did this myself (see the item from this list from the 24th with title "duh...") I had to mess with chomp and chop both (you might have to play with them to get your format exactly right), there might be a more efficient way to do this, but this works: *** while ($logResp ne "") { $logResp = ; chop $logResp; $eol = "\r\n"; $sendLR .= "$logResp$eol"; } chomp $sendLR; chop $sendLR; #do something with $sendLR ** -Chris -Original Message- From: Charles Scheepers [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 2:33 AM To: [EMAIL PROTECTED] Subject: linefeed Hi All I am having a problem with linefeed. I have written a program that writes records to an output file. The program that uses this file as input requires that all records are ended with "\x0A" and not CRLF (\x0D\x0A). This program runs on UNIX. How do I ensure that records are ended only with \x0A??? Do I have to use an other method than: print FILHNDL "Text...";??? Regards, Charles Scheepers Pr.Eng. [EMAIL PROTECTED] (011) 324-9026 (084) 511-6164 This communication is private, privileged and confidential intended only for the named addressee. Any recipient who is not a named addressee is not entitled to retain, copy, disseminate or take action in reliance upon this communication. If you have received it in error, please notify the sender immediately and destroy the original. This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. This communication is private, privileged and confidential intended only for the named addressee. Any recipient who is not a named addressee is not entitled to retain, copy, disseminate or take action in reliance upon this communication. If you have received it in error, please notify the sender immediately and destroy the original.
Re: HELP! Reg-ex question
Mike wrote: Given the following code snippet: - print "$text\n"; my $text="sour red apples"; my $pattern="(sour)"; my $replacement="very \$1"; $text=~s/$pattern/$replacement/; print "$text\n"; - I was expecting "very sour red apples" to be printed, but instead I got "very $1 red apples". I tried changing: $text=~s/$pattern/$replacement/; to $text=~s/$pattern/$replacement/ee; but that did not work either. How can I make it work, so that it was as if I had written: Enable warnings with either the -w flag or use warnings The reason it does not work is this, the /e modifier changes the replacement string to very $1. The second /e modifier will try to evaluate this as a perl code. As you can see this is not a valid perl code. You would have recieved a warning message if you had enabled warnings. Change $replacement to $replacement = "\"very \$1\""; The first /e modifier will change this to "very $1". The second /e modifier will give you the string you want. $test=~s/$pattern/very $1/; # With the "very $1" being extracted from the #$replacement variable Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Converting/executing a PERL script in binaries
HI, I'm wanting to execute my PERL script in a binary/executable form. I wrote a C wrapper to do so. However, when executing the binary code produced by the wrapper, it produced the warning message as attached the file WRAPPER-OUTPUT.txt. However, when executing just the script itself, the script did not produce the warning "The flags you gave make no sense since you're not sending mail. ". The output is shown below: [EMAIL PROTECTED] file-6.pl names /pgadm1/usr1/adm/cleaw/script/test/WEIRDER opened successfully $names[0]=cleaw $list= [EMAIL PROTECTED] HERE ... ELEMENTS: 10737418241 udp661program 1073741824 version 1 is not available ELEMENTS: 10737418251 udp899program 1073741825 version 1 is not available ELEMENTS: 10737418261 udp756program 1073741826 version 1 is not available ELEMENTS: 10737418271 udp813program 1073741827 version 1 is not available Sending mail now ... SUBJECT: RPCPING OUTPUT HOST :pgadm1 IP :172.30.209.15 OS :aix PROG NO VER PROTO PORTSERVICE RESPONSE 10737418241 udp661 program 1073741824 version 1 is not available 10737418251 udp899 program 1073741825 version 1 is not available 10737418261 udp756 program 1073741826 version 1 is not available 10737418271 udp813 program 1073741827 version 1 is not available I was wondering if someone could show me how I could convert a PERL script into a binary code? Or if the way that I've wrote my wrapper is wrong, kindly correct me. Are there any perl functions or modules which converts a PERL script into a binary code? Attached also are both my perl script(file-6.pl) and also my C wrapper code (visit.cc). Could someone kindly help me out? Thanks <> <> <> file-6.ZIP Description: Zip compressed data visit.cc Description: Binary data -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Count Function?
Nelson Ray wrote at Thu, 26 Jun 2003 19:25:37 -0700: > Does anyone know of any sort of a function or method in perl that returns > the number of times a search string exists in a scalar. Say, how many "a's" > are there in this sentence? I am able to write it myself, but I was > wondering if Perl had an inherent function for cleaner operation. I tried > looking through the list of functions at www.perldoc.com without success. > Thanks a lot for any help. perldoc -q "How can I count the number of occurrences of a substring" Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Count Function?
Nelson Ray wrote: Does anyone know of any sort of a function or method in perl that returns the number of times a search string exists in a scalar. Say, how many "a's" are there in this sentence? I am able to write it myself, but I was wondering if Perl had an inherent function for cleaner operation. I tried looking through the list of functions at www.perldoc.com without success. Thanks a lot for any help. tr/// is what you need, perldoc perlop Assuming your string is in $_, the number of a's will be my $acnt = tr/a//; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with cgi
Hi All, Seems to be OT but still thought you guys can help me I have an html page If I click submit I calls cgi script and executes that but in my Case Windows XP It is just opening that script. and not executig that. Could you please suggest how to solve this problem Thanks, Amit _ Get Your Private, Free Jatt Email at http://www.jatt.com/ _ Select your own custom email address for FREE! Get [EMAIL PROTECTED], No Ads, 6MB, IMAP, POP, SMTP & more! http://www.everyone.net/selectmail?campaign=tag -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: HELP! Reg-ex question
I can't test this out here, but I think the e after the regex makes the right side get evaluated as code, so maybe you need to put quotes around the right-hand side of your regex: $text=~s/$pattern/"$replacement"/e; -Original Message- From: Mike To: [EMAIL PROTECTED] Sent: 6/26/03 12:38 PM Subject: HELP! Reg-ex question Given the following code snippet: - print "$text\n"; my $text="sour red apples"; my $pattern="(sour)"; my $replacement="very \$1"; $text=~s/$pattern/$replacement/; print "$text\n"; - I was expecting "very sour red apples" to be printed, but instead I got "very $1 red apples". I tried changing: $text=~s/$pattern/$replacement/; to $text=~s/$pattern/$replacement/ee; but that did not work either. How can I make it work, so that it was as if I had written: $test=~s/$pattern/very $1/; # With the "very $1" being extracted from the #$replacement variable 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: Hmm....is a hot directory possible?
On Thursday 26 Jun 2003 10:38 pm, Jenda Krynicky wrote: > From: Chris Zimmerman <[EMAIL PROTECTED]> > > > Is there some way that I can write a bit of code that will watch a > > directory and as soon as a file is written to that directory, > > something is run against that file? What would be the best way to > > turn this into a daemon? > > Depends on the OS. > Under windows it'd be Win32::ChangeNotify and > Win32::Daemon(::Simple)? I know a while back (12 months?) a talk was given at our local LUG - http://www.wylug.org.uk - about hooks being placed in the Linux kernel so that user mode processed could register an interest in a file or directory and would receive a SIG if any change occured. The idea was so that progs like 'top' could become much more efficient by sleeping instead of polling, but I don't know how far along this is, or whether anyone's written a perl module for it yet. Gary > > Jenda > = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = > When it comes to wine, women and song, wizards are allowed > to get drunk and croon as much as they like. > -- Terry Pratchett in Sourcery -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Count Function?
Does anyone know of any sort of a function or method in perl that returns the number of times a search string exists in a scalar. Say, how many "a's" are there in this sentence? I am able to write it myself, but I was wondering if Perl had an inherent function for cleaner operation. I tried looking through the list of functions at www.perldoc.com without success. Thanks a lot for any help. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using whence
`$cmd` or it identical twin qx($cmd) both shell out and actually do an sh -c. So if you are looking for something specifically in ksh you'll have to run ksh from within the qx(). |b On Thu, 2003-06-26 at 16:21, David Parker wrote: > Hi. I have a perl script that calls various programs. I would like to be able to > verify that a given program is being called from the right place - what I would use > "whence" for in the korn shell. > > I tried > >$path = `whence $cmdname`; > > but I don't get anything in $path. I'm undoubtedly missing something - I'm a > beginner! > > Thanks in advance for any clues > > - DAP > -- > David Parker > Rocket Software > (617) 614-2128 > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
HELP! Reg-ex question
Given the following code snippet: - print "$text\n"; my $text="sour red apples"; my $pattern="(sour)"; my $replacement="very \$1"; $text=~s/$pattern/$replacement/; print "$text\n"; - I was expecting "very sour red apples" to be printed, but instead I got "very $1 red apples". I tried changing: $text=~s/$pattern/$replacement/; to $text=~s/$pattern/$replacement/ee; but that did not work either. How can I make it work, so that it was as if I had written: $test=~s/$pattern/very $1/; # With the "very $1" being extracted from the #$replacement variable Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How can i make this faster?
hi, i wrote this little program. it reads a file and puts the output into a treelike structure. the content of the file is the output of the du command. something like that: 124k /var/backups/dpkg.status.3.gz 12k /var/log/auth.log.1.gz 12k /var/log/daemon.log.1.gz 12k /var/log/debug.1.gz 12k /var/log/syslog.2.gz 12k /var/log/syslog.3.gz 132k /var/backups/dpkg.status.1.gz 132k /var/backups/dpkg.status.2.gz 4.0k /var/log/auth.log.2.gz 4.0k /var/log/debug.2.gz 4.0k /var/log/kern.log.1.gz the program works fine for a small directory, but as soon as the directory is bigger, it takes a long time to start. do you have any idea how to make this faster? --- #!/usr/bin/perl use diagnostics; use strict; use Tk; use Tk::HList; use Tk::Tree; use File::Basename; my $mw = tkinit; my $hl = $mw->ScrlTree(-separator=> '/', -drawbranch => 1, -scrollbars => 'osoe', -selectmode => 'extended', -selectforeground => 'red', ) ->pack(-fill => 'both', -expand => 1 ); open SD,'; my %hash = reverse map split, ; #; print "Datei '$_' belegt '$hash{$_}'.\n" for sort keys %hash; $hl->add('/'); $hl->item('create', '/', 0, -text => '/'); for my $file (sort keys %hash) { print "file: '$file'\n"; my @path = split '/', $file; shift @path; # leeren Eintrag vorn entfernen print "path: '@path'\n"; my $path = ""; for my $pt (@path) { print "inpatharray: $pt\n"; $path .= "/$pt"; print "path: $path\n"; if (! $hl->info('exists', $path)) { my $realFile= fileparse($file); if (-d $path) { $hl->add($path); $hl->item('create', $path, 0, -text => "$path", -image => $hl->Getimage('folder'), ); $hl->autosetmode; } else { $hl->add($path); $hl->item('create', $path, 0, -text => "$path", -image => $hl->Getimage('file'), ); $hl->autosetmode; } } else { print "weder noch\n"; } } } --- to create the LIST file, simply do: du -h -a /usr> /tmp/all 2>/dev/null -->or /var or any big directory sort +1 /tmp/all > /tmp/LIST zhis should generate a file called LIST in the /tmp directory. i hope someone has an idea because this is really important. THANKS YOU VERY MUCH :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help me perl : sftp
It was Friday, June 27, 2003 when vemulakonda uday bhaskar took the soap box, saying: : dear all : : i have a code to tranfer file between two linux machines using : sftp : : for that i used "use Net::SFTP", but it is giving error saying : "Can't locate Net.SFTP.pm [EMAIL PROTECTED] : (@INC contains /usr/lib/perl5/5.6.0/1386-Linux..) at shh3.pl : linux.." : how should i go and fix the problem You need to install Net::SFTP on your computer. The simple approach would be this, on the command line: perl -MCPAN -e'install Net::SFTP' Alternativley, you could download it from http://search.cpan.org/author/BTROTT/Net-SFTP-0.05/ : My code : Your code seems fine, if not a little messy. :-) And by messy I mean, you should not post your username and password, or even private IP address to a public mailing list like this. It is most important that you change your password immediatley. Good luck. Casey West -- I am a superhero. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]