![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to split special characters "|" using awk | krishna9 | Shell Programming and Scripting | 3 | 05-22-2008 06:30 AM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| split the string "Setview: arv-temp-view" | amitrajvarma | Shell Programming and Scripting | 2 | 10-11-2007 05:14 AM |
| deleting newline characters but not the "true" \n character | caddyjoe77 | Shell Programming and Scripting | 1 | 08-15-2007 10:21 PM |
| Perl - split with "|" | lumdev | Shell Programming and Scripting | 3 | 02-04-2007 02:14 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
perl split funciton - special character "/"
HI,
I have a directory structure. /abc/def/ghi/ I want to store it into array. So that if I do a pop function on that array I can easily go to previous directory. But how can i split and store it. @Directory = split(/\//,$DirectoryVarialbe) That doest works. Any other escape sequence should be given?? Kindly help. |
|
||||
|
Perl split function
Hi,
It should work fine. I tried the following... Code:
#!/usr/bin/perl -w
use strict;
# Program to accept a file path and store it in a array
my $dir = "/abc/def/ghi/";
my @Dir = split(/\//, $dir);
pop(@Dir);
my $PreviousDir = join("/", @Dir);
print "The original Directory is $dir\n";
print "The new Directory is $PreviousDir\n";
|
|
||||
|
Thakns this worked!!!
Is there any simple method to do to parent directory. similar to "cd .."?? Quote:
|
|
||||
|
Thanks for your reply. The escape sequence worked. Initially i managed to load the array without even spliting the fields from the sclar variable. That was in an attempt of trail and error. Now I forgot how I did that though.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| perl split, split perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|