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

Re: [PBML] how to?

Expand Messages
  • Jeff Eggen
    ... This is somewhat like the solution to your problem from yesterday. s/ /usr /apache /// Yuck, lots of slashes. Let s clean that up: s!/usr/apache/!! This
    Message 1 of 8 , Feb 28, 2002
    • 0 Attachment
      >>> david.m.nguyen@... 02/28/02 08:59am >>>
      >I have following lines in my daily report, how do I use perl to print only
      >report name like report1.pdf, report2.pdf, report3.doc , if I could I also
      >like to print them out like http://webserver/report1.pdf
      ><http://webserver/report1.pdf> so user can click on the link to view PDF
      >file. Is is a way to do this in perl?

      >/usr/apache/report1.pdf
      >/usr/apache/report2.pdf
      >/usr/apache/report3.doc

      This is somewhat like the solution to your problem from yesterday.

      s/\/usr\/apache\///

      Yuck, lots of slashes. Let's clean that up:

      s!/usr/apache/!!

      This will trim the path off. I'm assuming your files all have path /usr/apache/filename; if they don't, the regexp changes substantially.

      Question to the masses: does Perl have something like *nix's "basename" command? Or do we have to use regular expressions to get the job done?

      To print it out as a link on your website, just run

      print "http://webserver/$filename\n";

      Where $filename is the variable containing the results of the regexp above.
    • daymobrew
      ... Yes. use File::Basename; my $FullPath = /usr/apache/report1.pdf ; print Basename of $FullPath is , basename( $FullPath ), n ; This prints: Basename of
      Message 2 of 8 , Feb 28, 2002
      • 0 Attachment
        > does Perl have something like *nix's "basename" command?
        Yes.

        use File::Basename;

        my $FullPath = '/usr/apache/report1.pdf';
        print "Basename of $FullPath is ", basename( $FullPath ), "\n";

        This prints:
        Basename of /usr/apache/report1.pdf is report1.pdf

        --- In perl-beginner@y..., "Jeff Eggen" <jeggen@s...> wrote:
        > >>> david.m.nguyen@x... 02/28/02 08:59am >>>
        > >I have following lines in my daily report, how do I use perl to
        print only
        > >report name like report1.pdf, report2.pdf, report3.doc , if I
        could I also
        > >like to print them out like http://webserver/report1.pdf
        > ><http://webserver/report1.pdf> so user can click on the link to
        view PDF
        > >file. Is is a way to do this in perl?
        >
        > >/usr/apache/report1.pdf
        > >/usr/apache/report2.pdf
        > >/usr/apache/report3.doc
        >
        > This is somewhat like the solution to your problem from yesterday.
        >
        > s/\/usr\/apache\///
        >
        > Yuck, lots of slashes. Let's clean that up:
        >
        > s!/usr/apache/!!
        >
        > This will trim the path off. I'm assuming your files all have
        path /usr/apache/filename; if they don't, the regexp changes
        substantially.
        >
        > Question to the masses: does Perl have something like
        *nix's "basename" command? Or do we have to use regular expressions
        to get the job done?
        >
        > To print it out as a link on your website, just run
        >
        > print "http://webserver/$filename\n";
        >
        > Where $filename is the variable containing the results of the
        regexp above.
      • Nguyen, David M
        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,
        Message 3 of 8 , Feb 28, 2002
        • 0 Attachment
          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|");
          @result = <CMD>;

          print @result;

          close(CMD);




          -----Original Message-----
          From: Jeff Eggen [mailto:jeggen@...]
          Sent: Thursday, February 28, 2002 9:24 AM
          To: perl-beginner@yahoogroups.com
          Subject: Re: [PBML] how to?


          >>> david.m.nguyen@... 02/28/02 08:59am >>>
          >I have following lines in my daily report, how do I use perl to print only
          >report name like report1.pdf, report2.pdf, report3.doc , if I could I also
          >like to print them out like http://webserver/report1.pdf
          ><http://webserver/report1.pdf> so user can click on the link to view PDF
          >file. Is is a way to do this in perl?

          >/usr/apache/report1.pdf
          >/usr/apache/report2.pdf
          >/usr/apache/report3.doc

          This is somewhat like the solution to your problem from yesterday.

          s/\/usr\/apache\///

          Yuck, lots of slashes. Let's clean that up:

          s!/usr/apache/!!

          This will trim the path off. I'm assuming your files all have path
          /usr/apache/filename; if they don't, the regexp changes substantially.

          Question to the masses: does Perl have something like *nix's "basename"
          command? Or do we have to use regular expressions to get the job done?

          To print it out as a link on your website, just run

          print "http://webserver/$filename\n";

          Where $filename is the variable containing the results of the regexp above.



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        • daymobrew
          I recommend using the File::Find module. What is the $datafile value likely to be? report?.pdf ? ... print it ... like.... ... print only ... could I also ...
          Message 4 of 8 , Feb 28, 2002
          • 0 Attachment
            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|");
            > @result = <CMD>;
            >
            > print @result;
            >
            > close(CMD);
            >
            >
            >
            >
            > -----Original Message-----
            > From: Jeff Eggen [mailto:jeggen@s...]
            > Sent: Thursday, February 28, 2002 9:24 AM
            > To: perl-beginner@y...
            > Subject: Re: [PBML] how to?
            >
            >
            > >>> david.m.nguyen@x... 02/28/02 08:59am >>>
            > >I have following lines in my daily report, how do I use perl to
            print only
            > >report name like report1.pdf, report2.pdf, report3.doc , if I
            could I also
            > >like to print them out like http://webserver/report1.pdf
            > ><http://webserver/report1.pdf> so user can click on the link to
            view PDF
            > >file. Is is a way to do this in perl?
            >
            > >/usr/apache/report1.pdf
            > >/usr/apache/report2.pdf
            > >/usr/apache/report3.doc
            >
            > This is somewhat like the solution to your problem from yesterday.
            >
            > s/\/usr\/apache\///
            >
            > Yuck, lots of slashes. Let's clean that up:
            >
            > s!/usr/apache/!!
            >
            > This will trim the path off. I'm assuming your files all have path
            > /usr/apache/filename; if they don't, the regexp changes
            substantially.
            >
            > Question to the masses: does Perl have something like
            *nix's "basename"
            > command? Or do we have to use regular expressions to get the job
            done?
            >
            > To print it out as a link on your website, just run
            >
            > print "http://webserver/$filename\n";
            >
            > Where $filename is the variable containing the results of the
            regexp above.
            >
            >
            >
            > Unsubscribing info is here:
            > http://help.yahoo.com/help/us/groups/groups-32.html
            >
            > Your use of Yahoo! Groups is subject to
            http://docs.yahoo.com/info/terms/
          • Nguyen, David M
            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* .
            Message 5 of 8 , Mar 1, 2002
            • 0 Attachment
              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@...]
              Sent: Thursday, February 28, 2002 2:34 PM
              To: perl-beginner@yahoogroups.com
              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|");
              > @result = <CMD>;
              >
              > print @result;
              >
              > close(CMD);
              >
              >
              >
              >
              > -----Original Message-----
              > From: Jeff Eggen [mailto:jeggen@s...]
              > Sent: Thursday, February 28, 2002 9:24 AM
              > To: perl-beginner@y...
              > Subject: Re: [PBML] how to?
              >
              >
              > >>> david.m.nguyen@x... 02/28/02 08:59am >>>
              > >I have following lines in my daily report, how do I use perl to
              print only
              > >report name like report1.pdf, report2.pdf, report3.doc , if I
              could I also
              > >like to print them out like http://webserver/report1.pdf
              > ><http://webserver/report1.pdf> so user can click on the link to
              view PDF
              > >file. Is is a way to do this in perl?
              >
              > >/usr/apache/report1.pdf
              > >/usr/apache/report2.pdf
              > >/usr/apache/report3.doc
              >
              > This is somewhat like the solution to your problem from yesterday.
              >
              > s/\/usr\/apache\///
              >
              > Yuck, lots of slashes. Let's clean that up:
              >
              > s!/usr/apache/!!
              >
              > This will trim the path off. I'm assuming your files all have path
              > /usr/apache/filename; if they don't, the regexp changes
              substantially.
              >
              > Question to the masses: does Perl have something like
              *nix's "basename"
              > command? Or do we have to use regular expressions to get the job
              done?
              >
              > To print it out as a link on your website, just run
              >
              > print "http://webserver/$filename\n";
              >
              > Where $filename is the variable containing the results of the
              regexp above.
              >
              >
              >
              > Unsubscribing info is here:
              > http://help.yahoo.com/help/us/groups/groups-32.html
              >
              > Your use of Yahoo! Groups is subject to
              http://docs.yahoo.com/info/terms/



              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
            • uvega@technitrade.com
              Hi do i unsubscribe my email address? thanks Ulises [Non-text portions of this message have been removed]
              Message 6 of 8 , Mar 1, 2002
              • 0 Attachment
                Hi do i unsubscribe my email address?

                thanks

                Ulises

                [Non-text portions of this message have been removed]
              • Franki
                reading below your post would be a good start. Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html ... From:
                Message 7 of 8 , Mar 1, 2002
                • 0 Attachment
                  reading below your post would be a good start.

                  Unsubscribing info is here:
                  http://help.yahoo.com/help/us/groups/groups-32.html

                  -----Original Message-----
                  From: uvega@...
                  [mailto:uvega@...]On Behalf Of uvega@...
                  Sent: Saturday, 2 March 2002 1:56 AM
                  To: perl-beginner@yahoogroups.com
                  Subject: Re: [PBML] how to?


                  Hi do i unsubscribe my email address?

                  thanks

                  Ulises

                  [Non-text portions of this message have been removed]



                  Unsubscribing info is here:
                  http://help.yahoo.com/help/us/groups/groups-32.html

                  Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                • 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 8 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.