Professional Web Applications Themes

Processing files in Multiple directories (Bash or Perl?) - PERL Beginners

Hi, I have a perl code, with usage: mycode.pl file.txt > file1.out Now I would like to execute this code for files in multiple directory (e.g. dir1, dir2, dir3, ...dir10). As I am new for both Bash and Perl, would like to know if it is be easier to do this with Perl or Bash? I have already have a bash script (didn't know how to proceed): ------------------------------- #!bin/bash for i in * do if [ -d $i ] then find $i -name '*.fa*' #perl mycode.pl $i > #????? don't know how to go from here fi done ------------------------------------- Would ...

  1. #1

    Default Processing files in Multiple directories (Bash or Perl?)

    Hi,

    I have a perl code, with usage:

    mycode.pl file.txt > file1.out

    Now I would like to execute this code
    for files in multiple directory (e.g. dir1, dir2, dir3, ...dir10).

    As I am new for both Bash and Perl, would like to know
    if it is be easier to do this with Perl or Bash?


    I have already have a bash script (didn't know how to proceed):

    -------------------------------
    #!bin/bash

    for i in *
    do
    if [ -d $i ]
    then
    find $i -name '*.fa*'

    #perl mycode.pl $i > #????? don't know how to go from here
    fi
    done
    -------------------------------------

    Would any body kindly advice?

    Thanks so much for your time.
    Hope to hear from you again

    Regards
    Edward WIJAYA
    SINGAPORE
    --
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
    Edward Guest

  2. #2

    Default RE: Processing files in Multiple directories (Bash or Perl?)

    Original Message-----
    From: Edward WIJAYA [mailto:com.sg]
    Sent: Monday, July 19, 2004 11:37 AM
    To: org
    Subject: Processing files in Multiple directories (Bash or Perl?)

    Hi,

    I have a perl code, with usage:

    mycode.pl file.txt > file1.out

    Now I would like to execute this code
    for files in multiple directory (e.g. dir1, dir2, dir3, ...dir10).

    As I am new for both Bash and Perl, would like to know
    if it is be easier to do this with Perl or Bash?


    I have already have a bash script (didn't know how to proceed):

    -------------------------------
    #!bin/bash

    for i in *
    do
    if [ -d $i ]
    then
    find $i -name '*.fa*'

    #perl mycode.pl $i > #????? don't know how to go from here
    fi
    done
    -------------------------------------

    Would any body kindly advice?

    Thanks so much for your time.
    Hope to hear from you again

    Regards
    Edward WIJAYA
    SINGAPORE


    I find this easier to do but then I know perl better than bash...

    DEV,SUN2>./foo file1=a,b,c/d/e file2=x/f/g file3=/,home/cgi-bin
    Find file2 in Dirs = (x/f/g)
    Find file1 in Dirs = (a,b,c/d/e)
    Find file3 in Dirs = (/,home/cgi-bin)
    DEV,SUN2>more foo
    #! /usr/local/bin/perl
    use strict;
    my %params;
    foreach (ARGV) {
    my ($file, $dirs)=split /=/;
    {$params{$file}} = split /,/, $dirs;
    }
    foreach (keys %params) {
    print "Find $_ in Dirs = (", join (',', {$params{$_}}), ')', "\n";
    # do any "stuff" you want then call the already existing perl script
    # like see if the file exist in the dir before calling other
    script
    # or better yet - sub ... I develop lots of things in little
    blocks
    # get them working then combine...
    }
    DEV,SUN2>

    I also like the way read "reads" ...
    John Guest

  3. #3

    Default How to pass two arrays as arg in a subroutine?

    Hi,

    I have a subroutine that take 2 arrays as argument.
    I dont' know how to construct it?

    sub mysub{

    my (array1, array2) = _; # is this correct? How do I do it?

    #process array1
    #process array2 etc

    return array3;
    }

    Please advice.

    Thanks so much for your time.

    Regards,
    Edward WIJAYA
    SINGAPORE
    Edward Guest

Similar Threads

  1. Perl or Bash error?
    By Juman in forum PERL Beginners
    Replies: 4
    Last Post: February 25th, 07:59 PM
  2. exit perl script and cd in bash?
    By Kenton Brede in forum PERL Beginners
    Replies: 5
    Last Post: January 21st, 03:58 AM
  3. Replies: 4
    Last Post: November 28th, 05:28 PM
  4. perl and bash about localization
    By Eric Schwartz in forum PERL Miscellaneous
    Replies: 1
    Last Post: September 6th, 05:24 AM
  5. How to execute perl from bash
    By Nicolas Briones in forum UNIX Programming
    Replies: 3
    Last Post: July 31st, 03:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139