Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-08-2009
Member
 
Join Date: Jul 2009
Posts: 43
Replace backslash with forward slash in Perl

I'm new to perl and i am having a serious problem importing a file into a database. I need a way to replace the backslash with the forward slash.Is it possible buy writing a user defined function? Can anyone please help me... Thanks in advance!
Reply With Quote
  #2  
Old 03-08-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Replace backslash with forward slash in Perl

Try this :
Code:
open ULFILE, ">$upload_dir/$filename";

binmode ULFILE;

while ( <$upload_filehandle> )
{
  $_ =~ s/\\//g;
  
  print ULFILE;
}

close ULFILE;
Replace variables accordingly...
Reply With Quote
  #3  
Old 03-08-2009
Member
 
Join Date: Jul 2009
Posts: 43
Re: Replace backslash with forward slash in Perl

Ok, thanks, i will try it out... But any other code or script? Just in case this doesn't work, Thanks though... Will try your code and get back about it...
Reply With Quote
  #4  
Old 03-08-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Replace backslash with forward slash in Perl

Well, try this out :

Code:
find -name "*.html" -type f | while read file
do 
  awk '{ gsub( /\\/, "/" ); print }' $file > $file.$$
  mv $file.$$ $file
done
Hope this works...
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Replace backslash with forward slash in Perl"
Thread Thread Starter Forum Replies Last Post
Keyboard Backslash \ displays # ndaka123488 Hardware Peripherals 1 10-11-2011 12:11 AM
Double Slash after .com jamiehook01 Tips & Tweaks 1 27-09-2011 12:34 AM
Keyboard problem forward slash replaced with ? LavRaj Windows Vista Performance 2 08-01-2011 08:31 AM
Replace backslash in a string Gunner 1 Software Development 5 18-02-2010 05:43 AM
Backslash key is showing hash key Nalini_sh Portable Devices 3 08-12-2009 07:06 PM


All times are GMT +5.5. The time now is 08:37 PM.