Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 21st, 2000, 11:36 AM
Zabu Zabu is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 9 Zabu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm not familiar w/ perl, does anyone know how to convert this php code into perl ?

<?
//put file in array
$fcontents = file ('http://www.domain.com/file_to_print.php3');
//print each lines
while ( list( $line_num, $line ) = each( $fcontents ) ) {
$val = stripslashes( $line );
echo $val;
}
?>

I'm trying to read & print output from a file that is located on another site in order to share news between my domains.

Reply With Quote
  #2  
Old August 21st, 2000, 11:55 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
You have to use the excellent LWP module set (well, you don't _have_ to, but it'd be damn silly not to). Something like:

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->agent('SomeUAString' . $ua->agent);

my $req = HTTP::Request->new( GET => 'http://www.domain.com/somefile.php3' );

my $res = $ua->request($req);

print $res->content;
[/code]

I'm not sure what stripslashes does for you in PHP (I don't do PHP). If you let me know I'll give you equivalent Perl code. If it's just used to remove escape characters from the stream (e.g. ' => '), use:
$res->content =~ s///g;
before the prin $res->content line.

Loads of docs on LWP can be found with perldoc LWP

Reply With Quote
  #3  
Old August 21st, 2000, 12:05 PM
Zabu Zabu is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 9 Zabu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanx so much for your help.
(yes the 'stripslashes function' is to escape quote)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > perl to read file (converting php codes)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap