[32089] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3353 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 16 14:09:31 2011

Date: Sat, 16 Apr 2011 11:09:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 16 Apr 2011     Volume: 11 Number: 3353

Today's topics:
    Re: dereferencing in perl <tadmc@seesig.invalid>
    Re: dereferencing in perl <Uno@example.invalid>
    Re: grabbing a facebook group <Uno@example.invalid>
    Re: grabbing a facebook group <Uno@example.invalid>
    Re: grabbing a facebook group <derykus@gmail.com>
    Re: grabbing a facebook group <m@rtij.nl.invlalid>
    Re: grabbing a facebook group <mvdwege@mail.com>
    Re: grabbing a facebook group <Uno@example.invalid>
    Re: grabbing a facebook group <mvdwege@mail.com>
    Re: grabbing a facebook group <tadmc@seesig.invalid>
    Re: grabbing a facebook group <sherm.pendley@gmail.com>
    Re: grabbing a facebook group <sherm.pendley@gmail.com>
        List of valid HTML friendly mime types <seven.reeds@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 15 Apr 2011 15:22:45 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: dereferencing in perl
Message-Id: <slrniqh9vn.5hi.tadmc@tadbox.sbcglobal.net>

J. Gleixner <glex_no-spam@qwest-spam-no.invalid> wrote:
> Uno wrote:
>> On 04/14/2011 05:54 PM, Uno wrote:
>> 
>>> So I'm back at the beginning again.
>>>
>>> my $subject = $c->xhdr("", $i);
>>> print "$subject\n";
>>>
>>> Is there no way shorter way to what I intend 


> Why do you care how many lines it takes?


Because he is new to programming, and neophytes always think
that that is bettter for some reason.


> It doesn't really matter how you do it or how many lines it takes,
> as long as you understand it.


That sounds like someone who is NOT a new programmer.

:-)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Sat, 16 Apr 2011 00:16:39 -0600
From: Uno <Uno@example.invalid>
Subject: Re: dereferencing in perl
Message-Id: <90sqi8FsbgU1@mid.individual.net>

On 04/15/2011 02:22 PM, Tad McClellan wrote:
> J. Gleixner<glex_no-spam@qwest-spam-no.invalid>  wrote:

>> Why do you care how many lines it takes?
>
>
> Because he is new to programming, and neophytes always think
> that that is bettter for some reason.

$ perl client8.pl
News::NNTPClient::SOCK1 command: GROUP comp.lang.perl.misc
News::NNTPClient::SOCK1 result(211): 4711 658334 663070 comp.lang.perl.misc
News::NNTPClient::SOCK1 command: XHDR Subject 663068
News::NNTPClient::SOCK1 result(221): Subject fields follow
News::NNTPClient::SOCK1 received 1 lines
663068 List of valid HTML friendly mime types

Use of uninitialized value $arg1 in concatenation (.) or string at 
client8.pl line 19, <SOCK1> line 7.

News::NNTPClient::SOCK1 command: XHDR Subject 663069
News::NNTPClient::SOCK1 result(221): Subject fields follow
News::NNTPClient::SOCK1 received 1 lines
663069 FAQ 4.58 How do I look up a hash element by value?

Use of uninitialized value $arg1 in concatenation (.) or string at 
client8.pl line 19, <SOCK1> line 10.

News::NNTPClient::SOCK1 command: XHDR Subject 663070
News::NNTPClient::SOCK1 result(221): Subject fields follow
News::NNTPClient::SOCK1 received 1 lines
663070 FAQ 4.40 What is the difference between $array[1] and @array[1]?

Use of uninitialized value $arg1 in concatenation (.) or string at 
client8.pl line 19, <SOCK1> line 13.

News::NNTPClient::SOCK1 command: QUIT
News::NNTPClient::SOCK1 result(205): .
$ cat client8.pl
#!/usr/bin/perl
use strict;
use warnings;
use Net::NNTP ();
require News::NNTPClient;

my $group = 'comp.lang.perl.misc';
my $server = 'News.Individual.NET';
my $user = '';
my $pass = '';

my $c = new News::NNTPClient($server);
$c->authinfo($user, $pass);
$c->debug(2);
my ($first, $last) = ($c->group($group));
  for my $i ( $last-2 .. $last ){
      (my $subject, my $arg1) = $c->xhdr("Subject", $i);
     print "$subject\n";
     print "$arg1\n";
   }
__END__


$

Do I succumb to the same criticism if I think "better" is better with 
fewer than three t's?:D

Anyways, still looking at xhdr, and this seemed to be the only relevant 
stuff in NNTP.pm:

