Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: File Input and Output

by grashoper (Monk)
on Aug 23, 2007 at 16:40 UTC ( #634685=note: print w/replies, xml ) Need Help??

in reply to File Input and Output

Ah good stuff here, I have succesfully opened my file and echoed its output, now I want to figure how to read in a number of files, and replace a value within each file, these files are in multiple directories..with differing account codes as names, the files themselves are named with the current date.txt I need to read in about 80 directories, parsing each file for current date, and modify the files to remove this "bad" value then re-write to original filename..

Replies are listed 'Best First'.
Re^2: File Input and Output
by Anonymous Monk on May 18, 2016 at 20:33 UTC

    I m having trouble using this in a script. I have a test file that looks like :

    open(my $fh1, ">>", "outputcontrol.txt"); open(my $fh2, ">>", "outputoutput.txt"); while ( <> ) { my $count = ($_ =~ y/x//); print "$count \n"; # print $_; if ( $count != $delim_amnt_per_line ) { print fh1 $_; } my ($prefix) = substr $_, 0, 7; next if $seen{$prefix}++; print fh2 $_; }

    Its supposed to do some checks on delimiter per line and remove duplicates based on a substring, my problem is that i have zero output on the filehandles. Whereas if i ran it with just print it would print normally, both expected outputs on STDOUT. Can someone help me?

      You replied to a node from 2007, its author was last here 1 year ago.

      Nevertheless, when using lexical filehandles (i.e. open my $fh1, the dollar sign isn't optional. Fix:

      print $fh2 $_; # ^ # | # Here.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-01-23 03:34 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (63 votes). Check out past polls.