Re: Perl Scripting problem - please help!

From: Jim Gibson (jgibson_at_mail.arc.nasa.gov)
Date: 03/17/05

  • Next message: Joe Smith: "Re: Perl Scripting problem - please help!"
    Date: Thu, 17 Mar 2005 13:32:48 -0800
    
    

    In article <313a5f9e.0503170647.66bb7bee@posting.google.com>, Mark
    <budman@generation.net> wrote:

    > Hello,
    >
    > I am new to PERL and I want to do a simple function (in LINUX):
    >
    > find all files that have the extension pseudo.pdf and put the file
    > names in a file;
    > parse the file and change all file names current filename plus date:
    >
    > pseudo+date+.pdf
    >
    > Move the new file to pseudo directory :
    >
    > I have written the code which seems to work without any errors and has
    > been accepted by PERL:
    >
    > #!/usr/bin/perl -w
    > open (pdfs, "/var/www/html/reports/shops/pdflist.txt")
    > ||Error('open','file');
    > @fnames=<pdfs>;
    > close (pdfs);
    >
    > ($second,$minute,$hour,$day,$month,$year,$weekday,$dayofyear,$isdst)=localtime
    > (time);
    > $cmonth=$month+1;
    > $cyear=($year % 100);
    > $fdate=$cmonth.'-'.$day.'-'.$cyear;
    > $ext='.pdf';
    > foreach $pdffile (@fnames2) {
    > $pdffile=$pdffile.$fdate.$ext;
    > }
    > $n=1;
    > foreach $fnames (@fnames) {
    > $cnt=index($fnames,".pdf");
    > $newfile=substr($fnames,0,$cnt);
    > $newpdf=$newfile.$fdate.$ext;
    > print "fnames: $fnames \n";
    > print "new file: $newfile \n";
    > print "newpdf: $newpdf \n";
    > print "old= /var/www/html/reports/shops/$fnames \n";
    > print "new= /var/www/html/reports/shops/$newfile/$newpdf \n";
    > rename("/var/www/html/reports/shops/$fnames","/var/www/html/reports/shops/
    > $newfile/$newpdf");
    > print "\n";
    >
    > }
    >
    >
    > I cannot get the rename function to work even if I use the same
    > directory. I don't get any errors and the file permissions are set
    > correctly on the files.
    >
    > Anyone know why this does not work?

    Perhaps because the directory /var/www/html/reports/shops/$newfile does
    not exist?

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---


  • Next message: Joe Smith: "Re: Perl Scripting problem - please help!"

    Relevant Pages

    • Perl Scripting problem - please help!
      ... I am new to PERL and I want to do a simple function: ... Move the new file to pseudo directory: ... foreach $pdffile { ... foreach $fnames { ...
      (comp.lang.perl)
    • Perl Scripting problem - please help
      ... I am new to PERL and I want to do a simple function: ... Move the new file to pseudo directory: ... foreach $pdffile { ... foreach $fnames { ...
      (comp.lang.perl.misc)
    • UTF-8-codierte Umlaute via print und warn ausgeben
      ... Unter Windows/Cygwin im Cygwin-Terminal mit Cygwins Perl: ... Im UTF-8-Xterm funktioniert die Umlautausgabe mit print und warn, ... der zweite foo.pl-Aufruf unter Linux (und im ... Cygwin Perl (im xterm und im "gewoehnlichen" Cygwin-Terminal) und auch ...
      (de.comp.lang.perl.misc)
    • Re: LD_LIBRARY_PATH on x86_64 linux
      ... I imagine you also have to take in to account whether you are using 64bit OS vs 32 bit perl, etc. etc. I've always dealt with this issue on my Sun boxes and resorted to using a wrapper script. ... My environment generally needs to be different for launching other oracle applications, so this way I don't break other things. ... Subject: LD_LIBRARY_PATH on x86_64 linux ... on other Linux platforms, too. ...
      (perl.dbi.users)
    • Re: Demand of PF CLI
      ... >> using the PF APIs directly, or providing such access in perl, python, ... >> style approach was taken to embrace other firewall solutions. ... > you mean this module could work for Linux iptables too. ... There is Linux's iptables, ipf on NetBSD and Solaris, ...
      (comp.unix.bsd.openbsd.misc)