Re: remove the last paragraph tag and its contents

2009-03-17 Thread Gunnar Hjalmarsson
ent inside the pair. If that's the case, it's probably not a disaster if it would fail occasionally, and a simple substitution may be sufficient: s,(.+),$1,is -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...

Re: Editing file

2009-03-20 Thread Gunnar Hjalmarsson
--/; push @keep, $_; } seek $fh, 0, 0; truncate $fh, 0; print $fh @keep; http://perldoc.perl.org/functions/open.html -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: Editing file

2009-03-21 Thread Gunnar Hjalmarsson
Randal L. Schwartz wrote: "Gunnar" == Gunnar Hjalmarsson writes: Gunnar> Martin Spinassi wrote: Is there any way to open a file for input and output at the same time? Gunnar> Yes. Open it with the '+<' MODE. Gunnar> open my $fh, '+<', $

Re: Editing file

2009-03-21 Thread Gunnar Hjalmarsson
Chas. Owens wrote: There is also the ongoing danger of putting untrusted file names in @ARGV[4], $ perl -we "undef @ARGV[4]" Scalar value @ARGV[4] better written as $ARGV[4] at -e line 1. $ Maybe your previous footnote style was better after all. ;-) -- Gunnar Hjalmarsson E

Re: whatz wrong here ?

2009-03-23 Thread Gunnar Hjalmarsson
$ John pointed out one mistake. The other mistake is your use of single quotes around the ISBN. $ perl -MBusiness::ISBN -le ' $isbn = Business::ISBN->new("0-59610-206-2"); print $isbn->as_string; ' 0-596-10206-2 $ -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cg

Re: quick regex question

2009-03-25 Thread Gunnar Hjalmarsson
Rick Bragg wrote: I need a quick regex to strip out the following: Never heard of that. What is a quick regex? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h

Re: bot trouble

2009-03-28 Thread Gunnar Hjalmarsson
2 3', }; and you are using Data::Dumper to extract values from it when you'd better just say: my $nick = $message->{who}; my $str = $message->{body}; Hopefully that hint helps you move forward. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl --

Re: Can't Retrieve Data From foreach block

2009-03-30 Thread Gunnar Hjalmarsson
; open my $fh, '<', $file or die "Opening $file failed: $!"; my @lastnames; while ( <$fh> ) { my @line = split /\t/; chomp @line; # if the record has no further elements push @lastnames, $line[1]; } -- Gunnar Hjalmarsson Email:

Re: @array a copy of @names???

2009-04-02 Thread Gunnar Hjalmarsson
perldoc.perl.org/perlsub.html There is no reason in this case to use the & character, and most Perl programmers today would say that which_element_is("dan", @names); is the preferred 'normal' way to call a function. (Others have answered the question you asked.) --

Re: LWP

2009-04-08 Thread Gunnar Hjalmarsson
ANJAN PURKAYASTHA wrote: I have a file stored at a location: http://parent_dir/file Which among gazillion LWP options can I use to download and store the file on my machine? use LWP::Simple; getstore('http://parent_dir/file', 'file'); -- Gunnar Hja

Re: LWP

2009-04-08 Thread Gunnar Hjalmarsson
: use LWP::Simple; my $url = 'http://parent_dir/file'; my $local = '/path/to/local/file'; my $file = getstore($url, $local); getstore() returns the HTTP status code, so 'file' is not the most appropriate name of a variable to which the return value is assigned. --

Re: CPAN not working for me

2009-04-11 Thread Gunnar Hjalmarsson
if that's the reason why the install failed the first time, but have you installed the htmldoc program? To retry, I believe you first need to remove the HTML-HTMLDoc-0.10-8rfFZS directory. HTH -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mai

Re: escaping regex to do math on backreferences

2009-04-12 Thread Gunnar Hjalmarsson
earth would you want to do that? Is that even possible? I doubt it. I suggest you check out the Games::Poker::HandEvaluator module at CPAN. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-ma

Re: escaping regex to do math on backreferences

2009-04-12 Thread Gunnar Hjalmarsson
Chas. Owens wrote: my @rank = qw/ 2 3 4 5 6 7 8 9 10 J Q K A /; my @rank = qw/A 2 3 4 5 6 7 8 9 10 J Q K A /; --^ -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e

Re: escaping regex to do math on backreferences

2009-04-13 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Sun, Apr 12, 2009 at 21:58, Gunnar Hjalmarsson wrote: Chas. Owens wrote: my @rank = qw/ 2 3 4 5 6 7 8 9 10 J Q K A /; my @rank = qw/A 2 3 4 5 6 7 8 9 10 J Q K A /; --^ snip That depends on who you play with. Ok. Also, if you make that change you

Re: how to add support of Msql and CGI in Apache.

2009-04-13 Thread Gunnar Hjalmarsson
http://httpd.apache.org/docs/2.0/ssl/ AFAIK, MySQL is not an HTTP server configuration thing. (Do you have a Perl question?) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h

Re: how to add support of Msql and CGI in Apache.

2009-04-13 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: Raheel Hassan wrote: I am facing problems in executing cgi programs, on Apache web server, can any body tell me how i can configure my Apache server so that it can support CGI and Msql. I also wanted to enable ssl support in the Apache server. http

Re: Several packages in one file, no Export possible?

2009-04-15 Thread Gunnar Hjalmarsson
that I can use in package Amy e.g. Util::foo() or Util->foo() but then I cannot get the @EXPORT working. Try import Util; instead. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: \w regular expressions unicode

2009-04-18 Thread Gunnar Hjalmarsson
smörgåsbord"; $s = decode "UTF-8", $utf8_encoded; print "Match" if $s =~ /^\w+$/; ' Match $ -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: qx() vs backticks

2009-04-19 Thread Gunnar Hjalmarsson
R. Hicks wrote: Are there any gotchas for using qx() to run system commands versus backticks? No, it's the same thing. http://perldoc.perl.org/perlop.html#qx/STRING/ -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-uns

Re: Bareword "Google::Adwords::Campaign" not allowed while "strictsubs" in use

2009-04-19 Thread Gunnar Hjalmarsson
Adwords::CampaignService POD say something else. Such mistakes makes me doubt the quality of those modules. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: Gunnar Hjalmarsson wrote: Stanisław T. Findeisen wrote: Hi how to write regular expressions matching against Unicode (eg., UTF-8) strings? For instance, in my regexp: qr/^([.<>@ \w])*$/ Decode the UTF-8 encoded strings before applying the regex o

Re: libwww-perl library

2009-04-22 Thread Gunnar Hjalmarsson
whatever the path is to your 5.6 library) Could the folks who host my website simply not have the library? That seems odd. It's kind of basic, isn't it? Even if libwww-perl is not among the standard modules, I believe it's included in most Perl distributions. -- Gunnar Hjalm

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: Gunnar Hjalmarsson wrote: What assumptions does Perl make regarding input file (i.e., the program/script file) encoding? AFAIK, it just converts the bytes into Perl's internal format, but it does not assume anything (at least not by default) with respect t

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: Stanisław T. Findeisen wrote: With "use utf8" (http://perldoc.perl.org/utf8.html) one can however make them parsed (decoded) (provided they are valid UTF-8). No. The utf8 pragma is about allowing UTF-8 encoded *symbols*, e.g. variable names or subroutine n

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
"FALSE" here, but uncomment "use utf8" and it gets "TRUE". Looks like with "use utf8" those string literals aren't ordinary byte strings anymore. Perhaps they are as if Encode::decode had been applied to them? Yes, it seems to be so. Please also see

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson wrote: snip Yeah, it looks so. With "use utf8" (http://perldoc.perl.org/utf8.html) one can however make them parsed (decoded) (provided they are valid UTF-8). No. The utf8 pragma is about allowing UTF-8 encode

Re: libwww-perl library ok, but 'get' still funny

2009-04-25 Thread Gunnar Hjalmarsson
including use of scripts or web crawlers) and shall ensure that you comply with the instructions set out in any robots.txt file present on the Services." -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: package variables

2009-04-28 Thread Gunnar Hjalmarsson
t what Perl requested me to do. $ perl -Mstrict -e'$var=""' Global symbol "$var" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors. $ The wording of that error message isn't very well thought out. :( -- Gunnar

Re: package variables

2009-04-28 Thread Gunnar Hjalmarsson
Jenda Krynicky wrote: From: "Chas. Owens" On Tue, Apr 28, 2009 at 13:38, Gunnar Hjalmarsson wrote: snip Fully qualified names do not trip strict. Which is a reason to avoid using them. I once work at a place that wrote Perl 5 as if it were still Perl 4. They had turned on stri

Re: package variables

2009-04-29 Thread Gunnar Hjalmarsson
nt that it's more into it than just adding the package name. (Such a hint would have been really useful in my case.) Though I bet people will be confused in cases like perl -Mstrict -e 'local $var = 4' because quite a few people think "local $foo" is a declaration.

Reporting bugs (was: package variables)

2009-04-29 Thread Gunnar Hjalmarsson
Chas. Owens wrote: 2009/4/28 Gunnar Hjalmarsson : snip I believe the standard response is "patches are welcome." Are they? The number of open or "new" bugs at http://rt.perl.org/rt3/Public/ makes me fear something else. ( I did submit a bug report a few weeks ago: ht

Re: Reporting bugs

2009-04-29 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Wed, Apr 29, 2009 at 17:20, Gunnar Hjalmarsson wrote: Chas. Owens wrote: 2009/4/28 Gunnar Hjalmarsson : snip I believe the standard response is "patches are welcome." Are they? The number of open or "new" bugs at http://rt.perl.org/rt3/Public/ mak

Re: Reporting bugs

2009-05-01 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Wed, Apr 29, 2009 at 19:07, Chas. Owens wrote: On Wed, Apr 29, 2009 at 18:44, Gunnar Hjalmarsson wrote: snip You are encouraged to include a patch also when submitting a bug report - I did so in the above example, btw - so I still not quite get the distinction. Are the

Re: Reporting bugs

2009-05-01 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Fri, May 1, 2009 at 10:18, Gunnar Hjalmarsson wrote: I agree that perldiag says all that needs to be said. But a common way to work with perldiag is to look up cryptic error or warning messages when needed rather than using the diagnostics pragma. Unfortunately the

Re: Variable in for loop is not automatically local?

2009-05-02 Thread Gunnar Hjalmarsson
ought to be implicitly localized to the loop. http://perldoc.perl.org/perlsyn.html#Foreach-Loops OTOH, I believe it's advisable to always my() declare loop variables, even if there happens to be a global variable with the same name. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cg

Re: Variable in for loop is not automatically local?

2009-05-04 Thread Gunnar Hjalmarsson
question. Just wanted to mention that you basically do that with references. perl -le ' $y = "green"; $x = \$y; $$x = "red"; print $y; ' red -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.

Re: LWP Select Options Count

2009-05-12 Thread Gunnar Hjalmarsson
print "There are $count options.\n"; Please study the above and compare it with your attempt and the HTML::TokeParser docs. Also, if there are two dropdowns and the second is a dependent of the first e.g. select size then select availabe colors; how do i count the total possible combina

Re: Array Initialization

2009-05-12 Thread Gunnar Hjalmarsson
print "\n"; ' 1 $ -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Array Initialization

2009-05-12 Thread Gunnar Hjalmarsson
John W. Krahn wrote: Gunnar Hjalmarsson wrote: John W. Krahn wrote: my() happens when the code is compiled so it is *not* re-run every time through the loop. The assignment happens when the code is run so it is re-run every time. $ perl -e ' for (1..5) { my $count; $count

Re: Array Initialization

2009-05-12 Thread Gunnar Hjalmarsson
John W. Krahn wrote: Gunnar Hjalmarsson wrote: John W. Krahn wrote: Gunnar Hjalmarsson wrote: John W. Krahn wrote: my() happens when the code is compiled so it is *not* re-run every time through the loop. The assignment happens when the code is run so it is re-run every time. $ perl -e

Re: Array Initialization

2009-05-13 Thread Gunnar Hjalmarsson
s compiled so it is *not* re-run every time through the loop." is very wrong. Yep, that's it. John, honestly I thought that you had made a 'typo', and that my little snippet would be sufficient to call your attention to it. -- Gunnar Hjalmarsson Email: http://www.gunna

Re: Help with LWP

2009-05-13 Thread Gunnar Hjalmarsson
with cookies, and it's possible that the script requires one or more cookie to be sent as part of the request. Those are two obvious things, but there might be more into it. Why not simply ask them? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: File::Find

2009-05-18 Thread Gunnar Hjalmarsson
AndrewMcHorney wrote: I looked at the documentation for this function and I find it confusing. Try File::Finder for a less confusing interface to *the module* File::Find. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr

Re: File::Find

2009-05-18 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Mon, May 18, 2009 at 19:05, Gunnar Hjalmarsson wrote: AndrewMcHorney wrote: I looked at the documentation for this function and I find it confusing. Try File::Finder for a less confusing interface to *the module* File::Find. snip Huh, never looked at File::Finder

Re: File::Find

2009-05-18 Thread Gunnar Hjalmarsson
opendir(), readdir() and grep(). -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Finding all files (what I want to do)

2009-05-19 Thread Gunnar Hjalmarsson
ible. By writing a Perl program. Show us what you have so far, let us know which part(s) of it you find difficult, and somebody may be willing to help you fix it. Don't expect anybody to write the whole program for you for free. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/co

Re: Save html page using perl

2009-05-22 Thread Gunnar Hjalmarsson
Jeff Pang wrote: We use "wget -p" to get the page and its full dependency. You could also use LWP but that's complicated to fetch the page and all its dependency. I thought that the portable WWW::Mechanize was the way to go rather than wget when there is a need to follow lin

Re: Difference between for & foreach loop

2009-05-25 Thread Gunnar Hjalmarsson
loops, but a true for loop is something else. Can anyone suggest me a good url which can tell the difference between two? http://perldoc.perl.org/perlsyn.html -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: interaction with a module and http tags

2009-05-25 Thread Gunnar Hjalmarsson
al in both the sub and the main code? If that is true, you'd better ask W3C. It has nothing to do with Perl. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: interaction with a module and http tags

2009-05-25 Thread Gunnar Hjalmarsson
here is no "straight perl inline html". HTML is HTML, whether it is on a static page or generated by a program, e.g. a Perl program. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e

Re: interaction with a module and http tags

2009-05-25 Thread Gunnar Hjalmarsson
jm wrote: Gunnar Hjalmarsson wrote: jm wrote: seems to be some requirement for html via a module call that's not necessary in straight perl inline html. I'm still confused about what the real problem is, but it sounds like you are on the wrong track. AFAIK, there is no &quo

Re: Can't locate HTML::Parser in @INC

2009-06-04 Thread Gunnar Hjalmarsson
test script was run as have read access to /usr/local/lib/perl5/site_perl/5.10.0/x86_64-linux/HTML/Parser.pm ? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

Re: 2 minutes and 8 second (how do i convert it to 02:08)??

2009-06-11 Thread Gunnar Hjalmarsson
Rob Coops wrote: $text = "2 minutes, and 8 seconds"; $text =~ /(\d{1,2}).*?(\d{1,2}).*/; -^^ When you are extracting stuff, .* is _always_ redundant in the beginning or end of a regex. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/

Re: word substitute with character count.

2009-06-18 Thread Gunnar Hjalmarsson
th $newword < length $oldword ? sprintf "%-${length_old}s", $newword : substr $newword, 0, $length_old; s/$oldword/$replace/; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additio

Re: question about constants

2009-06-23 Thread Gunnar Hjalmarsson
p work as expected, but second doesnt. My questions are: How did you expect the second loop to work, and what output did you get? (They both "worked" fine for me.) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl

Re: question about constants

2009-06-23 Thread Gunnar Hjalmarsson
Roman Makurin wrote: On Wed, Jun 24, 2009 at 03:02:00AM +0200, Gunnar Hjalmarsson wrote: Roman Makurin wrote: use constant { A => 1, B => 2, C => 3 }; @a = (1, 2, 3); @b = (A, B, C); # first loop while(my $i = shift @a) { print $i, $/ } # second loop

Re: question about constants

2009-06-24 Thread Gunnar Hjalmarsson
Steve Bertrand wrote: Roman Makurin wrote: On Wed, Jun 24, 2009 at 04:37:52AM +0200, Gunnar Hjalmarsson wrote: Strange. It looks like strictures and warnings are not enabled (@a and @b are not declared). Try to add use strict; use warnings; and see if that makes Perl give you a

Re: Need help w/ substitute ie. s/x/y/

2009-07-03 Thread Gunnar Hjalmarsson
ist of such records, one on each line, and with identical markup? If not, trying to do it with one substitution is a crazy idea. If it's a real world thing, you most likely should use an HTML parser. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Best way to mix two lists

2009-07-10 Thread Gunnar Hjalmarsson
rlish) way to mix two lists in this way. You can use a hash slice. @{ $data{$key} }{ @fields } = split /:/, $val; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@

Re: file uploader

2009-08-02 Thread Gunnar Hjalmarsson
P headers automaticly... but I couldn't find such a thing. Which browser related file size limitations are you talking about? CGI.pm or CGI::UploadEasy allows you to set the max size to whatever value you wish. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To

Re: usage of Split

2010-07-28 Thread Gunnar Hjalmarsson
the given string. Can you clarify what you mean by that? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: CGI warning/error

2008-03-14 Thread Gunnar Hjalmarsson
OTOH, is there really any good reason to bother with a CGI.pm method for this task? print "$_\n $ENV{$_}\n" for grep /^HTTP_/, keys %ENV; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: CGI warning/error

2008-03-14 Thread Gunnar Hjalmarsson
Kashif Salman wrote: On Fri, Mar 14, 2008 at 11:10 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > The -w switch enables warnings dynamically, and apparently CGI.pm isn't > 'warnings safe'. To get rid of those warnings, you can replace the -w > switch with

Re: subroutine in here document

2008-03-14 Thread Gunnar Hjalmarsson
Kashif Salman wrote: I know I can create html code using CGI and call a subroutine in there easily but if i were to use a here document for my html code, can I call a subroutine in there? print< Check out the FAQ entry perldoc -q "function calls" -- Gunnar Hjalmarsso

