Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: doughnut charts with gd:graph

by theravadamonk (Scribe)
on Jul 25, 2018 at 11:53 UTC ( [id://1219250]=note: print w/replies, xml ) Need Help??


in reply to Re: doughnut charts with gd:graph
in thread doughnut charts with gd:graph

Thanks for your reply since I want to complete this

I understand the below code

my @df = `df /var`;

I can print df in this way..

print @df;

it shows in this way

Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg_mail-lv_var 94959436 1415576 88713448 2% /var

Pls explain this below code? I think you split 2 things. (i.e - white spaces and another). Difficult to understand. Sir, Pls explain in detail. Your effort will NOT got to waste.

my ($used, $free) = (split (/\s+/, $df[1]))[2,3]; #HOW TO PRINT THE OU +TPUT?

Finally, How to print $used and $free

the below lines will NOT?

print $used; print $free;
I think the above one line can be written in these 2 lines? AM I RIGHT?
my $used = (split (/\s+/, $df[1]))[2]; my $free = (split (/\s+/, $df[1]))[3];

Waiting for yor REPLY...

Replies are listed 'Best First'.
Re^3: doughnut charts with gd:graph
by hippo (Bishop) on Jul 25, 2018 at 13:06 UTC
    Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg_mail-lv_var 94959436 1415576 88713448 2% /var

    That explains why the scalars are not set for you. If your Filesystem paths are so long as to overflow like this you will need to use -P. That will avoid the wrapping and hence the assignment errors. Note that this is a demonstrably good reason not to shell out but to use a module instead.

    Here is an SSCCE demonstrating this use of -P:

    #!/usr/bin/env perl use strict; use warnings; my @df = `df -P /var`; my ($used, $free) = (split (/\s+/, $df[1]))[2,3]; print "used $used, free $free\n";

    The split acts on $df[1] (which is the second line returned by df) and splits it on whitespace (like awk does). You then want only the 3rd and 4th fields for your used and free figures but indexing in Perl starts at zero hence the slice of [2,3]. Hopefully that makes it clear enough?

      Hopefully that makes it clear enough?

      Yeah, It's pretty clear. I realized it. Thanks for it.

      You already have the image as a pie so why not just overlay a background-coloured circle on the middle?

      Whole day, I tried, But, still no success..

      Could you pls give a try? It may be easy for you. I don't Want to stop writing this code.. I want to continue..

      The other thing is How to Display values ($used and $free ) in pie chart?

      in Bar chart,We have below line

      show_values => 1,

      I need everyone's replies to complete this code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1219250]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found