Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Writing to file...

by imrags (Monk)
on Jul 22, 2009 at 07:48 UTC ( #782207=note: print w/ replies, xml ) Need Help??


in reply to Writing to file...

Depends where you are failing...
If you are failing to browse thru the directory, then here's the code.

print_dir ( "YOUR/DIRECTORY/PATH" ); sub print_dir { my ($dir_name) = @_; opendir ( my $dir_h , "$dir_name") or die "Unable to open dir :$dir +_name: $!\n"; while ( my $file = readdir($dir_h) ) { next if ( "$dir_name/$file" =~ /\/\.$/ or "$dir_name/$file" =~ /\ +/\.\.$/ ); if ( -d "$dir_name/$file" ) { print_dir ( "$dir_name/$file" ); } print "$dir_name/$file - "."\n"; } }
It'll browse thru directories/sub-directories as well.
If you are failing to replace the carats, then this will help to find carats in a string
my $string = "xyz^^ is strange"; print $string if($string =~ /\^\^/);
Raghu


Comment on Re: Writing to file...
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://782207]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2015-07-28 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls