Global variables and a forked process

2003-08-14 Thread Ahmed Moustafa
Does a forked process share the memory locations of the global variables from the parent process? Thanks in advance! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Global variables and a forked process

2003-08-14 Thread Ahmed Moustafa
Steve Grazzini wrote: On Sat, Aug 09, 2003 at 01:04:26PM -0700, Ahmed Moustafa wrote: Does a forked process share the memory locations of the global variables from the parent process? Changes made after the fork() won't be visible in the other process, if that's what you're

Re: Global variables and a forked process

2003-08-10 Thread Ahmed Moustafa
Steve Grazzini wrote: On Sat, Aug 09, 2003 at 05:14:34PM -0700, Ahmed Moustafa wrote: Steve Grazzini wrote: Changes made after the fork() won't be visible in the other process, if that's what you're wondering. Yes, that's exactly what I am wondering. So, is there a way to

Re: switch user

2003-06-16 Thread Ahmed Moustafa
Steve Grazzini wrote: Ahmed Moustafa <[EMAIL PROTECTED]> wrote: [ That address is bouncing, by the way. ] It should not! What was the message that you got? How can I switch user "su" in perl? It's much easier to do that before running the script. :-) $ su -c ./scr

switch user

2003-06-16 Thread Ahmed Moustafa
How can I switch user "su" in perl? Thanks in advance, Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How does ZOMBIE/defunct affect the system?

2002-08-14 Thread Ahmed Moustafa
- Original Message - From: "Bob Showalter" <[EMAIL PROTECTED]> To: "'Ahmed Moustafa'" <[EMAIL PROTECTED]>; "Perl beginners" <[EMAIL PROTECTED]> Sent: Wednesday, August 14, 2002 10:08 AM Subject: RE: How does ZOMBIE/defunct af

Re: How does ZOMBIE/defunct affect the system?

