Remy Guo wrote:
hi all,
I've got a problem in following script:
sub A {
our %a;
$a{"fred"} = 1;
$a{"bella"} = 2;
...
}
sub B {
if ($fred != $a{"fred"}) {
print "fred failed.\n";
}
if ($bella != $a{"bella"} {
print "bella failed.\n";
}
}
The problem
Trev wrote:
I'm trying to use Perl to replace a line in a few XML files I have.
Example XML below, I'm wanting to change the Id= part from Id="/Local/
App/App1" to Id=/App1". I know there's an easy way to do this with
perl alone however I'm trying to use XML::Simple or any XML plugin for
perl.
On 4/15/2010 1:40 PM, Open Source wrote:
I'm getting this error:
Undefined subroutine&XML::Simple::XMLin called at ./sample.pl line 3.
Here's my code and input file:
use XML::Simple;
use Data::Dumper;
$data = XMLin("sample.xml");
print Dumper($data);
John
43
M
Operations
There mu
On 4/13/2010 7:13 AM, WashingtonGeorge wrote:
>
> Sorry,my expressions had something wrong a moment ago.i wanted to say
> in case i must to use a number bigger than 2**31-1,what should i do?
> Regards,
> George
"use a number bigger than 2**31-1"
See Math::BigInt
Use an array that big? Diff
On 1/20/2010 8:28 PM, Perl Noob wrote:
You can tell from my initial request that I have some knowledge. An
expert? No. But not an novice either. I had no real knowledge of the
<> until it was introduced to me on this list. I did find out what it
did, and incorporated it into my script. Howe
On 1/15/2010 2:11 PM, Grant wrote:
Anybody here familiar with XML::Simple? I need to parse some XML that
looks like this:
base64datahere
base64datahere
base64datahere
I need to be able to grab the correct set of base64 data. Does anyone
know how to do that?
- Grant
The "correct set"?
On 1/18/2010 2:10 PM, mike wrote:
Hello everyone:
I am trying to pass a hash of hashes from one script to another via a
cookie. I can get the cookie to pass, but when I try to get the inner
hash keys and values using what I think is the correct method, I
cannot get them. Here are two scripts wh
On 1/19/2010 6:03 PM, Perl Noob wrote:
I am AMAZED at the help available in this forum. It is an awesome
resource. I can see, though, that my situation needs to be stated
more clearly.
The data is not consistent throughout the entire file. I WISH I only
had to skip every other line. The prob
On 1/19/2010 12:09 AM, Perl Noob wrote:
I have a data file with thousands of records. The problem is that the
records in the data file span two lines for each record. I want to
write a perl script that makes each record a single line. The file
looks like this:
RECORD1FIELD1 RECORD1FIELD2
Dr.Ruud wrote:
Jeff Peng wrote:
Can the code (specially the regex) below be optimized to run faster?
#!/usr/bin/perl
for ($i=0; $i<1000; $i+=1) {
open HD,"index.html" or die $!;
while() {
print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/;
}
close HD;
}
Let me first "normal
Weide wrote:
Can anyone tell me why the map will not map out the unitialized
variable in this code with 'str'? Thanks a lot,
use strict;
use warnings;
sub total
{
my $firstone = shift;
my $sum = 0;
my $item = 0;
map { defined $_ ? $_ : 'str' } @_ ;
print @_;
}
my $hello;
Dermot wrote:
I would say say your just being flash but there is something in the
idea of having a sub {s/\s+//g; for @_;@_}. You do get re-usability.
The data is coming from tab-delimited files and I am trying to parse
the data into a sqlite3 db. In the process I'd like to validate the
data but
William wrote:
Hello, what is the syntax for having constant in regular expression ? Such as
use constant (NL => '\n');
#check if there is newline in the text
my $txt = "foo \n bar";
if($txt =~ m/
# ???
/x)
{
}
Constants cannot be interpolated into strings like variables.
This applies to in
Dermot wrote:
Hi,
I am trying to build a hash(ref) and while doing so I want to remove
any white space from strings such as "1280 x 1024". So I have
my $record = {
contributor => $resolution,
};
Perhaps I am trying to be too clever but I thought I could do
my $record = {
Amit Saxena wrote:
#! /usr/bin/perl
use warnings;
use strict;
open (PTR1, "))
{
sscanf($str, "%5d %11.2f", $data1, $data2);
# do whatever processing.
}
close (PTR1);
Regards,
Amit Saxena
sscanf()?
--
Brad
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional comma
Erasmo Perez wrote:
> I would like to know how could I transform the following CSV file:
...
> 1,2,3,4,5,6
...
> into the following CSV file:
...
> 1,2
> 1,3
> 1,4
> 1,5
> 1,6
Gunnar Hjalmarsson wrote:
> while (<>) {
> chomp;
> my ($first, @rest) = split /,/;
> print "
luke devon wrote:
Thanks for every one who tried to help me. but all were unsuccessful and I would like to submit my tries for your consideration.
This is how its done.
$ip = substr($ip, 0, (length($ip)-2));
(Please put your comments below others'.)
If that's how it's done, then you haven't
On Jul 10, 5:59 am, [EMAIL PROTECTED] (Anirban Adhikary)
wrote:
> Dear list
> I want to capture the output of w and then I want to do some job as per the
> o/p of w command in my linux system. So i have written the code as follows
>
> use strict;
> use warnings;
>
> open (LS, "w|") or die "can't op
On Jul 9, 12:44 am, [EMAIL PROTECTED] (Luke Devon) wrote:
> Hi
>
> How can we define NULL values in perl ? for instance if I wanted to assign a
> NULL value for a variable called "$x= , how would it be in the code ?
>
> Thank you
> Luke
>
> Send instant messages to your online friendshttp://uk.mes
On Jul 6, 9:31 am, [EMAIL PROTECTED] (Gunwant Singh) wrote:
> Thnx for your solution, although I did not get the complete solution as
> explained in your earlier email.
> Can you please simplify your explanation. Also, would it not be possible
> w/o making wordlist.unified.
>
> Thanks.
1 #!
On Jul 3, 4:38 pm, [EMAIL PROTECTED] (Rob Dixon) wrote:
> > Pardon me for being dense, but I can't figure out a case where
>
> >> if ($path[-1] eq '..') {
>
> > would ever be true.
>
> My intention was to preserve relative paths starting with '..', but I got it
> wrong. Here's V2.
>
> Rob
>
>
On Jul 2, 11:46 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
>
> This seems to do the job. Hope it helps.
>
> Rob
>
> sub canonical_path {
>
> my $path = shift;
> my @path;
>
> foreach (File::Spec->splitdir($path)) {
> if ($_ eq '..') {
> if ($path[-1] eq '..') {
> push @path, $
On Jun 30, 4:20 pm, [EMAIL PROTECTED] (Epanda) wrote:
> Hi,
>
> I have to do a substitution of a pattern in a text file,
So you know about perl -i, right?
>
> this pattern is a key of a hash table previously set.
>
> so I want to replace my pattern by the corresponding value of the key
> in the h
On Jun 28, 11:18 am, [EMAIL PROTECTED] (Luca Villa) wrote:
> I have a long text file like this:
>
> 324yellow
> 34house
> black
> 54532
> 15m21red56
> 44dfdsf8sfd23
>
> How can I obtain (Perl - Windows/commandline/singleline) the
> following?
>
> 1) only the numbers at the beginning before some alp
On Jun 26, 9:57 am, [EMAIL PROTECTED] (Pat Rice) wrote:
> Hi all
> I'm wondering if there is a nice way to parse this data, as in is
> there any module that could handle this type of data, as in the was it
> is presented? so that I can repeat is itn a tree like structure in
> HTML ?
>
> so I can pi
On Jun 23, 8:36 am, [EMAIL PROTECTED] (Luke Devon) wrote:
> Scalar value @array[2] better written as $array[2] at hell.pl line 22.
> Scalar value @array[1] better written as $array[1] at hell.pl line 31.
...
> Possible unintended interpolation of @array in string at hell.pl line 38.
...
> Global sy
On Jun 20, 1:30 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> Here is another way to do it:
>
> my $jump;
> while ( ) {
> $jump = $. + 10 if /regex/;
> print "the output" if $jump == $.;
> }
>
Two observations:
1. this will warn while $jump is undef
2. if regex is matched by one o
On Jun 21, 4:11 am, [EMAIL PROTECTED] (Gowthamgowtham) wrote:
> Hello All,
>
> I found this in Programming Perl - 3rd edition. Could not understand how
> this works.
>
> #!/bin/sh -- # perl, to stop looping
>
> eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
>
> if 0;
>
> Questions:
>
> - Wh
On Jun 17, 4:50 am, [EMAIL PROTECTED] (Luke Devon) wrote:
> Dear Friends
>
> I am going to capture some values/parameters which are comes trough URL. like
> Client_IP , domain name .etc. But i have no idea how it would be done by
> perl. Here i am going to use bcoz this program based on squid
On Jun 12, 9:37 am, [EMAIL PROTECTED] (Christopher Morgan) wrote:
> I have a complex array containing references to hashes. Some of the hash
> keys point to anonymous lists. A typical element from this array looks like
> this:
>
> {
>
> '_is_control_field' => '',
>
> '_ind2' => '0',
>
>
On Jul 2, 9:27 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> Gabriel Striewe wrote:
> > What do I do wrong?
>
> First of all, the ampersand subroutine designation is outdated and dangerous
> and it is far better to use the indirect notation for a subroutine call:
>
> $hello->()
>
> Perl will interpola
On Jun 18, 5:54 pm, [EMAIL PROTECTED] (John Degen) wrote:
> >- Original Message
> >From: Paul Lalli <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Sent: Monday, June 18, 2007 6:47:05 PM
> >Subject: Re: Command line usage
>
> >On Jun 18, 10:50 am, [EMAIL PROTECTED] (John Degen) wrote:
>
>
On Jun 20, 7:33 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> Well, sort of. Objects are simply intelligent data structures - structures
> with
> code as well as data that know how to perform operations on themselves.
Not to put too fine a point on it, but early on when I was learning
OOP, I often r
On Jun 14, 10:22 pm, [EMAIL PROTECTED] (Mathew Snyder) wrote:
> I fixed all of the bugs save one. I can't access any of my subroutines
> without
> explicitly using it with dates_emails::subroutine. I was under the impression
> that if I was exporting them all from the module, the subroutine woul
On Jun 8, 3:52 pm, [EMAIL PROTECTED] (Ash) wrote:
> Hello there!
>
> I need to remove decimal points from numbers. For eg 1.23 or 1.77
> would be just 1. Any suggestion is appreciated. Thank you.
Did anybody mention int()?
--
Brad
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional com
On Jun 7, 4:42 am, [EMAIL PROTECTED] (Mumia W.)
wrote:
> I hope that the list managers can stop Google's messages from making it
> to the mailing list.
Personally, I hope not. I'm one of those Luddites who uses Google
Groups.
I don't have a particular opinion about keeping usenet/mailing lists/
w
On Jun 1, 9:58 am, [EMAIL PROTECTED] (Chas Owens) wrote:
> On 31 May 2007 10:58:54 -0700, Paul Lalli <[EMAIL PROTECTED]> wrote:
>
> > On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote:
> > > I suspect one of the tutorials that Google or Perl.org points to has
> > > something in it that needs co
On May 28, 7:41 am, [EMAIL PROTECTED] (Jeevs) wrote:
> On May 28, 11:35 am, [EMAIL PROTECTED] (Jeevs) wrote:
>
> > @hashi = @hash{qw (jeevan, sarika)};
> > print @hashi;
>
> > this gives me the values of keys jeevan and sarika.. how does this
> > work ...
It works because that's the syntax for a h
On May 24, 5:36 am, [EMAIL PROTECTED] (Ben Edwards) wrote:
> I am passing a reference to a hash ($publisher) and a array with an
> unknown number of elements (@files). So the call is
>
> delete_from_publishers( $publisher, @files )
>
> Currently the beginning of the sub is:-
>
> sub remove_files_f
39 matches
Mail list logo