Help - Search - Member List - Calendar
Full Version: combinations
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44
Support our Sponsors!
Brian Volk
Brian Volk wrote:

QUOTE
but I am still having some problems with Scale and Write.  The error is:

"my" variable $img masks earlier declaration in same scope at C:/Program
Files/
erlEdit/scripts/image_test.pl line 25.
JPEG 70048.jpg
Can't call method "Scale" on an undefined value at C:/Program
Files/PerlEdit/sc
ipts/image_test.pl line 24.

As you can see the program starts to read from the image directoy, but when
it >.hits "Scale", I get the undefined value error.  I'm not sure what that

means.

No need to respond. I was using "my" agian on the same variable. It works
now.

Brian

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

foreach my $image_source_file(@images_to_process_list) {

my $img = new Image::Magick;
my $status=$img->Read("$image_source_folder\$image_source_file");

if ($status eq "") {

my $fmt = $img->Get('format');
print "JPEG $image_source_filen";
$img->Scale(width=>'30', height=>'30');
$img->Write("jpg:$image_dest_folder\$image_source_file");
undef $img;
}
}

-----Original Message-----
From: Brian Volk
Sent: Monday, September 13, 2004 10:18 AM
To: 'Beginners (E-mail)'
Subject: RE: perl crashing at $image->Read (file=> *ARGV);


Wiggins d'Anconia wrote:

QUOTE
It appears that the docs for I::M are incorrect and that C<Read> and
C<Write> must take a filehandle.  Difficult to tell since all the code
is XS/C and I didn't feel like popping the hood on it. You could try
switching back to using a handle but I would be more specific about it,
so for instance, within the foreach you would have:

open my $READHANDLE, $filename or die "Can't open file for reading: $!";
$image->Read('file' => $READHANDLE);

etc.

Or there is an issue with the installation, paths, etc. on Windows. You
should retrieve the actual error message from I::M and see what it says,
similar to,

my $result = $image->Read('file' => $filename);
print $result;

Well, I got it reading from a directory, Mike at the Image::Magick mailing
list help me out... "The read must contain the path as well as the filename.

$image->Read (file=> "$path\$file");"

but I am stil having some problems with Scale and Write. The error is:

"my" variable $img masks earlier declaration in same scope at C:/Program
Files/
erlEdit/scripts/image_test.pl line 25.
JPEG 70048.jpg
Can't call method "Scale" on an undefined value at C:/Program
Files/PerlEdit/sc
ipts/image_test.pl line 24.

As you can see the program starts to read from the image directoy, but when
it hits "Scale", I get the undefined value error. I'm not sure what that
means.

-------------------------------
#!/user/bin/perl -w

use strict;
use Image::Magick;

my $image_source_folder = "C:/images";
my $image_dest_folder = "C:/images_small";

opendir(IMAGES,$image_source_folder);
my @images_to_process_list=grep {!(/^./) && -f "$image_source_folder/$_"}
readdir(IMAGES);
closedir (IMAGES);

foreach my $image_source_file(@images_to_process_list) {

my $img = new Image::Magick;

my $status=$img->Read("$image_source_folder\$image_source_file");

if ($status eq "") {

my $fmt = $img->Get('format');
print "JPEG $image_source_filen";
my $img->Scale(width=>'30', height=>'30');
my
$img->Write("jpg:$image_dest_folder\$image_source_file");
undef $img;
}
}

Thanks for any help!

Brian


-----Original Message-----
From: Wiggins d'Anconia [mailto:[Email Removed]]
Sent: Thursday, September 09, 2004 6:32 PM
To: Brian Volk
Cc: Beginners (E-mail)
Subject: Re: perl crashing at $image->Read (file=> *ARGV);


Please bottom post....

Brian Volk wrote:
QUOTE
Thank you Wiggins!  I have changed everything that you suggested and I
think
I am much closer.  However, I have run into an error w/ the Read line.

foreach my $file (@files) {
$image->Read (file=> $file)

Bad filehandle: brian.jpg at C:/Program Files/PerlEdit/scripts/test_3.pl
line 17

as you can see the script is seeing the file name in the image directory.
I
re-read chapter 11 Learning Perl on Bad Filehandles but I'm still having
trouble.  Any suggestion would be greatly appreciated.

Thanks!

Brian


Either....

It appears that the docs for I::M are incorrect and that C<Read> and
C<Write> must take a filehandle. Difficult to tell since all the code
is XS/C and I didn't feel like popping the hood on it. You could try
switching back to using a handle but I would be more specific about it,
so for instance, within the foreach you would have:

open my $READHANDLE, $filename or die "Can't open file for reading: $!";
$image->Read('file' => $READHANDLE);

etc.

Or there is an issue with the installation, paths, etc. on Windows. You
should retrieve the actual error message from I::M and see what it says,
similar to,

my $result = $image->Read('file' => $filename);
print $result;

Have you checked out the info at:

http://www.dylanbeattie.net/magick/

It appears to be good info for Win32 specific stuff related to I::M.
Personally I can't even test it here so it is difficult for me to point
you in the right direction. Maybe one of the other M$ users will chime
in ...

http://danconia.org


QUOTE

-----Original Message-----
From: Wiggins d Anconia [mailto:[Email Removed]]
Sent: Thursday, September 09, 2004 12:28 PM
To: Brian Volk; Beginners (E-mail)
Subject: Re: perl crashing at $image->Read (file=> *ARGV);



Hi All,

I my perl script is crashing perl at this line;

$image->Read (file=> *ARGV);

I know that it is this line because I have commented out everything else
around it.  When I just have the Read statment, perl will crash.  Here is
the script, can someone please suggest what I am doing wrong.

Thanks!



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

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

use strict;
use Image::Magick;

my $images = "C:/images";
opendir (IMAGES, $images) or die "can not open $images: $!";

# load @ARGV for (<>)

@ARGV = map { "$images/$_" } grep { !/^./ } readdir IMAGES;



my @files = map { "$images/$_" } grep { !/^./ } readdir IMAGES;

Not sure why you are using @ARGV just for its special qualities (aka the
<> operator) why not name our variables, we are allowed too.


my $image = Image::Magick->new(magick=>'JPEG');

# Read images, Scale down and Write to new directory

while (<>) {


No need to use a while here, since you already have a complete array,

foreach my $file (@files) {


$image->Read (file=> *ARGV)


By naming our variables we now see that we are dealing with a filename,
rather than a typeglob reference.

$image->Read(file => $file)

The example you are using assumes that *ARGV contains an opened
filehandle to the file itself, *but* within the loop you are executing
on each line. See perldoc perlop for more. I would skip using the
special nature of the variables until you understand them. Try using
specifically named variables until the program works, then reduce it if
you must.


and $image->Scale (width=>'50', height=>'50')
and $image->Write ("C:/images")


C<Write> expects a filename argument, not a directory, or a handle.


and close (ARGV);


Not sure why these statements are strung together with C<and> they can
be separate, you haven't really benefited by making them a single
statement. And you wouldn't normally close ARGV.


}

closedir IMAGES;



You can close your dir earlier in the process, since you are done
reading from it.


Brian Volk
HP Products

<mailto:[Email Removed]> [Email Removed]



http://danconia.org



--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Bob Showalter
Schlabach, Torsten wrote:
QUOTE
Dear list,

I have a problem with Perl and I have no idea at all how to search
for it.

I have a CGI script that is calling a perl module. One function in
that module uses a sub which is defined only later in the source, but
there is a forward declaration available for the function with sub.
Conceptionally this looks like this:

FooModule.pm:

package FooModule;

sub usedLater;

sub theFunctionCalledFromoutside{

...

...

usedLater( $argument );

}

sub usedLater{

[... some code ...]

}

1;

The call

usedLater( $argument );

leads to this errror

Undefined subroutine &FooModule::usedLater called at ...

Any idea where to search? This is code I did not write myself and
others have reported it worked for them unter Perl 5.8.1. I have
5.8.0. I also tried with 5.8.5, but got the same error, so this does
not look like a Perl version issue.

The forward declaraction is not necessary. There's nothing in the snippet
you posted to explain the error; it should be working.

Is this a pure CGI environment, or are you running under mod_perl or
similar? Are you sure there is no package statement before the declaration
of usedLater? Are you positive there are no typos?

Torsten Schlabach
Well, it's not really MY code, but I will attach it.
It is line 103 that breaks! (The call to genDialog.)

Torsten

-----Ursprngliche Nachricht-----
Von: Jenda Krynicky [mailto:[Email Removed]]
Gesendet: Montag, 13. September 2004 18:47
An: '[Email Removed]'
Betreff: Re: Undefined subroutine [...] called at [...] though sub and routine exist


From: "Schlabach, Torsten" <[Email Removed]>
QUOTE
I have a CGI script that is calling a perl module. One function in
that module uses a sub which is defined only later in the source, but
there is a forward declaration available for the function with sub.
Conceptionally this looks like this:

FooModule.pm:

package FooModule;

sub usedLater;

sub theFunctionCalledFromoutside{

...

...

usedLater( $argument );

}

sub usedLater{

[... some code ...]

}

1;

Conceptualy this should work. You must have a typo or something in
your code. Show us some of the real code.

Jenda
===== [Email Removed] === http://Jenda.Krynicky.cz ====When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Torsten Schlabach
QUOTE
Is this a pure CGI environment,

Yes!

QUOTE
or are you running under mod_perl or similar?

No!

QUOTE
Are you sure there is no package statement before the declaration of usedLater?

None except the one saying "package FooModule;".

QUOTE
Are you positive there are no typos?

Yes, I am. This is because I haven't written the code but it is part of a module that other people have reported be work for them. I have posted it.

To me the 1.000.000 USD question would be: Is there any way to debug this? Like for example print a list of all known subs at a given point in time?

Torsten

-----Ursprngliche Nachricht-----
Von: Bob Showalter [mailto:[Email Removed]]
Gesendet: Montag, 13. September 2004 18:50
An: 'Schlabach, Torsten'; '[Email Removed]'
Betreff: RE: Undefined subroutine [...] called at [...] though sub and rou tine exist


Schlabach, Torsten wrote:
QUOTE
Dear list,

I have a problem with Perl and I have no idea at all how to search for
it.

I have a CGI script that is calling a perl module. One function in
that module uses a sub which is defined only later in the source, but
there is a forward declaration available for the function with sub.
Conceptionally this looks like this:

FooModule.pm:

package FooModule;

sub usedLater;

sub theFunctionCalledFromoutside{

...

...

usedLater( $argument );

}

sub usedLater{

[... some code ...]

}

1;

The call

usedLater( $argument );

leads to this errror

Undefined subroutine &FooModule::usedLater called at ...

Any idea where to search? This is code I did not write myself and
others have reported it worked for them unter Perl 5.8.1. I have
5.8.0. I also tried with 5.8.5, but got the same error, so this does
not look like a Perl version issue.

The forward declaraction is not necessary. There's nothing in the snippet you posted to explain the error; it should be working.

Is this a pure CGI environment, or are you running under mod_perl or similar? Are you sure there is no package statement before the declaration of usedLater? Are you positive there are no typos?

Randy W. Sims
Bee wrote:
QUOTE
- besize template 'aAuU', anything else tempplate I can use to
prepare fix length data ? - if yes, but how do I assuming the
block size is? In case,  if I write a binary file and I wanna
use seek.

You are going to have to explain that in more detail.

In case, I am doing something like a log with User v TimesOfSignIn.
So, user name will set as 30 char long, and the Signin times is about
in scope of a normal integer. I wanna make this a simple DB for this
but not a list of single files for each user. So I wanna make this
doable for ramdom read write, so, that should be in a binary file.

You want to have a look at DBM files. Read
perldoc DB_File
or
perldoc SDBM_File

Or you may try to install DBD::SQLite. That would give you the full
power of SQL without having to install anything but the module.

However, as the file is in a binary, I think there could be a size

benfit for me to compress the data length.

"Premature optimization is the root of all evil."

How many users are we talking about? Millions? I would not sweat over
a few KB you might save.


Yes, that's very right, I should have to do that with some db modules!!! I
am sorry I missed something to declare here . I just do it as an experiment
to know and learn how pack works in this ways.

So, I still looking for a pack way to get this job done. Actaully, I am still
quite confuse on what I can expect pack and unpack can giving help to me,
in furture. I guess I would have some light to know what pack is while this
get done.

pack and unpack simply provide a way to translate the bits of a string
in a specific way. eg. you can look at a string of bits as a series of
32-bit signed integers or you can look at the same string as a series of
8-bit characters. (It's sort of like a casting operator in C/C++.) It
provides a way of looking at or storing data in a very specific way.
It's primary use is looking at or creating binary data to be shared with
other (C-like) applications.

Randy.

Bob Showalter
Bee wrote:
QUOTE
In case, I am doing something like a log with User v
TimesOfSignIn. So, user name will set as 30 char long, and the
Signin times is about in scope of a normal integer. I wanna make
this a simple DB for this but not a list of single files for each
user. So I wanna make this doable for ramdom read write, so, that
should be in a binary file.
...
Yes, that's very right, I should have to do that with some db
modules!!! I am sorry I missed something to declare here . I just do
it as an experiment to know and learn how pack works in this ways.

What you're talking about here is serialization of data structures. Look
into the MLDBM module or the newer Tie::MLDBM module.

po
Shahj, Gurus,

Great topic - being somewhat new to perl related questions
come to mind - would be great to see these all be answered
in practical how to context as this seems to be a regular
situation.

With a @INC error running perl - how do you figure out which
module to use to resolve the package names using push, upshift,
& require?

Do you have to read suspect perl script modules to find out if
they still support the function or if it has been depricated?
What do you do when you can't find the module package to @INC
to fix it?

Paul

Perldiscuss - Perl Newsgroups And Mailing Lists wrote:
QUOTE
I want to add some paths to the @INC array to resolve certain package
names at runtime.

One of the methods is: "push(@INC,$path) or unshift($path,@INC)" and then
say "require package_name;".
the problem with this is that we still need to use the "::" operator with
the symbols to resolve the package namespace.
eg: package_name::test_sub();

The other method that I came across was to use the PERL5LIB/ PERLLIB
environment variable. This actually needs us to create an OS level env
variable, which I would like to avoid.

Apart from these is there a method that can modify @INC  at runtime.



po
Shahj, Gurus,

Great topic - being somewhat new to perl related questions
come to mind - would be great to see these all be answered
in practical how to context as this seems to be a regular
situation.

With a @INC error running perl - how do you figure out which
module to use to resolve the package names using push, upshift,
& require?

Do you have to read suspect perl script modules to find out if
they still support the function or if it has been depricated?
What do you do when you can't find the module package to @INC
to fix it?

Paul

Perldiscuss - Perl Newsgroups And Mailing Lists wrote:
QUOTE
I want to add some paths to the @INC array to resolve certain package
names at runtime.

One of the methods is: "push(@INC,$path) or unshift($path,@INC)" and then
say "require package_name;".
the problem with this is that we still need to use the "::" operator with
the symbols to resolve the package namespace.
eg: package_name::test_sub();

The other method that I came across was to use the PERL5LIB/ PERLLIB
environment variable. This actually needs us to create an OS level env
variable, which I would like to avoid.

Apart from these is there a method that can modify @INC  at runtime.



Michael S. Robeson II
Ok, well I think I can see the forest but I have little idea as to what
is actually going on here. I spent a few hours looking things up and I
have a general sense of what is actually occurring but I am getting
lost in the details that were posted in the last digest. See below:


On Sep 19, 2004, at 10:08, [Email Removed] wrote:

QUOTE
I see that you also made use of arrays. It struck me that, since the
starting point is strings and not lists, using substr() would be more
straight-forward:

my %hash3;
for ( keys %hash1 ) {
while ( my $aa = substr $hash1{$_},0,1,'' ) {

I have never seen anything like this nor can I find anything in any of
my Perl books to help me explain what the 0,1 and the " are doing to
the substr of $hash1. I assume it is position information of some kind?
If so, what is going on?

QUOTE
$hash3{$_} .= $aa eq '-' ? '---' : substr $hash2{$_},0,3,'';

This is something new to me. I think I follow your use of the ?:
pattern feature. However, none of the perl books I have discuss it's
use in this fashion. So, I am unsure of how you know to do that, or
rather... how would I have known that I can do that? But basically I
see that you are looking for '-' and equating it with what is matching
between the ? and : (i.e. '---').

So, as far as I can tell, you are saying: "hey, if you find '-' in $aa
then append a '---' in $hash3, otherwise append the next three DNA
letters". However, I do not understand the syntax of how perl is
actually doing this.

Help with explanation would be greatly appreciated. As you can see I
can see what the big picture is, it's just that I am unable to
determine mechanistically how perl is actually going about doing it.
Also, any online references to the techniques used above would be
great. I'd look for them myself but I do not know what some of these
are actually called?

-Thanks so much, I have learned a little just from this much so far.
-mike

Gunnar Hjalmarsson
Michael S. Robeson II wrote:
QUOTE
Ok, well I think I can see the forest but I have little idea as to
what is actually going on here. I spent a few hours looking things
up and I have a general sense of what is actually occurring but I
am getting lost in the details that were posted in the last digest.

Well, before an attempt to explain and/or point you to the applicable
docs, I'd like to change my mind once again. :) This is my latest
idea:

my %hash3;
for ( keys %hash1 ) {
my $dna = $hash2{$_};
for my $aa ( split //, $hash1{$_} ) {
$hash3{$_} .= $aa eq '-' ? '---' : substr $dna,0,3,'';
}
}

I'll assume that you don't have a problem with the outer loop, that
simply iterates over the hash keys. As a first step in each iteration
I copy the DNA sequence to the $dna variable, so as to not destroying
%hash2.

Over to the 'tricky' part. The inner loop iterates over each character
in the amino-acid sequence data, and respective character is assigned
to $aa. For that I use the split() function:
http://www.perldoc.com/perl5.8.4/pod/func/split.html

QUOTE
$hash3{$_} .= $aa eq '-' ? '---' : substr $hash2{$_},0,3,'';

This is something new to me. I think I follow your use of the ?:
pattern feature. However, none of the perl books I have discuss
it's use in this fashion.

That sounds strange to me, because that's how it should be used...
Read about the conditional operator in
http://www.perldoc.com/perl5.8.4/pod/perlop.html

OTOH, that notation is basically the same as:

if ( $aa eq '-' ) {
$hash3{$_} .= '---';
} else {
$hash3{$_} .= substr $dna,0,3,'';
}

which is a little more intuitive (at least I think it is).

QUOTE
So, as far as I can tell, you are saying: "hey, if you find '-' in
$aa then append a '---' in $hash3, otherwise append the next three
DNA letters".

Precisely.

QUOTE
However, I do not understand the syntax of how perl is actually
doing this.

Hopefully the if/else statement makes it easier to grasp, and the '.='
operator is used just for appending something to a string.

Finally we have my use of the substr() function.
http://www.perldoc.com/perl5.8.4/pod/func/substr.html
It returns the first three characters in $dna, and since I also pass
the null string as the fourth argument, it changes the content of $dna
at the same time, i.e. it replaces the first three characters with
nothing.

HTH. If you need further explanations, you'll have to ask specific
questions.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Drue Reeves
Anyone know how to call a PERL Script from a JSP and pass parameters to the script?

I have a JSP that will call PERL but, everytime we try to add a script nothing happens. Any ideas?

Thanks,

Drue

Drue Reeves
Truly newbie questions....

Why do some scripts have a CGI extension while other a .pl and still other a .plx? Does the .cgi extension give it some web characteristics?

Is there a way to run my script without specifying "perl" before the script? In other words, I want to type c:myscript.plx instead of c:perl myscript.plx.

Thanks,

Drue

You appear to be on a Windows system. The file extensions on Windows are for
association. Hence, to answer your second question first, if you're on
ActiveState Perl, all .pl extensions are automatically associated with perl, if
you did it right, and just typing 'foo.pl' in the shell should run it. .cgi,
..pl, etc. It doesn't matter to the interpreter. It may however matter to how it
is treated by the OS and other programs, such as a server.

--
-will
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite

Adrian Muhrer
Never heard of a .plx, but the .pl and .cgi are really just naming
convention.
Having said that if you are running activestate perl, it normally installs
with .pl associated with perl (but not cgi). If you are running nt4 (2k?)
or greater you should be able to run myscript.pl without putting perl in
front

I think you can set up apache to only run (for example) .cgi's and not .pl's
but I never have.

-----Original Message-----
From: Drue Reeves [mailto:[Email Removed]]
Sent: Tuesday, 21 September 2004 12:58
To: Gunnar Hjalmarsson; [Email Removed]
Subject: Two easy questions.




Truly newbie questions....

Why do some scripts have a CGI extension while other a .pl and still other a
..plx? Does the .cgi extension give it some web characteristics?

Is there a way to run my script without specifying "perl" before the script?
In other words, I want to type c:myscript.plx instead of c:perl
myscript.plx.

Thanks,

Drue


================================================================
This email message (and any accompanying file attachments) may contain copyright, confidential or privileged information and is intended for the sole use of the addressee named above. If you are not the intended recipient, or the person responsible for delivering this message to the intended recipient, please notify Australian Fast Foods Pty Ltd by return email and then delete the email, destroy any printed copy and do not disclose or use the information in it. Any unauthorised review, use, alteration, disclosure or distribution of this email (including attachments) by an unintended recipient is prohibited. Any views expressed in this message are those of the individual sender, Australian Fast Foods Pty Ltd does not represent that this message or any attached files are free from computer viruses.
================================================================

Doug Lewis
Your answer actually lies in the system that you are using first. The reason the CGI scripts hold the .cgi extension. Is because that is what your webserver uses to grab your CGI scripts from your CGI directory.

As for using perl myscript. That is a windows thing. If I remember correctly (Don't qoute me on this, because I don't use perl on windows.) but if you run your script in the directory that you have perl installed in, you don't need the perl part.

Hopefully I have explained it clearly enough, sorry it is rather late, and I am friggin tired, if when I read this in th morning it sounds shitty, I will reword it and re-email it.
Drue Reeves <[Email Removed]> wrote:


Truly newbie questions....

Why do some scripts have a CGI extension while other a .pl and still other a .plx? Does the .cgi extension give it some web characteristics?

Is there a way to run my script without specifying "perl" before the script? In other words, I want to type c:myscript.plx instead of c:perl myscript.plx.

Thanks,

Drue



---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

Raymond Raj
Hi!

"assoc " and "ftype" commands are used to associate extension for
particular file types..


QUOTE
Is there a way to run my script without specifying "Perl" before the
script? In other words, I want to type c:myscript.plx >instead of c:perl

myscript.plx.

yes you can, try "assoc /?" and "ftype /?" it'll tell how to associates
file types.

HTH
Raymond

-----Original Message-----
From: [Email Removed] [mailto:[Email Removed]]
Sent: Tuesday, September 21, 2004 8:37 AM
To: [Email Removed]; [Email Removed]
Subject: Re: Two easy questions.


You appear to be on a Windows system. The file extensions on Windows are
for
association. Hence, to answer your second question first, if you're on
ActiveState Perl, all .pl extensions are automatically associated with
perl, if
you did it right, and just typing 'foo.pl' in the shell should run it.
..cgi,
..pl, etc. It doesn't matter to the interpreter. It may however matter to
how it
is treated by the OS and other programs, such as a server.

--
-will
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Adrian Muhrer
Hi
I usually do something like...

$pgdbh = DBI->connect("DBI:Pg:dbname=testdb;host=myhost",
'user', 'pass', {RaiseError => 0, PrintError => 0})
or die "Cannot connect to testdbn";


Adrian


-----Original Message-----
From: Anish Kumar K. [mailto:[Email Removed]]
Sent: Tuesday, 21 September 2004 15:26
To: beginners perl
Subject: Can't connect to PG


Hi

I couldn't connect to the database. Following message is coming. Please help
me in this regard.

use strict;
use warnings;
use DBI;

my $dbh = DBI->connect('dbi:Pg:testdb','postgres','postgres')
or die "Cannot connect to testdbn";

exit;

Output

DBI->connect(testdb) failed: ERROR: Missing '=' after 'testdb' in conninfo
at chkdbi.pl line 5
Cannot connect to testdb


Thanks
Anish

================================================================
This email message (and any accompanying file attachments) may contain copyright, confidential or privileged information and is intended for the sole use of the addressee named above. If you are not the intended recipient, or the person responsible for delivering this message to the intended recipient, please notify Australian Fast Foods Pty Ltd by return email and then delete the email, destroy any printed copy and do not disclose or use the information in it. Any unauthorised review, use, alteration, disclosure or distribution of this email (including attachments) by an unintended recipient is prohibited. Any views expressed in this message are those of the individual sender, Australian Fast Foods Pty Ltd does not represent that this message or any attached files are free from computer viruses.
================================================================

Le Sandy Sun
yes.I think your question is making the 'perl command interpret' default
to excute the plx file that you made.You can make the configration in
windos to solve the problem.

-Sandy




Drue Reeves wrote:

QUOTE
Truly newbie questions....

Why do some scripts have a CGI extension while other a .pl and still other a .plx? Does the .cgi extension give it some web characteristics?

Is there a way to run my script without specifying "perl" before the script? In other words, I want to type c:myscript.plx instead of c:perl myscript.plx.

Thanks,

Drue





NYIMI Jose \
QUOTE
-----Original Message-----
From: Drue Reeves [mailto:[Email Removed]]
Sent: Tuesday, September 21, 2004 4:49 AM
To: [Email Removed]; Cary Andrews
Subject: calling Perl Script from JSP?



Anyone know how to call a PERL Script from a JSP and pass
parameters to the script?

I have a JSP that will call PERL but, everytime we try to add
a script nothing happens. Any ideas?


Very bad idea trying to mix Perl and JSP ...
Which feature of Perl do you want to use in your JSP page that you can't get from Java ?

Jos.


**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above.
Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent.

Prototyping can be useful in Perl. It shouldn't be overused, however. They
can be powerful when trying to make functions that look and feel like
built-ins. Trying to, for example, create a subroutine that looks like map, grep, and
sort is made by prototyping it as (&@) (will pass coderef and an array). If
you want to accept an array and handle it like splice does you can do (@;@)
(will pass array ref and an optional array).

There are very specific examples found in the manual in perldoc perlsub.

And there is a warning IF the subroutine is declared before you call it.

Prototyping(1,2); #No exception, just a warning

sub Prototyping ($$$) {
print pop;
}

Prototyping 1, 2, 3; #Good job
&Prototyping(1,2); #works, read perldoc perlsub
Prototyping(1); #Death

I'm an advocate of prototyping. I like the power it can display in making
your own functions behave like built-ins. But you can't go crazy with it and
prototype every sub you write. Only do it when it makes your and the
enduser's/maintainer's life easier.

--
-will
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite

Bob Gordon
If you are in 2K or XP you can go to the System Properties screen. In
there click on the advanced tab then "Environment Variables". Under
"System Variables" locate PATHEXT. Add ;.pl to the end of the list
then click OK.

The system should allow for executing .pl files. As long as you have
the #!...... info at the top of the file you should be OK.

Regards,

--
--==[ Bob Gordon ]==--

Jenda Krynicky
From: "NYIMI Jose (BMB)" <[Email Removed]>
QUOTE
-----Original Message-----
From: Drue Reeves [mailto:[Email Removed]]
Anyone know how to call a PERL Script from a JSP and pass
parameters to the script?

I have a JSP that will call PERL but, everytime we try to add
a script nothing happens. Any ideas?


Very bad idea trying to mix Perl and JSP ...
Which feature of Perl do you want to use in your JSP page that you
can't get from Java ?

Jos.

Ease of use? Freedom? The loads of CPAN modules? Simply ... the
power?

What exactly do you mean by "call"?

Do you need to
1) run a Perl script after the user clicks a link or button on the
page returned by your JSP?
2) start a local Perl script while processing the JSP on the server,
capture the output and include it in the resulting page?
3) start a remote Perl CGI script while processing the JSP on the
server, capture the output and include it in the resulting page?

In the first case you just need to either construct the URL to the
script plus the parameters or create a <form action="URL of the
script"> with some hidden fields for those values and let the user
submit the form.

In the other two cases you are very unlikely to get much help in
here. Try a Java/JSP related mailing list. I have no idea how to do
either in Java and I'd love it to remain so.

Jenda
===== [Email Removed] === http://Jenda.Krynicky.cz ====When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Drue Reeves
Mainly some LDAP calls. PERL makes it easy to develop applications that do search and modify in LDAP with very little code. Java and C++ take much more code. Plus, PERL had some example code that made the development very simple.

Why is it bad to mix JSP and PERL?

Maybe a better question is how do you call a PERL script from a web page (and pass parameters)?

Thank you,

Drue

"NYIMI Jose (BMB)" <[Email Removed]> wrote:
QUOTE
-----Original Message-----
From: Drue Reeves [mailto:[Email Removed]]
Sent: Tuesday, September 21, 2004 4:49 AM
To: [Email Removed]; Cary Andrews
Subject: calling Perl Script from JSP?



Anyone know how to call a PERL Script from a JSP and pass
parameters to the script?

I have a JSP that will call PERL but, everytime we try to add
a script nothing happens. Any ideas?


Very bad idea trying to mix Perl and JSP ...
Which feature of Perl do you want to use in your JSP page that you can't get from Java ?

Jos.


**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above.
Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent.

Chris Devers
First of all, "Perl" is the language, "perl" is the program that runs
programs written in Perl, and "PERL" isn't a word.

On Tue, 21 Sep 2004, Drue Reeves wrote:

QUOTE
Why is it bad to mix JSP and Perl?

They are just much different frameworks.

Most Java systems I'm aware of (and I'll plead guilty to some ignorance
here) pretty much want you to do everything in Java, from the JSP
scripts that display pages to the beans (or whatever) that implement the
site logic to, sometimes, the database itself.

Perl on the other hand is often the "glue" holding a heterogeneous
system together. It's very good for getting a bunch of disparate pieces
that are either old or maybe came from different places to play nicely
together.

I know nothing about your JSP system, but conventionally, shops that
have decided to go with JSP seem to do everything in JSP, just because
there's so much inertia behind getting everything locked in to Java.


I seem to be talking about the cultures more than the languages.

Oh well.

QUOTE
Maybe a better question is how do you call a Perl script from a web
page (and pass parameters)?

There is a lot of flexibility here.

Often, Perl *is* the web page, whether by a CGI script that runs perl
and executes the script with each page view, or a mod_perl plugin that
embeds perl into Apache so that scripts are persistent in memory (which
is the approach that JSP and other languages seem to take, right?).

But if you just have a static HTML document that needs to call Perl
somehow, the usual way is either by a form's <action> tag or just by
following a link. In either case, this usually ends up being a GET or
POST request to a Perl script that has been exposed as a web page with a
URL. For POST requests, the parameters are sent to the script basically
as a text document that is uploaded to the server, while for GET
requests the data comes in following the script. Hence,

http://google.com/search?q=http%20protocol
^ ^ ^ ^-- parameters to the script
| | +--- the script / program / whatever
| +---- the domain
+----- the protocol

And if this doesn't make sense, there's lots of documentation out there.
This book may help clarify things -- it's old now, but the fundamentals
haven't changed since it was published:

<http://www.oreilly.com/openbook/webclient/>

So, if you're working via HTTP -- as you're doing on the web -- then it
just ends up being a URL that you GET from or maybe POST to.

Make sense? More questions?


--
Chris Devers

Thomas Btzler
Bernd Mueller <[Email Removed]> asked:
QUOTE
Would someone be so nice to explain me how i change the
values in @INC, because i know where to find this SiteDefs.pm.

You could use the "use lib" pragma, like

use lib qw(/path/to/my/modules);

HTH,
Thomas

Bob Showalter
[Email Removed] wrote:
QUOTE
Ok here is the deal, our admin is trying to install DBD::Oracle for
me to access one of our affiliates databases. The oracle "instant
basic client" and "sqlplus" has been installed as well as
GetOpt::Long.

The installations all went well except for DBD::Oracle, it fails to
install, I am pretty sure because Oracle is NOT installed on this
machine, and will NOT be installed on this machine.

Hmmm, I would think if SQL*Plus is working that you would have enough stuff
on the client side. But the Linux client software for Oracle should be
available on Oracle's web site to give you whatever you need. You don't need
the Oracle server installation.

Another more radical approach would be to use DBD::Proxy. But you would need
to install Perl and DBD::Oracle on the database server. You wouldn't need
anything but Perl on the client.

Drue Reeves
Chris,

Thank you. This is starting to make more sense now. I may have more questions but, I'll go do some homework first. I'll start with the book you mentioned.

Thanks,

Drue

Chris Devers <[Email Removed]> wrote:
First of all, "Perl" is the language, "perl" is the program that runs
programs written in Perl, and "PERL" isn't a word.

On Tue, 21 Sep 2004, Drue Reeves wrote:

QUOTE
Why is it bad to mix JSP and Perl?

They are just much different frameworks.

Most Java systems I'm aware of (and I'll plead guilty to some ignorance
here) pretty much want you to do everything in Java, from the JSP
scripts that display pages to the beans (or whatever) that implement the
site logic to, sometimes, the database itself.