sub xhdr {
   @_ >= 2 && @_ <= 4 or croak 'usage: $nntp->xhdr( HEADER, [ 
MESSAGE-SPEC ] )';
   my $nntp = shift;
   my $hdr  = shift;
   my $arg  = _msg_arg(@_);

   $nntp->_XHDR($hdr, $arg)
     ? $nntp->_description
     : undef;
}

q1)  What does perl do when the interpreter sees this?

q2) Why do I not see $arg1 getting populated correctly?
-- 
Uno


------------------------------

Date: Sat, 16 Apr 2011 01:03:00 -0600
From: Uno <Uno@example.invalid>
Subject: Re: grabbing a facebook group
Message-Id: <90st95Fe2bU1@mid.individual.net>

On 04/15/2011 11:38 AM, Sherm Pendley wrote:

> For Facebook data, you'll probably have better luck using their API than
> trying to emulate a browser&  scraping their pages. There's a module
> for that:
>
>    <http://search.cpan.org/perldoc?Facebook>
>
> If you're talking about a FB *user*, rather than a *group*, it's even
> easier - they provide a tool to download a record of everything you've
> done there, including copies of any images&  videos you've posted.
> Unfortunately, there doesn't seem to be an equivalent tool for group
> activity.
>
>    <https://www.facebook.com/help/?topic=download>
>
> sherm--
>

Well, hot damn, sherm, I'm really pleased with my initial effort.  I 
went to a terminal and typed
cpan
install Facebook
, and it was doing it's thing, but telling me that it couldn't do 
things, so I ctrl-C'ed out of that and typed
sudo cpan
install Facebook
, and think I'm sitting pretty:

Running make install
Prepending /home/dan/.cpan/build/Facebook-0.102-C7c3EJ/blib/arch 
/home/dan/.cpan/build/Facebook-0.102-C7c3EJ/blib/lib to PERL5LIB for 
'install'
Installing /usr/local/share/perl/5.10.1/Facebook.pm
Installing /usr/local/share/perl/5.10.1/Facebook/Manual.pod
Installing /usr/local/share/perl/5.10.1/Facebook/Signed.pm
Installing /usr/local/share/perl/5.10.1/Facebook/Cookie.pm
Installing /usr/local/share/perl/5.10.1/Facebook/Cookbook.pod
Installing /usr/local/man/man3/Facebook::Cookie.3pm
Installing /usr/local/man/man3/Facebook::Signed.3pm
Installing /usr/local/man/man3/Facebook.3pm
Installing /usr/local/man/man3/Facebook::Cookbook.3pm
Installing /usr/local/man/man3/Facebook::Manual.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod
   FRANKS/Facebook-0.102.tar.gz
   make install  -- OK
Warning (usually harmless): 'YAML' not installed, will not store 
persistent state

cpan[2]>

Why is my terminal always telling me that 'YAML' is not installed, while 
python-yaml is?
-- 
Uno


------------------------------

Date: Sat, 16 Apr 2011 01:14:12 -0600
From: Uno <Uno@example.invalid>
Subject: Re: grabbing a facebook group
Message-Id: <90stu4FhtlU1@mid.individual.net>

On 04/15/2011 02:22 AM, bugbear wrote:

> I think facebook may well make extensive use of javascript and/or flash,
> which will complicate your task.
>
> BugBear

I'm able to complicate my task in any event:

