How do I control a C programme from perl?

2010-05-12 Thread robert Key
Hi, I want to capture UNBUFFERED output from a C programme and then control it depending on its output. Problem is nothing seems to unbufferd the output from the C programme. Only when the child has finished executing do I get all the output which is too late. The C programe is just like hel

Re: regex to add trailing slash if doesn't end in html

2010-05-12 Thread John W. Krahn
John W. Krahn wrote: Brian wrote: my @pages = ( "lc1", "lc2/", "lc3/index.html", "lc4/", "lc5", ); map {s/(some regex here)/$1\//} @pages; $ perl -le' my @pages = ( "lc1", "lc2/", "lc3/index.html", "lc4/", "lc5", ); print "@pages"; s|(? $ perl -le' my @pages = ( "lc1", "

Re: regex to add trailing slash if doesn't end in html

2010-05-12 Thread John W. Krahn
Brian wrote: Hi all. Hello, I think this should be relatively simple but i just can't figure it out. I have a list of files and directories. The files will all end in .html. All the remaining elements in the list are assumed to be directories. I'm looking for a regex to add a trailing slash t

Re: Perl general questions

2010-05-12 Thread Uri Guttman
> "APK" == Akhthar Parvez K writes: APK> 1) Since a hash defined in the main part (outside the APK> subroutines) of a program can be accessed from anywhere (from all APK> subroutines), is it fine, in regards to security or even code APK> elegancy, if we define a hash in the main part?

Perl general questions

2010-05-12 Thread Akhthar Parvez K
Hello, Just want to ensure my understanding about Perl basics is solid. In order to do that, I have a few questions to be cleared up front. 1) Since a hash defined in the main part (outside the subroutines) of a program can be accessed from anywhere (from all subroutines), is it fine, in regard

Re: regex to add trailing slash if doesn't end in html

2010-05-12 Thread Shawn H Corey
On 10-05-12 04:15 PM, Brian wrote: Hi all. I think this should be relatively simple but i just can't figure it out. I have a list of files and directories. The files will all end in .html. All the remaining elements in the list are assumed to be directories. I'm looking for a regex to add a tr

regex to add trailing slash if doesn't end in html

2010-05-12 Thread Brian
Hi all. I think this should be relatively simple but i just can't figure it out. I have a list of files and directories. The files will all end in .html. All the remaining elements in the list are assumed to be directories. I'm looking for a regex to add a trailing slash to the directories if on

AW: AW: Hash with variable name

2010-05-12 Thread HACKER Nora
Hi, > You put an escape character '\' (no quote) to point to another hash > (what follows / symbol, to be more precise). It's known as > (hash/array/code) references. > > my %stp_dirs = ('mvb' => \%mvb_dirs, > 'pkv' => \%pkv_dirs, > 'av' =>

AW: Hash with variable name

2010-05-12 Thread Thomas Bätzler
HACKER Nora asked: > Thanks for your explanation and the reference to perldoc, I understand > now. But it doesn't work yet, I still get the same error. I have > altered my source now as follows: > > my %stp_dirs = ( "mvb" => "\%mvb_dirs", > "pkv" => "\%pkv_di

Re: AW: Hash with variable name

2010-05-12 Thread Akhthar Parvez K
On Wednesday 12 May 2010, HACKER Nora wrote: > Thanks for your explanation and the reference to perldoc, I understand now. > But it doesn't work yet, I still get the same error. I have altered my source > now as follows: > > my %stp_dirs = ( "mvb" => "\%mvb_dirs", >  

Re: AW: Hash with variable name

2010-05-12 Thread Akhthar Parvez K
Hi Nora, On Wednesday 12 May 2010, HACKER Nora wrote: > > while ( my($sdir,$tdir) = each %{$stp_dirs{'mvb'}}) { > > print("SourceDir: $sdir\t\tTargetDir: $tdir\n"); > > } > > Is that 'mvb' intentional? Also, I don't understand why to put '\%' in front > of the values from the master hash.

AW: Hash with variable name

2010-05-12 Thread HACKER Nora
Hi Thomas, > If you "use strict;" you may not use symbolic references, i.e. (mis)use > a variable's name to create a reference to it. That's why I fixed your > code > by replacing the variable names with references to the variable I > assumed you'd wish to address. > > Maybe you should take a loo

AW: Hash with variable name

2010-05-12 Thread Thomas Bätzler
HACKER Nora asked: > > Try: > > > > my %stp_dirs = ('mvb' => \%mvb_dirs, > > 'pkv' => \%pkv_dirs, > > 'av' => \%av_dirs, > > 'be' => \%be_dirs, > > 'vvw' => \%vvw_dirs ); > > > > while ( my($sdir,$tdir) = each %{$s

AW: Hash with variable name

2010-05-12 Thread HACKER Nora
Hi Thomas, > Try: > > my %stp_dirs = ( 'mvb' => \%mvb_dirs, > 'pkv' => \%pkv_dirs, > 'av' => \%av_dirs, > 'be' => \%be_dirs, > 'vvw' => \%vvw_dirs ); > > while ( my($sdir,$tdir) = each %{$stp_dirs{'mvb'}}

AW: Hash with variable name

2010-05-12 Thread Thomas Bätzler
HACKER Nora wrote: > The script is being started with a parameter $stp (among others) that > can be one of mvb/pkv/av/be/vvw. This parameter is used as a key for a > master hash the values of which are names of other hashes themselves. > > # Master-Hash > my %stp_dirs = ( "mvb" => "mvb_dirs", >

Hash with variable name

2010-05-12 Thread HACKER Nora
Hello, Following the suggestion of one of you (sorry, don't remember who's...), I am skimming through my old Perl scripts and trying to improve them. Now I have a problem with one of them, after inserting "use strict;" - would be great, if you could help me: The script is being started with a par

Re: fork, read from child process and timeout

2010-05-12 Thread C.DeRykus
On May 11, 12:56 am, weizhong@gmail.com (Weizhong Dai) wrote: > Hi all, > > - > $pid = open(README, "program arguments |")  or die "Couldn't fork: $!\n"; > while () { >     # ...} > > close(README) > -- > > my problem is: I read fr