Perl on the other hand is often the "glue" holding a heterogeneous
system together. It's very good for getting a bunch of disparate pieces
that are either old or maybe came from different places to play nicely
together.

I know nothing about your JSP system, but conventionally, shops that
have decided to go with JSP seem to do everything in JSP, just because
there's so much inertia behind getting everything locked in to Java.


I seem to be talking about the cultures more than the languages.

Oh well.

QUOTE
Maybe a better question is how do you call a Perl script from a web
page (and pass parameters)?

There is a lot of flexibility here.

Often, Perl *is* the web page, whether by a CGI script that runs perl
and executes the script with each page view, or a mod_perl plugin that
embeds perl into Apache so that scripts are persistent in memory (which
is the approach that JSP and other languages seem to take, right?).

But if you just have a static HTML document that needs to call Perl
somehow, the usual way is either by a form's tag or just by
following a link. In either case, this usually ends up being a GET or
POST request to a Perl script that has been exposed as a web page with a
URL. For POST requests, the parameters are sent to the script basically
as a text document that is uploaded to the server, while for GET
requests the data comes in following the script. Hence,

http://google.com/search?q=http%20protocol
^ ^ ^ ^-- parameters to the script
| | +--- the script / program / whatever
| +---- the domain
+----- the protocol

And if this doesn't make sense, there's lots of documentation out there.
This book may help clarify things -- it's old now, but the fundamentals
haven't changed since it was published:



So, if you're working via HTTP -- as you're doing on the web -- then it
just ends up being a URL that you GET from or maybe POST to.

Make sense? More questions?


--
Chris Devers

Ramon Chavez
Hi everyone.

I'm trying to call a SSI from a page generated by a Perl script. Obviously the SSI can't be called because it is not an HTML file. But if I use the .htaccess parsing method, a with .shtml, (AddHandler server-parsed .pl) I got all the code of my script listed.

This SSI will call another .pl , a counter to be precise.
I could include the code of the counter in the main script, but I didn't wrote the counter and don't want to do anything wrong, I mean I respect other's work.
I was thinking in 'use' or 'require', but it's not about the functions in the counter, it's about the whole output.

Any advice on where to look now?
Thanks.
-rm-

Levon Barker
I have had to do this.

Did a fair bit of research and the best that I could come up with (and
what we have implemented) is to call mod_perl url from java. That way we
don't have to recompile each time, and get some database persistance
with Apache::DBI.

Works out quite well.


On Sep 23, 2004 04:24 PM, Siegfried Heintze <[Email Removed]>
wrote:

QUOTE
I did a google search on calling Perl from Java. I found one site
(http://ebb.org/perljvm/) that suggested the most promising project
tackling
this problem had been abandoned.

The traditional approach is apparently very cumbersome: Have Java call
C and
C all Perl. This sounds very tedious.

Does this sum up the situation?

Thanks,
Siegfried


--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response



Siegfried Heintze
This works and does what I want it to:

perl -e '@x = split("\.", "a.b.c"); print $x[0];'

Why does not this work?
perl -e 'print @{split("\.", "a.b.c")}[0];'

Is there a compact way to take a slice of a split (or other function that
returns an array) without creating a temporary variable?

Thanks,
Siegfried

William Gunther
On Thu, 23 Sep 2004 13:43:08 -0600, Siegfried Heintze
<[Email Removed]> wrote:
QUOTE
This works and does what I want it to:

perl -e '@x = split("\.", "a.b.c"); print $x[0];'

Why does not this work?
perl -e 'print  @{split("\.", "a.b.c")}[0];'

Because split doesn't return an array reference, it returns a list.

print( (split(/./, "a.b.c"))[0] );

QUOTE

Is there a compact way to take a slice of a split (or other function that
returns an array) without creating a temporary variable?

Thanks,
Siegfried

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response





--
-will
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite

Jenda Krynicky
From: "Siegfried Heintze" <[Email Removed]>
QUOTE
This works and does what I want it to:

perl -e '@x = split("\.", "a.b.c"); print $x[0];'

Why does not this work?
perl -e 'print  @{split("\.", "a.b.c")}[0];'

Is there a compact way to take a slice of a split (or other function
that returns an array) without creating a temporary variable?

perl -e 'print ((split("\.", "a.b.c"))[0]);'

It's a bit tricky. The outermost braces belong to print(), the next
ones enclose the call to split() so that it can be sliced and the
innermost enclose the parameters for split(). Only the innermost may
be left out.

This makes the slicing of function result a bit clearer I think:

($hour, $minute, $sec) = (localtime())[2,1,0];

Jenda
===== [Email Removed] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Wiggins d Anconia
QUOTE
This works and does what I want it to:

perl -e '@x = split("\.", "a.b.c"); print $x[0];'

Why does not this work?
perl -e 'print  @{split("\.", "a.b.c")}[0];'

Is there a compact way to take a slice of a split (or other function that
returns an array) without creating a temporary variable?

Thanks,
Siegfried


Sometimes when working out this kind of detail it is helpful to make a
full script and activate strict/warnings. In the above case you get the
following,

QUOTE
perl -Mstrict -w -e 'print  @{split("\.", "a.b.c")}[0];'
Use of implicit split to @_ is deprecated at -e line 1.

Can't use string ("3") as an ARRAY ref while "strict refs" in use at -e
line 1.

Essentially C<split> returns a list, the construct C<@{ }> is a way to
slice into a hash, which you don't have. So you need to slice into a
list, which in this case is done like,

perl -Mstrict -w -e 'print ((split("\.", "a.b.c"))[0]);'

Notice the extra set of parens, otherwise you get a syntax error because
C<print> would otherwise use the first set as an argument list.

HTH,

http://danconia.org

Siegfried Heintze
I did a google search on calling Perl from Java. I found one site
(http://ebb.org/perljvm/) that suggested the most promising project tackling
this problem had been abandoned.

The traditional approach is apparently very cumbersome: Have Java call C and
C all Perl. This sounds very tedious.

Does this sum up the situation?

Thanks,
Siegfried

Jenda Krynicky
From: "Wiggins d Anconia" <[Email Removed]>
QUOTE
This works and does what I want it to:

perl -e '@x = split("\.", "a.b.c"); print $x[0];'

Why does not this work?
perl -e 'print  @{split("\.", "a.b.c")}[0];'

Is there a compact way to take a slice of a split (or other function
that returns an array) without creating a temporary variable?

Thanks,
Siegfried


Sometimes when working out this kind of detail it is helpful to make a
full script and activate strict/warnings. In the above case you get
the following,

perl -Mstrict -w -e 'print  @{split("\.", "a.b.c")}[0];'
Use of implicit split to @_ is deprecated at -e line 1.
Can't use string ("3") as an ARRAY ref while "strict refs" in use at
-e line 1.

Essentially C<split> returns a list, the construct C<@{ }> is a way to
slice into a hash, which you don't have.

There'd have to be a name of a variable between the @ and the opening
curly brace for that to be a hash slice. This way its an array
dereference:

@arr = (1,2,3);
$rArr = @arr;
@other = @{$rArr};

Of course in this case you do not need the braces.

You'd use the @{} if the thing you need to dereference is more
complex, for example if you need to dereference a function result.

So
print join(', ', @{function('returning', 'arrayref')});
would be correct, just like
print join(', ', @{function('returning', 'arrayref')}[1,2,4,7]);

If you'd want just one item from the referenced array you would of
course use ${}[] instead:

print ${function('returning', 'arrayref')}[2];

In this case the function doesn't return a reference, but a list so
there is no point in trying to dereference anything :-)

This is where the "Can't use string ("3") as an ARRAY ref while
"strict refs" in use at -e line 1." message comes from. The split()
is evaluated in scalar context and thus returns the number of
elements found in the string. And then the code tries to do this:

perl -e 'print @{3}[0];'

Jenda
===== [Email Removed] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Madhu Reddy
hi,
I want to check the status of File handle before
reading/writing to file ? How to do this ?

like following

open(FH_IN_FILE, ">file.txt");

# This statement is executed by some other function
close(FH_IN_FILE);


print FH_IN_FILE "SOME DATA";

here before writing to file, i want to check the
status of FH_IN_FILE..(whether file is opened or
closed )

Thanks









__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

Wiggins d Anconia
QUOTE
hi,
I want to check the status of File handle before
reading/writing to file ? How to do this ?

like following

open(FH_IN_FILE, ">file.txt");


Which itself is a bad idea, always check that the open succeeded in the
first place,

open FH_IN_FILE, ">file.txt" or die "Can't open file for writing: $!";

QUOTE
# This statement is executed by some other function
close(FH_IN_FILE);


Iffy, but ok.

QUOTE

print FH_IN_FILE "SOME DATA";

here before writing to file, i want to check the
status of FH_IN_FILE..(whether file is opened or
closed )


perldoc -f fileno

Is about the only way to check (IIRC). The only way to know whether a
file can really be written to is to try and catch any errors that occur.

QUOTE
Thanks

http://danconia.org


John W. Krahn
Madhu Reddy wrote:
QUOTE
hi,

Hello,

QUOTE
I want to check the status of File handle before
reading/writing to file ? How to do this ?

like following

open(FH_IN_FILE, ">file.txt");

# This statement is executed by some other function
close(FH_IN_FILE);


print FH_IN_FILE "SOME DATA";

here before writing to file, i want to check the
status of FH_IN_FILE..(whether file is opened or
closed )

if ( defined fileno FH_IN_FILE ) {
print FH_IN_FILE "SOME DATA";
}
else {
warn "Error: FH_IN_FILE is closed!n";
}



John
--
use Perl;
program
fulfillment

Charles K. Clarkson
Edward WIJAYA <[Email Removed]> wrote:

: My question is how can I modify my code below
: so it can store and then returns all the "k-clique" found?

That's a tough one. The regex was designed to see if
there was at least one k-clique in a graph -- not to find
all of them.

You'll need to get better control over the vertices.
That's the first line of the regex.

/
.*b (d+) , .*b (d+) , .*b (d+)b .* ;
(?= .* b 1-2 b)
(?= .* b 1-3 b)
(?= .* b 2-3 b)
/x

I don't know enough about regexes to step through each
solution. I would probably resort to the use of a loop to
step through the vertices and perhaps a regex for the
second part of the string.

1-2,1-3,1-4,2-3,2-4,3-4,1-5,5-6,5-9,5-7,7-8,8-9,6-9



HTH,

Charles K. Clarkson
--
Mobile Homes Specialist



Here's a version of the current script that uses
strict. I would suggest you play with it rather than
the one you presented.


#!/usr/bin/perl

use strict;
use warnings;

my @vertices = 1 .. 9;
my @edges = (
[1,2], [1,3], [1,4], [1,5],
[2,3], [2,4],
[3,4],
[5,6], [5,7], [5,9],
[6,9],
[7,8],
[8,9],
);

# Build regular expression
my $k = shift || 3;
my $regex =
'.*b ' .
join(' , .*b ', ('(d+)') x $k) .
'b .* ;' .
"n";

foreach my $i ( 1 .. $k - 1 ) {
foreach my $j ( $i + 1 .. $k ) {
$regex .= '(?= .* b ' . "\$i-\$j" . ' b)' . "n";
}
}

# Build string
my $string =
join( ',', @vertices) . ';' .
join( ',', map "$_->[0]-$_->[1]", @edges);

# Test for at least one k-clique
if ( $string =~ /$regex/x ) {
print "($1, $2, $3)n";
}

__END__

Bob Showalter
[Email Removed] wrote:
QUOTE
I need to Call a PERL script on OTHER  SERVER from MY SERVER  and get
the file generated there back to MY SERVER
Can you please suggest how can i do that?

Something like Net::SSH or Net::Rexec should do the trick.

Gavin Henry
Wiggins d Anconia said:
QUOTE
I really like Perl, but lately everywhere I seem to go and talk to say I
shouldn't be learning Perl as it's old and Python is better.


I'm impressed, come to the Midwest in the US, around here they have only
heard of M$ and Cobol.  Ironically, Python is showing its age, just look
at Ruby. Of course Perl 6/Parrot stands to make all of the discussion
moot.

Yeah, that will shut them all up.

By the way, my program now works great thanks to your sub advice. I still
have some cleaning to do, like my resize sub abd incorporating file tests
etc.

You can see how bad my program is at:

http://www.perl.me.uk

It's called ebaypics

Advice from you in a new thread, would be very appreciated.

Gavin.



QUOTE
<snip

http://danconia.org


Wiggins d Anconia
QUOTE
I really like Perl, but lately everywhere I seem to go and talk to say I
shouldn't be learning Perl as it's old and Python is better.


I'm impressed, come to the Midwest in the US, around here they have only
heard of M$ and Cobol. Ironically, Python is showing its age, just look
at Ruby. Of course Perl 6/Parrot stands to make all of the discussion moot.

<snip>

http://danconia.org

John W. Krahn
Gavin Henry wrote:
QUOTE

By the way, my program now works great thanks to your sub advice. I still
have some cleaning to do, like my resize sub abd incorporating file tests
etc.

You can see how bad my program is at:

http://www.perl.me.uk

It's called ebaypics

Advice from you in a new thread, would be very appreciated.

Don't put quotes around variables.

Found in /usr/lib/perl5/5.8.2/pod/perlfaq4.pod
What's wrong with always quoting "$vars"?

perldoc perldata


Don't use '&' with subroutine calls.

Found in /usr/lib/perl5/5.8.2/pod/perlfaq7.pod
What's the difference between calling a function as &foo and foo()?

perldoc perlsub


QUOTE
# Generate weblinks
sub links {
my ($url, @list) = @_;
my @return;
foreach (@list) {
push @return, "$url/$_n";
}
return @return;
}

# Put the generated weblinks from the subroutine links into an array
my @email_links = links($website, @thumbs);

This is what map() was invented for:

my @email_links = map "$website/$_n", @thumbs;



John
--
use Perl;
program
fulfillment

Gavin Henry
On Tuesday 28 Sep 2004 22:11, John W. Krahn wrote:
QUOTE
Gavin Henry wrote:
By the way, my program now works great thanks to your sub advice. I still
have some cleaning to do, like my resize sub abd incorporating file tests
etc.

You can see how bad my program is at:

http://www.perl.me.uk

It's called ebaypics

Advice from you in a new thread, would be very appreciated.

Don't put quotes around variables.

Found in /usr/lib/perl5/5.8.2/pod/perlfaq4.pod
What's wrong with always quoting "$vars"?

perldoc perldata


Thanks I will update with your comments.
QUOTE

Don't use '&' with subroutine calls.

Found in /usr/lib/perl5/5.8.2/pod/perlfaq7.pod
What's the difference between calling a function as &foo and foo()?

perldoc perlsub

# Generate weblinks
sub links {
my ($url, @list) = @_;
my @return;
foreach (@list) {
push @return, "$url/$_n";
}
return @return;
}

# Put the generated weblinks from the subroutine links into an array
my @email_links = links($website, @thumbs);

This is what map() was invented for:

my @email_links = map "$website/$_n", @thumbs;



John
--
use Perl;
program
fulfillment

--
Just getting into the best language ever...
Fancy a [Email Removed]? Just ask!!!

Wiggins d Anconia
QUOTE
My what long lines you have :)

It may not be commercial grade but, who of us writes commerical
applications all the time.

I do mostly, private corporate backends mostly among other things :)
I use it for the quick tasks and simple scripts also of course. (the
projects never end the same as durability and ability)

And cPanel (http://cpanel.net) is mostly perl for instance.
I'd say that's pretty commercial seeing as how many webhosts use it.

An associate of mine worked for/does consulting for a nationwide
communications provider that uses all perl for the website, and backend
employee/customer/support/work order/materials handling/etc etc.

Apple's website uses perl last I heard (the .adp extension is their
special build of it)

That's just 4 that I knew off off the top of my head.
QUOTE

Perhaps you meant commercial grade as in you don't have to spend
thousands of dollars on a devleopment suite (hint hint Microsoft) and
hire a team of engineers to keep it running (hint hint PHP), in that
case I'd agree ;p

One thing my associate says that I agree with that may help with the
language blues is be proud of perl! When you do web apps in perl, use
.pl instead of .cgi. Show some pride man!! If you're host can't add one
line to apache conf to be able to serve .pl files then get a new host.


I say drop the extension completely, no one needs to know what your
implementation is, as long as it works.

QUOTE
[shameless plug] go to jupiterhost.net we *love* Perl [/shameless plug]

I like this thread, lots of opinions + not too many flames = productive
learning


U ignorant piece of.... uh sorry....

QUOTE
Just my .02

Lee.M - JupiterHost.Net

NYIMI Jose \
QUOTE
-----Original Message-----
From: Wiggins d Anconia [mailto:[Email Removed]]
Sent: Wednesday, September 29, 2004 4:38 PM
To: JupiterHost.Net; [Email Removed]
Subject: Re: Becoming Disenheartened - Everyone talks about
Python and says Perl is old news.


My what long lines you have :)

It may not be commercial grade but, who of us writes commerical
applications all the time.

I do mostly, private corporate backends mostly among other
things :) I
use it for the quick tasks and simple scripts also of course. (the
projects never end the same as durability and ability)

And cPanel (http://cpanel.net) is mostly perl for instance. I'd say
that's pretty commercial seeing as how many webhosts use it.

An associate of mine worked for/does consulting for a nationwide
communications provider that uses all perl for the website,
and backend
employee/customer/support/work order/materials handling/etc etc.

Apple's website uses perl last I heard (the .adp extension is their
special build of it)

That's just 4 that I knew off off the top of my head.

http://perl.oreilly.com/pub/a/oreilly/perl...ss_stories.html
http://poe.perl.org/?Organizations_Using_POE

Those are just a few more...

Indeed !
http://masonhq.com/?MasonPoweredSites

