Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Split file using perl and regexp

by davido (Archbishop)
on Jan 17, 2013 at 21:17 UTC ( #1013892=note: print w/ replies, xml ) Need Help??


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

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.


Dave


Comment on Re^3: Split file using perl and regexp
Re^4: Split file using perl and regexp
by brad_nov (Novice) on Jan 17, 2013 at 21:36 UTC
    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.

Re^4: Split file using perl and regexp
by brad_nov (Novice) on Jan 17, 2013 at 22:03 UTC
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-08-30 21:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls