Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: Split file using perl and regexp

by brad_nov (Novice)
on Jan 17, 2013 at 20:21 UTC ( #1013882=note: print w/replies, xml ) Need Help??

in reply to Re: Split file using perl and regexp
in thread Split file using perl and regexp

I mean I was able to split the file based on the solution given by Kenosis. It's an extension to yesterday's problem. Sorry if I was not clear. Thanks.

Replies are listed 'Best First'.
Re^3: Split file using perl and regexp
by davido (Archbishop) on Jan 17, 2013 at 21:17 UTC

    If it's an extension of yesterday's problem, post the code that you're currently using so that we can help in extending it.

    Otherwise it just looks like you're making zero progress on your own, and hoping someone will do free work for you.


      I am currently using the script like this
      $split_file=$ARGV[0]; $split_file=~ s{.*/}{}; $split_file=~ s{\.[^.]+$}{}; print "split_file=$split_file\n"; while (<>) { if ( my ($m_id) = /^\d+\|(\d+?)\|/ ) { open my $fh, '>>', "${split_file}_" . $m_id . '.txt'; print $fh $_; } }
      I am trying to create a script for each scenario and pass it as variable.

        By using data placeholders, viz., ~somedata~some data~~~~~~~~~~~~some data~~~~~, you may be omitting information that would assist in crafting a solution to accomplish your end--assuming you're not redacting information.

        Consider showing samples of the actual data, provided it's suitible for public consumption, as this will likely be more beneficial.

      Currently I am using the below script to split into multiple files:
      $split_file=$ARGV[0]; $split_file=~ s{.*/}{}; $split_file=~ s{\.[^.]+$}{}; print "split_file=$split_file\n"; while (<>) { if ( my ($m_id) = /^\d+\|(\d+?)\|/ ) { open my $fh, '>>', "${split_file}_" . $m_id . '.txt'; print $fh $_; } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013882]
[choroba]: Integration testing
[stevieb]: heh, yeah, sorry. This is integration testing for certain. In fact, it's even Continuous Integration ;)
[stevieb]: Obviously, Travis CI just won't cut it for these distributions...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-06-25 23:24 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (572 votes). Check out past polls.