Plus more ...



**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above.
Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent.

JupiterHost.Net
Wiggins d Anconia wrote:


QUOTE
I like this thread, lots of opinions + not too many flames = productive
learning

U ignorant piece of.... uh sorry....


hehe good one :)

Gavin Henry
Roime bin Puniran said:
QUOTE
How can i rename any file using PERL?...Where should i start?..Where i
can find any tutorial?


using linux:

man mv

you can use a system() call or backticks ``

QUOTE

This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response







--
Just getting into the best language ever...
Fancy a [Email Removed]? Just ask!!!

Chris Devers
On Thu, 30 Sep 2004, Gavin Henry wrote:

QUOTE
Roime bin Puniran said:
How can i rename any file using PERL?...Where should i start?..Where i
can find any tutorial?

using linux:

man mv

you can use a system() call or backticks ``

The question wasn't how to do this with Linux though, it was about how
to use Perl.

The message headers suggest that Roime is using Windows --

Content-Type: text/plain;
charset="Windows-1252"

-- so the other response about the rename command was appropriate.

Moreover, rename() is a basic part of Perl, so even on Linux there is no
need to do this with a system call to the `mv` command.



--
Chris Devers

Chris Devers
On Thu, 30 Sep 2004, Murphy, Ged (Bolton) wrote:

QUOTE
I'm trying to print a block of code using 'print <<LABEL; but am
getting an error stating perl can't find the termination label.
Test code and error as follows:

#!/usr/bin/perl

print <<TEST;
this is my tester text
TEST

Can't find string terminator "TEST" anywhere before EOF at photo.pl
line 3.

Weird bugs like this were what made me stop using heredocs in most
cases. I find multi-line q{} blocks much more readable:

#!/usr/bin/perl

print qq[
this is my first tester text, with "double-quotes"
];

print q{
this is my second tester text [with 'single-quotes']
};

This way, most text editors tend to be able to pick up the string
terminating characters () [] {} and help make sure that things remain
balanced. I've had better luck this way than I ever did with heredocs.


--
Chris Devers


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.