Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi All,

I am a real real beginner of Perl.

I am trying to write a Perl Script to extract all the filenames with the date <FileName>.20041204****** in the given list of Filenames as below and place BSC, SBSCSubsystem and MCBTS filenames in separate files:

-rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 arun2-20041127120100

-rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 abc2-20041127130812

-rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 abc1-20041127131046

-rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202143000

-rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202140000

-rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202133000

-rw-rw-rw- 1 bsmbin bsmbin 7018 Dec 3 02:06 MCBTSSubsystem-20041202143000

-rw-rw-rw- 1 bsmbin bsmbin 7019 Dec 3 02:06 MCBTSSubsystem-20041202140000

-rw-rw-rw- 1 bsmbin bsmbin 7020 Dec 3 02:06 MCBTSSubsystem-20041202133000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202143000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202140000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202133000

-rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 03:00 SBSCSubsystem-20041202150000

-rw-rw-rw- 1 bsmbin bsmbin 7020 Dec 3 03:00 MCBTSSubsystem-20041202150000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 03:00 BSC-20041202150000

-rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 04:00 SBSCSubsystem-20041202160000

-rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 04:00SBSCSubsystem-20041202153000

The Algorithm I thought of is like this :-

1) Create 3 separate Files with names BSC, SBSCSubsystem and MCBTSSubsystem using File I/O.

2) First, check in the given list of filenames starting from the top, files with name BSC-20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File BSC.Continue this process, until you reach the end of the List.

3) Second, check in the given list of filenames starting from the top, files with name SBSCSubsystem- 20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File SBSCSubsystem. Continue this process, until you reach the end of the List.

4) Third, check in the given list of filenames starting from the top, files with name MCBTSSubsystem- 20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File MCBTSSubsystem. Continue this process, until you reach the end of the List.

In this way, all the respective filenames are transferred to the corresponding Files. Think that Regular Expressions might be required to implement the Logic of File Sorting.

Can anyone help me with a Perl Script for the same.

Thanks,

Kiran

Considered: gregor42 - reap: dupliate of Sorting names using Regular Expressions and placing them in different Files.. Final vote: Keep = 5, Edit = 1, Reap = 20.
Unconsidered: davido. Keep votes blocked reaping. Node has a followup, and is buried in a thread; reaping not advisable.


In reply to Re^7: Sorting names using Regular Expressions and placing them in different Files. by Kiran Kumar K V N
in thread Sorting names using Regular Expressions and placing them in different Files. by Kiran Kumar K V N

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found