Re: Modifying StanzaFile

2008-03-14 Thread Gunnar Hjalmarsson
while (<>) { if ( /^define\s+(\w+){\s+(.+)}/s ) { my ($name, $vars) = ($1, $2); while ( $vars =~ /^\s*(\w+)=(\w+)/gm ) { $HoH{$name}{$1} = $2; } } } } print Dumper \%HoH; -- Gunnar Hjalmar

Re: Concatenating arrays from arrays of arrays

2008-03-15 Thread Gunnar Hjalmarsson
that case, why bother with the arrays of arrays? Everything I try either crashes the computer or gives me an array of arrays instead of a flat list. Let's see it. And please include sample data. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe,

Re: reg:file handling

2008-03-16 Thread Gunnar Hjalmarsson
; truncate $FH, 0 or die $!; seek $FH, 0, 0 or die $!; foreach ( @lines ) { s/FRCC/FRE/; print $FH $_; } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: diff of two files

2008-03-17 Thread Gunnar Hjalmarsson
Bareword "DB" not allowed while "strict subs" in use at test.pl line 2. Execution of test.pl aborted due to compilation errors. C:\home> The FAQ entry "perldoc -q difference.+arrays" may be useful. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: perl warnings

2008-03-17 Thread Gunnar Hjalmarsson
eq ". How can I get rid of that without using "no warnings". I tried 'if (defined("$action"))' but that still produces a warning. if ( ! $action ) {...} -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: flock - exclusive file locking

2008-03-17 Thread Gunnar Hjalmarsson
he script will never die at that line, since the constant O_WRONLY is always true. You need to do either sysopen( my $fh, $file_path, O_WRONLY ) || die ... ---^--^ or sysopen my $fh, $file_path, O_WRONLY or die ...

Re: perl warnings

2008-03-17 Thread Gunnar Hjalmarsson
Paul Lalli wrote: On Mar 17, 2:46 pm, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote: if ( ! $action ) {...} That'll work great until some jackass puts "?action=0" in the URL. So what? If you put random crap in the URL, you can't reasonably expect a meaningful resp

Re: FW: How to install Date::Manip on cygwin perl?

2008-03-18 Thread Gunnar Hjalmarsson
Siegfried Heintze (Aditi) wrote: It looks like the CPAN program does not anticipate paths with spaces in them. So it seems. You may want to try other methods to install the module. http://search.cpan.org/src/SBECK/Date-Manip-5.48/INSTALL -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi

Re: Loop within Loop

2008-03-18 Thread Gunnar Hjalmarsson
olumn$_" } }, split /,/, $cols{$_}; } push @AoHoA, \%tmp; } print Dumper [EMAIL PROTECTED]; __DATA__ ColumA|ColumB|ColumC|ColumD|ColumE Test|A,F|ACY,FAC|ACYA,FCSA,FCSC|ACYEA,FCSA2 Test2|A|A1,A2,A3,A4,A5,A6|B1,B2|C1,C2,C3 Test3|B|b10,B11,B12,B13,|C1,C2| -- Gunnar Hjalmarsson Email: http://www.gun

