How do I do this one-liner (windows command) in perl ?

Discussion in 'Perl Misc' started by Mark, Apr 29, 2004.

  1. Mark

    Mark Guest

    This is all I need to be able to do in Perl:

    if exist c:\data\bad\* (move c:\data\)

    Thanks.
    Mark, Apr 29, 2004
    #1
    1. Advertising

  2. Mark

    Tore Aursand Guest

    On Thu, 29 Apr 2004 14:53:54 -0400, Mark wrote:
    > This is all I need to be able to do in Perl:
    >
    > if exist c:\data\bad\* (move c:\data\)


    What does it mean? I guess 'move' takes two arguments, no? Where do you
    want to move things?

    Anyway. Take a look at the File::Copy, File::Find and File::Find::Rule
    modules. They should help you do the task.


    --
    Tore Aursand <>
    "Leadership is doing what is right when no one is watching." (George
    Van Valkenburg)
    Tore Aursand, Apr 29, 2004
    #2
    1. Advertising

  3. Mark

    Mark Guest

    On Thu, 29 Apr 2004 21:01:07 +0200, Tore Aursand <> wrote:

    >On Thu, 29 Apr 2004 14:53:54 -0400, Mark wrote:
    >> This is all I need to be able to do in Perl:
    >>
    >> if exist c:\data\bad\* (move c:\data\)

    >
    >What does it mean? I guess 'move' takes two arguments, no? Where do you
    >want to move things?


    The above checks to see if there is anything in c:\data\bad\
    If there is, move it to c:\data\

    >Anyway. Take a look at the File::Copy, File::Find and File::Find::Rule
    >modules. They should help you do the task.


    I've poked around a bit with those, but I'm green as can be with Perl. I was
    hoping this would be simple to those who 'know'....
    Mark, Apr 29, 2004
    #3
  4. Mark

    Paul Lalli Guest

    On Thu, 29 Apr 2004, Mark wrote:

    > On Thu, 29 Apr 2004 21:01:07 +0200, Tore Aursand <> wrote:
    >
    > >On Thu, 29 Apr 2004 14:53:54 -0400, Mark wrote:
    > >> This is all I need to be able to do in Perl:
    > >>
    > >> if exist c:\data\bad\* (move c:\data\)

    > >
    > >What does it mean? I guess 'move' takes two arguments, no? Where do you
    > >want to move things?

    >
    > The above checks to see if there is anything in c:\data\bad\
    > If there is, move it to c:\data\
    >
    > >Anyway. Take a look at the File::Copy, File::Find and File::Find::Rule
    > >modules. They should help you do the task.

    >
    > I've poked around a bit with those, but I'm green as can be with Perl. I was
    > hoping this would be simple to those who 'know'....


    It is. But we are not here to write programs for you. What we are here
    (volunteering) for, is to help you with your Perl problems. If you have a
    question about the best way to get something done, we point you in the
    right direction. If you have a question as to why some piece of code is
    not working the way you think it should, we help clarify the code and/or
    your thinking. Please do not ask us to do for free what many of us do for
    a living.

    Look at those modules, make an attempt, and if it doesn't work, show us
    where you're running into difficulties, and we'll try to help.

    Now that you've clarified the problem a bit, I'm going to suggest you also
    take a look at
    perldoc perlrun
    and search for the -i argument


    Paul Lalli
    Paul Lalli, Apr 29, 2004
    #4
  5. Mark

    Mark Guest

    On Thu, 29 Apr 2004 15:36:30 -0400, Paul Lalli <> wrote:

    >On Thu, 29 Apr 2004, Mark wrote:
    >
    >> On Thu, 29 Apr 2004 21:01:07 +0200, Tore Aursand <> wrote:
    >>
    >> >On Thu, 29 Apr 2004 14:53:54 -0400, Mark wrote:
    >> >> This is all I need to be able to do in Perl:
    >> >>
    >> >> if exist c:\data\bad\* (move c:\data\)
    >> >
    >> >What does it mean? I guess 'move' takes two arguments, no? Where do you
    >> >want to move things?

    >>
    >> The above checks to see if there is anything in c:\data\bad\
    >> If there is, move it to c:\data\
    >>
    >> >Anyway. Take a look at the File::Copy, File::Find and File::Find::Rule
    >> >modules. They should help you do the task.

    >>
    >> I've poked around a bit with those, but I'm green as can be with Perl. I was
    >> hoping this would be simple to those who 'know'....

    >
    >It is. But we are not here to write programs for you. What we are here
    >(volunteering) for, is to help you with your Perl problems. If you have a
    >question about the best way to get something done, we point you in the
    >right direction. If you have a question as to why some piece of code is
    >not working the way you think it should, we help clarify the code and/or
    >your thinking. Please do not ask us to do for free what many of us do for
    >a living.
    >
    >Look at those modules, make an attempt, and if it doesn't work, show us
    >where you're running into difficulties, and we'll try to help.
    >
    >Now that you've clarified the problem a bit, I'm going to suggest you also
    >take a look at
    >perldoc perlrun
    >and search for the -i argument
    >
    >
    >Paul Lalli



    Thanks for spending more time writing that up than it would have taken to just
    translate the code.

    *sigh* Back to google where the usefull information resides.



    >
    Mark, Apr 29, 2004
    #5
  6. Mark

    Paul Lalli Guest

    On Thu, 29 Apr 2004, Mark wrote:

    > >> I've poked around a bit with those, but I'm green as can be with Perl. I was
    > >> hoping this would be simple to those who 'know'....

    > >
    > >It is. But we are not here to write programs for you. What we are here
    > >(volunteering) for, is to help you with your Perl problems. If you have a
    > >question about the best way to get something done, we point you in the
    > >right direction. If you have a question as to why some piece of code is
    > >not working the way you think it should, we help clarify the code and/or
    > >your thinking. Please do not ask us to do for free what many of us do for
    > >a living.
    > >
    > >Look at those modules, make an attempt, and if it doesn't work, show us
    > >where you're running into difficulties, and we'll try to help.
    > >
    > >Now that you've clarified the problem a bit, I'm going to suggest you also
    > >take a look at
    > >perldoc perlrun
    > >and search for the -i argument
    > >
    > >
    > >Paul Lalli

    >
    >
    > Thanks for spending more time writing that up than it would have taken to just
    > translate the code.
    >
    > *sigh* Back to google where the usefull information resides.


    Hahaha. I love people like this. People who are just completely adverse
    to reading documentation. The funniest part (to me) is that if Mark had
    actually read the perldoc I suggested, he would have actually found the
    exact answer, and an example one-liner that does precisely what he wants.

    Oh well. Happy Surfing, Mark.

    Paul Lalli
    Paul Lalli, Apr 29, 2004
    #6
  7. Mark

    Mark Guest

    On Thu, 29 Apr 2004 15:49:15 -0400, Paul Lalli <> wrote:

    >On Thu, 29 Apr 2004, Mark wrote:
    >
    >> >> I've poked around a bit with those, but I'm green as can be with Perl. I was
    >> >> hoping this would be simple to those who 'know'....
    >> >
    >> >It is. But we are not here to write programs for you. What we are here
    >> >(volunteering) for, is to help you with your Perl problems. If you have a
    >> >question about the best way to get something done, we point you in the
    >> >right direction. If you have a question as to why some piece of code is
    >> >not working the way you think it should, we help clarify the code and/or
    >> >your thinking. Please do not ask us to do for free what many of us do for
    >> >a living.
    >> >
    >> >Look at those modules, make an attempt, and if it doesn't work, show us
    >> >where you're running into difficulties, and we'll try to help.
    >> >
    >> >Now that you've clarified the problem a bit, I'm going to suggest you also
    >> >take a look at
    >> >perldoc perlrun
    >> >and search for the -i argument
    >> >
    >> >
    >> >Paul Lalli

    >>
    >>
    >> Thanks for spending more time writing that up than it would have taken to just
    >> translate the code.
    >>
    >> *sigh* Back to google where the usefull information resides.

    >
    >Hahaha. I love people like this. People who are just completely adverse
    >to reading documentation. The funniest part (to me) is that if Mark had
    >actually read the perldoc I suggested, he would have actually found the
    >exact answer, and an example one-liner that does precisely what he wants.


    And, once again, google came through for me. I should have know better to
    just start there.

    BTW, I just checked your perldoc and the examples shown do NOT do what I want
    (as expected). Thanks for playing.

    I love people like YOU who are so full of themselves and have a godlike
    attitude. You need to come down a few pegs.

    It's not up to you to decide to teach me. That's not what I asked for and
    have no use for it.

    This is a one time deal with me and will not have any use for Perl in the
    foreseeable future.

    Good luck continuing with your "holier than thou" mission.
    Mark, Apr 29, 2004
    #7
  8. Mark

    Paul Lalli Guest

    On Thu, 29 Apr 2004, Mark wrote:

    > >> Thanks for spending more time writing that up than it would have taken to just
    > >> translate the code.
    > >>
    > >> *sigh* Back to google where the usefull information resides.

    > >
    > >Hahaha. I love people like this. People who are just completely adverse
    > >to reading documentation. The funniest part (to me) is that if Mark had
    > >actually read the perldoc I suggested, he would have actually found the
    > >exact answer, and an example one-liner that does precisely what he wants.

    >
    > And, once again, google came through for me. I should have know better to
    > just start there.


    To start there to get a pre-written program for you? Yes, you absolutely
    should have. This isn't the place for it.

    > BTW, I just checked your perldoc and the examples shown do NOT do what I want
    > (as expected). Thanks for playing.


    <sigh> Please try to read.
    As shown above, Perl creates the backup file whether or
    not any output is actually changed. So this is just a
    fancy way to copy files:

    $ perl -p -i '/some/file/path/*' -e 1 file1 file2 file3...

    > I love people like YOU who are so full of themselves and have a godlike
    > attitude. You need to come down a few pegs.
    >
    > It's not up to you to decide to teach me. That's not what I asked for and
    > have no use for it.
    >
    > This is a one time deal with me and will not have any use for Perl in the
    > foreseeable future.
    >
    > Good luck continuing with your "holier than thou" mission.


    Out of pure curiousity, let's do a hypothetical situation. Say you have a
    leaky pipe in your bathroom. You come upon a total stranger that you
    happen to know is a professional plumber. Do you ask him what kind of
    wrench to use to fix it, or do you ask him to come over to your house and
    fix it for you (for free, of course)? I'm seriously curious about this.
    Maybe I'm the one with the bizzare point of view. I'm willing to accept
    that possibility.

    But hell, I've gotten into enough flame mini-wars in the past two days to
    last quite a while. Reply to this or don't. This will be my final word
    on the subject, I promise.

    Paul Lalli
    Paul Lalli, Apr 29, 2004
    #8
  9. Mark <> wrote:

    > *sigh* Back to google where the usefull information resides.



    Thank you for going away.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Apr 29, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee
    Replies:
    0
    Views:
    342
    Xah Lee
    Oct 20, 2005
  2. Alain Helfenstein

    Ruby Command Line One Liner

    Alain Helfenstein, Jan 1, 2009, in forum: Ruby
    Replies:
    5
    Views:
    137
    Alain Helfenstein
    Jan 11, 2009
  3. Robert Miller

    Deciphering a very cryptic perl "one-liner"

    Robert Miller, Jun 4, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    317
    Ben Morrow
    Jun 4, 2004
  4. Larry
    Replies:
    1
    Views:
    99
    Martien Verbruggen
    Feb 3, 2005
  5. perl one liner

    , May 11, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    73
Loading...

Share This Page