ithout
making typos first.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- Meister Eckhart
-
".g" part optional (so long as the word boundaries
still match).
The remaining problem is in the definition of a "word". What about "I got
a grab-bag gift"? Should "grab-bag" match? It doesn't currently, because
the '-' is not a vali
gt; 100
round(123.456,-1) --> 120
round(123.456)--> 123
round(123.456,0) --> 123
round(123.456,1) --> 123.5
round(123.456,2) --> 123.46
It works with positive and negative numbers (both as the numbers BEING
rounded and the places to round TO).
--
Jeff "japhy" P
ToNumber{lc($a->[2])} <=> $AlphaToNumber{lc($b->[2])}
or
$a->[3] <=> $b->[3]
} map {
[ $_, /^.(\d{4})(\w{3})(\d{2})/ ]
} @user_links;
Here, your @user_links array holds the data that Wags was reading from the
DATA filehandle. We still execute the map() o
rd) a line of output
print $write "$x\n";
<$read>; # read (and discard) the next line of output
print $write "$y\n";
chomp(my $z = <$read>); # read (and save) the next line of output
close $read;
close $write;
--
Jeff "japhy&q
") },
no_chdir => 0,
}, $spec_entry);
Here, we create an anonymous function (sub { ... }) and use it. This
anonymous function, when called, just calls the find_...(...) function.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Bro
, you
could convert the month NAMES to numerical representations (Jan => 01, Dec
=> 12), and then after you've sorted them (ASCIIbetically will work here)
you can change those numerical representations back to the month names.
--
Jeff "japhy" Pinyan % How can w
ing variable
a lot (and it needs a descriptive name).
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %
.
Identical. Use a flip-flop. It's easier.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %--
ay and just
use the return value from grep() in-place:
for my $host (@hosts) {
my %freq;
$freq{$_}++ for grep /$host/i, @logfile;
# open file
for (sort keys %freq) {
print "$_: $freq{$_}\n";
}
# close file
}
Voila.
--
Jeff "japhy" Pinyan
while () { # this is better-looking than 'for (;;)'
if (/^-BEGIN/ .. /^-END/) {
print;
}
}
The flip-flop operator (..) is *false* UNTIL the left expression evaluates
to true. THEN it STAYS *true* until the right expression evaluates to
true.
--
Jeff
my %copy = %something;
foo2();
Now you have %copy and %something. Is that the situation?
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been
rewind it, you need to
write
seek(FILEHANDLE, 0, 0);
to get back to the beginning.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago
x27;t need the quotes around the hash
key 'bbookref' if it's a simple string (no whitespace or non-alphanumeric
characters):
$fullXmlHash{$xmlData{bbookref}} = \%xmlData;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734
then >
(.*?)# zero or more characters ($2)
(?= <.+?> ) # look ahead for '<...>' (but don't actually match it)
}{<$1>$2}xg;
The /x modifier there allows me to embed that whitespace and comments in
the regex half of the s///, and the /g modifier me
hash, print it." so this is doing
# the job of reading EACH line of EACH file, and ONLY printing those
# lines which are not found in the %exclude hash.
while (<>) {
chomp;
print "$_\n" unless $exclude{$_};
}
}
Presto!
perldoc perlrun (for $^I
On Jun 14, Praedor Atrebates said:
On Tuesday 14 June 2005 17:34, Jeff 'japhy' Pinyan wrote:
The [...] construct is a character class -- it represents a set of
characters, any of which can match. Thus, [KRH] matches a 'K', an 'R', or
an 'H'. But [A{3
ictive than I've
started out with?
Hrm, so the middle part must be NO LESS than 3 and NO MORE than 5, and is
made up solely of L, V, I, F, Y, and A characters?
$dnakmotif = qr/[KRH][LVIFYA]{3,5}[KRH]/;
looks like it does the trick.
--
Jeff "japhy" Pinyan % How can we ever
nly eixsts inside those { } blocks of code. Do
this instead:
my $n;
if ($a < 10) { $n = two_face->new("vii", 7) }
else { $n = two_face->new("viii", 8) }
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734
7;m using Perl -v 5.8.0.
The Switch.pm module isn't standard with Perl, but is a way to do it...
... but in your case, all you really need is a hash!
my %day_of_week = (
mon => 0,
tue => 1,
wed => 2,
thu => 3,
fri => 4,
sat => 5,
sun =
e at the end of your argument to die(), there will be
no file and line number information.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been over
ply begins.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- Meister Eckhart
--
To unsubscribe, e-mail: [
tsoever and from the second line onwards, the
spaces are appended at the beginning of the line instead of the end.
That doesn't sound right... you *are* chomp()ing the string, so the
newline should disappear. Perhaps you also have \r (carriage return) at
the end of each line too?
--
Jeff
On Jun 3, Jay Savage said:
On 6/3/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
s/\b(I|II|...)\b//g;
This isn't going to get them all; it says to match (between word
boundaries) "I" or "II" or any three non-newlines. So it will catch
"I
aren't touching any word
characters.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- Meister
not a character.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- Meister Eckhart
--
To unsubscribe, e-ma
roblems" and "abintern" won't match. ("Abintern" isn't a word, but I
wanted to prove a point.)
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.
es PERL know not to put in another one?
I don't have my Camel at hand. Is this an AUTOLOADing issue?
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have lon
On Jun 1, Dermot Paikkos said:
s/\s*$//; # delete all whitespace at the end of the string
Except that it's awfully silly-looking. I'd *at least* do
s/\s+$//;
which is monumentally faster, although not perfect.
--
Jeff "japhy" Pinyan % How can we ever be t
t". So your regex would be
s!\^AMATH\^D(\d{7}\.dat):(\d{1,2})\^B!math($1,$2)!eg;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been over
able holds the current line
number.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- Meister Eckhar
e 45
main::mediausage() called at disk_cache-tape_slot-usage.pl line
This means that Perl is interpreting your code as
print MU color("bold", "Media Usage Key ...");
and the problem is that the color() function isn't expecting that "Media"
string. Th
'#!/usr/bin/perl\n'
which means that Unix is looking for the program '/usr/bin/perl\r', and
that file doesn't exist.
Another question is what is the simplest way to replace "\r\n" with "\r" or
"\n"?
I think you'd just want to remove
On May 25, John Doe said:
Am Mittwoch, 25. Mai 2005 04.10 schrieb Jeff 'japhy' Pinyan:
Jeff, thanks a lot for taking over.
My explanation would not have been so understandable and with this fullness.
Glad to be of service.
--
Jeff "japhy" Pinyan % How can we ev
On May 25, Jay Savage said:
On 5/25/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
On May 25, Jay Savage said:
/e(?{push @bar, pos})/g;
should work, but seems to ignore the /g.
Because as you wrote it, the regex is in void context, which means it'll
only match
I'd do:
/e(?{ push @bar, pos })(?!)/;
If 'e' is more than one character, you'll need to use
/(?>pattern)(?{ push @bar, pos })(?!)/;
You could also use $-[0] instead of pos().
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acac
\b (word boundary) anchor will fail, and the regex will
backtrack until it reaches a point where there's a word character on one
side and a non-word character on the other.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the
e using an array. In
fact, you already HAVE the array (@files) since you're using the elements
of the array both as paths to files AND as the filehandles themselves.
It's a little unorthodox, but it's not a crime. I wouldn't do it, though,
I'd create filehandles:
my @
in Perl, you have to use chr(8596) or a hex sequence like
\x{2194}. Next, tr/// doesn't know what "\chr(29)" means. tr/// just
takes normal characters, octal or hex escape sequences, and ranges (two
characters with a - between them).
my $count = ($a =~ tr/\x{2194}//);
works
for (@all_files) { push @files, $_ if $_ ne "." and $_ ne ".." }
# lines 4-7
my @files_and_ages;
for (@files) {
push @files_and_ages, [
sprintf(...), $_
];
}
# line 3
my @old_files;
for (@files_and_ages) {
push @old_files, $_ if $_->[0] &g
ot;this", "that", "those"), then "@array" is "this that
those". However, if @array is ("this\n", "that\n", "those\n"), then
"@array" is "this
that
those
".
Don't put the array in quotes when
;
but this one is really slow from what i see.
How have you seen this to be slow?
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been over
q is for strings, and you're trying to use
character classes (or more generally, regexes).
if (substr($line, 0, 1) =~ /[a-zA-Z]/) { ... }
and
if ($line =~ /^[\s\d]+$/) { ... }
probably do what you want.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acaci
On May 18, Lance Murray said:
perl -i -p -e "s/oldhostname/newhostname/g" /etc/hosts
However, what is the syntax if I wanted to just process a text stream to
stdout?, e.g.:
cat /etc/hosts | perl "s/in_text/out_text/g"
Simple: use the -p and -e switches, but not the -i sw
On May 15, Paul D. Kraus said:
Hello,
my $image = Image::Magick->new;
# trouble
open(IMAGE, 'open(IMAGE, "That needs to be
open(IMAGE, "
That's because the variable name is 'sku', not 'sku_unprocessed'.
--
Jeff "japhy" Pinyan % Ho
out when the hash gets re-optimized, etc.
Second, do you know how this test is failing to recognize the 'ea'
abbreviation?
I might be able to help, but we'd have to see some sample code that
demonstrates the problem.
--
Jeff "japhy" Pinyan % How can we ever
@F) = split(" ", $_, 0);
print $f[4];
}
-e syntax OK
Perl will magically produce the @F array for you, as shown. It's up to
YOU not to make the typo.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated,
$self = shift;
# my @loop = GetOfficers($self);
my @loop = GetOfficers();
}
You should be doing:
my @loop = GetOfficers($self);
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.p
ML_ProjectName => $row->{Name},
);
# put this row into the loop by reference
push(@Officer, \%line);
}
return @Officer
Instead, say
return [EMAIL PROTECTED];
}
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the c
On Apr 14, Jeff 'japhy' Pinyan said:
On Apr 13, Anish Kumar K said:
The code gives strange error
$subject = I get some value from the function
Yes, and it's an object of class XML::LibXML::NodeList that doesn't have an
'eq' operator overloaded for it. Contact th
ot;. Any idea why?
Because you used '...' to send the string to perl -e, that's why. Your
internal quotes are the same as your external quotes.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we w
if ("$subject" eq '' or not defined $subject) { ... }
And I would do those tests in the other order:
if (not defined $subject or "$subject" eq '') { ... }
Assuming the object CAN be string-ified, then putting it quotes will help
you to work around the pr
On Apr 1, Randal L. Schwartz said:
"Jeff" == Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> writes:
Jeff>sub new {
Jeff> my $that = shift;
Jeff> my $class = ref($that) || $that;
Jeff> my $self = $class->SUPER::new();
Jeff> $self-&
) method is calling LogonDB's _init()
method. To get around that, you'll have to do:
package DBLogon;
use Logon;
@ISA = qw (Logon);
use Carp;
sub new {
my $that = shift;
my $class = ref($that) || $that;
my $self = $class->SUPER::new();
$self->SUPER::_i
On Mar 31, Ramprasad A Padmanabhan said:
$str = "[EMAIL PROTECTED]";
Should become
[EMAIL PROTECTED]
I'd use index() and substr():
if ((my $p = index($str, '@')) > -1) { substr($str, $p) =~ tr/_/./ }
--
Jeff "japhy" Pinyan % How can we ever be the
think of is:
s/(\S+)(\s+)(\S+)/$3$2$1/g;
That reverses every pair of fields, and retains the whitespace that was
between them.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.pe
alue?
If there is no explicit return value for a function, it returns the LAST
thing it evaluated.
As far as documentation goes, please read
perldoc perlboot
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for ever
exmorf_ruisweg2.pl line 12."
Windows doesn't let you do in-place editing without making a backup file.
Therefore, $^I can't be "". Make it ".bak", and you'll be fine.
--
Jeff "japhy" Pinyan % How can we ever be the sold short
On Mar 15, Chris Devers said:
system($command)
or die "Couldn't run command '$command': $!";
That needs to be
system($command) == 0
or die ...;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734
ch is the same as $foo{bar}->[2]->[5]
which is the same as the ugly ${ ${ $foo{bar} }[2] }[5].
Read 'perlreftut' for more details.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every
ect}}) {
which looks very messy. It works, but it's got a lot of extra braces.
I'd use one of the following:
foreach my $key (keys %{ $$hashref{$object} }) {
# or
foreach my $key (keys %{ $hashref->{$object} }) {
--
Jeff "japhy" Pinyan % How can we ever be the
am('pass');
# ...
open PASSWORD, "< password.dat" or die "can't read password.dat: $!";
while (my $n = ) {
my $p = ;
chomp ($n, $p);
if ($n eq $name) {
if ($pass eq $p) {
# the names match and the passwords match
}
else
On Mar 11, Peter Rabbitson said:
_NASTY_SUB (\%{$batches{$current_batch}});
my %cards = %{clone (\%{$sources{${$batch_ref}{by_method}}{card_def}} )};
You've got two instances of
\%{ thing_which_is_a_hashref }
where you could just write
thing_which_is_a_hashref
--
Jeff "jap
hierarchy. Time::Period::Extended,
for example.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- M
accessed.
(Mnemonic: many programs use "." to mean the current line num-
ber.)
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago
On Feb 15, Eduardo Vázquez Rodríguez said:
open(INPUT, $file) or die "Can't read from file: $! $file";
# Where we "move" the pointer to line number 10
$. = 0;
You don't need to initialize $. to 0. It's a magical variable that holds
the right value.
--
o use $.? That is, why create
another variable which does the same thing?
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www
On Feb 11, Anish Kumar K. said:
open INPUT, "a.txt" | die "Cannot open the file";
That should be:
open INPUT "a.txt" or die "cannot open a.txt: $!";
while ()
{
$temp=$temp.$_;
}
You could write that as
$temp .= $_;
print "the entire file is
On Feb 9, Tham, Philip said:
$var1 =~ s/^*.4160 //.;
$var1 =~ s/\smodules*.$//;
Your primary problem is that you're using "*." when you mean ".*"
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the che
p over.
Consider this:
sub XYZ {
my $z = 0;
for (my $i = 0; $i < 10; $i++) { $z += $i }
}
The return value here is '', which is the result of '$i < 10' when $i is
10. 10 < 10 is false, and it returns ''.
--
Jeff "japhy" Pinyan
rray::Unique is a transparent solution -- that is, all you do is
tie the array to T::A::U and things get done. Using hashes isn't all that
hard, but T::A::U does that for you.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the
f) = split /\s*=\s*/;
Then you want to put that pair into the hash:
$dict{$term} = $def;
}
Using the hash, and opening the file, I leave up to you.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every
1];
s/./*/g;
print;
}
That should work (I didn't test it, though).
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
h
re literal,
>should the '\' not be literal as well?
The right-hand side is a double-quoted string. "." isn't special in a
double-quoted string, but "\" is.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #
On Oct 19, Bryan Harris said:
>Does anyone happen to know why this doesn't work as expected?
>
>perl -e '$_="1\n";s/\Z/2/g;print'
>
>Why does it print "2" twice?
It works as *I* expect it to. \Z matches at the end of the string, OR
before a NEWLINE at the end of the string. Therefore, in the st
t, and then include
my %freq;
you'll be ok.
If not, just include:
%freq = ();
before the foreach loop below:
> foreach $number (@numbers){
> $freq{$number}++;
> print OUTFILE $number if $freq{$number}==1;
>}
>
>}
--
Jeff "japhy" Pinyan
>ignores my getopt(s) single-chars. Is this normal? What can I do to solve
>this?
>
>I want to use perl with "-w" option and the "strict" pracma. Is this posible?
If you're using Perl 5.6, don't use "-w" anymore, use the "warnings"
pragma.
In your case, apparently the IP address is longer than
both the username and the password, so the IP is all you're seeing.
($user = <$client>) =~ s/\r?\n$//;
($pass = <$client>) =~ s/\r?\n$//;
That should work for you.
--
Jeff "japhy" Pinyan % How can we eve
>How do I do it best ?
I'd do:
my @parts = split /{\d+}/, $string;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlm
On Sep 28, Christian Stalp said:
>$socket-> send ( $data , $flags ) or die "could not send!\n";
To send data to the socket, just print() to it:
print $socket "$data\n";
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Bro
On Sep 21, Errin Larsen said:
>On Tue, 21 Sep 2004 14:58:43 -0400 (EDT), Jeff 'japhy' Pinyan
><[EMAIL PROTECTED]> wrote:
>> On Sep 21, Bob Showalter said:
>>
>> > my %hash = (
>> > foo => 1,
>> > bar => 2,
>>
thod of an object.
See the documentation for prototypes. Chances are, you don't need them.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been ov
which can vary at runtime. I know that
>I only want to keep 'bar' and 'qux' however).
>my @keys = qw(bar qux);
You could do:
my %keep_these_keys;
@keep_these_keys{qw( bar qux )} = ();
delete @hash{ grep !exists $keep_these_keys{$_}, keys %hash };
--
Jeff &
G";
$phone_number =~ tr/A-Z/222333444555666888/;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %
On Sep 20, Gunnar Hjalmarsson said:
>Jeff 'japhy' Pinyan wrote:
>> On Sep 19, JupiterHost.Net said:
>>>
>>>I want to add a hash to a hash,
>>>
>>>So how can I add %w to %q in that example?
>>
>> The general way is:
>>
On Sep 19, JupiterHost.Net said:
>I want to add a hash to a hash,
>
>So how can I add %w to %q in that example?
The general way is:
# to add %w to %q
@q{keys %w} = values %w;
If there are overlapping keys, %w's values will be used.
--
Jeff "japhy" Pinyan %
";
>print $str;
>
>produce "number one, number one" to the output. But what I must to do, that
>output would be
>"number one, number two" ??
You could use my DynScalar module from CPAN:
use DynScalar;
my $var;
my $str = dynamic { "number $var,"
rint $x . " ";
>}
You should use a hash instead of a set of variables.
my %vars = (
foo => 'test',
);
Then you do:
for (@bar) {
s/\[%([^%]+)%]/$vars{$1}/g;
}
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia B
gt;
>Error Column "duration" is of type integer but expression is of type character
>varying
You neglected to show us the code that actually inserts the data into the
table. Perhaps you've accidentally quoted the data?
--
Jeff "japhy" Pinyan % How can w
ng, I know I could easily:
>
>$option = "0".$option;
I'd suggest sprintf():
my $two_digit_day = sprintf "%02d", $one_or_two_digit_day;
To remove them, simply do:
$date =~ s/^0+//;
That will remove all leading zeroes from a string.
--
Jeff "japhy"
/^1(?!\d)/, which reads "start of
string, '1', NOT followed by a digit".
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overp
es in the function
definition:
sub get_params {
...
}
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.o
'CGTTAAagctgcgAAGTTCT');
Use substr($str, $pos, 0, $addition) to insert $addition into $str at
position $pos.
$a = "perl";
$b = "t ea";
substr($a, 2, 0, $b);
print $a; # "pet earl"
To get a random position, I'd use:
subs
tured, and all the others remove all the $DIGIT
variables.
If you do:
for (split /\n/, $EDM_nonactive_tapelist) {
print "$1\n" if !/\*Orig/ and /st_9840_acs_0/ and /\((E\d+)/;
}
The problem you're having with substr() is that the third argument is the
LENGTH of the substring
ck (FILE, 2) or die "cannot flock $file: $!";
For safety's sake, use Fcntl's flock() constants.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ %
o use &&
instead of ||:
system("some system command") && die "system failed: $!";
or else
system("some system command") == 0 || die "system failed: $!";
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI A
FILE, 0, 0; # you need to go to the front first
1 while ;
$lines = $.;
seek FILE, 0, 0;
truncate FILE, 0;
print FILE "whatever\n";
close FILE;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who
st =gethostbyaddr($c_ip, AF_INET);
>
>Eww. You're using IO::Socket, so *use* it:
What I meant was that you're using the IO::Socket module, but instead of
using its easy and convenient object methods, you're using the klunky and
awkward Socket module's functions.
IO::Socket
my ($port, $host) = ($client->peerport, $client->peerhost);
# do whatever logging you want with those values...
print $client tail(-75, "/var/log/radius.log");
close $client; # not strictly necessary, due to scoping
}
--
Jeff "japhy" Pinyan % How
day, because there was an extra hour in
the day.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ %-- Me
201 - 300 of 1591 matches
Mail list logo