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

Re: [PBML] return file handger

Expand Messages
  • merlyn@stonehenge.com
    ... jiqiang I want to write a subroutine for openfile (see below). jiqiang However, the subroutine failed to be returned to jiqiang $fhandle. Can anybody
    Message 1 of 11 , May 10, 2007
    • 0 Attachment
      >>>>> "jiqiang" == jiqiang yao <jiqiang123@...> writes:

      jiqiang> I want to write a subroutine for openfile (see below).
      jiqiang> However, the subroutine failed to be returned to
      jiqiang> $fhandle. Can anybody tells me why?

      Yes, stop using package-based filehandles. Use lexical filehandles.

      sub openfile {
      open my $handle, "<", shift or die "Cannot open: $!";
      return $handle;
      }

      But if it's this short, I wouldn't even write a subroutine.

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    • jiqiang yao
      Thank you very much. Can you write a similar one to open a directory? ...
      Message 2 of 11 , May 14, 2007
      • 0 Attachment
        Thank you very much.

        Can you write a similar one to open a directory?

        --- merlyn@... wrote:

        > >>>>> "jiqiang" == jiqiang yao
        > <jiqiang123@...> writes:
        >
        > jiqiang> I want to write a subroutine for openfile
        > (see below).
        > jiqiang> However, the subroutine failed to be
        > returned to
        > jiqiang> $fhandle. Can anybody tells me why?
        >
        > Yes, stop using package-based filehandles. Use
        > lexical filehandles.
        >
        > sub openfile {
        > open my $handle, "<", shift or die "Cannot open:
        > $!";
        > return $handle;
        > }
        >
        > But if it's this short, I wouldn't even write a
        > subroutine.
        >
        > --
        > Randal L. Schwartz - Stonehenge Consulting Services,
        > Inc. - +1 503 777 0095
        > <merlyn@...>
        > <URL:http://www.stonehenge.com/merlyn/>
        > Perl/Unix/security consulting, Technical writing,
        > Comedy, etc. etc.
        > See PerlTraining.Stonehenge.com for onsite and
        > open-enrollment Perl training!
        >




        ____________________________________________________________________________________Yahoo! oneSearch: Finally, mobile search
        that gives answers, not web links.
        http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
      • Rob Biedenharn
        That s an odd way to phrase a request for Randall s consulting rates? Perhaps you could try perldoc -f opendir before you decide whether you really want to
        Message 3 of 11 , May 14, 2007
        • 0 Attachment
          That's an odd way to phrase a request for Randall's consulting
          rates? Perhaps you could try
          perldoc -f opendir
          before you decide whether you really want to hire a consultant.

          -Rob

          On May 14, 2007, at 12:28 PM, jiqiang yao wrote:

          > Thank you very much.
          >
          > Can you write a similar one to open a directory?
          >
          > --- merlyn@... wrote:
          >
          >>>>>>> "jiqiang" == jiqiang yao
          >> <jiqiang123@...> writes:
          >>
          >> jiqiang> I want to write a subroutine for openfile
          >> (see below).
          >> jiqiang> However, the subroutine failed to be
          >> returned to
          >> jiqiang> $fhandle. Can anybody tells me why?
          >>
          >> Yes, stop using package-based filehandles. Use
          >> lexical filehandles.
          >>
          >> sub openfile {
          >> open my $handle, "<", shift or die "Cannot open:
          >> $!";
          >> return $handle;
          >> }
          >>
          >> But if it's this short, I wouldn't even write a
          >> subroutine.
          >>
          >> --
          >> Randal L. Schwartz - Stonehenge Consulting Services,
          >> Inc. - +1 503 777 0095
          >> <merlyn@...>
          >> <URL:http://www.stonehenge.com/merlyn/>
          >> Perl/Unix/security consulting, Technical writing,
          >> Comedy, etc. etc.
          >> See PerlTraining.Stonehenge.com for onsite and
          >> open-enrollment Perl training!
          >>

          Rob Biedenharn http://agileconsultingllc.com
          Rob@...
        • merlyn@stonehenge.com
          ... jiqiang Can you write a similar one to open a directory? Yes. I can. What s your budget? ... -- Randal L. Schwartz - Stonehenge Consulting Services,
          Message 4 of 11 , May 14, 2007
          • 0 Attachment
            >>>>> "jiqiang" == jiqiang yao <jiqiang123@...> writes:

            jiqiang> Can you write a similar one to open a directory?

            Yes. I can. What's your budget?

            :-)

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
            See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
          • jiqiang yao
            Hi, How to save the contents as html file given an internet address? ____________________________________________________________________________________Be a
            Message 5 of 11 , May 14, 2007
            • 0 Attachment
              Hi,
              How to save the contents as html file given an
              internet address?



              ____________________________________________________________________________________Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
              http://answers.yahoo.com/dir/?link=list&sid=396545469
            • jiqiang yao
              Thank you, Rob. I have written a subroutine which can extract all the files within this folder and this is exactly what I need. ...
              Message 6 of 11 , May 14, 2007
              • 0 Attachment
                Thank you, Rob.
                I have written a subroutine which can extract all the
                files within this folder and this is exactly what I
                need.

                --- Rob Biedenharn <Rob@...> wrote:

                > That's an odd way to phrase a request for Randall's
                > consulting
                > rates? Perhaps you could try
                > perldoc -f opendir
                > before you decide whether you really want to hire a
                > consultant.
                >
                > -Rob
                >
                > On May 14, 2007, at 12:28 PM, jiqiang yao wrote:
                >
                > > Thank you very much.
                > >
                > > Can you write a similar one to open a directory?
                > >
                > > --- merlyn@... wrote:
                > >
                > >>>>>>> "jiqiang" == jiqiang yao
                > >> <jiqiang123@...> writes:
                > >>
                > >> jiqiang> I want to write a subroutine for
                > openfile
                > >> (see below).
                > >> jiqiang> However, the subroutine failed to be
                > >> returned to
                > >> jiqiang> $fhandle. Can anybody tells me why?
                > >>
                > >> Yes, stop using package-based filehandles. Use
                > >> lexical filehandles.
                > >>
                > >> sub openfile {
                > >> open my $handle, "<", shift or die "Cannot
                > open:
                > >> $!";
                > >> return $handle;
                > >> }
                > >>
                > >> But if it's this short, I wouldn't even write a
                > >> subroutine.
                > >>
                > >> --
                > >> Randal L. Schwartz - Stonehenge Consulting
                > Services,
                > >> Inc. - +1 503 777 0095
                > >> <merlyn@...>
                > >> <URL:http://www.stonehenge.com/merlyn/>
                > >> Perl/Unix/security consulting, Technical writing,
                > >> Comedy, etc. etc.
                > >> See PerlTraining.Stonehenge.com for onsite and
                > >> open-enrollment Perl training!
                > >>
                >
                > Rob Biedenharn http://agileconsultingllc.com
                > Rob@...
                >
                >
                >




                ____________________________________________________________________________________
                It's here! Your new message!
                Get new email alerts with the free Yahoo! Toolbar.
                http://tools.search.yahoo.com/toolbar/features/mail/
              • Damien Carbery
                ... use LWP::Simple; my $status = getstore( http://www.yahoo.com , yahoo-home.html ); print File downloaded. if is_success($status);
                Message 7 of 11 , May 15, 2007
                • 0 Attachment
                  --- In perl-beginner@yahoogroups.com, jiqiang yao <jiqiang123@...> wrote:
                  >
                  > Hi,
                  > How to save the contents as html file given an
                  > internet address?
                  >

                  use LWP::Simple;
                  my $status = getstore( 'http://www.yahoo.com', 'yahoo-home.html' );
                  print "File downloaded." if is_success($status);
                Your message has been successfully submitted and would be delivered to recipients shortly.