Results 1 to 4 of 4

Thread: Replace backslash with forward slash in Perl

  1. #1
    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!

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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...

  3. #3
    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...

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    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...

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,716,172,654.42237 seconds with 17 queries