2002-08-14 Thread Ahmed Moustafa
fect the system? > > -Original Message- > > From: Sudarshan Raghavan [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 14, 2002 7:49 AM > > To: Perl beginners > > Subject: Re: How does ZOMBIE/defunct affect the system? > > > >

Re: system() retuens -1

2002-08-14 Thread Ahmed Moustafa
> > I call external programs with system(). It used to return the correct > > value i.e. zero if there is no error and a non-zero value otherwise. > > Recently, it always returns -1 even if the external programs work fine. > > What could be the reason? > > > From perldoc -f system: > > The ret

Re: How does ZOMBIE/defunct affect the system?

2002-08-13 Thread Ahmed Moustafa
Ahmed Moustafa wrote: > Drieux wrote: > >> >> >>use POSIX ":sys_wait_h"; >>#... >>do { >>$kid = waitpid(-1,&WNOHANG); >>} until

system() retuens -1

2002-08-13 Thread Ahmed Moustafa
I call external programs with system(). It used to return the correct value i.e. zero if there is no error and a non-zero value otherwise. Recently, it always returns -1 even if the external programs work fine. What could be the reason? Thanks in advance, Ahmed -- To unsubscribe, e-mail: [EMA

Re: How does ZOMBIE/defunct affect the system?

2002-08-13 Thread Ahmed Moustafa
> Proc::Daemon is a pure Perl module, so it is a perfect Perl example of > how to create a daemon in Unix. Is there a particular reason you cannot > use Proc::Daemon (uncooperative sysadmins)? Exactly, also, I already have something in place and I need to fix it. -- To unsubscribe, e-mail: [

Re: How does ZOMBIE/defunct affect the system?

2002-08-13 Thread Ahmed Moustafa
Drieux wrote: > > On Monday, August 12, 2002, at 11:31 , Ahmed Moustafa wrote: > >> Drieux wrote: >> >>> what you want is >>> how do I create a demon process >>> that will be able to run independent of my programme: >>> cf: >>

Re: How does ZOMBIE/defunct affect the system?

2002-08-12 Thread Ahmed Moustafa
options, please? Your help will appreciated so much. --Ahmed Moustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How does ZOMBIE/defunct affect the system?

2002-08-10 Thread Ahmed Moustafa
the forked processes to terminate? Thanks!!! -- Ahmed Moustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

How does ZOMBIE/defunct affect the system?

2002-08-09 Thread Ahmed Moustafa
If a Perl program generates ZOMBIE/defunct processes, how does that affect the system? Do the following code avoid the ZOMBIE/defunct? # do { $pid = waitpid (-1, &WNOHANG); } until $pid == -1; # Your help will be appreciated so much. -- Ahmed Moustafa -- To unsubscribe, e-

Re: accessing an array in a hash

2002-05-12 Thread Ahmed Moustafa
', 'world']); print $hash{"array"}[0]; print $hash{"array"}[1]; -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Global variables in forked processes

2002-05-09 Thread Ahmed Moustafa
Thanks a lot. I understand that. I was thinking that variable 'x' of a forked process 'p2' would point at the same memory location of variable 'x' of a parent process 'p1'. That can't be true. If that was true, 'p1' and 'p2'

Re: Perl and Visual Basic

2002-05-03 Thread Ahmed Moustafa
t- data > sent to output files, etc..) There is the VB's *Shell* function which let's you call an external executable program (including the Perl interperter). -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Send email with attachment

2002-04-29 Thread Ahmed Moustafa
Bob Showalter wrote: >>-Original Message- >>From: Ahmed Moustafa >>Sent: Sunday, April 28, 2002 2:47 PM >>To: [EMAIL PROTECTED] >>Subject: Send email with attachment >> >> >>Hi All, >> >>Would you post an example of sendi

Send email with attachment

2002-04-28 Thread Ahmed Moustafa
Hi All, Would you post an example of sending an email with attachment(s) using Net::SMTP, please? Thanks in advance. Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Net::SFTP installation on Windows

2002-04-25 Thread Ahmed Moustafa
Ahmed Moustafa wrote: > How can I install Net::SSH and Net::SFTP on ActivePerl (Windows NT), please? Has anyone had Net:SFTP working on Windows? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: OpenInteract and others

2002-04-25 Thread Ahmed Moustafa
rl there at http://openacs.org/bboard/search-entire-system.tcl?query_string=perl -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Unix to dos; dos to unix...

2002-04-25 Thread Ahmed Moustafa
s, Inc. (Baltimore Office) > [EMAIL PROTECTED] > 410-494-1600 x4058 > <<...OLE_Obj...>> If your file is already in the DOS file format (each line ends with CR and LF), your script will replace the LF with CR and LF; which means your lines will end with CR + CR + LF. And, that&#

Re: Standalone exe's

2002-04-22 Thread Ahmed Moustafa
Peter Lang wrote: > Hi All, > > This is a newbie question. Can you generate a stand alone > ..exe file from Perl? > > Thanks > Peter Perl2Exe <http://www.indigostar.com/perl2exe.htm> -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAI

Re: Windows IDE for Perl ?

2002-04-22 Thread Ahmed Moustafa
Peter Lang wrote: > Hi All, > > Are there MS Windows based IDE for Perl, with debug and > trace / step thru facilities, free or otherwise? > > Thanks > Peter Take a look at Visual Perl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

synchronized block

2002-04-22 Thread Ahmed Moustafa
How a block of code is atomized (e.g. synchronized blocks in Java)? Thanks in advance. -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to thread in Perl?

2002-04-19 Thread Ahmed Moustafa
c, isn't? Or, is there a standard procedure? How can a child process be forced to be killed (in the cleaning up)? -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to thread in Perl?

2002-04-18 Thread Ahmed Moustafa
Chas, Thanks a lot! > #the main loop has exited, so we should check to see if there are > #any unreaped children > waitpid $_ for keys %running; My main loop is iterating forever i.e. a daemon; thus, any code after the main loop will not be executed. So, what do you think? Once again, thanks.

Re: How to thread in Perl?

2002-04-17 Thread Ahmed Moustafa
> You are better off trying > > $SIG{CHLD} = 'IGNORE'; > > at the top of your program and seeing if zombies are left out there. If > so then you might want to use pop or shift like this > > waitpid shift @children while @children; Do I really need to hold the pid's of the kids process somewhere?

Re: OT: Old uunet gag was Re: How to thread in Perl?

2002-04-16 Thread Ahmed Moustafa
Is there a way to know the Missile Address from an IP address? -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Net::SFTP installation on Windows

2002-04-16 Thread Ahmed Moustafa
How can I install Net::SSH and Net::SFTP on ActivePerl (Windows NT), please? Your help will be appreciated so much. Thanks, Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to thread in Perl?

2002-04-15 Thread Ahmed Moustafa
> > You are better off trying > > > > $SIG{CHLD} = 'IGNORE'; > > > > at the top of your program and seeing if zombies are left out there. > > There were no zombies left after the program termination. Then, I don't need > even to push the ids from the children in the stack, right? Something happen

Re: How to thread in Perl?

2002-04-15 Thread Ahmed Moustafa
> You are better off trying > > $SIG{CHLD} = 'IGNORE'; > > at the top of your program and seeing if zombies are left out there. There were no zombies left after the program termination. Then, I don't need even to push the ids from the children in the stack, right? > Missile Address: 33:48:3.521N

Re: How to thread in Perl?

2002-04-15 Thread Ahmed Moustafa
> #reap the children to avoid zombies > waitpid $_ for (@children); Do I need to pop the pid's from the stack children? Thanks, Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How can a sub return true or false?

2002-04-14 Thread Ahmed Moustafa
Steven Brooks wrote: > You could use 0 as false and 1 (or another non-zero value) as true. Why does an empty string work as 0 (false)? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How can a sub return true or false?

2002-04-13 Thread Ahmed Moustafa
Ahmed Moustafa wrote: > I use " " for true and "" for false. Is there a more standard (or > readable) values for true and false? > > Thanks in advance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

How can a sub return true or value?

2002-04-13 Thread Ahmed Moustafa
I use " " for true and "" for false. Is there a more standard (or readable) values for true and false? Thanks in advance. -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: (-e $filename) gives Use of uninitialized value at...

2002-04-13 Thread Ahmed Moustafa
Jeff 'Japhy' Pinyan wrote: > The default scope for ALL variables is to the package they belong to. If > you declare a variable with 'my', or give it a fully qualified package > name (like $Foo::x), then the default is not the case. I found the same for subroutin

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

2002-04-13 Thread Ahmed Moustafa
Elaine -Hfb- Ashton wrote: > I always found the local, my, our mess pretty confusing and the best > explanation is MJD's "Coping with Scoping" > > http://perl.plover.com/FAQs/Namespaces.html > > Make good note of the text in red :) Elaine, thanks a lot for MJD's article. There is a great differ

Re: what is the value of WNOHANG?

2002-04-13 Thread Ahmed Moustafa
process. Then, the pid's of the child processes don't need to be held to be waited for. -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: what is the value of WNOHANG?

2002-04-12 Thread Ahmed Moustafa
I found it in . It was 0x0001. Is use POSIX ":sys_wait_h"; portable? Ahmed Moustafa wrote: > > waitpid $pid,&WNOHANG; > > > What is the value of the flag WNOHANG in waitpid? > What does it mean when $pid is -1? > > Thanks in advance. -- To unsu

what is the value of WNOHANG?

2002-04-12 Thread Ahmed Moustafa
waitpid $pid,&WNOHANG; What is the value of the flag WNOHANG in waitpid? What does it mean when $pid is -1? Thanks in advance. -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: regular expression to get a file extension

2002-04-11 Thread Ahmed Moustafa
> # foo.txt.bak => bak > ($extension) = $name =~ /.*\.([^.]*)/; > # or > # ($extension) = $name =~ /\.([^.]*)$/; It doesn't work if there is no extension in $name. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: (-e $filename) gives Use of uninitialized value at...

2002-04-10 Thread Ahmed Moustafa
To: "'Agustin Rivera'" <[EMAIL PROTECTED]>; "Ahmed Moustafa" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, April 10, 2002 10:19 AM Subject: RE: (-e $filename) gives Use of uninitialized value at... > Assuming you have all warnings on, vi

Re: (-e $filename) gives Use of uninitialized value at...

2002-04-10 Thread Ahmed Moustafa
What is the default scope for a variable defined inside a subroutine? - Original Message - From: "Nikola Janceski" To: "'Agustin Rivera'"; "Ahmed Moustafa"; <[EMAIL PROTECTED]> Sent: Wednesday, April 10, 2002 10:19 AM Subject: RE: (-e

(-e $filename) gives Use of uninitialized value at...

2002-04-10 Thread Ahmed Moustafa
I'm using (-e $filename) to check the existence of $filename. If the file exists, it returns true, otherwise it gives 'Use of uninitialized value at...line #' (# is the line number of the if statement -if ($filename)-. Why does that happen and how I can fix it, please? Thanks in advance. --Ahmed

Re: regular expression to get a file extension

2002-04-09 Thread Ahmed Moustafa
John W. Krahn wrote: > Ahmed Moustafa wrote: > >>Jeff, thanks a lot for your explanation. I really appreciate it. >> >>Jeff 'Japhy' Pinyan wrote: >> >>>Please use File::Basename. Save us all the headache. >>> >>I was thinking that

Re: regular expression to get a file extension

2002-04-09 Thread Ahmed Moustafa
Jeff, thanks a lot for your explanation. I really appreciate it. Jeff 'Japhy' Pinyan wrote: > Please use File::Basename. Save us all the headache. I was thinking that avoiding modules would make the code more portable. Am I right? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

regular expression to get a file extension

2002-04-08 Thread Ahmed Moustafa
$1); What is wrong with my regular expression? How can it be done in a single regular expression? -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Newbie Help please.

2002-03-31 Thread Ahmed Moustafa
g is $map($some_string)\n"; > > When I run it though I get the following complaint from perl: > > A string please: blue > Use of uninitialized value in concatenation (.) at ./key3.pl line 6, > line 1. > The value for blue is (blue) In line 6, it's $map{$some_string} not

why does flock give Bad file number?

2002-03-29 Thread Ahmed Moustafa
Why does exclusive flock give Bad file number (Solaris)? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Transfer a file via FTP

2002-03-29 Thread Ahmed Moustafa
Jenda Krynicky wrote: > Anyway when reading file you don't need any end of line character, > the system KNOWs how long is the file at the moment and > will return undef if you've read all there is. I didn't get what you meant by " will return undef if you've read all there is"; would you expl

Transfer a file via FTP

2002-03-28 Thread Ahmed Moustafa
When a file is transferred via FTP, when is the EOF character added to the file (only at the end of transmission or also during the transferring)? Your help will be appreciated so much. -- Ahmed Moustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: How to thread in Perl?

2002-03-27 Thread Ahmed Moustafa
implemented in Perl? > > On Tue, 2002-03-26 at 15:56, Ahmed Moustafa wrote: > >>Chas, thanks a lot for your example. >> >>if the while loop is inside a main infinite loop (as if it was a >>daemon), do I still need to have the waitpid function? and if yes, where

Re: How to thread in Perl?

2002-03-26 Thread Ahmed Moustafa
Chas, thanks a lot for your example. if the while loop is inside a main infinite loop (as if it was a daemon), do I still need to have the waitpid function? and if yes, where should be located? Once again, thanks a lot! Chas Owens wrote: > On Tue, 2002-03-26 at 01:14, Ahmed Moustafa wr

Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa
Tagore Smith wrote: > Ahmed Moustafa wrote: > > >>So, how can a new different process by forked? Or, how a function be >>called and the next step execute without waiting for the previous >>function to terminate? >> > >For your original qu

Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa
Jim Conner wrote: > At 20:28 03.25.2002 -0800, Ahmed Moustafa wrote: > >>> Jim Conner wrote: >>> >>>> I suck at this kind of topic but the only way I can think of doing >>>> such a thing is this: >>>> >>>> Use IPC. >&g

Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa
> Jim Conner wrote: > >> I suck at this kind of topic but the only way I can think of doing >> such a thing is this: >> >> Use IPC. >> >> fork off something like 10 children each child working on a separate >> file and use sysvmsg sysvshem (I do not believe these are functions >> and I can't l

Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa
> > Anyone else? Im shooting in the dark really. > > - Jim > > > At 19:04 03.25.2002 -0800, Ahmed Moustafa wrote: > >> Matthew Harrison wrote: >> >>> What exactly do you mean by 'thread'? >> >> >> I've a loop w

Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa
Matthew Harrison wrote: > What exactly do you mean by 'thread'? I've a loop which scans directories looking for files and processes the existing files. I'd like process each file independently (i.e. in parallel) rather than sequentially. > > On Mon, 25 M

How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa
How can I thread a function in Perl? Any help will be appreciated so much. Regards, -- Ahmed Moustafa http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: foreach loop

2002-03-16 Thread Ahmed Moustafa
uot;text here" just doesn't >happen?) > Thanks. > Mariusz > > > #!/usr/bin/perl -W > use CGI ':standard'; > > print "Content-type:text/html\n\n"; > > @names = param(); > foreach $name (@names) { > $$name = param($name); &

Re: Sites

2002-02-13 Thread Ahmed Moustafa
Naveen, take a look at http://arbornet.org/. I think it's what you are looking for. Good luck Naveen Parmar wrote: > Any recommendations on free Web sites where you may upload Perl scripts > and execute CGI scripts? > > TIA, > - NP -- Ahmed Moustafa [EMAIL PROTECTED

Re: Launch a url in my web browser?

2002-01-31 Thread Ahmed Moustafa
module? > > Able to do without bringing up a command prompt as part of the process? > > I was wonder if a script or module already exist. > > Or, what would such written script look like? > > Thanks. Alan. -- Ahmed Moustafa [EMAIL PROTECTED] | http://pobox.com/~amoust

Re: Copy a portion of a file to a new file?

2002-01-29 Thread Ahmed Moustafa
ose dest.txt when I reach the line > containing KEYWORD? Maybe > > while (<>) { > if /KEYWORD/; > exit > else print $ >> dest.txt; > } > > What would be the best approach? Thanx for any help! -- Ahmed Moustafa [EMAIL PROTECTED] | http://pobox.com/~amoustafa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: change type of fields

2002-01-22 Thread Ahmed Moustafa
l and I want it now. > > < I appreciate your sugesstions > > ___ > > -- Ahmed Moustafa [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Running scripts within browsers

2002-01-20 Thread Ahmed Moustafa
Naveen, You don't run a perl, if you mean a cgi script, in a browser. You run it under a web server, which supports cgi. Naveen Parmar wrote: > Hello, > > My activeperl installation was fine. When I try to run my example Perl > scripts within IE, the browser does not even recognize them?? >

Re: how do I load a new page?

2002-01-20 Thread Ahmed Moustafa
I think your script needs to return something to the broswer. I.E. #Code begins print "content-type text/html\n\n"; print "Done"; #Code ends I hope that helps. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Adding/deleting a file

2002-01-16 Thread Ahmed Moustafa
Hi Rory, Assuming that if there is a problem in opening the file then it's 0, I hope the following code helps. #Code Begings if (open (INFILE, "; close (INFILE); } else { $flag = 0; } if ($flag == 0) { $flag = 1; } else { $flag = 0; } open (OUTFILE, ">file.txt") || die; pr

Re: Pointers versus References

2002-01-12 Thread Ahmed Moustafa
I believe the two terms, reference and pointer, are equivalent. By the way, In Java, they call it reference also, I think. --Ahmed [EMAIL PROTECTED] | http://www.photo.net/users/ahmed Patrick Hall wrote: > Hi pholks, > > It's taken me a while to wrap my head around > references, since I thoug

Re: How do I delete a file from Perl?

2002-01-12 Thread Ahmed Moustafa
It's "perldoc -f system" not "perldoc system". --Ahmed Gary Hawkins wrote: >> system("rm -rf $file"); >> >>But if you copied this from another source, that source was totally >>unaware that deletion of files like THAT is TOTALLY unsafe. A safer >>approach is: >> >> system("rm", "-rf", $file);

Re: How do I delete a file from Perl?

2002-01-12 Thread Ahmed Moustafa
Randy, You can delete a file, or a list of files, using "unlink". Example: ## unlink $file; ## perldoc -f unlink Hope that helps. Ahmed [EMAIL PROTECTED] | http://www.photo.net/user/ahmed Randolph S. Kahle wrote: > I am writing my first perl program (copied from a magazine). > > The only li

return code

2002-01-10 Thread Ahmed Moustafa
Hi All, I'm calling a Java application using "system". How can I know the return code of the called Java application? Your help will be appreciated so much. Ahmed -- [EMAIL PROTECTED] | http://www.photo.net/users/ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-

Re: Hash of hash of array

2002-01-09 Thread Ahmed Moustafa
Jon,thanks a lot for your help :) Jon Molin wrote: > Ahmed Moustafa wrote: > >>Hi All, >> >>My data structure is a hash of a hash of an array. I build it from an >>input file by the following code. Could you help me write it back to an >>output file

Hash of hash of array

2002-01-09 Thread Ahmed Moustafa
Hi All, My data structure is a hash of a hash of an array. I build it from an input file by the following code. Could you help me write it back to an output file, please? # Code Begins %data = ( ); open (IN, "in.txt") || die; while () { chop; ($user_name, $file_name, $modified_by, $last_mo

Re: add text to the end of a word. HELP!!

2002-01-02 Thread Ahmed Moustafa
Leon, I've tested reading and writing from the same file and it didn't work. I think that can't be done in any language. Leon wrote: > - Original Message ----- > From: "Ahmed Moustafa" <[EMAIL PROTECTED]> > Newsgroups: perl.beginners > T

Re: add text to the end of a word. HELP!!

2002-01-01 Thread Ahmed Moustafa
Can you open a file for reading and writing as the same time? Leon wrote: > There are many ways to do it. Some would use regexes or map. Anyway heres > one solution assuming your file contain only 1 word in one line.. > > open FILE, 'yourfile.txt' or die "$!\n"; > while (){ > chomp; >

Re: Hash question...

2001-12-17 Thread Ahmed Moustafa
; 'YES', > 'user3' => 'NO', > ); > > Would I start by doing something like the following... > > foreach $user (keys %popusers) { > #Check each home dir /home/$user for file test.pl > #Begin new hash (%popusers_file) > } > > Is this the correct way of going about this one??? > > Regards, > > Dan -- Ahmed Moustafa [EMAIL PROTECTED] | http://arbornet.org/~ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: very basic newbie q: executing a script/dir permissions

2001-12-13 Thread Ahmed Moustafa
I think you should have something like the cgi-bin directory under the web server where your cgi script should be. It depends on your web server and how you configure it. [EMAIL PROTECTED] wrote: > Hello, > > Tried to be as descriptive as possible in my subject > line. I have worked with per

Re: Restarting a daemon...

2001-12-06 Thread Ahmed Moustafa
Hi Daniel, I had the following code. I hope it would help. # Before your while loop: #--- open (PID, $pidfile) || die "Cannot $pidfile: $!\n"; while ( $pid = ) { system "kill -9 $pid"; } close (PID); open (PID, ">$pidfile") || die "Can

Re: Is A File Encrypted?

2001-12-06 Thread Ahmed Moustafa
If you expect a certian pattern of text in the file, I think, you can grep the file from the expected text pattern. If you find any, then the file is not encrypted; otherwise, the probability of the file being encrypted would be higher. --Ahmed [EMAIL PROTECTED] | http://arbornet.org/~ahmed On T

RE: Confirmation...

2001-12-06 Thread Ahmed Moustafa
Hi Messier, Try that: #[1] $str="206.48.16.3/12345"; $str=~ s/\/.*//g; #[2] $str="src=206.48.16.3/12345"; $str=~ s/^src=|\/.*//g; I hope that helps. --Ahmed [EMAIL PROTECTED] | http://arbornet.org/~ahmed On Thu, 6 Dec 2001, Messier, Jean-Francois wrote: > I'm a beginner in those regu

RE: perl script to remove control M's

2001-12-05 Thread Ahmed Moustafa
This programs exists for Windows also. --Ahmed [EMAIL PROTECTED] | http://arbornet.org/~ahmed On Wed, 5 Dec 2001, Sidharth Malhotra wrote: > Most unix systems have a program called dos2unix that does the same > thing. > % man dos2unix > % dos2unix sourcefile targetfile > > Hth. Sid. > >

Re: traversing Windows directories

2001-12-05 Thread Ahmed Moustafa
You need to write a recursive function to scan your root dir and list all the file and directories and do the same for each one of the sub directories. Once you find the file you are looking for, return. --Ahmed [EMAIL PROTECTED] | http://arbornet.org/~ahmed On Wed, 5 Dec 2001, Torres, Jose wrot

Re: traversing Windows directories

2001-12-05 Thread Ahmed Moustafa
I think it does not matter it your system is Windows or *nix. --Ahmed [EMAIL PROTECTED] | http://arbornet.org/~ahmed On Wed, 5 Dec 2001, Torres, Jose wrote: > Hi, > > How do you traverse Windows directories in Perl? Let's say J:\foo\bar\logs > has a variable number of folders, each of which I

Re: Loop

2001-12-05 Thread Ahmed Moustafa
Try using "last" instead of "break". - Original Message - From: "Purshottam Chandak" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 05, 2001 7:19 AM Subject: Loop > i was trying to work it out, for any kind of array. > the following pseudo code doesn't seem to wor

Re: Simpler....

2001-12-04 Thread Ahmed Moustafa
ll do sub($status) >? Also we will say that sub() does break the loop but will return where >it left off after the sub sub() and sub2() has finished what it is >doing? > >Cheers, > >Dan > >-----Original Message- >From: Ahmed Moustafa [mailto:[EMAIL PROTECTED]] &g

Re: Simpler....

2001-12-04 Thread Ahmed Moustafa
Dan, does sub() changes the value of $status? Also, do sub() and sub2() break the loop? Daniel Falkenberg wrote: > Hey all, > > Please don't stree to much over this one but, is there an easier way of > writing this? > > while(1){ > if ($status == 1) { > #Do this sub... > sub(); >

Net:SFTP license and security

2001-12-04 Thread Ahmed Moustafa
Hi All, I need documents describing the license of using Net:SFTP http://search.cpan.org/search?dist=Net-SFTP also the security issues of it i.e is the connection between the client and the server is *really* encrypted? Your help will be appreciated so much. --Ahmed Moustafa [EMAIL PROTECTED

Re: Can Perl work like Expect?

2001-12-04 Thread Ahmed Moustafa
cember 04, 2001, Ahmed Moustafa <[EMAIL PROTECTED]> wrote: > > AM> Thanks a lot. Where can I find exmaples for using Expect.pm, please? > > http://search.cpan.org/search?mode=module&query=expect > but, for telnet and ftp you can use Net::Telnet and Net::FTP modules. >

Re: Can Perl work like Expect?

2001-12-03 Thread Ahmed Moustafa
Hi Brett, Thanks a lot. Where can I find exmaples for using Expect.pm, please? Brett W. McCoy wrote: > On Mon, 3 Dec 2001, Ahmed Moustafa wrote: > > >>I used to use Expect http://expect.nist.gov/ for dealing with >>interactive programs i.e. Telnet and FTP. >> >

Can Perl work like Expect?

2001-12-03 Thread Ahmed Moustafa
will be appreciated so much. Ahmed -- Ahmed Moustafa [EMAIL PROTECTED] | http://arbornet.org/~ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to know a file is being processed?

2001-11-29 Thread Ahmed Moustafa
If I try to lock a file while it is still being transferred, would that cause an error? If so, then I can I know the file is still being processed. What do you think, please? Thanks, Ahmed Randal L. Schwartz wrote: >>>>>>"Ahmed" == Ahmed Moustafa Ibrahim Ahme

Re: deleting white spaces

2001-11-28 Thread Ahmed Moustafa Ibrahim Ahmed
Michael, You don't you need the line beginning and line termination in s/(^|[^ ]) ([^ ]|$)/$1$2/g; Would s/([^ ]) ([^ ])/$1$2/g be simpler? Thanks, Ahmed - Original Message - From: Michael Fowler To: Pedro A Reche Gallardo Cc: [EMAIL PROTECTED] Sent: Wednesday, November 28, 2001 1

RE: deleting white spaces

2001-11-28 Thread Ahmed Moustafa Ibrahim Ahmed
Rex, Would you explain your regexp, please? Also, what do you think about this: $string =~ s/([^\s])\s([^\s])/$1$2/g; Thanks, Ahmed On Wed, 28 Nov 2001 [EMAIL PROTECTED] wrote: > Let me give it a shot...How about this? > --Rex > > $string = "I want to delete all this spaces, but

Re: open read write

2001-11-28 Thread Ahmed Moustafa Ibrahim Ahmed
Hi Nafiseh, I think can't open a file for reading and writing at the same time. Anyway, the following should help: #-- open (FILE, $file) || die "Can't open $file: $!\n"; $value = ; close (FILE); $value += 10; open (FILE, ">$file") || die "Can't open $file: $!\n";

Re: shell in perl

2001-11-27 Thread Ahmed Moustafa Ibrahim Ahmed
lity which recommended Perl. Thanks, Ahmed - Original Message - From: Michael Fowler To: Ahmed Moustafa Ibrahim Ahmed Cc: [EMAIL PROTECTED] ; Nafiseh Saberi Sent: Tuesday, November 27, 2001 10:37 AM Subject: Re: shell in perl On Tue, Nov 27, 2001 at 04:18:15AM -0800, Ahmed Moustafa Ibr

Re: shell in perl

2001-11-27 Thread Ahmed Moustafa Ibrahim Ahmed
Performance wise, both are almost the same, I think. But using the Perl built-in functions would help make your code more portable. --Ahmed Nafiseh Saberi wrote: > hi all. > > we can write shell script in perl source. > but which of them is better ?? > e.g: > for build directory.. > we can w

Test Automation

2001-11-26 Thread Ahmed Moustafa Ibrahim Ahmed
Hi Everybody, How can I automate the process of testing my Perl script? Is there a standard way to do? Is there a tool for testing Perl scripts? Your help will be appreciated so much. Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to get rid of the last Ip number with a regex

2001-11-26 Thread Ahmed Moustafa Ibrahim Ahmed
To do the substitution, you can do that: s/[^\.]+$/0/; I'm not sure if that what you are looking for or not. Jorge Goncalvez wrote: > Hi, I have this: > open (IPCONF,"< $_Globals{IPCONFIG}") or die "je ne peux ouvrir > $_Globals{IPCONFIG} :$!"; > @ten=; close IPCONF; > foreach(@ten){

  1   2   >