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...
--/;
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
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, '+<', $
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
$
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
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
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
--
;
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:
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.)
--
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
:
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.
--
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
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
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
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
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
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
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/
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/
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
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/
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
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
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
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
"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
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
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/
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
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
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.
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
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
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
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
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
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.
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
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/
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
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
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
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/
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
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
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/
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
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
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
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/
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
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
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
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/
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
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
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
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
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/
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...@
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
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/
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/
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
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
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
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,
;
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/
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/
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/
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 ...
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
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
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
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/
_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/
(<>) {
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/
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
\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()
*', '\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/
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
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
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
#x27;valc' => 'three',
'vala' => 'something2',
'and' => 'and'
},
'something' => {
'so' =>
[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
,
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
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;
---^^^^
;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/
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/
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
gt; '103',
'c' => '101',
'a' => 'alpha',
'b' => '100',
'd' => '102'
}
);
# printing examples
print "number - four is: $HoH{number}{four}\n";
print
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
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
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/
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
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/
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/
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;
}
--
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
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 - 100 of 918 matches
Mail list logo