Re: Using Perl to parse comma diliminated fields ---

2008-03-18 Thread Gunnar Hjalmarsson
quot;Current Temperature: $temp\n", "Current Humidity: $humidity\n", "Current Illumination: $lumes\n"; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: context?

2008-03-18 Thread Gunnar Hjalmarsson
_function "foo"" Execution of test.pl aborted due to compilation errors. C:\home> -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: reg:file handling

2008-03-19 Thread Gunnar Hjalmarsson
(<>) { chomp; while ( my $line = substr $_, 0, 80, '' ) { print "$line\n"; } } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: reg:file handling

2008-03-19 Thread Gunnar Hjalmarsson
Richard Lee wrote: Gunnar Hjalmarsson wrote: Gowri Chandra Sekhar Barla, TLS, Chennai wrote: I have a file in which 10 lines are there each line is of with different sizes I want to print these lines in another files If size of line is greater than 80 I should break the line while

Re: Package???

2008-03-20 Thread Gunnar Hjalmarsson
\n"; C:\home>perl test.pl "our" variable $name masks earlier declaration in same scope at test.pl line 9. sanket Fred Fred C:\home> The third print() statement, even if within package main, outputs the package variable $Fred::name. In other words, since the our()

Re: get the matching regex pattern

2008-03-20 Thread Gunnar Hjalmarsson
*', '\sjoke'); $_ = 'This is a joke'; if ( /($x[0])|($x[1])/ ) { print '$x[', $1 ? '0' : '1', "] matched.\n"; } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: get the matching regex pattern

2008-03-20 Thread Gunnar Hjalmarsson
Just posted to clpmisc: Original Message Subject: Re: get the matching regex pattern Date: Thu, 20 Mar 2008 18:44:23 +0100 From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> Newsgroups: comp.lang.perl.misc Ram Prasad wrote: I have a somewhat strange requirement ... You had

Re: Package???

2008-03-20 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Thu, Mar 20, 2008 at 1:13 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: Chas. Owens wrote: First off, don't do that. Messing around with another package's variables ties you to that version of the module and is bad juju. Not sure I understand how t

Re: parsing CSV files with control and extended ASCII characters

2008-03-20 Thread Gunnar Hjalmarsson
ext::CSV, that way of creating a new object is mentioned at the top of the SYNOPSIS section. The solution to your problem is stated right after that. So, the usual recommendation: "Read the docs for the module you are using." is very much applicable. ;-) -- Gunnar Hjalm

Re: how to replace @ inside of { }

2008-03-22 Thread Gunnar Hjalmarsson
#x27;valc' => 'three', 'vala' => 'something2', 'and' => 'and' }, 'something' => { 'so' => &#

Re: why variable inside submodule did not change value

2008-03-22 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: What do you mean by "but since you have declared a subroutine that references the variable" Suggested reading: http://perldoc.perl.org/perlsub.html#Persistent-Private-Variables http://perldoc.perl.org/perlfaq7.html#What's-a-closure%3f -- Gunnar Hj

Re: why variable inside submodule did not change value

2008-03-22 Thread Gunnar Hjalmarsson
, making the sub anonymous also works. test() if (1); sub test { print "$testcounter.\n\n"; } my $test = sub { print "$testcounter.\n\n"; }; $test->(); -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cg

