Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] how to?

Expand Messages
  • daymobrew
    How did you use the File::Find module? The following code prints out the names of pdf files: #!/usr/local/bin/perl -w use strict; use File::Find; sub wanted {
    Message 1 of 8 , Mar 1, 2002
    • 0 Attachment
      How did you use the File::Find module?
      The following code prints out the names of pdf files:

      #!/usr/local/bin/perl -w

      use strict;
      use File::Find;

      sub wanted
      {
      if ( $File::Find::name =~ /\.pdf$/i )
      {
      print "$File::Find::name\n";
      }
      }

      File::Find::find({wanted => \&wanted, no_chdir => 1 }, '.' );

      I'm not sure how you change the '/\.pdf$/i' regular expression to be
      a variable, which is what I think you need to do. I'm sure someone
      has the Perl Cookbook handy to look this up.

      --- In perl-beginner@y..., "Nguyen, David M" <david.m.nguyen@x> wrote:
      > I had tried using Find::File module to search but it could not
      search PDF
      > files. $datafile is anything when user types in, for example "
      *report.pdf*
      > " .
      >
      > Thanks,
      > David
      >
      > -----Original Message-----
      > From: daymobrew [mailto:daymobrew@y...]
      > Sent: Thursday, February 28, 2002 2:34 PM
      > To: perl-beginner@y...
      > Subject: Re: [PBML] how to?
      >
      >
      > I recommend using the File::Find module.
      > What is the $datafile value likely to be? "report?.pdf"?
      >
      > --- In perl-beginner@y..., "Nguyen, David M" <david.m.nguyen@x>
      wrote:
      > > The problem I have is I capture all lines into array @result and
      > print it
      > > out. How do I change each line in array? Here's my script looks
      > like....
      > >
      > > Thanks,
      > > David
      > >
      > > #!/usr/local/bin/perl -w
      > >
      > >
      > > use CGI qw(param);
      > >
      > >
      > >
      > > $base_url = 'http://softswitch';
      > >
      > > $datafile = param("datafile");
      > >
      > >
      > > print "Content-type: text/html\n\n";
      > >
      > > print "<html><head><title>SoftSwitch Web
      Server</title></head><body>
      > >
      > > <body text=#53761f link=#53761f vlink=#53761f alink=#659942>
      > >
      > > <center><H1><b>SoftSwitch Web Server</b></H1><H2>Results</H2></c
      > > enter><p>";
      > >
      > >
      > >
      > > print "<HR><P>\n";
      > >
      > > print "<pre><font color=#53761F>";
      > > open(CMD, "find /var/apache/htdocs/sonusnotification -name
      $datafile
      > > -print|");

      <snip loads>
    Your message has been successfully submitted and would be delivered to recipients shortly.