Current location: Hot Scripts Forums » Programming Languages » Perl » Converting from Perl to PHP


Converting from Perl to PHP

Reply
  #1 (permalink)  
Old 07-23-04, 03:45 PM
G-Money G-Money is offline
New Member
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Converting from Perl to PHP

I wasnt sure which section to put this into the perl or php, but I need some major help, I am having a tuff time even though its a small script, I have done much bigger ones then this one, but I have no idea what to do now. So can someone please help me convert this perl to php. Thanks

--------------------------------------------------------------------------

#! /usr/bin/perl -w
# this script will take data from disConnectND and parse it and output a clean format
# this is data that was copied and pasted from disConnectND course schedule

# @lines = split /\n/, `cat /usr/local/admin/scripts/txt/summer04.txt`;
@lines = split /\n/, `cat /usr/local/www/apps.vcsu.edu/asp/ConnectND`;

$x = 0;
while( $x < 35) {

shift @lines; $x++;
}

$i=0;

foreach $line(@lines) {

if( ($line and $line ne '' and !($line =~ m/^\t$|^\s+$/)) or $line eq '0' ) {

if( $line =~ m/^Class Nbr/ ) { $i=0; }

if( $i > 0 and $i < 11 ) { print "$line,"; }
elsif( $i == 15 ) {

if( $line =~ m/AM|PM/ ) { print "$line-"; }
else { print ""; }
}
elsif( $i == 16 ) {

if( $line =~ m/AM|PM/ ) { print "$line,"; }
else { print ","; }
}
elsif( $i == 17 ) { print "$line,"; }
elsif( $i == 18 ) {

($building,$roomNum) = split / RM /, $line;
if( !$roomNum ) { $roomNum = ''; }
print "$building,$roomNum,";
}
elsif( $i == 23 ) { print "$line\n"; }

# print "$i= [$line]\n";

$i++;
}
}

-------------------------------------------------------------------------
Reply With Quote
  #2 (permalink)  
Old 07-23-04, 04:38 PM
rec0n rec0n is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Earth
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
<?php
# this script will take data from disConnectND and parse it and output a clean format
# this is data that was copied and pasted from disConnectND course schedule

$lines = preg_split("/\n/", `cat /usr/local/www/apps.vcsu.edu/asp/ConnectND`);

$x = 0;
while ($x < 35) 
{
  array_shift($lines);
  $x++;
}

$i = 0;

foreach ($lines AS $line) 
{

  if (($line && $line != "" && !preg_match("/^\t$|^\s+$/", $line)) || $line == "0") 
  {

    if (preg_match("/^Class Nbr/", $line)) $i = 0;

    if ( $i > 0 && $i < 11) 
    {
      print "$line,";
    } 
    elsif ($i == 15) 
    {

      if (preg_match("/AM|PM/", $line)) print "$line-";

    } 
    elsif ($i == 16) 
    {

      if (preg_match("/AM|PM/", $line)) 
      {
        print "$line,";
      } 
      else 
      {
        print ",";
      }

    } 
    elsif ($i == 17) 
    {
      print "$line,";
    } 
    elsif ($i == 18) 
    {

      list($building, $roomNum) = preg_split("/ RM /", $line);

      if (!$roomNum) $roomNum = "";

      print "$building,$roomNum,";
    }
    elsif ($i == 23) 
    {
      print "$line\n";
    }

    $i++;
  }

}
?>
__________________
-- my bad lol
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Translate ASP to PHP and PERL POSERA ASP 0 06-12-04 01:12 AM
convert perl code to php phptalk Perl 1 01-15-04 02:06 AM
php visual basic perl cgi - outsource programming to india outsource_india General Advertisements 0 10-28-03 03:21 AM
Converting My/SQL 'DATETIME' to PHP... giropets PHP 1 10-20-03 08:09 PM
Bookings/Availability PHP or Perl Script Mista Mike Script Requests 1 08-20-03 08:37 AM


All times are GMT -5. The time now is 03:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.