$ ./fb1.pl
 ./fb1.pl: line 2: use: command not found
 ./fb1.pl: line 3: use: command not found
 ./fb1.pl: line 5: use: command not found
 ./fb1.pl: line 7: syntax error near unexpected token `('
 ./fb1.pl: line 7: `  my $fb = Facebook->new('
$ cat fb1.pl
  #!/usr/bin/perl
use strict;
use warnings;

use Facebook;

   my $fb = Facebook->new(
     app_id => $app_id,
     api_key => $api_key,
     secret => $secret,
   );

   use Facebook::Signed;

   my $logged_in_fb = Facebook->new(
     signed => Facebook::Signed->new(
       secret => $secret,
       facebook_data => $facebook_cookie_for_your_application_as_text,
     ),
     app_id => $app_id,
     secret => $secret,
         api_key => $api_key,
   );

   # If you dont provide secret, it will try to fetch it from signed values
   my $shorter_logged_in_fb = Facebook->new(
     signed => Facebook::Signed->new(
       secret => $secret,
       facebook_data => $facebook_cookie_for_your_application_as_text,
     ),
     app_id => $app_id,
     api_key => $api_key,
   );

   # You need to have Facebook::Graph installed so that this works
   my $gettys_facebook_profile = $fb->graph->query
     ->find(100001153174797)
     ->include_metadata
     ->request
     ->as_hashref;

__END__

$

How does my interpreter all of a sudden not know what I mean when I say 
"use?"
-- 
Uno


------------------------------

Date: Sat, 16 Apr 2011 01:26:06 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: grabbing a facebook group
Message-Id: <0fa92900-006d-4324-9861-944f232af6d3@d19g2000prh.googlegroups.com>

On Apr 16, 12:14=A0am, Uno <U...@example.invalid> wrote:
> On 04/15/2011 02:22 AM, bugbear wrote:
>
> > I think facebook may well make extensive use of javascript and/or flash=
,
> > which will complicate your task.
>
> > BugBear
>
> I'm able to complicate my task in any event:
>
> $ ./fb1.pl
> ./fb1.pl: line 2: use: command not found
> ./fb1.pl: line 3: use: command not found
> ./fb1.pl: line 5: use: command not found
> ./fb1.pl: line 7: syntax error near unexpected token `('
> ./fb1.pl: line 7: ` =A0my $fb =3D Facebook->new('
> $ cat fb1.pl

> =A0 #!/usr/bin/perl
^^^^
^^^^
^^^^
Eliminate leading space above

> use strict;
> use warnings;
> ...
>
> How does my interpreter all of a sudden not know what I mean when I say
> "use?"

--
Charles DeRykus




------------------------------

Date: Sat, 16 Apr 2011 10:30:49 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: grabbing a facebook group
Message-Id: <pm0o78-73q.ln1@news.rtij.nl>

On Sat, 16 Apr 2011 01:14:12 -0600, Uno wrote:

> On 04/15/2011 02:22 AM, bugbear wrote:
> 
>> I think facebook may well make extensive use of javascript and/or
>> flash, which will complicate your task.
>>
>> BugBear
> 
> I'm able to complicate my task in any event:
> 
> $ ./fb1.pl
> ./fb1.pl: line 2: use: command not found ./fb1.pl: line 3: use: command
> not found ./fb1.pl: line 5: use: command not found ./fb1.pl: line 7:
> syntax error near unexpected token `(' ./fb1.pl: line 7: `  my $fb =
> Facebook->new(' $ cat fb1.pl
>   #!/usr/bin/perl
> use strict;
> use warnings;


Get rid of the spaces before the hash. Your shell does not see it needs 
to start perl, so it is interpreted by the shell as a shell script.

M4


------------------------------

Date: Sat, 16 Apr 2011 10:39:24 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: grabbing a facebook group
Message-Id: <86wriur3nn.fsf@gareth.avalon.lan>

Uno <Uno@example.invalid> writes:

>
> $ ./fb1.pl
> ./fb1.pl: line 2: use: command not found
> ./fb1.pl: line 3: use: command not found
> ./fb1.pl: line 5: use: command not found
> ./fb1.pl: line 7: syntax error near unexpected token `('
> ./fb1.pl: line 7: `  my $fb = Facebook->new('
> $ cat fb1.pl
>  #!/usr/bin/perl
> use strict;
> use warnings;
<snip>

> How does my interpreter all of a sudden not know what I mean when I
> say "use?"

Because your system is trying to run a shell script instead of perl.

When you launch an executable text file, Linux will look at the first
two characters: if these are #!, then the rest of the line will be used
as the interpreter command to run the text file with. If the first two
characters are *not* #!, then the code will be run by your shell.

Now take a *good* look at your code. What are the first two characters?

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


------------------------------

Date: Sat, 16 Apr 2011 03:20:21 -0600
From: Uno <Uno@example.invalid>
Subject: Re: grabbing a facebook group
Message-Id: <90t5alF6n5U1@mid.individual.net>

On 04/16/2011 02:39 AM, Mart van de Wege wrote:

> Because your system is trying to run a shell script instead of perl.
>
> When you launch an executable text file, Linux will look at the first
> two characters: if these are #!, then the rest of the line will be used
> as the interpreter command to run the text file with. If the first two
> characters are *not* #!, then the code will be run by your shell.
>
> Now take a *good* look at your code. What are the first two characters?
>
> Mart
>

$ perl fb1.pl
Global symbol "$app_id" requires explicit package name at fb1.pl line 8.
Global symbol "$api_key" requires explicit package name at fb1.pl line 9.
Global symbol "$secret" requires explicit package name at fb1.pl line 10.
BEGIN not safe after errors--compilation aborted at fb1.pl line 13.
$

It was a single, white space.  I find that white space is not your 
friend in perl.
-- 
Uno


------------------------------

Date: Sat, 16 Apr 2011 16:26:23 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: grabbing a facebook group
Message-Id: <86sjtiqnlc.fsf@gareth.avalon.lan>

Uno <Uno@example.invalid> writes:

> On 04/16/2011 02:39 AM, Mart van de Wege wrote:
>
>> Because your system is trying to run a shell script instead of perl.
>>
>> When you launch an executable text file, Linux will look at the first
>> two characters: if these are #!, then the rest of the line will be used
>> as the interpreter command to run the text file with. If the first two
>> characters are *not* #!, then the code will be run by your shell.
>>
>> Now take a *good* look at your code. What are the first two characters?
>>
>> Mart
>>
>
> $ perl fb1.pl
> Global symbol "$app_id" requires explicit package name at fb1.pl line 8.
> Global symbol "$api_key" requires explicit package name at fb1.pl line 9.
> Global symbol "$secret" requires explicit package name at fb1.pl line 10.
> BEGIN not safe after errors--compilation aborted at fb1.pl line 13.
> $
>
> It was a single, white space.  I find that white space is not your
> friend in perl.

When people do you the courtesy of patiently explaining how something
works, please do have the courtesy in return of actually *reading* what
they wrote.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


------------------------------

Date: Sat, 16 Apr 2011 09:50:46 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: grabbing a facebook group
Message-Id: <slrniqjat8.7uj.tadmc@tadbox.sbcglobal.net>

Uno <Uno@example.invalid> wrote:
> On 04/16/2011 02:39 AM, Mart van de Wege wrote:
>
>> Because your system is trying to run a shell script instead of perl.
>>
>> When you launch an executable text file, Linux will look at the first
>> two characters: if these are #!, then the rest of the line will be used
>> as the interpreter command to run the text file with. If the first two
>> characters are *not* #!, then the code will be run by your shell.
>>
>> Now take a *good* look at your code. What are the first two characters?
>>
>> Mart
>>
>
> $ perl fb1.pl
> Global symbol "$app_id" requires explicit package name at fb1.pl line 8.
> Global symbol "$api_key" requires explicit package name at fb1.pl line 9.
> Global symbol "$secret" requires explicit package name at fb1.pl line 10.
> BEGIN not safe after errors--compilation aborted at fb1.pl line 13.
> $
>
> It was a single, white space.  I find that white space is not your 
> friend in perl.


There *was no perl* involved!

Your original code never invoked the perl interpreter.

So:

   white space is not your friend in shebang lines


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Sat, 16 Apr 2011 13:26:33 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: grabbing a facebook group
Message-Id: <m2aafqds52.fsf@sherm.shermpendley.com>

Uno <Uno@example.invalid> writes:

> Why is my terminal always telling me that 'YAML' is not installed,
> while python-yaml is?

Because YAML is a Perl module, and python-yaml is not.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Sat, 16 Apr 2011 13:27:52 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: grabbing a facebook group
Message-Id: <m262qeds2v.fsf@sherm.shermpendley.com>

Uno <Uno@example.invalid> writes:

> On 04/15/2011 02:22 AM, bugbear wrote:
>
>> I think facebook may well make extensive use of javascript and/or flash,
>> which will complicate your task.
>>
>> BugBear
>
> I'm able to complicate my task in any event:
>
> $ ./fb1.pl
> ./fb1.pl: line 2: use: command not found
> ./fb1.pl: line 3: use: command not found
> ./fb1.pl: line 5: use: command not found
> ./fb1.pl: line 7: syntax error near unexpected token `('
> ./fb1.pl: line 7: `  my $fb = Facebook->new('
> $ cat fb1.pl
>  #!/usr/bin/perl

You have an extra space before #!, so your script is (mis)interpreted as
a shell script.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Fri, 15 Apr 2011 13:52:24 -0700 (PDT)
From: "seven.reeds" <seven.reeds@gmail.com>
Subject: List of valid HTML friendly mime types
Message-Id: <acc2c1ca-7842-481e-b593-3e2d5857b31e@a11g2000pro.googlegroups.com>

Hi,

I have what I thought was gong to be a fairly simple CGI issue.
I have a web form that has either a 'FileUpload" field or a text field
that *should* have a fully qualified URL string.  The CGI script will
receive one or the other, not both.

I will know if I have image/video data if the "$CGI->upload()" method
returns something useful.  I will know that I have a valid URL if
the value of "$CGI->param('image')" sent through LWP::Simple::head
an array of values.

I want to be a bit cautious as well.  I want to limit the SIZE of the
delivered graphic data.  I can check that once it is delivered/
fetched.

I also want to limit the range of allowed MIME types.  There are a
huge number of MIME types defined but only a small number of them are
"valid" for rendering in HTML pages.

This is where I am probably starting to reinvent the wheel.
LWP::Simple::head will tell me the "content-type" of the item and
the "$CGI->upload()" also returns content-type info.  What I am not
instantly seeing is a list of "valid" HTML display types.

Does such a thing exist in Perl module form?  I have seen posts here
where folks hard-code the allowed list into a Perl structure.  Is that
the best/only way?


thanks


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 3353
***************************************


home help back first fref pref prev next nref lref last post