Linux-DVB-DVBT-Apps-QuartzPVR

 view release on metacpan or  search on metacpan

lib/Linux/DVB/DVBT/Apps/QuartzPVR/Config/PHP.pm  view on Meta::CPAN

									$line = "our \$$var = $val ;" ;
								}
								# hash
								elsif ($val =~ /^array\((.*=>.*)\)/) 
								{
									print " + + hash\n" if $DEBUG>=2 ;
									$val = $1 ;
									$line = "our \%$var = (\n" ;
									while ($val =~ /\s*($VARNAME|$STRING)\s*=>\s*($SCALAR)\s*,*/g) 
									{
										$line .= "\t$1 => $2,\n" ;
									}
									$line .= ") ;" ;
								}
								# array
								elsif ($val =~ /^array\((.*)\)/) 
								{
									print " + + array\n" if $DEBUG>=2 ;
									$val = $1 ;
									$line = "our \@$var = (" ;
									while ($val =~ /\s*($SCALAR)\s*,*/g) 
									{
										$line .= "$1, " ;
									}
									$line .= ") ;" ;
								}
								else 
								{
									# Unknown
									print "UNKNOWN\n" if $DEBUG>=2 ;
									next ;
								}
							}

							# defines
							elsif ($line =~ /^define\s*\(\s*($STRING|$VARNAME)\s*,\s*($SCALAR)\s*\)/) 
							{
								my $var = $1 ;
								my $val = process_scalar($2) ;

								$line = "use constant $var => $val ;" ;
								print " + define $var = $val\n" if $DEBUG>=2 ;

							}

							# includes
							elsif ($line =~ /^(?:include|require|require_once|include_once)\s*\(?\s*($STRING)\s*\)?/) 
							{
								print " + include $1 = $2\n" if $DEBUG>=2 ;
								my ($php) = ($1) ;
								
								# Convert to module name
								$php =~ s%[\\/]%::%g ;
								$php =~ s%\..*$%% ;
								$php =~ s%[\'\"]%%g ;

#								# Include settings into this namespace
#								$line = "use PHP;\n" ;
#								$line .= "require_php('$php', $namespace);" ;
								##$line = '' ;
								$line = require_php($php, $namespace);

							}


							else 
							{
								# Unknown
								print "UNKNOWN\n" if $DEBUG>=2 ;
								next ;
							}


							$cmd .= "$line\n" ;
						}
					}

					$PHP_INC{"$module $namespace"} = $cmd ;

					print "cmd <$cmd>\n" if $DEBUG ;
					eval $cmd ;
					if ($@)
					{
						print $@ ;
					}
					else 
					{
						# loaded ok
						$loaded = $cmd ;

						dumpvar($namespace) if $DEBUG ;
					}

					close $fh ;
					last ;
		       }
			}

			last if $realfilename ;
	   }


	   unless ($realfilename)
	   {
		   print "Can't find $filename in \@PHP_INC\n" ;
		   print "\@PHP_INC is:\n" ;
		   print "  $_\n" foreach (@PHP_INC) ;
		   die ;
	   }

	}


	return ($loaded) ;
}


# ============================================================================================
# UNEXPORTED BY DEFAULT
# ============================================================================================



( run in 0.885 second using v1.01-cache-2.11-cpan-5837b0d9d2c )