Forum Moderators: coopster

Message Too Old, No Replies

convert perl to PHP

I want some help with conversion

         

gogyro

11:14 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



I need to convert a perl script to php ....
I made the half of it ... but I don't know some things
ex:
# Init the array
for($a=0;$a<=$#data_host;$a++){
$data_in[$a]=0;
$data_out[$a]=0;
$data_total[$a]=0;
}
@ipfm_filename=`cat $CONFIGURATION_FILE ¦ grep -v "#" ¦ grep FILENAME`;
for($n=0;$n<=$#ipfm_filename;$n++){
$ipfm_filename[$n]=~ s/^FILENAME\s(\S.)/$1/;
$ipfm_filename[$n]=~ s/"//g;
}
@ipfm_dump=`cat $CONFIGURATION_FILE ¦ grep -v "#" ¦ grep "DUMP EVERY"`;
for($n=0;$n<=$#ipfm_dump;$n++){
$ipfm_dump[$n]=~ s/^DUMP\sEVERY\s(\S.)/$1/;
$ipfm_dump[$n]=~ s/"//g;
$ipfm_hour[$n]=$ipfm_dump[$n];
$IPFM_MINUTE[$n]=$ipfm_dump[$n];
$IPFM_SECOND[$n]=$ipfm_dump[$n];
$ipfm_hour[$n] =~ s/(\d+)\shour/$1/;
$IPFM_MINUTE[$n] =~ s/(\d+)\sminutes/$1/;

if someone can help I will apreciate ...

MonkeeSage

11:23 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out the [preg_grep() [php.net]] function.

Jordan

jatar_k

1:18 am on Oct 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld gogyro,

the for loop should work as is except for $# and I am not familiar with the function of that symbol.

MonkeeSage has some good advice there, also take a look through the Regular Expression Functions (Perl-Compatible) [php.net]

MonkeeSage

1:21 am on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"$#" is the 1-based count of the array in Perl, didn't even see that...for PHP, I believe that count() does the same thing.

Jordan