Re: how to replace @ inside of { }

2008-03-23 Thread Gunnar Hjalmarsson
e to it, $HoH{$1}, needs to be dereferenced. @{ $HoH{$1} }{ @keys_list } = split; ^ The keys_list is one of the anonymous arrays in %HoA. The reference to it, $HoA{$1}, needs to be dereferenced as well. @{ $HoH{$1} }{ @{ $HoA{$1} } } = split; ---^^^^

Re: how to replace @ inside of { }

2008-03-24 Thread Gunnar Hjalmarsson
;t just introduce variables such as $data and %_, without showing how they were populated, and expect others to follow your line of thinking. Please post a _complete_ program that we can copy and run, and that illustrates the issue you want help to resolve. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Concatenating Strings

2008-03-24 Thread Gunnar Hjalmarsson
recommended approach. You probably ought to make use of a hash instead. my %strA = ( 0 => 'A0', 1 => 'A1,b,c', 2 => 'A2', 3 => 'A3,d,e', ); print "VarB:$strA{$_}\n" foreach 0..3; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Concatenating Strings

2008-03-24 Thread Gunnar Hjalmarsson
e, but if you replace the last line with print $$varName; it outputs '123' under certain conditions. Please see my other message in this thread about why that approach is not a good idea. However, I think you might be able to use hashes and get what you want. Indeed. -- Gunnar Hjalmars

Re: how to replace @ inside of { }

2008-03-24 Thread Gunnar Hjalmarsson
gt; '103', 'c' => '101', 'a' => 'alpha', 'b' => '100', 'd' => '102' } ); # printing examples print "number - four is: $HoH{number}{four}\n"; print

Re: how to replace @ inside of { }

2008-03-25 Thread Gunnar Hjalmarsson
Rob Dixon wrote: Richard Lee wrote: Gunnar Hjalmarsson wrote: C:\home>type test.pl use Data::Dumper; my %HoA = ( something => [ qw/val1 val2 val3 and so forth/ ], something2 => [ qw/vala valb valc and so forth/ ], something3 => [ qw/valZ valZ1 valZ2 so forth/ ], ); my

Re: Really literal string

2008-03-25 Thread Gunnar Hjalmarsson
Keenlearner wrote: I like to store multiline perl code inside a scalar variable, but I don't want perl to interpolate the variable inside the code. my $t = "abc"; my $s = < Use single quotes. my $s = <<'TEXT'; http://perldoc.perl.org/perlop.html#Si

Re: Really literal string

2008-03-25 Thread Gunnar Hjalmarsson
C:\home> A single quotes here-document is the safest way to ensure that nothing gets changed. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: How to replace one line in a text file with Perl?

2008-03-26 Thread Gunnar Hjalmarsson
p/dst". I need to preserve the line /tmp/dst/file2 plus the others that start with */test Any ideas on how to do this with perl? Check out the Tie::File module. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additiona

Re: question on lexical declaration and submodule

2008-03-26 Thread Gunnar Hjalmarsson
t latter statement. if ($counter < 5){ $counter += 1; } } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: question on lexical declaration and submodule

2008-03-26 Thread Gunnar Hjalmarsson
into a separate block (see above). -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: question on lexical declaration and submodule

2008-03-27 Thread Gunnar Hjalmarsson
ing_module { my $counter = $_; You probably mean: my $counter = shift; or my ($counter) = @_; if ($counter < 5) { $counter += 1; } $_ = $counter; You do not want that line! print "Counter counting $counter\n"; return $counter; } --

Re: $topIter->next()

2008-03-27 Thread Gunnar Hjalmarsson
Just posted to clpmisc: Original Message Subject: Re: Operator ->() Date: Thu, 27 Mar 2008 20:35:27 +0100 From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> Newsgroups: comp.lang.perl.misc Subra wrote: [ exactly the same question as was posted to the beginners list a fe

Re: special chars as scalar inside regex

2008-03-28 Thread Gunnar Hjalmarsson
x27;s a FAQ. perldoc -q "How can I quote a variable to use in a regex?" -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

  1   2   3   4   5   6   7   8   9   10   >