Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    31

    Unanswered: howto do for i in * with perl

    How can I convert this shell script to perl for WINDOW
    mydir="c:\data"
    mytmp="c:\tmp"
    myexcel="c:\excel"

    for i in $mydir/*2003

    do

    copy $i $mytmp
    $myexcel\my_work_book.xls # run EXCEL
    delete $mytmp\$i

    done

  2. #2
    Join Date
    Nov 2003
    Posts
    65
    Don't know if you had figured it out by now or not. But i would start with the following:
    Code:
    my $dir= "c:\\data";
    my $tmp= "c:\\tmp";
    my $excel= "c:\\excel";
    
    my $mydir = $dir."//*2003";
    
    opendir(DIR,$mydir);
    my @list_of_files = readdir(DIR);
    foreach(@list_of_files)
    {
        if ( -f $_ )
        {
    	system("copy $i $tmp");
    	#
    	# Code to open excel
    	#
    	system("del $tmp\\$i");
        }
    }
    hasn't been tested but i'm sure you can figure it out.

    Quote Originally Posted by josephg
    How can I convert this shell script to perl for WINDOW
    mydir="c:\data"
    mytmp="c:\tmp"
    myexcel="c:\excel"

    for i in $mydir/*2003

    do

    copy $i $mytmp
    $myexcel\my_work_book.xls # run EXCEL
    delete $mytmp\$i

    done

Posting Permissions

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